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

Fix create compsets heron function 2 #19

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions src/heron.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,13 @@ def create_componentsets_in_HERON(comp_sets_folder, heron_input_xml):

# Goin through the FORCE componentSets to extract relevant info
for textfile in comp_set_files_list:
if textfile.startswith('componentSet'):
if textfile.startswith('componentSet') and (textfile.endswith('.json') or textfile.endswith('.txt')):
textfile_path = comp_sets_folder+"/"+textfile
comp_set_dict = json.load(open(textfile_path))
try:
with open(textfile_path) as textfile_opened:
comp_set_dict = json.load(textfile_opened)
except json.JSONDecodeError as e:
raise ValueError(f"The content of {textfile_path} is not in proper JSON format and cannot be read") from e
comp_set_name = comp_set_dict.get('Component Set Name')

ref_driver = comp_set_dict.get('Reference Driver')
Expand Down Expand Up @@ -90,10 +94,13 @@ def create_componentsets_in_HERON(comp_sets_folder, heron_input_xml):
node.append(ET.Comment(f" Some of this component economic info are imported from: {textfile_path}"))
print("The 'cashflow' subnode is found too and is updated")
Cashflow_NODE_FOUND = "True"
elements_to_update = []
for subsubnode in subnode:
if subsubnode.tag in ['reference_driver', 'reference_price', 'scaling_factor_x']:
subnode.remove(subsubnode)
elements_to_update.append(subsubnode)
print(f"WARNING: The value of the {subsubnode.tag} is updated.")
for element in elements_to_update:
subnode.remove(element)
new_cash_node = subnode
new_cash_node.append(ET.Comment(f" Some of this component cashFlow info are imported from: {textfile_path}"))

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,6 @@
<driver>
<Function method="capacity">functions</Function>
</driver>
<reference_driver>
<fixed_value>10.0</fixed_value>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so essentially, these were the original reference drivers that instead of their values getting updated, a new node was added and the old one remained?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Exactly. The design was that any and all reference_driver, reference_price, and scaling_factor_x nodes were cleared, then all three were added; however, the old nodes were not all deleted.

</reference_driver>
<!-- Some of this component cashFlow info are imported from: Sets1//componentSet_pumps.txt-->
<reference_driver>
<fixed_value>2.74763868640817</fixed_value>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -181,9 +181,6 @@
<driver>
<variable>BOP2_capacity</variable>
</driver>
<scaling_factor_x>
<fixed_value>0.692</fixed_value>
</scaling_factor_x>
<!-- Some of this component cashFlow info are imported from: Sets1//componentSet_turbines.txt-->
<reference_driver>
<fixed_value>26.4222377835452</fixed_value>
Expand Down
Loading