First time here? Check out the Help page!
1 | initial version |
The code shown below shows what it does. It literally just makes a new objects swaps it out for the water heater, then removes the water heater. Approach 1 seems like the right one. I assume the measure runs fine but you simulation is failing with missing setpoint. You can edit the model in the GUI after the measure has run to add anything else that is necessary.
2 | No.2 Revision |
The code shown below shows what it does. It literally just makes a new objects swaps it out for the water heater, then removes the water heater. Approach 1 seems like the right one. I assume the measure runs fine but you simulation is failing with missing setpoint. You can edit the model in the GUI after the measure has run to add anything else that is necessary.
# create thermal storage object
new_chilled_water = OpenStudio::Model::ThermalStorageChilledWaterStratified.new(model)
placeholder = nil
# loop through plant loops and swap objects
model.getPlantLoops.each do |plant_loop|
puts "Checking #{plant_loop.name}"
plant_loop.supplyComponents.each do |component|
if component.name.to_s == wh_name
placeholder = component
puts "found #{component.name}"
# swap components
supply_inlet_node = component.to_WaterToWaterComponent.get.supplyInletModelObject.get.to_Node.get
new_chilled_water.addToNode(supply_inlet_node)
demand_inlet_node = component.to_WaterToWaterComponent.get.demandInletModelObject.get.to_Node.get
new_chilled_water.addToNode(demand_inlet_node)
end
end
end
# remove unused water heater from the model
if not placeholder.nil?
puts "Removing water heater"
placeholder.remove
end
3 | No.3 Revision |
The code shown below shows what it the measure does. It literally just makes a new objects swaps it out for the water heater, then removes the water heater. Approach 1 seems like the right one. I assume the measure runs fine but you simulation is failing with missing setpoint. You can edit the model in the GUI after the measure has run to add anything else that is necessary.
# create thermal storage object
new_chilled_water = OpenStudio::Model::ThermalStorageChilledWaterStratified.new(model)
placeholder = nil
# loop through plant loops and swap objects
model.getPlantLoops.each do |plant_loop|
puts "Checking #{plant_loop.name}"
plant_loop.supplyComponents.each do |component|
if component.name.to_s == wh_name
placeholder = component
puts "found #{component.name}"
# swap components
supply_inlet_node = component.to_WaterToWaterComponent.get.supplyInletModelObject.get.to_Node.get
new_chilled_water.addToNode(supply_inlet_node)
demand_inlet_node = component.to_WaterToWaterComponent.get.demandInletModelObject.get.to_Node.get
new_chilled_water.addToNode(demand_inlet_node)
end
end
end
# remove unused water heater from the model
if not placeholder.nil?
puts "Removing water heater"
placeholder.remove
end