I am making progress with python scripting using Automation2. Now I need to change some settings in a PropertyPackage (or rather the underlying flash algorithm I think, like the number of iterations etc.). I cannot figure out how to get the actual PropertyPackage instance from the Flowsheet class. All I could access was the IPropertyPackage and I do not know how to get to the flash algorithm settings from there.
I have a factory class which creates the FlowSheet instance:
May I ask what you're trying to do overall? There are multiple ways of accessing and using flash settings.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Anonymous
-
2022-06-03
Overall: A command line tool that creates an expander stage according to some input data and calculates the flow sheet to get the gas quantities at the outlet. I need to match some benchmark data which is presumably "correct" and noticed that the stage power and liquefication rate are way off with the default settings (e.g. 200 kW power generated instead of 650 kW, no liquefication vs. 10% mol and suchlike).
Tightening the tolerances and decreasing maximum step sizes help a lot, as does forcing the phase at the inlet, so I need to access these settings (as in the screenshot) from the python script.
I also noticed a few oddities (let me know if you want this moved to a separate thread):
1. For most property packages, the "edit" button does nothing (e.g. Peng-Robinson-Stryjek-Vera 2 (PRSV2-VL)). Exceptions are e.g. Peng-Robinson (PR) and Lee-Kessler-Plöcker. The screenshot is from using PR.
2. The inlet conditions are such that there is only the gas phase, with a liquefication rate of about 10% mol at the outlet. The power generated varies greatly if I force the phase at the inlet to vapour (which it is anyway). I gathered from the source code that there are different solvers depending on the phase being forced. but should they not converge to a "similar" solution if there is only one phase anyway?
About 1, if you are running the Cross-Platform UI, then it is true, I didn't create the editor for most property packages. The opposite is true for the Classic UI on Windows.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Anonymous
-
2022-06-03
I attached one of my flowsheets where I made some adjustments in the GUI. I had to change the composition and various quantities a bit for obfuscation, but the issue is still there to a lesser extent:
I reduced the maximum temperature step size from 30 to 10 for the solver to converge with forced phase.
With forced phase, the generated power is 609.96 kW. Without forced phase, the generated power is 511.42 kW.
Maybe you can make some sense of this.
Anyway, any clues about how to access the PropertyPackage settings from python?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Anonymous
-
2022-06-08
[Quick note: The whole concept of vb's interfaces is quite alien to me, coming from C++ and Fortran]
Ok, I found a workaround for the property package issue. Simply create a factory function that creates and configures the property package before adding it to the flowsheet, instead of letting the flowsheet's function create it.
Now I still have the problem of how to force the phase in one material stream, as I do not know how to create a MaterialStream, configure it and then assign it to the flow sheet. I use
Ok. Your model is not simple to deal with, as it involves a large amount of hydrogen. Not all models will work with it, and this is not a problem with the property package settings. You don't have and don't need to force any phase anywhere - just select the right model.
If I remember well, the best available property package for hydrogen simulations is Grayson-Streed.
Regards,
Daniel
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi all,
I am making progress with python scripting using Automation2. Now I need to change some settings in a PropertyPackage (or rather the underlying flash algorithm I think, like the number of iterations etc.). I cannot figure out how to get the actual PropertyPackage instance from the Flowsheet class. All I could access was the IPropertyPackage and I do not know how to get to the flash algorithm settings from there.
I have a factory class which creates the FlowSheet instance:
Then I can get the IPropertyPackage like this:
Can I somehow get the actual PropertyPackage instance? Or is there a way to change settings in the flash algorithm the PropertyPackage uses?
May I ask what you're trying to do overall? There are multiple ways of accessing and using flash settings.
Overall: A command line tool that creates an expander stage according to some input data and calculates the flow sheet to get the gas quantities at the outlet. I need to match some benchmark data which is presumably "correct" and noticed that the stage power and liquefication rate are way off with the default settings (e.g. 200 kW power generated instead of 650 kW, no liquefication vs. 10% mol and suchlike).
Tightening the tolerances and decreasing maximum step sizes help a lot, as does forcing the phase at the inlet, so I need to access these settings (as in the screenshot) from the python script.
I also noticed a few oddities (let me know if you want this moved to a separate thread):
1. For most property packages, the "edit" button does nothing (e.g. Peng-Robinson-Stryjek-Vera 2 (PRSV2-VL)). Exceptions are e.g. Peng-Robinson (PR) and Lee-Kessler-Plöcker. The screenshot is from using PR.
2. The inlet conditions are such that there is only the gas phase, with a liquefication rate of about 10% mol at the outlet. The power generated varies greatly if I force the phase at the inlet to vapour (which it is anyway). I gathered from the source code that there are different solvers depending on the phase being forced. but should they not converge to a "similar" solution if there is only one phase anyway?
Ok, what is the inlet composition?
About 1, if you are running the Cross-Platform UI, then it is true, I didn't create the editor for most property packages. The opposite is true for the Classic UI on Windows.
I attached one of my flowsheets where I made some adjustments in the GUI. I had to change the composition and various quantities a bit for obfuscation, but the issue is still there to a lesser extent:
I reduced the maximum temperature step size from 30 to 10 for the solver to converge with forced phase.
With forced phase, the generated power is 609.96 kW. Without forced phase, the generated power is 511.42 kW.
Maybe you can make some sense of this.
Anyway, any clues about how to access the PropertyPackage settings from python?
[Quick note: The whole concept of vb's interfaces is quite alien to me, coming from C++ and Fortran]
Ok, I found a workaround for the property package issue. Simply create a factory function that creates and configures the property package before adding it to the flowsheet, instead of letting the flowsheet's function create it.
instead of
Now I still have the problem of how to force the phase in one material stream, as I do not know how to create a MaterialStream, configure it and then assign it to the flow sheet. I use
so the MaterialStream object is buried in vb interfaces that do not expose the required member variable.
Apparently, I can call member functions fo the MaterialStream class on this object like this:
But how do I access and modify member variables, like MaterialStream.ForcePhase?
Ok. Your model is not simple to deal with, as it involves a large amount of hydrogen. Not all models will work with it, and this is not a problem with the property package settings. You don't have and don't need to force any phase anywhere - just select the right model.
If I remember well, the best available property package for hydrogen simulations is Grayson-Streed.
Regards,
Daniel