-
-
Notifications
You must be signed in to change notification settings - Fork 350
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
[stub] YAML summary of ReactorNet structure #694
base: main
Are you sure you want to change the base?
Conversation
b83d3d5
to
a501589
Compare
Another possible use of this serialization is to produce a GUI to generate complicated reactor networks. |
Codecov Report
@@ Coverage Diff @@
## master #694 +/- ##
==========================================
- Coverage 70.63% 70.39% -0.24%
==========================================
Files 372 372
Lines 43567 43715 +148
==========================================
Hits 30773 30773
- Misses 12794 12942 +148
Continue to review full report at Codecov.
|
Codecov Report
@@ Coverage Diff @@
## main #694 +/- ##
==========================================
+ Coverage 71.28% 71.35% +0.06%
==========================================
Files 377 377
Lines 46335 46488 +153
==========================================
+ Hits 33032 33171 +139
- Misses 13303 13317 +14
Continue to review full report at Codecov.
|
Haven't thought about those possibilities, but I'm sure there are some packages out there that can be leveraged. I was merely interested in testing |
8eb72f4
to
4fe2aa6
Compare
8302778
to
1b9629e
Compare
I think that serialization of reactor networks to a YAML format could have a number of useful applications, although I consider pickling for use with the The way I envisioned implementing serialization to YAML, both for this case as well as for |
OK. It shouldn't be too difficult to convert, now that I have a structure. Any comments on the layout? PS: on second thought, I do recall that some of the emitters ( |
@speth ... I had another look at |
Ad structure: ReactorNet:
ReactorBase:
- reactor:
type: Reactor
Phase:
- ohmech:
thermo: IdealGas
kinetics: Gas
- reservoir:
type: Reservoir
Phase:
- ohmech:
thermo: IdealGas
... as well as writing |
Correct, the |
In terms of the structure, you could flatten it a bit. Given that the names for each component have to be unique in order to make the connections, you can just use a mapping instead of a list of single-key mappings, e.g. ReactorNet:
ReactorBase:
reactor:
type: Reactor
phase: ohmech
thermo.type: IdealGas
kinetics.type: Gas
reservoir:
type: Reservoir
phase: ohmech
thermo.type: IdealGas You could also flatten it another level if you don't worry about separating objects of different types into different groups, but I can see how that does simplify the implementation of calling the factory functions, so perhaps retaining that is worthwhile. I would suggest that names here follow patterns more like what is done in the YAML format, and not duplicate jargon from the implementation, e.g. instead of I'm also wondering how to encode all of the information that is needed to reconstruct the network. For the Serialization of user-defined functions will also be a pretty substantial challenge, without reverting to something like the more difficult to use "building block" style ones that were used in the old Python module, and are still used in the Matlab toolbox. |
@speth ... thanks for the feedback. I'll think about it some more. Regarding
I wrote this PR mostly as I wanted to have a simple test case to understand serialization. I can create |
@speth ... 👍 on skipping sequences and using plain names. Anticipating #696 (which will guarantee unique names for C++ reactor-network:
reactors:
reactor:
type: Reactor
phase: [ohmech_1]
reservoir:
type: Reservoir
phase: [ohmech_1]
flow-devices:
mfc:
type: MassFlowController
in: reservoir
out: reactor Also, I agree that serialization of user defined functions may be non-trivial. Haven't looked into this (and probably shouldn't for the time being.) At least for the moment, it appears to be low priority. PS: the lists for |
Pushed a revision with some changes. I opted to retain the list entries for named objects to differentiate between groups and what are entries (it should be easily be parsed by human eyes). The output for the reactor-network:
reactors:
- downstream:
type: Reservoir
phases: [gas]
- upstream:
type: Reservoir
phases: [gas]
- IdealGasReactor_1:
type: IdealGasReactor
phases: [gas, Pt_surf]
flow-devices:
- PressureController_1:
type: PressureController
reactors: [IdealGasReactor_1, downstream]
- MassFlowController_1:
type: MassFlowController
reactors: [upstream, IdealGasReactor_1] |
3391b47
to
d4bc9f1
Compare
Renaming to ‘stub’ as there is a clear dependence on YAML work and questions about surface kinetics (#699) remain. |
d4bc9f1
to
8706830
Compare
8706830
to
cd22913
Compare
cd22913
to
d72cd3b
Compare
* recreate ReactorNet structure * list ReactorBase, WallBase, FlowDevice and ReactorSurface objects * create of unique names based on * implementation for Phase list is partial, Kinetics is missing * names only available for ReactorBase
* pass name attributes from Cython to C++ layer for FlowDevice and WallBase objects * create name and type attributes for ReactorSurface objects
d72cd3b
to
bf2eb07
Compare
Hello |
@joebarteam11 ... thanks for your question; the answer for whether this is still pursued really is 'it depends'. I am currently working on an improved way of serializing simulation output (see #1426, although it's not necessarily evident). For |
Thanks for your reply @ischoegl, I can't wait to check out these new features! |
This PR proposes a self-documenting YAML structure for
ReactorNet
objects that is generated dynamically in the C++ layer viayaml-cpp
. While the initial PR simply displays the structure, the idea can be extended to (re-)createReactorNet
objects from YAML files, which would also enable pickling for multiprocessing purposes.Partially addresses #570
Proposed Changes
ReactorNet
(native usingyaml-cpp
)type
andname
attributes toReactorSurface
FlowDevice
,Wall
andReactorSurface
are correctly passed between python and C++Illustration
produces
More involved setups are avaliable in examples, where
ic_engine.py
andsurf_pfr.py
are good test cases as they involve non-trivialReactorNet
configurations.Thoughts
An extension of this idea that includes simulation parameters and setup details is straight forward, and would allow for serialization/pickling of
ReactorNet
objects. However, this task remains dependent on some code changes that are beyond the scope of this PR and thus should be handled separately.Main issues that are beyond the scope of this PR:
Func1
objectsSolution
handler approach and C++ thermo/kinetics managers.ReactorSurface
is an outlier.