Skip to content

Commit

Permalink
Merge branch 'develop' into zonehvac-evap-cooler
Browse files Browse the repository at this point in the history
  • Loading branch information
joseph-robertson committed Jan 2, 2025
2 parents 9265da3 + 0314c3e commit 6562431
Show file tree
Hide file tree
Showing 26 changed files with 798 additions and 53 deletions.
5 changes: 4 additions & 1 deletion python/module/openstudio.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,10 @@
# When we're using system python to load the **installed** C:\openstudio-X.Y-Z\Python stuff (not PyPi package)
# This allows finding openstudiolib.dll and the msvc ones in the bin/ folder while we're in the Python/ folder
# Otherwise you'd have to manually copy these DLLs from bin/ to Python/
os.add_dll_directory(os.path.abspath(os.path.join(os.path.dirname(__file__), '..', 'bin')))
bin_dir = os.path.abspath(os.path.join(os.path.dirname(__file__), '..', 'bin'))
if os.path.isdir(bin_dir):
os.add_dll_directory(bin_dir)

import openstudioairflow as airflow
import openstudioenergyplus as energyplus
import openstudioepjson as epjson
Expand Down
48 changes: 31 additions & 17 deletions resources/model/OpenStudio.idd
Original file line number Diff line number Diff line change
Expand Up @@ -17112,8 +17112,8 @@ OS:DistrictHeating:Steam,

OS:GroundHeatExchanger:Vertical,
\extensible:2
\min-fields 22
\max-fields 220
\min-fields 23
\max-fields 221
\memo Variable short time step vertical ground heat exchanger model based on
\memo Yavuztruk, C., J.D.Spitler. 1999. A Short Time Step response Factor Model for
\memo Vertical Ground Loop Heat Exchangers
Expand Down Expand Up @@ -17143,67 +17143,72 @@ OS:GroundHeatExchanger:Vertical,
N2, \field Number of Bore Holes
\type integer
\minimum> 0.0
N3, \field Bore Hole Length
N3, \field Bore Hole Top Depth
\required-field
\type real
\units m
\minimum 0.0
N4, \field Bore Hole Length
\type real
\units m
\minimum> 0.0
N4, \field Bore Hole Radius
N5, \field Bore Hole Radius
\type real
\units m
\minimum> 0.0
N5, \field Ground Thermal Conductivity
N6, \field Ground Thermal Conductivity
\type real
\units W/m-K
\ip-units Btu-in/hr-ft2-R
\minimum> 0.0
N6, \field Ground Thermal Heat Capacity
N7, \field Ground Thermal Heat Capacity
\type real
\units J/m3-K
\minimum> 0.0
N7, \field Ground Temperature
N8, \field Ground Temperature
\type real
\units C
\minimum> 0.0
N8, \field Grout Thermal Conductivity
N9, \field Grout Thermal Conductivity
\type real
\units W/m-K
\ip-units Btu-in/hr-ft2-R
\minimum> 0.0
N9, \field Pipe Thermal Conductivity
N10, \field Pipe Thermal Conductivity
\type real
\units W/m-K
\ip-units Btu-in/hr-ft2-R
\minimum> 0.0
N10, \field Pipe Out Diameter
N11, \field Pipe Out Diameter
\type real
\units m
\minimum> 0.0
\ip-units in
N11, \field U-Tube Distance
N12, \field U-Tube Distance
\type real
\units m
\minimum> 0.0
N12, \field Pipe Thickness
N13, \field Pipe Thickness
\type real
\units m
\minimum> 0.0
\ip-units in
N13, \field Maximum Length of Simulation
N14, \field Maximum Length of Simulation
\type real
\minimum> 0.0
A5, \field Undisturbed Ground Temperature Model
\required-field
\type object-list
\object-list UndisturbedGroundTempModels
N14, \field G-Function Reference Ratio
N15, \field G-Function Reference Ratio
\type real
\units dimensionless
\minimum> 0.0
\default 0.0005
N15, \field G-Function Ln(T/Ts) Value
N16, \field G-Function Ln(T/Ts) Value
\type real
\begin-extensible
N16; \field G-Function G Value
N17; \field G-Function G Value
\type real

OS:GroundHeatExchanger:HorizontalTrench,
Expand Down Expand Up @@ -31790,7 +31795,16 @@ OS:WaterHeater:HeatPump,
\note A schedule value of 1 denotes inlet air is drawn only from outdoors.
\note Schedule values between 0 and 1 denote a mixture of zone and outdoor air
\note proportional to the schedule value.
A19; \field Control Sensor Location In Stratified Tank
A19, \field Tank Element Control Logic
\type choice
\key MutuallyExclusive
\key Simultaneous
\required-field
\note MutuallyExclusive means that once the tank heating element is active the
\note heat pump is shut down until setpoint is reached.
\note Simultaneous (default) means that both the tank heating element and
\note heat pump are used at the same time recover the tank temperature.
A20; \field Control Sensor Location In Stratified Tank
\note Used to indicate height of control sensor if Tank Object Type is WaterHeater:Stratified
\type choice
\key Heater1
Expand Down
25 changes: 19 additions & 6 deletions ruby/engine/embedded_help.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
# See also https://openstudio.net/license
########################################################################################################################

require 'stringio'

module EmbeddedScripting
@@fileNames = EmbeddedScripting::allFileNamesAsString.split(';')

Expand Down Expand Up @@ -56,6 +58,17 @@ def self.preprocess_ruby_script(s)
# DLM: ignore for now
#Encoding.default_external = Encoding::ASCII

# We patch Kernel.open, and IO.open
# to read embedded files as a StringIO, not as a FileIO
# But Gem.open_file for eg expects it to be a File, not a StringIO, and on
# Windows it will call File::flock (file lock) to protect access, but StringIO
# does not have this method
class FakeFileAsStringIO < StringIO
def flock(operation)
return 0
end
end

module Kernel
# ":" is our root path to the embedded file system
# make sure it is in the ruby load path
Expand Down Expand Up @@ -329,21 +342,21 @@ def open(name, *args, **options)
#puts "string = #{string}"
if block_given?
# if a block is given, then a new IO is created and closed
io = StringIO.open(string)
io = FakeFileAsStringIO.open(string)
begin
result = yield(io)
ensure
io.close
end
return result
else
return StringIO.open(string)
return FakeFileAsStringIO.open(string)
end
else
#puts "IO.open cannot find embedded file '#{absolute_path}' for '#{name}'"
if block_given?
# if a block is given, then a new IO is created and closed
io = StringIO.open("")
io = FakeFileAsStringIO.open("")
begin
result = yield(io)
ensure
Expand Down Expand Up @@ -459,21 +472,21 @@ def self.open(name, *args, **options)
#puts "string = #{string}"
if block_given?
# if a block is given, then a new IO is created and closed
io = StringIO.open(string)
io = FakeFileAsStringIO.open(string)
begin
result = yield(io)
ensure
io.close
end
return result
else
return StringIO.open(string)
return FakeFileAsStringIO.open(string)
end
else
puts "IO.open cannot find embedded file '#{absolute_path}' for '#{name}'"
if block_given?
# if a block is given, then a new IO is created and closed
io = StringIO.open("")
io = FakeFileAsStringIO.open("")
begin
result = yield(io)
ensure
Expand Down
5 changes: 5 additions & 0 deletions src/cli/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,11 @@ if(BUILD_TESTING)
PASS_REGULAR_EXPRESSION "Hello from -x, at National Renewable Energy Laboratory"
)

# Test for 5315
add_test(NAME OpenStudioCLI.EmbeddedScripting.uuid
COMMAND $<TARGET_FILE:openstudio> ${CMAKE_CURRENT_SOURCE_DIR}/test/ensure_uuid_can_be_loaded.rb
)

add_test(NAME OpenStudioCLI.Classic.Run_RubyOnly
COMMAND $<TARGET_FILE:openstudio> classic run -w compact_ruby_only.osw
WORKING_DIRECTORY "${PROJECT_BINARY_DIR}/resources/Examples/compact_osw/"
Expand Down
5 changes: 5 additions & 0 deletions src/cli/test/ensure_uuid_can_be_loaded.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
require 'uuid'

u = UUID.new

puts u.inspect
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ namespace energyplus {
auto propertiesObjectName = modelObject.nameString() + " Properties";
propertiesIdfObject.setName(propertiesObjectName);

propertiesIdfObject.setDouble(GroundHeatExchanger_Vertical_PropertiesFields::DepthofTopofBorehole, 1);
propertiesIdfObject.setDouble(GroundHeatExchanger_Vertical_PropertiesFields::DepthofTopofBorehole, modelObject.boreHoleTopDepth());

if ((value = modelObject.boreHoleLength())) {
propertiesIdfObject.setDouble(GroundHeatExchanger_Vertical_PropertiesFields::BoreholeLength, value.get());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,11 @@ namespace energyplus {
idfObject.setString(WaterHeater_HeatPump_PumpedCondenserFields::ParasiticHeatRejectionLocation, value);
}

{
auto value = modelObject.tankElementControlLogic();
idfObject.setString(WaterHeater_HeatPump_PumpedCondenserFields::TankElementControlLogic, value);
}

{
auto tank = modelObject.tank();
if (auto stratifiedTank = tank.optionalCast<model::WaterHeaterStratified>()) {
Expand Down
3 changes: 2 additions & 1 deletion src/energyplus/Test/GroundHeatExchangerVertical_GTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ TEST_F(EnergyPlusFixture, ForwardTranslator_GroundHeatExchangerVertical) {

EXPECT_TRUE(ghx.setDesignFlowRate(0.004));
EXPECT_TRUE(ghx.setNumberofBoreHoles(100));
EXPECT_TRUE(ghx.setBoreHoleTopDepth(1.35));
EXPECT_TRUE(ghx.setBoreHoleLength(80.0));
EXPECT_TRUE(ghx.setBoreHoleRadius(0.7E-01));
EXPECT_TRUE(ghx.setGroundThermalConductivity(0.7));
Expand Down Expand Up @@ -108,7 +109,7 @@ TEST_F(EnergyPlusFixture, ForwardTranslator_GroundHeatExchangerVertical) {
EXPECT_EQ(100, response.getDouble(GroundHeatExchanger_ResponseFactorsFields::NumberofBoreholes).get());
EXPECT_EQ(0.001, response.getDouble(GroundHeatExchanger_ResponseFactorsFields::GFunctionReferenceRatio).get());

EXPECT_EQ(1, properties.getDouble(GroundHeatExchanger_Vertical_PropertiesFields::DepthofTopofBorehole).get());
EXPECT_EQ(1.35, properties.getDouble(GroundHeatExchanger_Vertical_PropertiesFields::DepthofTopofBorehole).get());
EXPECT_EQ(80.0, properties.getDouble(GroundHeatExchanger_Vertical_PropertiesFields::BoreholeLength).get());
EXPECT_EQ(0.7E-01 * 2, properties.getDouble(GroundHeatExchanger_Vertical_PropertiesFields::BoreholeDiameter).get());
EXPECT_EQ(0.7, properties.getDouble(GroundHeatExchanger_Vertical_PropertiesFields::GroutThermalConductivity).get());
Expand Down
21 changes: 21 additions & 0 deletions src/model/GroundHeatExchangerVertical.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,12 @@ namespace model {
return getInt(OS_GroundHeatExchanger_VerticalFields::NumberofBoreHoles, true);
}

double GroundHeatExchangerVertical_Impl::boreHoleTopDepth() const {
boost::optional<double> value = getDouble(OS_GroundHeatExchanger_VerticalFields::BoreHoleTopDepth, true);
OS_ASSERT(value);
return value.get();
}

boost::optional<double> GroundHeatExchangerVertical_Impl::boreHoleLength() const {
return getDouble(OS_GroundHeatExchanger_VerticalFields::BoreHoleLength, true);
}
Expand Down Expand Up @@ -139,6 +145,11 @@ namespace model {
OS_ASSERT(result);
}

bool GroundHeatExchangerVertical_Impl::setBoreHoleTopDepth(double boreHoleTopDepth) {
bool result = setDouble(OS_GroundHeatExchanger_VerticalFields::BoreHoleTopDepth, boreHoleTopDepth);
return result;
}

bool GroundHeatExchangerVertical_Impl::setBoreHoleLength(boost::optional<double> boreHoleLength) {
bool result(false);
if (boreHoleLength) {
Expand Down Expand Up @@ -443,6 +454,7 @@ namespace model {
OS_ASSERT(getImpl<detail::GroundHeatExchangerVertical_Impl>());

setNumberofBoreHoles(120);
setBoreHoleTopDepth(1);
setBoreHoleLength(76.2);
setBoreHoleRadius(0.635080E-01);
setGroundThermalConductivity(0.692626);
Expand Down Expand Up @@ -513,6 +525,7 @@ namespace model {
<< undisturbedGroundTemperatureModel.briefDescription() << ".");
}
setNumberofBoreHoles(120);
setBoreHoleTopDepth(1);
setBoreHoleLength(76.2);
setBoreHoleRadius(0.635080E-01);
setGroundThermalConductivity(0.692626);
Expand Down Expand Up @@ -596,6 +609,10 @@ namespace model {
return getImpl<detail::GroundHeatExchangerVertical_Impl>()->numberofBoreHoles();
}

double GroundHeatExchangerVertical::boreHoleTopDepth() const {
return getImpl<detail::GroundHeatExchangerVertical_Impl>()->boreHoleTopDepth();
}

boost::optional<double> GroundHeatExchangerVertical::boreHoleLength() const {
return getImpl<detail::GroundHeatExchangerVertical_Impl>()->boreHoleLength();
}
Expand Down Expand Up @@ -664,6 +681,10 @@ namespace model {
getImpl<detail::GroundHeatExchangerVertical_Impl>()->resetNumberofBoreHoles();
}

bool GroundHeatExchangerVertical::setBoreHoleTopDepth(double boreHoleTopDepth) {
return getImpl<detail::GroundHeatExchangerVertical_Impl>()->setBoreHoleTopDepth(boreHoleTopDepth);
}

bool GroundHeatExchangerVertical::setBoreHoleLength(double boreHoleLength) {
return getImpl<detail::GroundHeatExchangerVertical_Impl>()->setBoreHoleLength(boreHoleLength);
}
Expand Down
4 changes: 4 additions & 0 deletions src/model/GroundHeatExchangerVertical.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@ namespace model {

boost::optional<int> numberofBoreHoles() const;

double boreHoleTopDepth() const;

boost::optional<double> boreHoleLength() const;

boost::optional<double> boreHoleRadius() const;
Expand Down Expand Up @@ -108,6 +110,8 @@ namespace model {

void resetNumberofBoreHoles();

bool setBoreHoleTopDepth(double boreHoleTopDepth);

bool setBoreHoleLength(double boreHoleLength);

void resetBoreHoleLength();
Expand Down
4 changes: 4 additions & 0 deletions src/model/GroundHeatExchangerVertical_Impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ namespace model {

boost::optional<int> numberofBoreHoles() const;

double boreHoleTopDepth() const;

boost::optional<double> boreHoleLength() const;

boost::optional<double> boreHoleRadius() const;
Expand Down Expand Up @@ -94,6 +96,8 @@ namespace model {

void resetNumberofBoreHoles();

bool setBoreHoleTopDepth(double boreHoleTopDepth);

bool setBoreHoleLength(boost::optional<double> boreHoleLength);

void resetBoreHoleLength();
Expand Down
Loading

0 comments on commit 6562431

Please sign in to comment.