Skip to content

Commit

Permalink
Merge branch 'heron-unit-testing' of github.com:caleb-sitton-inl/FORC…
Browse files Browse the repository at this point in the history
…E into heron-unit-testing
  • Loading branch information
caleb-sitton-inl committed Jun 26, 2024
2 parents 2e4071b + 4c80198 commit 124161c
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 9 deletions.
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>
</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

0 comments on commit 124161c

Please sign in to comment.