Running multiple separate offdesign calculations in same script
Hi @fwitte , The idea that I wish to establish through this code is to check multiple cases one after the other and produce a compiled documentation for the result. Cases that I wish to establish:
- Changing the feedwater flowrate
- Changing the flue gas flowrate
- Changing both simultaneously
The error that I am facing is the order in which to conduct them. If I do 1, then 2 then 3 then I get the following error after 1:
ValueError: unable to calculate melting line T(p) for polynomial_in_Theta curve for p=611.655; bounds are 611.657,2.18447e+09 Pa
However, if I run 1 in the end, I do not get this error and the program runs smoothly and I get consistent results. I have attached both scripts below in a zip file. They are named with _fail and _work to indicate working code or the one giving the above error.
Between two offdesign calculations I manually try resetting values to the design case. For example, if I change the flow rate of the feedwater input during the simulation, I change it back before running the second case as I could not find a function provided in TesPy to do the same.
Please advise. Thanks!
Hi,
that's a somewhat "ever green", which you can stumble over when using TESPy more in detail. By specification of the init_path parameter when resetting the variables to the design case the starting values are reset to the design state. Due to the nature of the solver it is always favorable to perform smaller steps in changing parameters to preserve a good initial guess (starting values) for the solution.
Change line 268 to
nw.solve('offdesign', design_path='./srinath_char', init_path='./srinath_char')
On top of that, allow me two remarks on your code. Since v0.4.2 results are available in DataFrames. You can access them by the class names and apply all pandas DataFrame methods further, e.g. calculate the total power of the turbines.
total_power = nw.results['Turbine']['P'].sum()
Or, you could use a Bus and add the turbines to the Bus. The automatic model report will then also include the respective results. E.g. see the SEGS.py script and the corresponding SEGS_model_report.pdf in https://github.com/fwitte/SEGS_exergy.
- However, I think a more extensive discussion of this topic in the online documentation would be very useful for all users as it is a fact to easily oversee when there is not yet a lot of experience in handling such issues. I could imagine a tutorial section in the docs.
- An automatic "resetter" e.g.
mynetwork.reset_to_design_state()method could be a good addition to the software. It would need to do the following tasks:- Set starting values to design state (method is somewhat available already)
- Set values of user specifications to their value in design state (this is new)
- Solve system (this step should be optional at max, should not really be necessary)
Best regards
Hi @fwitte ,
It works!
Will look into a possible implementation of reset_to_design_state() method implementation.
One doubt, is there any way to get all user specified parameters to implement the second requirement of the function?
Thank you once again :)
You might be able to use the data from the Network.specifications dictionary (same structure as the .results dictionary). The data are set up in the different preprocessing setups, thus available for every network after initialised once.