Editing intermediate variables in PySAM

  • marcelofer
  • Topic Author
More
17 Nov 2020 17:48 #9011 by marcelofer
Editing intermediate variables in PySAM was created by marcelofer
Paul, 

I have a CSP project (based on the TcstroughEmpirical module) where I am trying to edit some of the calculations done by PySAM to check for the feasibility of the changes that I am proposing. For example, I would like to be able to edit how a variable is calculated or to edit the value of a variable present in the Outputs (PySAM.TcstroughEmpirical.TcstroughEmpirical.Output) group before they are passed on to another calculation.

Here is a more concrete example where the goal is to obtain CSP power production + redirect some of the incident solar energy to another process:
  • Use a user-defined weather file 
  • Calculate optical parameters (sun position and angle, incidence angle modifier, efficiency, etc.) 
  • Calculate the amount of solar energy received by the solar field (Outputs.QsfAbs) + the amount of solar energy redirected in my project (user-defined variable)
  • Send the value of Outputs.QsfAbs to the power block calculations, as it normally happens in SAM
I am aware that I might be able to use PySSC for this, but I am not sure how to proceed. If editing through PySSC is not an option and you don't think there is another option, would I be able to get all of the equations used in a module through PySAM/PySSC and create my own module based on the empirical calculations, for example?

Thank you in advance for your help. Let me know if you need any other details or if the question is not clear.

Best,
Marcelo

Please Log in or Create an account to join the conversation.

  • pgilman
More
19 Nov 2020 11:55 #9015 by pgilman
Replied by pgilman on topic Editing intermediate variables in PySAM
Hi Marcelo,

When you run the SSC library through PySAM or one of the other methods provided with the SAM Software Development Kit (SDK) , you can only access the inputs to the overall library, not inputs and outputs of sub-models within the library. In your example, the power block inputs are not accessible via PySAM.

The empirical trough model and others in SAM are written in C++. The source code files associated with the empirical trough model are:

Overall model:
github.com/NREL/ssc/blob/develop/ssc/cmod_tcstrough_empirical.cpp

Solar field model:
github.com/NREL/ssc/blob/develop/tcs/sam_trough_model_type805.cpp

Thermal energy storage model:
github.com/NREL/ssc/blob/develop/tcs/sam_trough_storage_type806.cpp

Power cycle model:
github.com/NREL/ssc/blob/develop/tcs/sam_trough_plant_type807.cpp

Best regards,
Paul.

Please Log in or Create an account to join the conversation.

  • marcelofer
  • Topic Author
More
19 Nov 2020 13:07 #9016 by marcelofer
Replied by marcelofer on topic Editing intermediate variables in PySAM
Paul, 

Thank you for sending each separate model, those will be really helpful in the case that I rewrite these using Python or MATLAB.

I was able to find the actual line that I would like to modify in the solar field model:  github.com/NREL/ssc/blob/develop/tcs/sam_trough_model_type805.cpp#L1107 .

Would you know if I am able to modify this line in my local version of SSC? If not, is there a way to overwrite that line through PySAM or should I focus on rewriting the models you referred to in Python/MATLAB to be able to customize them?

Thanks for your time and advice,
Marcelo

Please Log in or Create an account to join the conversation.

  • pgilman
More
20 Nov 2020 22:13 #9022 by pgilman
Replied by pgilman on topic Editing intermediate variables in PySAM
Hi Marcelo,

It is only possible to modify that line of code in the C++ source code. To do that, you would have to set up a build environment for your own version of SAM based on the instructions here: github.com/NREL/SAM/wiki .

It is not possible to access the code at that level through PySAM or the SAM SDK tools ( sam.nrel.gov/software-development-kit-sdk ).

Best regards,
Paul..

Please Log in or Create an account to join the conversation.

  • marcelofer
  • Topic Author
More
22 Nov 2020 18:18 #9024 by marcelofer
Replied by marcelofer on topic Editing intermediate variables in PySAM
Thank you!

Please Log in or Create an account to join the conversation.

Moderators: pgilman
Powered by Kunena Forum