Skip to content
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

Running multiple separate offdesign calculations in same script #268

Open
govind-menon110 opened this issue May 18, 2021 · 3 comments
Open

Comments

@govind-menon110
Copy link
Contributor

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
Copy link
Member

fwitte commented May 18, 2021

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

@govind-menon110
Copy link
Contributor Author

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
Copy link
Member

fwitte commented May 18, 2021

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants