-
Notifications
You must be signed in to change notification settings - Fork 43
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Heat solver interface #1083
Heat solver interface #1083
Conversation
6f15f22
to
c43eee7
Compare
I think the approach you took makes sense. But I think in the future, a
sounds good, were we also going to add a
What is the main problem with using names? I feel like it might be the ideal. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks really good @dbochkov-flexcompute. Mostly minor comments and clarifications here.
"""Abstract placement for boundary conditions.""" | ||
|
||
|
||
class StructureBoundary(AbstractBCPlacement): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what does it mean for a boundary condition to be on a structure boundary? Does it completely encase the structure geometry? And then if it's, say, structure-structure, it only exists at the intersection between the two geometries?
For example, if I specify a HeatFluxBoundaryCondition of flux=0 between two structures, that means no heat can flow between them?
When will this heat solver be available? at the moment from gdsfactory we can run heat solving using femwell |
It turns out it's quite some effort to really nail everything down. This will not make it in the official 2.4.0 which will be released next week, but we will let you know as soon as it is available in a 2.5 pre-release so that you can start testing. This will be very valuable for us, too! |
c43eee7
to
0d18820
Compare
Major revision taking into account all comment. Most significant additions are PolySlab support, Symmetry support, and proper monitor/simulation data classes. It seemed to accomplish that the most natural way would be to create abstract base classes for main components since their optic and heat specification will share many things, I put them in
Demonstration notebooks have been updated too:
One concerns: we chose to just copy relevant code from |
Yes, that sounds important. Let's aim to have that done for 2.5 too. Maybe even do the refactor as soon as we start a 2.5 branch? |
What do you have in mind regarding
or did you have something else in mind? |
I see, not so straightforward yeah, but in terms of backwards compatibility I think we'll need to do something like point 2. for now, where simulation is still initialized with center, size, medium, and then a scence is maybe initialized as a private attribute or is stored as a cached property or something. |
052b62f
to
b194bb2
Compare
b194bb2
to
7c6f5f2
Compare
efdae96
to
61455ac
Compare
there are currently 4 commits in this PR:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @dbochkov-flexcompute. I think this looks really good. Mostly this is just minor stuff.
else: | ||
est_flex_unit = task_info.estFlexUnit | ||
if est_flex_unit is not None and est_flex_unit > 0: | ||
# Wait for task to finish |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I won't go through all of this logic, but we should test this pretty thoroughly because the webapi logic tends to break in weird ways sometimes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good idea, everything seemed to be working, except for download_log. but it was an issue on backend and now is fixed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
have you tried job and batch of heat simulation? or even mixes of simulation and heat sim? it could be interesting to see how that works too.
In my experience, sometimes the bugs were happening in web.monitor()
in weird edge cases, for example
- a task errors (if that happens we generally try the task again and see if it errors twice)
- the timing is somewhat different for whatever reason (task runs before the % done is ready)
There were some improvements earlier this year to fix some of these issues but if this PR changes any of that logic, they could appear again. Will be good to run a bunch just to ensure they don't pop up again because they can be quite tricky to reproduce.
6e01916
to
1d63001
Compare
addressed comments + added a beta stage disclaimer in heat solver webapi:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm pretty lost here so @dbochkov can you at least help me understand the current state and the plan for the general unification of things?
For example: HeatSimulation inherits from AbstractSimulation, but Simulation does not. Similarly HeatSimulationData inherits from AbstractSimulationData, but SimulationData does not. And while AbstractMonitorData has been introduced, both MonitorData and HeatMonitorData just inherit from Dataset.
Is there currently any duplicated code between Scene and Simulation?
I propose clarifying how everything is meant to work and putting the next few days of effort into actually merging this PR into 2.5 in a way that will avoid duplicated code and further code divergence. Then we can review/fix smaller details.
At this stage So, the idea was to only have heat classes inheriting new |
Otherwise, we seemed to have converged on pretty much everything in this PR. Just need to test out |
I think separate PR is fine. Just sooner rather than later. Generally as far as I'm concerned we could merge this soon (after you rebase again and answer all current comments, etc.) And just get it out there so that we can start getting some real user feedback and start fixing things. :) |
Is it currently possible for a user to have a look at the mesh that was used after a solver run? I guess they should at least be able to download the mesh file even if we don't provide any gmesh-wrapped functionality because of their GPL license. |
yes, it's not ideal currently, but you can directly download mesh ("mesh.cgns") or solution+mesh ("volume_proc0.vtu") using This user experience can definitely be improved. Probably, once we have heat monitors that return data on the original unstructured grid instead of interpolated to an equivalent Cartesian one. One idea could be to introduce something like |
2620021
to
f879527
Compare
d41f70d
to
8045068
Compare
Since the old PR (#896) became very outdated, I've decided to open a new one.
Major changes/additions (directory structure is up for discussion, just whatever seemed to make sense for now):
components/heat_spec.py
:All medium classes can now have field
heat_spec
which can be eitherSolidSpec
orFuildSpec
for specifying thermal properties. To remind, there are three categories of properties:Medium
,Lorentz
, etc classesheat_spec
.PerturbationMedium
andPerturbationPoleResidue
classes.And this is how different options interact with heat solver:
heat_spec=None
orheat_spec=FluidSpec()
will not be included in solution domain for the heat equation, and they will not be converted to custom mediums after applying temperature fields.heat_spec=SolidSpec(...)
will be included in solution domain for heat equation, but they will not be converted to custom mediums after applying temperature fields.PerturbationMedium
andPerturbationPoleResidue
) withheat_spec=SolidSpec(...)
will be included in solution domain for heat equation, and they will be converted to custom mediums after applying temperature fields. (the fullest material description)components/scene.py
:Carved out geometric only information from
Simulation
into classScene
for easier transfer of geometric information between different solvers. Basically, it containsstructures
,medium
,center
,size
+ plotting functionality.Simulation
. I think we should still have eps plotting inScene
class (along with thermal conductivity plotting, and perhaps other properties in future), so I adjusted the plotting of custom medium to use custom medium sample points + structure bounds instead of simulation grid. But now the question is whetherSimulation
in future should just directly borrow this plotting method or to have its own based on actual simulation grid?Simulation
, only added propertySimulation.scene
and class methodSimulation.from_scene(scene: Scene, **kwargs)
to transferringScene
between optic/heat simulation.HeatSimulation
does have fieldscene: Scene
components/bc_placement.py
:This file defines classes for placement of boundary conditions on complex interfaces (
BCPlacementType=[StructureBoundary, StructureStructureInterface, MediumMediumInterface, etc]
). I realized this should be separated from heat solver components because it can be reused for other future solvers.components/heat/
:The remaining of heat components are placed in this directory to keep everything tidy (yes, you see what I did here lol) and they include:
boundary.py
boundary conditions specifications:TemperatureBC
,HeatFluxBC
,ConvectionBC
+HeatBoundarySpec
grid.py
heat grid specification: currently,UniformHeatGrid
andDistanceHeatGrid
. I can that this can go either way: we can introduce more classes to give the user more control or, contrary, unify everything into one spec so that the user don't have to think about what to select at all.sim_data.py
definesHeatSimulationData
which is currently simplyHeatSimulation
instance + temperatureSpatialDataArray
simulation.py
definesHeatSimulation
source.py
heat source: currently onlyUniformHeatSource
viz.py
some parameters for plotting heat informationNotebooks with demonstrations
There are two draft notebooks demonstrating:
These are meant to provide more explanation on how every component is interacting with each other
additional major things off the top of my head to discuss:
placement = td.StructureStructureInterface(structures=["box", "sphere"])
. This doesn't seem ideal. We could maybe just pass structures/mediums themselves. But that will increase size ofHeatSimulation
instances. Maybe an alternative is to just record hash of passed structures/mediums? But then it would be harder to point user which structure/medium is missing from a heat simulation.