SAM sCO2 cycle integration macro

  • Xiangfei Kong
  • Topic Author
More
28 May 2024 18:41 #13211 by Xiangfei Kong
SAM sCO2 cycle integration macro was created by Xiangfei Kong
Dear developers:

Recently, I want to run a simulation about MSPT with SCO2 power cycle. I try to use the sCO2 cycle integration macro to define the power cycle. After running the macro, the message box shows "Macro did not finish, [132] operand to sizeof must be a array, string, or table type".  See the picture below. Does problem affect the simulation and how to solve this problem.

 

Thanks.

Best regards. 

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

  • Paul Gilman
More
29 May 2024 10:15 #13212 by Paul Gilman
Replied by Paul Gilman on topic SAM sCO2 cycle integration macro
Hi Xiangfei Kong,

To run the "sCO2 Cycle Integration" macro with SAM's Molten Salt Power Tower model, you must first run the "Supercritical Carbon Dioxide (sCO2) Power Cycle Model" in Python to generate a JSON file. the macro reads the JSON file to populate SAM inputs with data from the Python model. The Python model is available in the SAM GitHub repository at github.com/NREL/SAM/tree/develop/samples/CSP/sco2_analysis_python_V2 .

You can investigate the macro error about Line 132 by clicking View code at the top right corner of SAM's Macros page to see the macro's source code. SAM macros are written in the LK scripting language, which is described on the SAM website here: sam.nrel.gov/lk-script.html .

This error suggests that there is a problem with the UDPC (User Defined Power Cycle) input table on the Power Cycle page. The 'udpc_table' value is set in Line 107 of the macro from the 'udpc_table' variable in the JSON file generated by the Python script.

Hopefully this information helps you troubleshoot this problem.

Best regards,
Paul.

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

  • leizuh
More
25 Dec 2024 04:28 #13749 by leizuh
Replied by leizuh on topic SAM sCO2 cycle integration macro
Dear Paul
  I also met with this problem. I ran the 'design_point_examples' code in python and imported the 'design_solution_default_path' using the macro. Please help me with this problem. I also want to know why sco2 has been banned after the 2020 version. Was the earlier version with sco2 suffering with too many bugs?
  The json file is attached.
  Best regards

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

  • Ty Neises
More
10 Jan 2025 09:08 - 10 Jan 2025 10:07 #13804 by Ty Neises
Replied by Ty Neises on topic SAM sCO2 cycle integration macro
Hello,

We designed the sCO2 Macro to read a json created by the Off Design model in the sCO2 Python code. The off-design model exercises the designed cycle over combinations of expected ambient temperature, HTF inlet temperature, and HTF inlet mass flow rate. The macro looks for this off-design information to populate the User Defined Power Cycle (UDPC) inputs on the Power Cycle Page in SAM. The jsons you are trying to load only contain design-point outputs, so the macro can’t load the off-design inputs.

The off-design calculations are important for the SAM simulation because the sCO2 cycle will have a different normalized off-design response than the steam cycle off-design model that SAM uses by default. Additionally, the structure of the UDPC code means that a unique UDPC table typically is required to match each unique cycle design. We removed the sCO2 code from the SAM code because the time required to solve the necessary off-design calculations for a given cycle design is usually on the time scale of a few hours, which is too slow to typical SAM use. We plan to create generalized off-design maps that work for a broad range of cycle designs, but we don’t have an estimated date of completion yet.

You have a few options to resolve this macro issue. I recommend using the Python file (mspt_default_generate_sco2_udpc.py) to generate off-design results corresponding to your design point. Otherwise, you can modify the SAM Macro to skip the step the looks for the UDPC table in the json by adding logic to skip “Input Check 1” if the json does not have the UDPC. You do this by adding

if(typeof(udpc_table) != "null"){

to line 128 of the macro and then closing the brackets ‘}’ at line 190. With this second approach, you must either 1) change the UDPC table on the Power Cycle page to something that represents your design or 2) use the Steam model and be comfortable with some inaccuracy in the off-design performance.
Last edit: 10 Jan 2025 10:07 by Paul Gilman.

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

Moderators: Paul Gilman
Powered by Kunena Forum