idaholab / FORCE

The Framework for Optimization of ResourCes and Economics is a collection of software tools, models, and datasets acquired and developed under the Integrated Energy Systems (IES) program to enable analysis of technical and economic viability of myriad IES configurations. FORCE is the consolidating interface and data repository for all the IES toolsets ranging from macro technoeconomic analysis to transient process modeling and experimental validation for integrated energy systems.
MIT License
8 stars 13 forks source link

[DEFECT] Bug in create_componentsets_in_HERON() function #17

Closed caleb-sitton-inl closed 3 months ago

caleb-sitton-inl commented 4 months ago

Thank you for the defect report

Defect Description

Under certain circumstances, the src/heron/create_componentsets_in_HERON() function will not correctly update HERON components. Specifically, when multiple back-to-back children nodes of a single cashflow both need to be updated, the second will not be deleted. This causes a duplication of the node instead of its replacement and incorrect updating. The cause is a for loop in which children nodes that need to be updated are directly removed. This causes the iterator to skip over subsequent children nodes.

Steps to Reproduce

  1. Create a HERON input XML script (see screenshot below for example)
    • Ensure it contains a component with an <economics> subnode that has a <CashFlow> child
    • Ensure above CashFlow has a name containing the string "capex"
    • Place two or more subnodes back-to-back as children of the capex CashFlow node that need to be updated (e.g., <reference_driver>, <reference_price>, or <scaling_factor_x> nodes)
  2. Call src/heron/create_componentsets_in_HERON() function with the above XML script and a valid componentSets folder containing a component set with the same name as the component in the HERON input XML
  3. Observe output as an XML script or run <result_tree_name>.findall('./Components/Component/economics/CashFlow/<second_child_name>') (see screenshot)

Expected Behavior

The function should remove all <reference_driver>, <reference_price>, and <scaling_factor_x> children nodes of the capex CashFlow. It should then add new nodes with the values from the componentSet file. Thus, there should be exactly one each of the <reference_driver>, <reference_price>, and <scaling_factor_x> subnodes within the capex CashFlow.

Screenshots and Input Files

Screenshot 2024-06-20 at 4 00 03 PM Screenshot 2024-06-20 at 4 02 45 PM

OS

MacOS

OS Version

No response

Dependency Manager

CONDA

For Change Control Board: Issue Review

For Change Control Board: Issue Closure