oemof / tespy

Thermal Engineering Systems in Python (TESPy). This package provides a powerful simulation toolkit for thermal engineering plants such as power plants, district heating systems or heat pumps.
https://tespy.readthedocs.io
MIT License
256 stars 80 forks source link

Running multiple separate offdesign calculations in same script #268

Open govind-menon110 opened 3 years ago

govind-menon110 commented 3 years ago

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:

  1. Changing the feedwater flowrate
  2. Changing the flue gas flowrate
  3. 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!

Offdesign.zip

fwitte commented 3 years ago

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.

Best regards

govind-menon110 commented 3 years ago

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 :)

fwitte commented 3 years ago

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.