I tried to implement a swimming pool following this post on Unmet Hours. If I just create the pool by itself, all is well, though it shows up nowhere in OpenStudioApplication 1.4.0 and so I cannot pick it. But it does appear in the .OSM file, so i know it is there.
However, it falls apart when I try to add it to the plant loop. Then I get the following error:
[03:52:20.973528 ERROR] Found error in state 'translator' with message ["D:\\OSN\\src\\model\\SwimmingPoolIndoor.cpp@149 : Object of type 'OS:SwimmingPool:Indoor' and named 'Swimming Pool' does not have an Surface attached.::/ruby/2.7.0/gems/openstudio-workflow-2.3.1/lib/openstudio/workflow/util/model.rb:124:in `translateModel'\n:/ruby/2.7.0/gems/openstudio-workflow-2.3.1/lib/openstudio/workflow/util/model.rb:124:in `translate_to_energyplus'\n:/ruby/2.7.0/gems/openstudio-workflow-2.3.1/lib/openstudio/workflow/jobs/run_translation.rb:72:in `perform'\n:/ruby/2.7.0/gems/openstudio-workflow-2.3.1/lib/openstudio/workflow/run.rb:291:in `step'\n:/ruby/2.7.0/gems/openstudio-workflow-2.3.1/lib/openstudio/workflow/run.rb:233:in `run'\n:/openstudio_cli.rb:1173:in `execute'\n:/openstudio_cli.rb:803:in `execute'\n:/openstudio_cli.rb:1972:in `'\neval:188:in `eval'\neval:188:in `require_embedded_absolute'\neval:173:in `block in require_embedded'\neval:167:in `each'\neval:167:in `require_embedded'\neval:126:in `require'\neval:3:in `'"]}
I reached my wits' end really quick on this one. I know the surface in question is indeed there. Is this a bug in OpenStudioApplication 1.4.0/OpenStudio 3.4.0?
>>> Response to Denis Bourgeois <<<
Here is the Surface:
OS:Surface,
{2fbf64c8-fb40-4bfd-a26b-76f8ab875201}, !- Handle
Swimming Pool Surface, !- Name
Floor, !- Surface Type
, !- Construction Name
{d56986b7-3bde-4f2a-8fed-bb249f53d035}, !- Space Name
Ground, !- Outside Boundary Condition
, !- Outside Boundary Condition Object
NoSun, !- Sun Exposure
NoWind, !- Wind Exposure
, !- View Factor to Ground
, !- Number of Vertices
18.288, 12.192, 0, !- X,Y,Z Vertex 1 {m}
18.288, 3.048, 0, !- X,Y,Z Vertex 2 {m}
1.524, 3.048, 0, !- X,Y,Z Vertex 3 {m}
1.524, 12.192, 0; !- X,Y,Z Vertex 4 {m}
And here is the Swimming Pool Indoor:
OS:SwimmingPool:Indoor,
{205d8fd8-4623-4941-8f31-580c87b23912}, !- Handle
Swimming Pool, !- Name
{2fbf64c8-fb40-4bfd-a26b-76f8ab875201}, !- Surface Name
2.25552, !- Average Depth {m}
{954c56b7-a6c9-412d-871f-b5d42fc5b90d}, !- Activity Factor Schedule Name
{03694292-0009-4991-a974-c09401bd95b4}, !- Make-up Water Supply Schedule Name
{09a5ca37-f89d-4c5d-81bb-eec7f5b7a18c}, !- Cover Schedule Name
0, !- Cover Evaporation Factor
0, !- Cover Convection Factor
0, !- Cover Short-Wavelength Radiation Factor
0, !- Cover Long-Wavelength Radiation Factor
, !- Pool Water Inlet Node
, !- Pool Water Outlet Node
0.00630901963994975, !- Pool Heating System Maximum Water Flow Rate {m3/s}
464527116.568869, !- Pool Miscellaneous Equipment Power {W-s/m3}
{c40d9ba0-640c-4727-b3eb-379984c6bdc0}, !- Setpoint Temperature Schedule
50, !- Maximum Number of People
{954c56b7-a6c9-412d-871f-b5d42fc5b90d}, !- People Schedule
{7285f29a-52fc-4b24-b8ba-637ecaa59284}; !- People Heat Gain Schedule
Also, all schedules are generated automatically by
swimming_pool = OpenStudio::Model::SwimmingPoolIndoor.new(model,surface).
So with this model, when I try to generate a plant loop and then assign the swimming pool to it as follows, I get the error I reported.
plant_loop.addDemandBranchForComponent(swimming_pool)
Note that I am doing all this via "Apply Measure Now" in OpneStudioApplication, OpenStudioApplication, so I am not using the CLI. Maybe that is the reason, though I don't see why this should only work in CLI and not in Apply Measure Now?
>>> Additional Update <<<
As indicated in the comment below, when running the oneliner.bat file, it works, but when using Apply Measure Now from inside the same model (model.osm) in OpenStudioApplication 1.4.0 and running the measure below, it fails as originally described!
class ConfigureSwimmingPool < OpenStudio::Measure::ModelMeasure
def name
return "Configure Swimming Pool"
end
def description
return "This measure will configure a swimming pool and associated schedules."
end
def modeler_description
message = "The swimming pool will ..."
return message
end
def arguments(model)
argument_vector = OpenStudio::Measure::OSArgumentVector.new
return argument_vector
end
def run(model,runner,user_arguments)
super(model,runner,user_arguments)
if not runner.validateUserArguments(arguments(model), user_arguments)
return false
end
vt = OpenStudio::OSVersion::VersionTranslator.new
# vt.loadModel('model.osm').get()
m = model # modified to get model from which Apply Measure Now is called
s = m.getSurfaceByName('SP Surface').get()
pool = OpenStudio::Model::SwimmingPoolIndoor.new(m, s)
p = m.getPlantLoopByName('SP Loop').get()
p.addDemandBranchForComponent(pool)
# m.save('model.osm', true)
return true
end
end
ConfigureSwimmingPool.new.registerWithApplication