diff --git a/CMakeLists.txt b/CMakeLists.txt index 51f4e091159..ba93257831a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,5 +1,5 @@ message(STATUS "Using CMake ${CMAKE_VERSION}") -cmake_minimum_required(VERSION 3.19.0) +cmake_minimum_required(VERSION 3.20.0) cmake_policy(SET CMP0048 NEW) set(CMAKE_CXX_STANDARD 20) @@ -1216,7 +1216,9 @@ if(NOT UNIX) if(CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS) install(FILES ${CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS} DESTINATION "bin") install(FILES ${CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS} DESTINATION "Ruby" COMPONENT "RubyAPI") - install(FILES ${CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS} DESTINATION "CSharp/openstudio/" COMPONENT "CSharpAPI") + if (BUILD_CSHARP_BINDINGS) + install(FILES ${CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS} DESTINATION "CSharp/openstudio/" COMPONENT "CSharpAPI") + endif() endif() endif() diff --git a/ProjectMacros.cmake b/ProjectMacros.cmake index 13ff05944ff..9a06bdec2c8 100644 --- a/ProjectMacros.cmake +++ b/ProjectMacros.cmake @@ -326,20 +326,8 @@ macro(MAKE_SWIG_TARGET NAME SIMPLENAME KEY_I_FILE I_FILES PARENT_TARGET PARENT_S endif() - # Add the -py3 flag if the version used is Python 3 - set(SWIG_PYTHON_3_FLAGS "") - if (Python_VERSION_MAJOR) - if (Python_VERSION_MAJOR EQUAL 3) - set(SWIG_PYTHON_3_FLAGS "-py3;-relativeimport") - message(STATUS "${MODULE_NAME} - Building SWIG Bindings for Python 3") - else() - message(STATUS "${MODULE_NAME} - Building SWIG Bindings for Python 2") - endif() - else() - # Python2 has been EOL since January 1, 2020 - set(SWIG_PYTHON_3_FLAGS "-py3;-relativeimport") - message(STATUS "${MODULE_NAME} - Couldn't determine version of Python - Building SWIG Bindings for Python 3") - endif() + # The -py3 flag is now deprecated as Python 3 is the default the version used is Python 3 + set(SWIG_PYTHON_3_FLAGS "-relativeimport") add_custom_command( OUTPUT "${SWIG_WRAPPER_FULL_PATH}" "${PYTHON_GENERATED_SRC}" @@ -511,7 +499,7 @@ macro(MAKE_SWIG_TARGET NAME SIMPLENAME KEY_I_FILE I_FILES PARENT_TARGET PARENT_S # This is not working: "cannot open file 'python37.lib'" target_link_libraries(${swig_target} PUBLIC ${${PARENT_TARGET}_depends}) if (MSVC) - message("Python_LIBRARIES=${Python_LIBRARIES}") + message(DEBUG "Python_LIBRARIES=${Python_LIBRARIES}") target_link_libraries(${swig_target} PRIVATE Python::Module) endif() #target_link_libraries(${swig_target} PUBLIC ${${PARENT_TARGET}_depends}) ${Python_LIBRARIES}) diff --git a/csharp/CMakeLists.txt b/csharp/CMakeLists.txt index 3bf687ad476..995b65987ff 100644 --- a/csharp/CMakeLists.txt +++ b/csharp/CMakeLists.txt @@ -10,9 +10,11 @@ install(DIRECTORY "examples" PATTERN "*.docx" ) -file(TO_NATIVE_PATH "${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/csharp" CSHARP_LIBRARY_OUTPUT_DIRECTORY) -file(TO_NATIVE_PATH "${PROJECT_SOURCE_DIR}/csharp" CSHARP_SOURCE_DIR) -file(TO_NATIVE_PATH "${PROJECT_BINARY_DIR}/csharp_wrapper" CSHARP_BINARY_DIR) +set(CSHARP_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/csharp") + +# For csproj.in +file(TO_NATIVE_PATH "${CSHARP_LIBRARY_OUTPUT_DIRECTORY}" CSHARP_LIBRARY_OUTPUT_DIRECTORY_NATIVE) +file(TO_NATIVE_PATH "${PROJECT_SOURCE_DIR}/csharp" CSHARP_SOURCE_DIR_NATIVE) set(CSHARP_VERSION_MAJOR ${PROJECT_VERSION_MAJOR}) set(CSHARP_VERSION_MINOR ${PROJECT_VERSION_MINOR}) @@ -48,7 +50,9 @@ endif() # The Release/Debug can be stripped probably # Also probably don't need to use multiple `` which is the reason there's an extra netstandard2.0/ level -set(OPENSTUDIO_CSHARP_DLL "${CSHARP_LIBRARY_OUTPUT_DIRECTORY}/${CMAKE_BUILD_TYPE}/netstandard2.0/OpenStudio.dll") +# Note: can't use CMAKE_BUILD_TYPE as it's empty for multi generators (MSVC for eg). So we use a genex +# We use the non-native, cmake_path, version of library output directory otherwise install fails with mistmatched `/` and `\` on windows +set(OPENSTUDIO_CSHARP_DLL "${CSHARP_LIBRARY_OUTPUT_DIRECTORY}/$/netstandard2.0/OpenStudio.dll") # ignore deprecated warnings since we will export deprecated methods add_library(csharp_warnings INTERFACE) @@ -60,14 +64,11 @@ target_compile_options(csharp_warnings INTERFACE "$<${is_gnu_or_clang_genex}:-Wn # custom command to make OPENSTUDIO_CSHARP_DLL add_custom_command( OUTPUT ${OPENSTUDIO_CSHARP_DLL} - COMMAND "${DOTNET}" "build" "-c" "$" "/p:Platform=${CSHARP_PLATFORM}" "${PROJECT_BINARY_DIR}/csharp_wrapper/OpenStudio.csproj" + COMMAND "${DOTNET}" "build" "-c" "$" "/p:Platform=${CSHARP_PLATFORM}" "${PROJECT_BINARY_DIR}/csharp_wrapper/OpenStudio.csproj" DEPENDS ${ALL_CSHARP_WRAPPER_TARGETS} ${ALL_CSHARP_WRAPPER_FILES} ) - -install(FILES "${OPENSTUDIO_CSHARP_DLL}" DESTINATION CSharp/openstudio/ CONFIGURATIONS DEBUG COMPONENT "CSharpAPI") - - +install(FILES "${OPENSTUDIO_CSHARP_DLL}" DESTINATION CSharp/openstudio/ COMPONENT "CSharpAPI") # keep the following lists aligned with translator_names in ProjectMacros.cmake set(translator_wrappers diff --git a/csharp/developer/OpenStudio/OpenStudio.csproj.in b/csharp/developer/OpenStudio/OpenStudio.csproj.in index 3df4fc1ee85..355a0beca9a 100644 --- a/csharp/developer/OpenStudio/OpenStudio.csproj.in +++ b/csharp/developer/OpenStudio/OpenStudio.csproj.in @@ -5,9 +5,9 @@ $(TargetsForTfmSpecificContentInPackage);IncludeReferencedLibInPackage true false - ${CSHARP_LIBRARY_OUTPUT_DIRECTORY}\$(Configuration)\ + ${CSHARP_LIBRARY_OUTPUT_DIRECTORY_NATIVE}\$(Configuration)\ true - ${CSHARP_SOURCE_DIR}\developer\OpenStudio\StrongNameKeyFile.snk + ${CSHARP_SOURCE_DIR_NATIVE}\developer\OpenStudio\StrongNameKeyFile.snk diff --git a/developer/doc/ReleaseNotes/OpenStudio_Release_Notes_3_7_0_TDB.md b/developer/doc/ReleaseNotes/OpenStudio_Release_Notes_3_7_0_TDB.md index 67990451e91..0d145e891d7 100644 --- a/developer/doc/ReleaseNotes/OpenStudio_Release_Notes_3_7_0_TDB.md +++ b/developer/doc/ReleaseNotes/OpenStudio_Release_Notes_3_7_0_TDB.md @@ -74,6 +74,13 @@ You can also refer to the [OpenStudio SDK Python Binding Version Compatibility M ## New Features, Major Fixes and API-breaking changes * [#4827](https://github.com/NREL/OpenStudio/pull/4827) - #4748 #4817 - Validate BCLXML with schema when loading + make sorting of files in measure.xml consistent when saving +* [#4873](https://github.com/NREL/OpenStudio/pull/4873) - AirLoopHVACUnitarySystem set Method During XXX Operation + * Fix #4695 - AirLoopHVACUnitarySystem: Supply Air Flow Rate Method During Operation should be set via related setters/autosize + * Breaks the return of `supplyAirFlowRateMethodDuringCoolingOperation` and `supplyAirFlowRateMethodDuringHeatingOperation`: now returns `std::string` instead of `boost::optional` + * Deprecates many set/reset methods +* [#4932](https://github.com/NREL/OpenStudio/pull/4932) - Support undisturbed ground temperature models on GroundHeatExchangerVertical + * Fix #4930 - Support undisturbed ground temperature models on GroundHeatExchangerVertical + * Update `GroundHeatExchanger:Vertical` to actually use the Ground Temeprature Model field * [#4923](https://github.com/NREL/OpenStudio/pull/4923) - Fix #4692 - Modify `Model::load` to use the VersionTranslator instead of loading it assuming the version of the loaded OSM is the same as the current SDK version being used. ## Minor changes and bug fixes diff --git a/python/SetupPython.cmake b/python/SetupPython.cmake index 356552175fa..ef8c0678d7b 100644 --- a/python/SetupPython.cmake +++ b/python/SetupPython.cmake @@ -7,9 +7,9 @@ set(Python_USE_STATIC_LIBS OFF) # find_package(Python) has the problem that on github actions in particular it'll pick up the most recent python (eg 3.9) from the tool cache # even if you have used the setup-python action and set it to 3.8 if (PYTHON_VERSION) - find_package(Python ${PYTHON_VERSION} EXACT COMPONENTS Interpreter Development REQUIRED) + find_package(Python ${PYTHON_VERSION} EXACT REQUIRED COMPONENTS Interpreter Development OPTIONAL_COMPONENTS NumPy) else() - find_package(Python COMPONENTS Interpreter Development REQUIRED) + find_package(Python 3 EXACT REQUIRED COMPONENTS Interpreter Development OPTIONAL_COMPONENTS NumPy) endif() execute_process(COMMAND ${Python_EXECUTABLE} -m pytest --version diff --git a/python/engine/PythonEngine.cpp b/python/engine/PythonEngine.cpp index 7ed95f7254d..86a6559da41 100644 --- a/python/engine/PythonEngine.cpp +++ b/python/engine/PythonEngine.cpp @@ -30,9 +30,12 @@ void addToPythonPath(const openstudio::path& includePath) { if (!includePath.empty()) { PyObject* sys = PyImport_ImportModule("sys"); PyObject* sysPath = PyObject_GetAttrString(sys, "path"); + Py_DECREF(sys); // PyImport_ImportModule returns a new reference, decrement it + // fmt::print("Prepending '{}' to sys.path\n", includePath); PyObject* unicodeIncludePath = PyUnicode_FromString(includePath.string().c_str()); PyList_Insert(sysPath, 0, unicodeIncludePath); + Py_DECREF(sysPath); // PyObject_GetAttrString returns a new reference, decrement it } } @@ -41,30 +44,56 @@ void PythonEngine::pyimport(const std::string& importName, const std::string& in PyImport_ImportModule(importName.c_str()); } -void PythonEngine::setupPythonPath(const std::vector& includeDirs, const openstudio::path& pythonHomeDir) { - for (const auto& includeDir : includeDirs) { - addToPythonPath(includeDir); - } - if (!pythonHomeDir.empty()) { - wchar_t* a = Py_DecodeLocale(pythonHomeDir.generic_string().c_str(), nullptr); - Py_SetPythonHome(a); +void PythonEngine::setupPythonPath(const std::vector& includeDirs) { + + // Iterate in reverse order since addToPythonPath always inserts at pos 0 + // --python_path path1 --python_path path2 => includeDirs = ["path1", "path2"] + // std::ranges::reverse_view needs modern compilers + for (auto it = includeDirs.rbegin(); it != includeDirs.rend(); it++) { + addToPythonPath(*it); } } PythonEngine::PythonEngine(int argc, char* argv[]) : ScriptEngine(argc, argv), program(Py_DecodeLocale(pythonProgramName, nullptr)) { + // TODO: modernize and use PyConfig (new in 3.8): https://docs.python.org/3/c-api/init_config.html + // this frozen flag tells Python that the package and library have been frozen for embedding, so it shouldn't warn about missing prefixes Py_FrozenFlag = 1; - // Set the PYTHONPATH / PYTHONHOME to the E+ shipped standard library - // I think we need to set the python path before initializing the library + // Path to the E+ shipped standard library auto pathToPythonPackages = getEnergyPlusDirectory() / "python_standard_lib"; - wchar_t* a = Py_DecodeLocale(pathToPythonPackages.make_preferred().string().c_str(), nullptr); - Py_SetPath(a); - Py_SetPythonHome(a); + + // The PYTHONPATH / PYTHONHOME should be set before initializing Python + // If this Py_SetPath is called before Py_Initialize, then Py_GetPath won't attempt to compute a default search path + // The default search path is affected by the Py_SetPythonHome + // * if the user passed --python_home, we use that as the Python Home, and do not use Py_SetPath. But later we add the E+ standard_lib anyways + // so it takes precedence (to limit incompatibility issues...) + // * If the user didn't pass it, we use Py_SetPath set to the E+ standard_lib + + std::vector args(argv, std::next(argv, static_cast(argc))); + bool pythonHomePassed = false; + auto it = std::find(args.cbegin(), args.cend(), "--python_home"); + if (it != args.cend()) { + openstudio::path pythonHomeDir(*std::next(it)); + wchar_t* h = Py_DecodeLocale(pythonHomeDir.make_preferred().string().c_str(), nullptr); + Py_SetPythonHome(h); + pythonHomePassed = true; + } else { + wchar_t* a = Py_DecodeLocale(pathToPythonPackages.make_preferred().string().c_str(), nullptr); + Py_SetPath(a); + } Py_SetProgramName(program); // optional but recommended Py_Initialize(); + + if (pythonHomePassed) { + addToPythonPath(pathToPythonPackages); + } +#if defined(__APPLE__) || defined(__linux___) || defined(__unix__) + addToPythonPath(pathToPythonPackages / "lib-dynload"); +#endif + PyObject* m = PyImport_AddModule("__main__"); if (m == nullptr) { throw std::runtime_error("Unable to add module __main__ for python script execution"); diff --git a/python/engine/PythonEngine.hpp b/python/engine/PythonEngine.hpp index 8979c08de25..c2a03bad1cb 100644 --- a/python/engine/PythonEngine.hpp +++ b/python/engine/PythonEngine.hpp @@ -30,7 +30,7 @@ class PythonEngine final : public ScriptEngine ScriptObject eval(std::string_view sv) override; void exec(std::string_view sv) override; - virtual void setupPythonPath(const std::vector& includeDirs, const openstudio::path& pythonHomeDir) override; + virtual void setupPythonPath(const std::vector& includeDirs) override; protected: void* getAs_impl(ScriptObject& obj, const std::type_info&) override; diff --git a/resources/model/OpenStudio.idd b/resources/model/OpenStudio.idd index c5721bd7bef..fb2b16ebe12 100644 --- a/resources/model/OpenStudio.idd +++ b/resources/model/OpenStudio.idd @@ -11902,6 +11902,7 @@ OS:AirLoopHVAC:UnitarySystem, \key FlowPerFloorArea \key FractionOfAutosizedCoolingValue \key FlowPerCoolingCapacity + \default None \note Enter the method used to determine the cooling supply air volume flow rate. \note None is used when a cooling coil is not included in the unitary system or this field may be blank. \note SupplyAirFlowRate is selected when the magnitude of the supply air volume is used. @@ -11946,6 +11947,7 @@ OS:AirLoopHVAC:UnitarySystem, \key FlowPerFloorArea \key FractionOfAutosizedHeatingValue \key FlowPerHeatingCapacity + \default None \note Enter the method used to determine the heating supply air volume flow rate. \note None is used when a heating coil is not included in the unitary system or this field may be blank. \note SupplyAirFlowRate is selected when the magnitude of the supply air volume is used. @@ -16669,8 +16671,8 @@ OS:DistrictHeating, OS:GroundHeatExchanger:Vertical, \extensible:2 - \min-fields 21 - \max-fields 219 + \min-fields 22 + \max-fields 220 \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 @@ -16748,6 +16750,10 @@ OS:GroundHeatExchanger:Vertical, N13, \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 \type real \units dimensionless diff --git a/src/cli/CMakeLists.txt b/src/cli/CMakeLists.txt index 9e2426749df..36c5296ab3e 100644 --- a/src/cli/CMakeLists.txt +++ b/src/cli/CMakeLists.txt @@ -337,6 +337,61 @@ if(BUILD_TESTING) # ============ EndForward a Path properly no matter the slashes employed ============ + # ============ Native Ruby Gems / Python Modules - C extensions ============= + if (Python_NumPy_FOUND) + + if(NOT EXISTS "${Python_ROOT_DIR}") + # Python_STDLIB: we expect it to be + # Unix: ~/.pyenv/versions/3.8.12/lib/python3.8 or + # or on CI: /usr/lib/python3.8/ ... with numpy if install via pip3 and not apt install python3-numpy in `/usr/local/lib/python3.8/dist-packages/` + # Windows C:\Python38\Lib + cmake_path(GET Python_STDLIB PARENT_PATH Python_ROOT_DIR) + if(UNIX) + cmake_path(GET Python_ROOT_DIR PARENT_PATH Python_ROOT_DIR) + endif() + endif() + + if(UNIX) + if(EXISTS "${Python_SITELIB}") + set(PYTHON_PATH "${Python_SITELIB}" "${Python_STDLIB}/lib-dynload") + else() + set(PYTHON_PATH "${Python_STDLIB}/lib-dynload") + endif() + + if(NOT APPLE) + set(EXTRA_LOCAL_DIST "/usr/local/lib/python3.8/dist-packages") + if (EXISTS "${EXTRA_LOCAL_DIST}") + list(APPEND PYTHON_PATH "${EXTRA_LOCAL_DIST}") + endif() + endif() + else() + set(PYTHON_PATH "$") + endif() + + message(DEBUG "PYTHON_PATH=${PYTHON_PATH}") + + add_test(NAME OpenStudioCLI.Labs.execute_python_script.numpy.explicit_sys_path_insert + COMMAND $ labs execute_python_script execute_python_script_with_numpy.py ${Python_STDLIB} + WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/test/" + ) + + add_test(NAME OpenStudioCLI.Labs.execute_python_script.numpy.python_path + COMMAND $ labs + "$<$:--python_path;$>" + execute_python_script execute_python_script_with_numpy.py + COMMAND_EXPAND_LISTS + WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/test/" + ) + + add_test(NAME OpenStudioCLI.Labs.execute_python_script.numpy.python_home + COMMAND $ labs + --python_home "$" + execute_python_script execute_python_script_with_numpy.py + WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/test/" + ) + else() + message(AUTHOR_WARNING "Cannot run the python numpy test, as numpy isn't installed on your system python") + endif() file(GLOB RUBY_TEST_SRC # find all CLI test diff --git a/src/cli/main.cpp b/src/cli/main.cpp index 1d4a6d89839..3834de4caca 100644 --- a/src/cli/main.cpp +++ b/src/cli/main.cpp @@ -136,6 +136,7 @@ int main(int argc, char* argv[]) { experimentalApp ->add_option("-I,--include", includeDirs, "Add additional directory to add to front of Ruby $LOAD_PATH (may be used more than once)") ->option_text("DIR") + ->check(CLI::ExistingDirectory) ->group(rubySpecificOptionsGroupName); std::vector gemPathDirs; @@ -143,21 +144,25 @@ int main(int argc, char* argv[]) { ->add_option("--gem_path", gemPathDirs, "Add additional directory to add to front of GEM_PATH environment variable (may be used more than once)") ->option_text("DIR") + ->check(CLI::ExistingDirectory) ->group(rubySpecificOptionsGroupName); openstudio::path gemHomeDir; experimentalApp->add_option("--gem_home", gemHomeDir, "Set GEM_HOME environment variable") ->option_text("DIR") + ->check(CLI::ExistingDirectory) ->group(rubySpecificOptionsGroupName); openstudio::path bundleGemFilePath; experimentalApp->add_option("--bundle", bundleGemFilePath, "Use bundler for GEMFILE") ->option_text("GEMFILE") + ->check(CLI::ExistingFile) ->group(rubySpecificOptionsGroupName); openstudio::path bundleGemDirPath; experimentalApp->add_option("--bundle_path", bundleGemDirPath, "Use bundler installed gems in BUNDLE_PATH") ->option_text("BUNDLE_PATH") + ->check(CLI::ExistingDirectory) ->group(rubySpecificOptionsGroupName); // std::vector @@ -190,16 +195,19 @@ int main(int argc, char* argv[]) { ->add_option("--python_path", pythonPathDirs, "Add additional directory to add to front of PYTHONPATH environment variable (may be used more than once)") ->option_text("DIR") + ->check(CLI::ExistingDirectory) ->group(pythonSpecificOptionsGroupName); openstudio::path pythonHomeDir; experimentalApp->add_option("--python_home", pythonHomeDir, "Set PYTHONHOME environment variable") ->option_text("DIR") + ->check(CLI::ExistingDirectory) ->group(pythonSpecificOptionsGroupName); // This is a callback that's stored on the ScriptEngineInstance, triggered only the first time - std::function runSetupPythonPath = [&pythonEngine, &pythonPathDirs, &pythonHomeDir]() { - pythonEngine->setupPythonPath(pythonPathDirs, pythonHomeDir); + std::function runSetupPythonPath = [&pythonEngine, &pythonPathDirs]() { + // pythonHomeDir is retrieved from (argc, argv) actually, as Py_SetPythonHome has to be called before Py_Initialize + pythonEngine->setupPythonPath(pythonPathDirs); pythonEngine->registerType("openstudio::measure::ModelMeasure *"); pythonEngine->registerType("openstudio::measure::EnergyPlusMeasure *"); pythonEngine->registerType("openstudio::measure::ReportingMeasure *"); diff --git a/src/cli/test/execute_python_script_with_numpy.py b/src/cli/test/execute_python_script_with_numpy.py new file mode 100644 index 00000000000..8f205edbd3f --- /dev/null +++ b/src/cli/test/execute_python_script_with_numpy.py @@ -0,0 +1,49 @@ +"""Test for importing a python package with a C extension, numpy here.""" + +import sys +from pathlib import Path + + +def test_import_numpy(): + """Common test function.""" + print(f"{sys.path=}") + import numpy as np + + a = np.array([0, 1, 2, 3]) + assert a.sum() == 6 + + +def test_with_sys_path_explicit(std_lib: Path): + """Explicitly insert site-packages and lib-dynload in sys.path.""" + site_pack = std_lib / "site-packages" + if site_pack.exists(): + sys.path.insert(0, str(site_pack)) + # Only for unix + dynload = std_lib / "lib-dynload" + if dynload.exists(): + sys.path.insert(0, str(dynload)) + # Only for debian + dist_pack = std_lib.parent.parent / 'local/lib/python3.8/dist-packages' + if dist_pack.exists(): + sys.path.insert(0, str(dist_pack)) + + test_import_numpy() + + +def test_with_pythonpath_pythonhome(): + """Rely on passing PYTHONPATH/PYTHONHOME.""" + test_import_numpy() + + +if __name__ == "__main__": + if len(sys.argv) == 2: + std_lib = Path(sys.argv[1]) + print("Passed {std_lib=}") + + if std_lib.is_dir(): + test_with_sys_path_explicit(std_lib) + else: + raise ValueError(f"Python std_lib doesn't exist at {std_lib}") + + else: + test_with_pythonpath_pythonhome() diff --git a/src/energyplus/CMakeLists.txt b/src/energyplus/CMakeLists.txt index 1da5afc5462..c6430334ea3 100644 --- a/src/energyplus/CMakeLists.txt +++ b/src/energyplus/CMakeLists.txt @@ -735,6 +735,7 @@ set(${target_name}_test_src Test/GeneratorMicroTurbine_GTest.cpp Test/GeneratorWindTurbine_GTest.cpp Test/GroundHeatExchangerHorizontalTrench_GTest.cpp + Test/GroundHeatExchangerVertical_GTest.cpp Test/HeatExchangerDesiccantBalancedFlow_GTest.cpp Test/HeatExchangerDesiccantBalancedFlowPerformanceDataType1_GTest.cpp Test/HeatPumpAirToWaterFuelFired_GTest.cpp diff --git a/src/energyplus/ForwardTranslator/ForwardTranslateAirLoopHVACUnitarySystem.cpp b/src/energyplus/ForwardTranslator/ForwardTranslateAirLoopHVACUnitarySystem.cpp index 71466fe0d57..e087090796b 100644 --- a/src/energyplus/ForwardTranslator/ForwardTranslateAirLoopHVACUnitarySystem.cpp +++ b/src/energyplus/ForwardTranslator/ForwardTranslateAirLoopHVACUnitarySystem.cpp @@ -197,6 +197,34 @@ namespace energyplus { unitarySystem.setString(AirLoopHVAC_UnitarySystemFields::HeatingCoilObjectType, _heatingCoil->iddObject().name()); unitarySystem.setString(AirLoopHVAC_UnitarySystemFields::HeatingCoilName, _heatingCoil->name().get()); } + + // Supply Air Flow Rate Method During Heating Operation + unitarySystem.setString(AirLoopHVAC_UnitarySystemFields::HeatingSupplyAirFlowRateMethod, + modelObject.supplyAirFlowRateMethodDuringHeatingOperation()); + + // Supply Air Flow Rate During Heating Operation + if (modelObject.isSupplyAirFlowRateDuringHeatingOperationAutosized()) { + unitarySystem.setString(AirLoopHVAC_UnitarySystemFields::HeatingSupplyAirFlowRate, "Autosize"); + } else if (auto val_ = modelObject.supplyAirFlowRateDuringHeatingOperation()) { + unitarySystem.setDouble(AirLoopHVAC_UnitarySystemFields::HeatingSupplyAirFlowRate, val_.get()); + } + + // Supply Air Flow Rate Per Floor Area during Heating Operation + if (auto val_ = modelObject.supplyAirFlowRatePerFloorAreaduringHeatingOperation()) { + unitarySystem.setDouble(AirLoopHVAC_UnitarySystemFields::HeatingSupplyAirFlowRatePerFloorArea, val_.get()); + } + + // Fraction of Autosized Design Heating Supply Air Flow Rate + if (auto val_ = modelObject.fractionofAutosizedDesignHeatingSupplyAirFlowRate()) { + unitarySystem.setDouble(AirLoopHVAC_UnitarySystemFields::HeatingFractionofAutosizedHeatingSupplyAirFlowRate, val_.get()); + } + + // Design Supply Air Flow Rate Per Unit of Capacity During Heating Operation + if (auto val_ = modelObject.designSupplyAirFlowRatePerUnitofCapacityDuringHeatingOperation()) { + unitarySystem.setDouble(AirLoopHVAC_UnitarySystemFields::HeatingSupplyAirFlowRatePerUnitofCapacity, val_.get()); + } + } else { + unitarySystem.setString(AirLoopHVAC_UnitarySystemFields::HeatingSupplyAirFlowRateMethod, "None"); } // DX Heating Coil Sizing Ratio @@ -217,6 +245,34 @@ namespace energyplus { unitarySystem.setString(AirLoopHVAC_UnitarySystemFields::CoolingCoilObjectType, _coolingCoil->iddObject().name()); unitarySystem.setString(AirLoopHVAC_UnitarySystemFields::CoolingCoilName, _coolingCoil->name().get()); } + + // Supply Air Flow Rate Method During Cooling Operation + unitarySystem.setString(AirLoopHVAC_UnitarySystemFields::CoolingSupplyAirFlowRateMethod, + modelObject.supplyAirFlowRateMethodDuringCoolingOperation()); + + // Supply Air Flow Rate During Cooling Operation + if (modelObject.isSupplyAirFlowRateDuringCoolingOperationAutosized()) { + unitarySystem.setString(AirLoopHVAC_UnitarySystemFields::CoolingSupplyAirFlowRate, "Autosize"); + } else if (auto val_ = modelObject.supplyAirFlowRateDuringCoolingOperation()) { + unitarySystem.setDouble(AirLoopHVAC_UnitarySystemFields::CoolingSupplyAirFlowRate, val_.get()); + } + + // Supply Air Flow Rate Per Floor Area During Cooling Operation + if (auto val_ = modelObject.supplyAirFlowRatePerFloorAreaDuringCoolingOperation()) { + unitarySystem.setDouble(AirLoopHVAC_UnitarySystemFields::CoolingSupplyAirFlowRatePerFloorArea, val_.get()); + } + + // Fraction of Autosized Design Cooling Supply Air Flow Rate + if (auto val_ = modelObject.fractionofAutosizedDesignCoolingSupplyAirFlowRate()) { + unitarySystem.setDouble(AirLoopHVAC_UnitarySystemFields::CoolingFractionofAutosizedCoolingSupplyAirFlowRate, val_.get()); + } + + // Design Supply Air Flow Rate Per Unit of Capacity During Cooling Operation + if (auto val_ = modelObject.designSupplyAirFlowRatePerUnitofCapacityDuringCoolingOperation()) { + unitarySystem.setDouble(AirLoopHVAC_UnitarySystemFields::CoolingSupplyAirFlowRatePerUnitofCapacity, val_.get()); + } + } else { + unitarySystem.setString(AirLoopHVAC_UnitarySystemFields::CoolingSupplyAirFlowRateMethod, "None"); } // Use DOAS DX Cooling Coil @@ -252,68 +308,6 @@ namespace energyplus { } } - // Supply Air Flow Rate Method During Cooling Operation - s = modelObject.supplyAirFlowRateMethodDuringCoolingOperation(); - if (s) { - unitarySystem.setString(AirLoopHVAC_UnitarySystemFields::CoolingSupplyAirFlowRateMethod, s.get()); - } - - // Supply Air Flow Rate During Cooling Operation - if (modelObject.isSupplyAirFlowRateDuringCoolingOperationAutosized()) { - unitarySystem.setString(AirLoopHVAC_UnitarySystemFields::CoolingSupplyAirFlowRate, "Autosize"); - } else if ((d = modelObject.supplyAirFlowRateDuringCoolingOperation())) { - unitarySystem.setDouble(AirLoopHVAC_UnitarySystemFields::CoolingSupplyAirFlowRate, d.get()); - } - - // Supply Air Flow Rate Per Floor Area During Cooling Operation - d = modelObject.supplyAirFlowRatePerFloorAreaDuringCoolingOperation(); - if (d) { - unitarySystem.setDouble(AirLoopHVAC_UnitarySystemFields::CoolingSupplyAirFlowRatePerFloorArea, d.get()); - } - - // Fraction of Autosized Design Cooling Supply Air Flow Rate - d = modelObject.fractionofAutosizedDesignCoolingSupplyAirFlowRate(); - if (d) { - unitarySystem.setDouble(AirLoopHVAC_UnitarySystemFields::CoolingFractionofAutosizedCoolingSupplyAirFlowRate, d.get()); - } - - // Design Supply Air Flow Rate Per Unit of Capacity During Cooling Operation - d = modelObject.designSupplyAirFlowRatePerUnitofCapacityDuringCoolingOperation(); - if (d) { - unitarySystem.setDouble(AirLoopHVAC_UnitarySystemFields::CoolingSupplyAirFlowRatePerUnitofCapacity, d.get()); - } - - // Supply Air Flow Rate Method During Heating Operation - s = modelObject.supplyAirFlowRateMethodDuringHeatingOperation(); - if (s) { - unitarySystem.setString(AirLoopHVAC_UnitarySystemFields::HeatingSupplyAirFlowRateMethod, s.get()); - } - - // Supply Air Flow Rate During Heating Operation - if (modelObject.isSupplyAirFlowRateDuringHeatingOperationAutosized()) { - unitarySystem.setString(AirLoopHVAC_UnitarySystemFields::HeatingSupplyAirFlowRate, "Autosize"); - } else if ((d = modelObject.supplyAirFlowRateDuringHeatingOperation())) { - unitarySystem.setDouble(AirLoopHVAC_UnitarySystemFields::HeatingSupplyAirFlowRate, d.get()); - } - - // Supply Air Flow Rate Per Floor Area during Heating Operation - d = modelObject.supplyAirFlowRatePerFloorAreaduringHeatingOperation(); - if (d) { - unitarySystem.setDouble(AirLoopHVAC_UnitarySystemFields::HeatingSupplyAirFlowRatePerFloorArea, d.get()); - } - - // Fraction of Autosized Design Heating Supply Air Flow Rate - d = modelObject.fractionofAutosizedDesignHeatingSupplyAirFlowRate(); - if (d) { - unitarySystem.setDouble(AirLoopHVAC_UnitarySystemFields::HeatingFractionofAutosizedHeatingSupplyAirFlowRate, d.get()); - } - - // Design Supply Air Flow Rate Per Unit of Capacity During Heating Operation - d = modelObject.designSupplyAirFlowRatePerUnitofCapacityDuringHeatingOperation(); - if (d) { - unitarySystem.setDouble(AirLoopHVAC_UnitarySystemFields::HeatingSupplyAirFlowRatePerUnitofCapacity, d.get()); - } - // Supply Air Flow Rate Method When No Cooling or Heating is Required s = modelObject.supplyAirFlowRateMethodWhenNoCoolingorHeatingisRequired(); if (s) { diff --git a/src/energyplus/ForwardTranslator/ForwardTranslateGroundHeatExchangerVertical.cpp b/src/energyplus/ForwardTranslator/ForwardTranslateGroundHeatExchangerVertical.cpp index c7a817f066a..d573a1c6794 100644 --- a/src/energyplus/ForwardTranslator/ForwardTranslateGroundHeatExchangerVertical.cpp +++ b/src/energyplus/ForwardTranslator/ForwardTranslateGroundHeatExchangerVertical.cpp @@ -15,7 +15,6 @@ #include #include #include -#include #include "../../utilities/idd/IddEnums.hpp" #include #include @@ -91,6 +90,17 @@ namespace energyplus { // 1 { GroundHeatExchanger_ResponseFactorsExtensibleFields::gFunctionLn_T_Ts_Value, "gFunctionLn_T_Ts_Value", "g-Function Ln(T/Ts) Value"}, // 2 { GroundHeatExchanger_ResponseFactorsExtensibleFields::gFunctiongValue, "gFunctiongValue", "g-Function g Value"}, + // UndisturbedGroundTemperatureModelName, is required, so start by that + ModelObject undisturbedGroundTemperatureModel = modelObject.undisturbedGroundTemperatureModel(); + boost::optional _undisturbedGroundTemperatureModel = translateAndMapModelObject(undisturbedGroundTemperatureModel); + if (_undisturbedGroundTemperatureModel) { + s = _undisturbedGroundTemperatureModel->name().get(); + } else { + LOG(Warn, modelObject.briefDescription() << " cannot be translated as its undisturbed ground temperature model object cannot be translated: " + << undisturbedGroundTemperatureModel.briefDescription() << "."); + return boost::none; + } + // Name IdfObject idfObject = createRegisterAndNameIdfObject(openstudio::IddObjectType::GroundHeatExchanger_System, modelObject); @@ -104,25 +114,29 @@ namespace energyplus { idfObject.setString(GroundHeatExchanger_SystemFields::OutletNodeName, temp->name().get()); } - // Maximum Flow Rate + // Design Flow Rate if ((value = modelObject.designFlowRate())) { idfObject.setDouble(GroundHeatExchanger_SystemFields::DesignFlowRate, value.get()); } + // Undisturbed Ground Temperature Model Type idfObject.setString(GroundHeatExchanger_SystemFields::UndisturbedGroundTemperatureModelType, - "Site:GroundTemperature:Undisturbed:KusudaAchenbach"); + _undisturbedGroundTemperatureModel->iddObject().name()); - auto groundModelName = modelObject.nameString() + " Ground Temps"; - idfObject.setString(GroundHeatExchanger_SystemFields::UndisturbedGroundTemperatureModelName, groundModelName); + // Undisturbed Ground Temperature Model Name + idfObject.setString(GroundHeatExchanger_SystemFields::UndisturbedGroundTemperatureModelName, s.get()); + // Ground Thermal Conductivity if ((value = modelObject.groundThermalConductivity())) { idfObject.setDouble(GroundHeatExchanger_SystemFields::GroundThermalConductivity, value.get()); } + // Ground Thermal Heat Capacity if ((value = modelObject.groundThermalHeatCapacity())) { idfObject.setDouble(GroundHeatExchanger_SystemFields::GroundThermalHeatCapacity, value.get()); } + // GHE:Vertical:ResponseFactors Object Name auto responseFactorsObjectName = modelObject.nameString() + " Response Factors"; idfObject.setString(GroundHeatExchanger_SystemFields::GHE_Vertical_ResponseFactorsObjectName, responseFactorsObjectName); @@ -166,29 +180,6 @@ namespace energyplus { propertiesIdfObject.setDouble(GroundHeatExchanger_Vertical_PropertiesFields::UTubeDistance, value.get()); } - IdfObject groundIdfObject(IddObjectType::Site_GroundTemperature_Undisturbed_KusudaAchenbach); - m_idfObjects.push_back(groundIdfObject); - - groundIdfObject.setName(groundModelName); - - if ((value = modelObject.groundThermalConductivity())) { - groundIdfObject.setDouble(Site_GroundTemperature_Undisturbed_KusudaAchenbachFields::SoilThermalConductivity, value.get()); - } - - groundIdfObject.setDouble(Site_GroundTemperature_Undisturbed_KusudaAchenbachFields::SoilDensity, 920.0); - - if ((value = modelObject.groundThermalHeatCapacity())) { - groundIdfObject.setDouble(Site_GroundTemperature_Undisturbed_KusudaAchenbachFields::SoilSpecificHeat, value.get() / 920.0); - } - - if ((value = modelObject.groundTemperature())) { - groundIdfObject.setDouble(Site_GroundTemperature_Undisturbed_KusudaAchenbachFields::AverageSoilSurfaceTemperature, value.get()); - } - - groundIdfObject.setDouble(Site_GroundTemperature_Undisturbed_KusudaAchenbachFields::AverageAmplitudeofSurfaceTemperature, 3.2); - - groundIdfObject.setDouble(Site_GroundTemperature_Undisturbed_KusudaAchenbachFields::PhaseShiftofMinimumSurfaceTemperature, 8.0); - IdfObject rfIdfObject(IddObjectType::GroundHeatExchanger_ResponseFactors); m_idfObjects.push_back(rfIdfObject); diff --git a/src/energyplus/Test/GroundHeatExchangerVertical_GTest.cpp b/src/energyplus/Test/GroundHeatExchangerVertical_GTest.cpp new file mode 100644 index 00000000000..f7f3b7e853f --- /dev/null +++ b/src/energyplus/Test/GroundHeatExchangerVertical_GTest.cpp @@ -0,0 +1,121 @@ +/*********************************************************************************************************************** +* OpenStudio(R), Copyright (c) Alliance for Sustainable Energy, LLC. +* See also https://openstudio.net/license +***********************************************************************************************************************/ + +#include +#include "EnergyPlusFixture.hpp" + +#include "../ForwardTranslator.hpp" +#include "../ReverseTranslator.hpp" + +#include "../../model/Model.hpp" +#include "../../model/GroundHeatExchangerVertical.hpp" +#include "../../model/GroundHeatExchangerVertical_Impl.hpp" +#include "../../model/PlantLoop.hpp" +#include "../../model/Node.hpp" +#include "../../model/Node_Impl.hpp" + +#include "../../utilities/idf/IdfFile.hpp" +#include "../../utilities/idf/Workspace.hpp" +#include "../../utilities/idf/IdfObject.hpp" +#include "../../utilities/idf/WorkspaceObject.hpp" + +#include +#include +#include +#include +#include + +using namespace openstudio::energyplus; +using namespace openstudio::model; +using namespace openstudio; + +TEST_F(EnergyPlusFixture, ForwardTranslator_GroundHeatExchangerVertical) { + + ForwardTranslator ft; + + // Create a model + Model m; + + GroundHeatExchangerVertical ghx(m); + + EXPECT_TRUE(ghx.setDesignFlowRate(0.004)); + EXPECT_TRUE(ghx.setNumberofBoreHoles(100)); + EXPECT_TRUE(ghx.setBoreHoleLength(80.0)); + EXPECT_TRUE(ghx.setBoreHoleRadius(0.7E-01)); + EXPECT_TRUE(ghx.setGroundThermalConductivity(0.7)); + EXPECT_TRUE(ghx.setGroundThermalHeatCapacity(0.3E+07)); + EXPECT_TRUE(ghx.setGroundTemperature(14.0)); + EXPECT_TRUE(ghx.setGroutThermalConductivity(0.7)); + EXPECT_TRUE(ghx.setPipeThermalConductivity(0.4)); + EXPECT_TRUE(ghx.setPipeOutDiameter(2.7E-02)); + EXPECT_TRUE(ghx.setUTubeDistance(2.6E-02)); + EXPECT_TRUE(ghx.setPipeThickness(2.5E-03)); + EXPECT_TRUE(ghx.setMaximumLengthofSimulation(3)); + EXPECT_TRUE(ghx.setGFunctionReferenceRatio(0.001)); + + PlantLoop p(m); + EXPECT_TRUE(p.addSupplyBranchForComponent(ghx)); + + ASSERT_TRUE(ghx.inletModelObject()); + ASSERT_TRUE(ghx.inletModelObject()->optionalCast()); + ghx.inletModelObject()->cast().setName("GHX Inlet Node"); + + ASSERT_TRUE(ghx.outletModelObject()); + ASSERT_TRUE(ghx.outletModelObject()->optionalCast()); + ghx.outletModelObject()->cast().setName("GHX Outlet Node"); + + const Workspace w = ft.translateModel(m); + + WorkspaceObjectVector idfObjs = w.getObjectsByType(IddObjectType::GroundHeatExchanger_System); + ASSERT_EQ(1u, idfObjs.size()); + auto idfObject = idfObjs.front(); + + EXPECT_EQ("Ground Heat Exchanger Vertical 1", idfObject.getString(GroundHeatExchanger_SystemFields::Name).get()); + EXPECT_EQ("GHX Inlet Node", idfObject.getString(GroundHeatExchanger_SystemFields::InletNodeName).get()); + EXPECT_EQ("GHX Outlet Node", idfObject.getString(GroundHeatExchanger_SystemFields::OutletNodeName).get()); + EXPECT_EQ(0.004, idfObject.getDouble(GroundHeatExchanger_SystemFields::DesignFlowRate).get()); + + EXPECT_EQ("Site:GroundTemperature:Undisturbed:KusudaAchenbach", + idfObject.getString(GroundHeatExchanger_SystemFields::UndisturbedGroundTemperatureModelType).get()); + + ASSERT_TRUE(idfObject.getTarget(GroundHeatExchanger_SystemFields::UndisturbedGroundTemperatureModelName)); + const WorkspaceObject kusuda = idfObject.getTarget(GroundHeatExchanger_SystemFields::UndisturbedGroundTemperatureModelName).get(); + EXPECT_EQ(IddObjectType{IddObjectType::Site_GroundTemperature_Undisturbed_KusudaAchenbach}, kusuda.iddObject().type()); + + EXPECT_EQ(0.7, idfObject.getDouble(GroundHeatExchanger_SystemFields::GroundThermalConductivity).get()); + EXPECT_EQ(0.3E+07, idfObject.getDouble(GroundHeatExchanger_SystemFields::GroundThermalHeatCapacity).get()); + + ASSERT_TRUE(idfObject.getTarget(GroundHeatExchanger_SystemFields::GHE_Vertical_ResponseFactorsObjectName)); + const WorkspaceObject response = idfObject.getTarget(GroundHeatExchanger_SystemFields::GHE_Vertical_ResponseFactorsObjectName).get(); + EXPECT_EQ(IddObjectType{IddObjectType::GroundHeatExchanger_ResponseFactors}, response.iddObject().type()); + + EXPECT_TRUE(idfObject.isEmpty(GroundHeatExchanger_SystemFields::gFunctionCalculationMethod)); + ASSERT_FALSE(idfObject.getTarget(GroundHeatExchanger_SystemFields::GHE_Vertical_ArrayObjectName)); + + EXPECT_EQ(0.692626, kusuda.getDouble(Site_GroundTemperature_Undisturbed_KusudaAchenbachFields::SoilThermalConductivity).get()); + EXPECT_EQ(920.0, kusuda.getDouble(Site_GroundTemperature_Undisturbed_KusudaAchenbachFields::SoilDensity).get()); + EXPECT_DOUBLE_EQ(0.234700E+07 / 920.0, kusuda.getDouble(Site_GroundTemperature_Undisturbed_KusudaAchenbachFields::SoilSpecificHeat).get()); + EXPECT_EQ(13.375, kusuda.getDouble(Site_GroundTemperature_Undisturbed_KusudaAchenbachFields::AverageSoilSurfaceTemperature).get()); + EXPECT_EQ(3.2, kusuda.getDouble(Site_GroundTemperature_Undisturbed_KusudaAchenbachFields::AverageAmplitudeofSurfaceTemperature).get()); + EXPECT_EQ(8.0, kusuda.getDouble(Site_GroundTemperature_Undisturbed_KusudaAchenbachFields::PhaseShiftofMinimumSurfaceTemperature).get()); + + ASSERT_TRUE(response.getTarget(GroundHeatExchanger_ResponseFactorsFields::GHE_Vertical_PropertiesObjectName)); + const WorkspaceObject properties = response.getTarget(GroundHeatExchanger_ResponseFactorsFields::GHE_Vertical_PropertiesObjectName).get(); + EXPECT_EQ(IddObjectType{IddObjectType::GroundHeatExchanger_Vertical_Properties}, properties.iddObject().type()); + + 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(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()); + EXPECT_EQ(3.90E+06, properties.getDouble(GroundHeatExchanger_Vertical_PropertiesFields::GroutThermalHeatCapacity).get()); + EXPECT_EQ(0.4, properties.getDouble(GroundHeatExchanger_Vertical_PropertiesFields::PipeThermalConductivity).get()); + EXPECT_EQ(1.77E+06, properties.getDouble(GroundHeatExchanger_Vertical_PropertiesFields::PipeThermalHeatCapacity).get()); + EXPECT_EQ(2.7E-02, properties.getDouble(GroundHeatExchanger_Vertical_PropertiesFields::PipeOuterDiameter).get()); + EXPECT_EQ(2.5E-03, properties.getDouble(GroundHeatExchanger_Vertical_PropertiesFields::PipeThickness).get()); + EXPECT_EQ(2.6E-02, properties.getDouble(GroundHeatExchanger_Vertical_PropertiesFields::UTubeDistance).get()); +} diff --git a/src/model/AirLoopHVACUnitarySystem.cpp b/src/model/AirLoopHVACUnitarySystem.cpp index 83823e0e612..02fdd8168c2 100644 --- a/src/model/AirLoopHVACUnitarySystem.cpp +++ b/src/model/AirLoopHVACUnitarySystem.cpp @@ -24,11 +24,14 @@ #include "../utilities/core/Assert.hpp" #include "../utilities/data/DataEnums.hpp" +#include "utilities/core/Exception.hpp" #include #include #include +#include "../utilities/core/DeprecatedHelpers.hpp" + namespace openstudio { namespace model { @@ -291,7 +294,7 @@ namespace model { } boost::optional AirLoopHVACUnitarySystem_Impl::fanPlacement() const { - // No default, and return uninitalized if empty + // No default, and return uninitialized if empty return getString(OS_AirLoopHVAC_UnitarySystemFields::FanPlacement, false, true); } @@ -299,6 +302,10 @@ namespace model { return getObject().getModelObjectTarget(OS_AirLoopHVAC_UnitarySystemFields::SupplyAirFanOperatingModeScheduleName); } + bool AirLoopHVACUnitarySystem_Impl::hasHeatingCoil() const { + return !isEmpty(OS_AirLoopHVAC_UnitarySystemFields::HeatingCoilName); + } + boost::optional AirLoopHVACUnitarySystem_Impl::heatingCoil() const { return getObject().getModelObjectTarget(OS_AirLoopHVAC_UnitarySystemFields::HeatingCoilName); } @@ -313,6 +320,10 @@ namespace model { return isEmpty(OS_AirLoopHVAC_UnitarySystemFields::DXHeatingCoilSizingRatio); } + bool AirLoopHVACUnitarySystem_Impl::hasCoolingCoil() const { + return !isEmpty(OS_AirLoopHVAC_UnitarySystemFields::CoolingCoilName); + } + boost::optional AirLoopHVACUnitarySystem_Impl::coolingCoil() const { return getObject().getModelObjectTarget(OS_AirLoopHVAC_UnitarySystemFields::CoolingCoilName); } @@ -360,8 +371,10 @@ namespace model { return getObject().getModelObjectTarget(OS_AirLoopHVAC_UnitarySystemFields::SupplementalHeatingCoilName); } - boost::optional AirLoopHVACUnitarySystem_Impl::supplyAirFlowRateMethodDuringCoolingOperation() const { - return getString(OS_AirLoopHVAC_UnitarySystemFields::SupplyAirFlowRateMethodDuringCoolingOperation, true); + std::string AirLoopHVACUnitarySystem_Impl::supplyAirFlowRateMethodDuringCoolingOperation() const { + boost::optional value = getString(OS_AirLoopHVAC_UnitarySystemFields::SupplyAirFlowRateMethodDuringCoolingOperation, true); + OS_ASSERT(value); + return value.get(); } boost::optional AirLoopHVACUnitarySystem_Impl::supplyAirFlowRateDuringCoolingOperation() const { @@ -389,8 +402,10 @@ namespace model { return getDouble(OS_AirLoopHVAC_UnitarySystemFields::DesignSupplyAirFlowRatePerUnitofCapacityDuringCoolingOperation, true); } - boost::optional AirLoopHVACUnitarySystem_Impl::supplyAirFlowRateMethodDuringHeatingOperation() const { - return getString(OS_AirLoopHVAC_UnitarySystemFields::SupplyAirFlowRateMethodDuringHeatingOperation, true); + std::string AirLoopHVACUnitarySystem_Impl::supplyAirFlowRateMethodDuringHeatingOperation() const { + boost::optional value = getString(OS_AirLoopHVAC_UnitarySystemFields::SupplyAirFlowRateMethodDuringHeatingOperation, true); + OS_ASSERT(value); + return value.get(); } boost::optional AirLoopHVACUnitarySystem_Impl::supplyAirFlowRateDuringHeatingOperation() const { @@ -419,7 +434,8 @@ namespace model { } boost::optional AirLoopHVACUnitarySystem_Impl::supplyAirFlowRateMethodWhenNoCoolingorHeatingisRequired() const { - return getString(OS_AirLoopHVAC_UnitarySystemFields::SupplyAirFlowRateMethodWhenNoCoolingorHeatingisRequired, true); + // No default, and return uninitialized if empty + return getString(OS_AirLoopHVAC_UnitarySystemFields::SupplyAirFlowRateMethodWhenNoCoolingorHeatingisRequired, false, true); } boost::optional AirLoopHVACUnitarySystem_Impl::supplyAirFlowRateWhenNoCoolingorHeatingisRequired() const { @@ -665,20 +681,23 @@ namespace model { OS_ASSERT(result); } - bool AirLoopHVACUnitarySystem_Impl::setHeatingCoil(const boost::optional& heatingCoil) { - bool result(false); - if (heatingCoil) { - result = setPointer(OS_AirLoopHVAC_UnitarySystemFields::HeatingCoilName, heatingCoil.get().handle()); - } else { - resetHeatingCoil(); - result = true; + bool AirLoopHVACUnitarySystem_Impl::setHeatingCoil(const HVACComponent& heatingCoil) { + const bool result = setPointer(OS_AirLoopHVAC_UnitarySystemFields::HeatingCoilName, heatingCoil.handle()); + if (openstudio::istringEqual("None", supplyAirFlowRateMethodDuringHeatingOperation())) { + autosizeSupplyAirFlowRateDuringHeatingOperation(); + OS_ASSERT(setSupplyAirFlowRateMethodDuringHeatingOperation("SupplyAirFlowRate")); } return result; } void AirLoopHVACUnitarySystem_Impl::resetHeatingCoil() { - bool result = setString(OS_AirLoopHVAC_UnitarySystemFields::HeatingCoilName, ""); + const bool result = setString(OS_AirLoopHVAC_UnitarySystemFields::HeatingCoilName, ""); OS_ASSERT(result); + OS_ASSERT(setSupplyAirFlowRateMethodDuringHeatingOperation("None")); + resetSupplyAirFlowRateDuringHeatingOperation(); + resetSupplyAirFlowRatePerFloorAreaduringHeatingOperation(); + resetFractionofAutosizedDesignHeatingSupplyAirFlowRate(); + resetDesignSupplyAirFlowRatePerUnitofCapacityDuringHeatingOperation(); } bool AirLoopHVACUnitarySystem_Impl::setDXHeatingCoilSizingRatio(double dXHeatingCoilSizingRatio) { @@ -691,25 +710,27 @@ namespace model { OS_ASSERT(result); } - bool AirLoopHVACUnitarySystem_Impl::setCoolingCoil(const boost::optional& coolingCoil) { - bool result(false); - if (coolingCoil) { - result = setPointer(OS_AirLoopHVAC_UnitarySystemFields::CoolingCoilName, coolingCoil.get().handle()); - } else { - resetCoolingCoil(); - result = true; + bool AirLoopHVACUnitarySystem_Impl::setCoolingCoil(const HVACComponent& coolingCoil) { + const bool result = setPointer(OS_AirLoopHVAC_UnitarySystemFields::CoolingCoilName, coolingCoil.handle()); + if (openstudio::istringEqual("None", supplyAirFlowRateMethodDuringCoolingOperation())) { + autosizeSupplyAirFlowRateDuringCoolingOperation(); + OS_ASSERT(setSupplyAirFlowRateMethodDuringCoolingOperation("SupplyAirFlowRate")); } return result; } void AirLoopHVACUnitarySystem_Impl::resetCoolingCoil() { - bool result = setString(OS_AirLoopHVAC_UnitarySystemFields::CoolingCoilName, ""); + const bool result = setString(OS_AirLoopHVAC_UnitarySystemFields::CoolingCoilName, ""); OS_ASSERT(result); + OS_ASSERT(setSupplyAirFlowRateMethodDuringCoolingOperation("None")); + resetSupplyAirFlowRateDuringCoolingOperation(); + resetSupplyAirFlowRatePerFloorAreaDuringCoolingOperation(); + resetFractionofAutosizedDesignCoolingSupplyAirFlowRate(); + resetDesignSupplyAirFlowRatePerUnitofCapacityDuringCoolingOperation(); } bool AirLoopHVACUnitarySystem_Impl::setUseDOASDXCoolingCoil(bool useDOASDXCoolingCoil) { return setBooleanFieldValue(OS_AirLoopHVAC_UnitarySystemFields::UseDOASDXCoolingCoil, useDOASDXCoolingCoil); - ; } void AirLoopHVACUnitarySystem_Impl::resetUseDOASDXCoolingCoil() { @@ -760,190 +781,170 @@ namespace model { } bool AirLoopHVACUnitarySystem_Impl::setSupplyAirFlowRateMethodDuringCoolingOperation( - boost::optional supplyAirFlowRateMethodDuringCoolingOperation) { - bool result(false); - if (supplyAirFlowRateMethodDuringCoolingOperation) { - result = setString(OS_AirLoopHVAC_UnitarySystemFields::SupplyAirFlowRateMethodDuringCoolingOperation, - supplyAirFlowRateMethodDuringCoolingOperation.get()); - } else { - resetSupplyAirFlowRateMethodDuringCoolingOperation(); - result = true; - } + const std::string& supplyAirFlowRateMethodDuringCoolingOperation) { + const bool result = + setString(OS_AirLoopHVAC_UnitarySystemFields::SupplyAirFlowRateMethodDuringCoolingOperation, supplyAirFlowRateMethodDuringCoolingOperation); return result; } - void AirLoopHVACUnitarySystem_Impl::resetSupplyAirFlowRateMethodDuringCoolingOperation() { - bool result = setString(OS_AirLoopHVAC_UnitarySystemFields::SupplyAirFlowRateMethodDuringCoolingOperation, ""); - OS_ASSERT(result); - } - - bool AirLoopHVACUnitarySystem_Impl::setSupplyAirFlowRateDuringCoolingOperation(boost::optional supplyAirFlowRateDuringCoolingOperation) { - bool result(false); - if (supplyAirFlowRateDuringCoolingOperation) { - result = - setDouble(OS_AirLoopHVAC_UnitarySystemFields::SupplyAirFlowRateDuringCoolingOperation, supplyAirFlowRateDuringCoolingOperation.get()); - } else { - resetSupplyAirFlowRateDuringCoolingOperation(); - result = true; - } + bool AirLoopHVACUnitarySystem_Impl::setSupplyAirFlowRateDuringCoolingOperation(double supplyAirFlowRateDuringCoolingOperation) { + const bool result = + setDouble(OS_AirLoopHVAC_UnitarySystemFields::SupplyAirFlowRateDuringCoolingOperation, supplyAirFlowRateDuringCoolingOperation); + OS_ASSERT(setSupplyAirFlowRateMethodDuringCoolingOperation("SupplyAirFlowRate")); + // resetSupplyAirFlowRateDuringCoolingOperation(); + resetSupplyAirFlowRatePerFloorAreaDuringCoolingOperation(); + resetFractionofAutosizedDesignCoolingSupplyAirFlowRate(); + resetDesignSupplyAirFlowRatePerUnitofCapacityDuringCoolingOperation(); return result; } void AirLoopHVACUnitarySystem_Impl::resetSupplyAirFlowRateDuringCoolingOperation() { - bool result = setString(OS_AirLoopHVAC_UnitarySystemFields::SupplyAirFlowRateDuringCoolingOperation, ""); + const bool result = setString(OS_AirLoopHVAC_UnitarySystemFields::SupplyAirFlowRateDuringCoolingOperation, ""); OS_ASSERT(result); } void AirLoopHVACUnitarySystem_Impl::autosizeSupplyAirFlowRateDuringCoolingOperation() { - bool result = setString(OS_AirLoopHVAC_UnitarySystemFields::SupplyAirFlowRateDuringCoolingOperation, "Autosize"); + const bool result = setString(OS_AirLoopHVAC_UnitarySystemFields::SupplyAirFlowRateDuringCoolingOperation, "Autosize"); OS_ASSERT(result); + OS_ASSERT(setSupplyAirFlowRateMethodDuringCoolingOperation("SupplyAirFlowRate")); + // resetSupplyAirFlowRateDuringCoolingOperation(); + resetSupplyAirFlowRatePerFloorAreaDuringCoolingOperation(); + resetFractionofAutosizedDesignCoolingSupplyAirFlowRate(); + resetDesignSupplyAirFlowRatePerUnitofCapacityDuringCoolingOperation(); } bool AirLoopHVACUnitarySystem_Impl::setSupplyAirFlowRatePerFloorAreaDuringCoolingOperation( - boost::optional supplyAirFlowRatePerFloorAreaDuringCoolingOperation) { - bool result(false); - if (supplyAirFlowRatePerFloorAreaDuringCoolingOperation) { - result = setDouble(OS_AirLoopHVAC_UnitarySystemFields::SupplyAirFlowRatePerFloorAreaDuringCoolingOperation, - supplyAirFlowRatePerFloorAreaDuringCoolingOperation.get()); - } else { - resetSupplyAirFlowRatePerFloorAreaDuringCoolingOperation(); - result = true; - } + double supplyAirFlowRatePerFloorAreaDuringCoolingOperation) { + const bool result = setDouble(OS_AirLoopHVAC_UnitarySystemFields::SupplyAirFlowRatePerFloorAreaDuringCoolingOperation, + supplyAirFlowRatePerFloorAreaDuringCoolingOperation); + OS_ASSERT(setSupplyAirFlowRateMethodDuringCoolingOperation("FlowPerFloorArea")); + resetSupplyAirFlowRateDuringCoolingOperation(); + // resetSupplyAirFlowRatePerFloorAreaDuringCoolingOperation(); + resetFractionofAutosizedDesignCoolingSupplyAirFlowRate(); + resetDesignSupplyAirFlowRatePerUnitofCapacityDuringCoolingOperation(); return result; } void AirLoopHVACUnitarySystem_Impl::resetSupplyAirFlowRatePerFloorAreaDuringCoolingOperation() { - bool result = setString(OS_AirLoopHVAC_UnitarySystemFields::SupplyAirFlowRatePerFloorAreaDuringCoolingOperation, ""); + const bool result = setString(OS_AirLoopHVAC_UnitarySystemFields::SupplyAirFlowRatePerFloorAreaDuringCoolingOperation, ""); OS_ASSERT(result); } - bool AirLoopHVACUnitarySystem_Impl::setFractionofAutosizedDesignCoolingSupplyAirFlowRate( - boost::optional fractionofAutosizedDesignCoolingSupplyAirFlowRate) { - bool result(false); - if (fractionofAutosizedDesignCoolingSupplyAirFlowRate) { - result = setDouble(OS_AirLoopHVAC_UnitarySystemFields::FractionofAutosizedDesignCoolingSupplyAirFlowRate, - fractionofAutosizedDesignCoolingSupplyAirFlowRate.get()); - } else { - resetFractionofAutosizedDesignCoolingSupplyAirFlowRate(); - result = true; - } + bool + AirLoopHVACUnitarySystem_Impl::setFractionofAutosizedDesignCoolingSupplyAirFlowRate(double fractionofAutosizedDesignCoolingSupplyAirFlowRate) { + const bool result = setDouble(OS_AirLoopHVAC_UnitarySystemFields::FractionofAutosizedDesignCoolingSupplyAirFlowRate, + fractionofAutosizedDesignCoolingSupplyAirFlowRate); + OS_ASSERT(setSupplyAirFlowRateMethodDuringCoolingOperation("FractionOfAutosizedCoolingValue")); + resetSupplyAirFlowRateDuringCoolingOperation(); + resetSupplyAirFlowRatePerFloorAreaDuringCoolingOperation(); + // resetFractionofAutosizedDesignCoolingSupplyAirFlowRate(); + resetDesignSupplyAirFlowRatePerUnitofCapacityDuringCoolingOperation(); return result; } void AirLoopHVACUnitarySystem_Impl::resetFractionofAutosizedDesignCoolingSupplyAirFlowRate() { - bool result = setString(OS_AirLoopHVAC_UnitarySystemFields::FractionofAutosizedDesignCoolingSupplyAirFlowRate, ""); + const bool result = setString(OS_AirLoopHVAC_UnitarySystemFields::FractionofAutosizedDesignCoolingSupplyAirFlowRate, ""); OS_ASSERT(result); } bool AirLoopHVACUnitarySystem_Impl::setDesignSupplyAirFlowRatePerUnitofCapacityDuringCoolingOperation( - boost::optional designSupplyAirFlowRatePerUnitofCapacityDuringCoolingOperation) { - bool result(false); - if (designSupplyAirFlowRatePerUnitofCapacityDuringCoolingOperation) { - result = setDouble(OS_AirLoopHVAC_UnitarySystemFields::DesignSupplyAirFlowRatePerUnitofCapacityDuringCoolingOperation, - designSupplyAirFlowRatePerUnitofCapacityDuringCoolingOperation.get()); - } else { - resetDesignSupplyAirFlowRatePerUnitofCapacityDuringCoolingOperation(); - result = true; - } + double designSupplyAirFlowRatePerUnitofCapacityDuringCoolingOperation) { + const bool result = setDouble(OS_AirLoopHVAC_UnitarySystemFields::DesignSupplyAirFlowRatePerUnitofCapacityDuringCoolingOperation, + designSupplyAirFlowRatePerUnitofCapacityDuringCoolingOperation); + OS_ASSERT(setSupplyAirFlowRateMethodDuringCoolingOperation("FlowPerCoolingCapacity")); + resetSupplyAirFlowRateDuringCoolingOperation(); + resetSupplyAirFlowRatePerFloorAreaDuringCoolingOperation(); + resetFractionofAutosizedDesignCoolingSupplyAirFlowRate(); + // resetDesignSupplyAirFlowRatePerUnitofCapacityDuringCoolingOperation(); return result; } void AirLoopHVACUnitarySystem_Impl::resetDesignSupplyAirFlowRatePerUnitofCapacityDuringCoolingOperation() { - bool result = setString(OS_AirLoopHVAC_UnitarySystemFields::DesignSupplyAirFlowRatePerUnitofCapacityDuringCoolingOperation, ""); + const bool result = setString(OS_AirLoopHVAC_UnitarySystemFields::DesignSupplyAirFlowRatePerUnitofCapacityDuringCoolingOperation, ""); OS_ASSERT(result); } bool AirLoopHVACUnitarySystem_Impl::setSupplyAirFlowRateMethodDuringHeatingOperation( - boost::optional supplyAirFlowRateMethodDuringHeatingOperation) { - bool result(false); - if (supplyAirFlowRateMethodDuringHeatingOperation) { - result = setString(OS_AirLoopHVAC_UnitarySystemFields::SupplyAirFlowRateMethodDuringHeatingOperation, - supplyAirFlowRateMethodDuringHeatingOperation.get()); - } else { - resetSupplyAirFlowRateMethodDuringHeatingOperation(); - result = true; - } + const std::string& supplyAirFlowRateMethodDuringHeatingOperation) { + const bool result = + setString(OS_AirLoopHVAC_UnitarySystemFields::SupplyAirFlowRateMethodDuringHeatingOperation, supplyAirFlowRateMethodDuringHeatingOperation); return result; } - void AirLoopHVACUnitarySystem_Impl::resetSupplyAirFlowRateMethodDuringHeatingOperation() { - bool result = setString(OS_AirLoopHVAC_UnitarySystemFields::SupplyAirFlowRateMethodDuringHeatingOperation, ""); - OS_ASSERT(result); - } - - bool AirLoopHVACUnitarySystem_Impl::setSupplyAirFlowRateDuringHeatingOperation(boost::optional supplyAirFlowRateDuringHeatingOperation) { - bool result(false); - if (supplyAirFlowRateDuringHeatingOperation) { - result = - setDouble(OS_AirLoopHVAC_UnitarySystemFields::SupplyAirFlowRateDuringHeatingOperation, supplyAirFlowRateDuringHeatingOperation.get()); - } else { - resetSupplyAirFlowRateDuringHeatingOperation(); - result = true; - } + bool AirLoopHVACUnitarySystem_Impl::setSupplyAirFlowRateDuringHeatingOperation(double supplyAirFlowRateDuringHeatingOperation) { + const bool result = + setDouble(OS_AirLoopHVAC_UnitarySystemFields::SupplyAirFlowRateDuringHeatingOperation, supplyAirFlowRateDuringHeatingOperation); + OS_ASSERT(setSupplyAirFlowRateMethodDuringHeatingOperation("SupplyAirFlowRate")); + // resetSupplyAirFlowRateDuringHeatingOperation(); + resetSupplyAirFlowRatePerFloorAreaduringHeatingOperation(); + resetFractionofAutosizedDesignHeatingSupplyAirFlowRate(); + resetDesignSupplyAirFlowRatePerUnitofCapacityDuringHeatingOperation(); return result; } void AirLoopHVACUnitarySystem_Impl::resetSupplyAirFlowRateDuringHeatingOperation() { - bool result = setString(OS_AirLoopHVAC_UnitarySystemFields::SupplyAirFlowRateDuringHeatingOperation, ""); + const bool result = setString(OS_AirLoopHVAC_UnitarySystemFields::SupplyAirFlowRateDuringHeatingOperation, ""); OS_ASSERT(result); } void AirLoopHVACUnitarySystem_Impl::autosizeSupplyAirFlowRateDuringHeatingOperation() { - bool result = setString(OS_AirLoopHVAC_UnitarySystemFields::SupplyAirFlowRateDuringHeatingOperation, "Autosize"); + const bool result = setString(OS_AirLoopHVAC_UnitarySystemFields::SupplyAirFlowRateDuringHeatingOperation, "Autosize"); OS_ASSERT(result); + OS_ASSERT(setSupplyAirFlowRateMethodDuringHeatingOperation("SupplyAirFlowRate")); + // resetSupplyAirFlowRateDuringHeatingOperation(); + resetSupplyAirFlowRatePerFloorAreaduringHeatingOperation(); + resetFractionofAutosizedDesignHeatingSupplyAirFlowRate(); + resetDesignSupplyAirFlowRatePerUnitofCapacityDuringHeatingOperation(); } bool AirLoopHVACUnitarySystem_Impl::setSupplyAirFlowRatePerFloorAreaduringHeatingOperation( - boost::optional supplyAirFlowRatePerFloorAreaduringHeatingOperation) { - bool result(false); - if (supplyAirFlowRatePerFloorAreaduringHeatingOperation) { - result = setDouble(OS_AirLoopHVAC_UnitarySystemFields::SupplyAirFlowRatePerFloorAreaduringHeatingOperation, - supplyAirFlowRatePerFloorAreaduringHeatingOperation.get()); - } else { - resetSupplyAirFlowRatePerFloorAreaduringHeatingOperation(); - result = true; - } + double supplyAirFlowRatePerFloorAreaDuringHeatingOperation) { + const bool result = setDouble(OS_AirLoopHVAC_UnitarySystemFields::SupplyAirFlowRatePerFloorAreaduringHeatingOperation, + supplyAirFlowRatePerFloorAreaDuringHeatingOperation); + OS_ASSERT(setSupplyAirFlowRateMethodDuringHeatingOperation("FlowPerFloorArea")); + resetSupplyAirFlowRateDuringHeatingOperation(); + // resetSupplyAirFlowRatePerFloorAreaduringHeatingOperation(); + resetFractionofAutosizedDesignHeatingSupplyAirFlowRate(); + resetDesignSupplyAirFlowRatePerUnitofCapacityDuringHeatingOperation(); return result; } void AirLoopHVACUnitarySystem_Impl::resetSupplyAirFlowRatePerFloorAreaduringHeatingOperation() { - bool result = setString(OS_AirLoopHVAC_UnitarySystemFields::SupplyAirFlowRatePerFloorAreaduringHeatingOperation, ""); + const bool result = setString(OS_AirLoopHVAC_UnitarySystemFields::SupplyAirFlowRatePerFloorAreaduringHeatingOperation, ""); OS_ASSERT(result); } - bool AirLoopHVACUnitarySystem_Impl::setFractionofAutosizedDesignHeatingSupplyAirFlowRate( - boost::optional fractionofAutosizedDesignHeatingSupplyAirFlowRate) { - bool result(false); - if (fractionofAutosizedDesignHeatingSupplyAirFlowRate) { - result = setDouble(OS_AirLoopHVAC_UnitarySystemFields::FractionofAutosizedDesignHeatingSupplyAirFlowRate, - fractionofAutosizedDesignHeatingSupplyAirFlowRate.get()); - } else { - resetFractionofAutosizedDesignHeatingSupplyAirFlowRate(); - result = true; - } + bool + AirLoopHVACUnitarySystem_Impl::setFractionofAutosizedDesignHeatingSupplyAirFlowRate(double fractionofAutosizedDesignHeatingSupplyAirFlowRate) { + const bool result = setDouble(OS_AirLoopHVAC_UnitarySystemFields::FractionofAutosizedDesignHeatingSupplyAirFlowRate, + fractionofAutosizedDesignHeatingSupplyAirFlowRate); + OS_ASSERT(setSupplyAirFlowRateMethodDuringHeatingOperation("FractionOfAutosizedHeatingValue")); + resetSupplyAirFlowRateDuringHeatingOperation(); + resetSupplyAirFlowRatePerFloorAreaduringHeatingOperation(); + // resetFractionofAutosizedDesignHeatingSupplyAirFlowRate(); + resetDesignSupplyAirFlowRatePerUnitofCapacityDuringHeatingOperation(); return result; } void AirLoopHVACUnitarySystem_Impl::resetFractionofAutosizedDesignHeatingSupplyAirFlowRate() { - bool result = setString(OS_AirLoopHVAC_UnitarySystemFields::FractionofAutosizedDesignHeatingSupplyAirFlowRate, ""); + const bool result = setString(OS_AirLoopHVAC_UnitarySystemFields::FractionofAutosizedDesignHeatingSupplyAirFlowRate, ""); OS_ASSERT(result); } bool AirLoopHVACUnitarySystem_Impl::setDesignSupplyAirFlowRatePerUnitofCapacityDuringHeatingOperation( - boost::optional designSupplyAirFlowRatePerUnitofCapacityDuringHeatingOperation) { - bool result(false); - if (designSupplyAirFlowRatePerUnitofCapacityDuringHeatingOperation) { - result = setDouble(OS_AirLoopHVAC_UnitarySystemFields::DesignSupplyAirFlowRatePerUnitofCapacityDuringHeatingOperation, - designSupplyAirFlowRatePerUnitofCapacityDuringHeatingOperation.get()); - } else { - resetDesignSupplyAirFlowRatePerUnitofCapacityDuringHeatingOperation(); - result = true; - } + double designSupplyAirFlowRatePerUnitofCapacityDuringHeatingOperation) { + const bool result = setDouble(OS_AirLoopHVAC_UnitarySystemFields::DesignSupplyAirFlowRatePerUnitofCapacityDuringHeatingOperation, + designSupplyAirFlowRatePerUnitofCapacityDuringHeatingOperation); + OS_ASSERT(setSupplyAirFlowRateMethodDuringHeatingOperation("FlowPerHeatingCapacity")); + resetSupplyAirFlowRateDuringHeatingOperation(); + resetSupplyAirFlowRatePerFloorAreaduringHeatingOperation(); + resetFractionofAutosizedDesignHeatingSupplyAirFlowRate(); + // resetDesignSupplyAirFlowRatePerUnitofCapacityDuringHeatingOperation(); return result; } void AirLoopHVACUnitarySystem_Impl::resetDesignSupplyAirFlowRatePerUnitofCapacityDuringHeatingOperation() { - bool result = setString(OS_AirLoopHVAC_UnitarySystemFields::DesignSupplyAirFlowRatePerUnitofCapacityDuringHeatingOperation, ""); + const bool result = setString(OS_AirLoopHVAC_UnitarySystemFields::DesignSupplyAirFlowRatePerUnitofCapacityDuringHeatingOperation, ""); OS_ASSERT(result); } @@ -971,6 +972,8 @@ namespace model { if (supplyAirFlowRateWhenNoCoolingorHeatingisRequired) { result = setDouble(OS_AirLoopHVAC_UnitarySystemFields::SupplyAirFlowRateWhenNoCoolingorHeatingisRequired, supplyAirFlowRateWhenNoCoolingorHeatingisRequired.get()); + boost::optional supplyAirFlowRateMethodWhenNoCoolingorHeatingisRequired("SupplyAirFlowRate"); + result = result && setSupplyAirFlowRateMethodWhenNoCoolingorHeatingisRequired(supplyAirFlowRateMethodWhenNoCoolingorHeatingisRequired); } else { resetSupplyAirFlowRateWhenNoCoolingorHeatingisRequired(); result = true; @@ -985,6 +988,8 @@ namespace model { void AirLoopHVACUnitarySystem_Impl::autosizeSupplyAirFlowRateWhenNoCoolingorHeatingisRequired() { bool result = setString(OS_AirLoopHVAC_UnitarySystemFields::SupplyAirFlowRateWhenNoCoolingorHeatingisRequired, "Autosize"); + boost::optional supplyAirFlowRateMethodWhenNoCoolingorHeatingisRequired("SupplyAirFlowRate"); + result = result && setSupplyAirFlowRateMethodWhenNoCoolingorHeatingisRequired(supplyAirFlowRateMethodWhenNoCoolingorHeatingisRequired); OS_ASSERT(result); } @@ -994,6 +999,8 @@ namespace model { if (supplyAirFlowRatePerFloorAreaWhenNoCoolingorHeatingisRequired) { result = setDouble(OS_AirLoopHVAC_UnitarySystemFields::SupplyAirFlowRatePerFloorAreaWhenNoCoolingorHeatingisRequired, supplyAirFlowRatePerFloorAreaWhenNoCoolingorHeatingisRequired.get()); + boost::optional supplyAirFlowRateMethodWhenNoCoolingorHeatingisRequired("FlowPerFloorArea"); + result = result && setSupplyAirFlowRateMethodWhenNoCoolingorHeatingisRequired(supplyAirFlowRateMethodWhenNoCoolingorHeatingisRequired); } else { resetSupplyAirFlowRatePerFloorAreaWhenNoCoolingorHeatingisRequired(); result = true; @@ -1012,6 +1019,8 @@ namespace model { if (fractionofAutosizedDesignCoolingSupplyAirFlowRateWhenNoCoolingorHeatingisRequired) { result = setDouble(OS_AirLoopHVAC_UnitarySystemFields::FractionofAutosizedDesignCoolingSupplyAirFlowRateWhenNoCoolingorHeatingisRequired, fractionofAutosizedDesignCoolingSupplyAirFlowRateWhenNoCoolingorHeatingisRequired.get()); + boost::optional supplyAirFlowRateMethodWhenNoCoolingorHeatingisRequired("FractionOfAutosizedCoolingValue"); + result = result && setSupplyAirFlowRateMethodWhenNoCoolingorHeatingisRequired(supplyAirFlowRateMethodWhenNoCoolingorHeatingisRequired); } else { resetFractionofAutosizedDesignCoolingSupplyAirFlowRateWhenNoCoolingorHeatingisRequired(); result = true; @@ -1031,6 +1040,8 @@ namespace model { if (fractionofAutosizedDesignHeatingSupplyAirFlowRateWhenNoCoolingorHeatingisRequired) { result = setDouble(OS_AirLoopHVAC_UnitarySystemFields::FractionofAutosizedDesignHeatingSupplyAirFlowRateWhenNoCoolingorHeatingisRequired, fractionofAutosizedDesignHeatingSupplyAirFlowRateWhenNoCoolingorHeatingisRequired.get()); + boost::optional supplyAirFlowRateMethodWhenNoCoolingorHeatingisRequired("FractionOfAutosizedHeatingValue"); + result = result && setSupplyAirFlowRateMethodWhenNoCoolingorHeatingisRequired(supplyAirFlowRateMethodWhenNoCoolingorHeatingisRequired); } else { resetFractionofAutosizedDesignHeatingSupplyAirFlowRateWhenNoCoolingorHeatingisRequired(); result = true; @@ -1051,6 +1062,8 @@ namespace model { result = setDouble( OS_AirLoopHVAC_UnitarySystemFields::DesignSupplyAirFlowRatePerUnitofCapacityDuringCoolingOperationWhenNoCoolingorHeatingisRequired, designSupplyAirFlowRatePerUnitofCapacityDuringCoolingOperationWhenNoCoolingorHeatingisRequired.get()); + boost::optional supplyAirFlowRateMethodWhenNoCoolingorHeatingisRequired("FlowPerCoolingCapacity"); + result = result && setSupplyAirFlowRateMethodWhenNoCoolingorHeatingisRequired(supplyAirFlowRateMethodWhenNoCoolingorHeatingisRequired); } else { resetDesignSupplyAirFlowRatePerUnitofCapacityDuringCoolingOperationWhenNoCoolingorHeatingisRequired(); result = true; @@ -1071,6 +1084,8 @@ namespace model { result = setDouble( OS_AirLoopHVAC_UnitarySystemFields::DesignSupplyAirFlowRatePerUnitofCapacityDuringHeatingOperationWhenNoCoolingorHeatingisRequired, designSupplyAirFlowRatePerUnitofCapacityDuringHeatingOperationWhenNoCoolingorHeatingisRequired.get()); + boost::optional supplyAirFlowRateMethodWhenNoCoolingorHeatingisRequired("FlowPerHeatingCapacity"); + result = result && setSupplyAirFlowRateMethodWhenNoCoolingorHeatingisRequired(supplyAirFlowRateMethodWhenNoCoolingorHeatingisRequired); } else { resetDesignSupplyAirFlowRatePerUnitofCapacityDuringHeatingOperationWhenNoCoolingorHeatingisRequired(); result = true; @@ -1374,8 +1389,8 @@ namespace model { OS_ASSERT(ok); ok = setLatentLoadControl("SensibleOnlyLoadControl"); OS_ASSERT(ok); - autosizeSupplyAirFlowRateDuringCoolingOperation(); - autosizeSupplyAirFlowRateDuringHeatingOperation(); + getImpl()->setSupplyAirFlowRateMethodDuringCoolingOperation("None"); + getImpl()->setSupplyAirFlowRateMethodDuringHeatingOperation("None"); autosizeSupplyAirFlowRateWhenNoCoolingorHeatingisRequired(); setMaximumSupplyAirTemperature(80.0); setMaximumOutdoorDryBulbTemperatureforSupplementalHeaterOperation(21.0); @@ -1514,7 +1529,7 @@ namespace model { return getImpl()->supplementalHeatingCoil(); } - boost::optional AirLoopHVACUnitarySystem::supplyAirFlowRateMethodDuringCoolingOperation() const { + std::string AirLoopHVACUnitarySystem::supplyAirFlowRateMethodDuringCoolingOperation() const { return getImpl()->supplyAirFlowRateMethodDuringCoolingOperation(); } @@ -1538,7 +1553,7 @@ namespace model { return getImpl()->designSupplyAirFlowRatePerUnitofCapacityDuringCoolingOperation(); } - boost::optional AirLoopHVACUnitarySystem::supplyAirFlowRateMethodDuringHeatingOperation() const { + std::string AirLoopHVACUnitarySystem::supplyAirFlowRateMethodDuringHeatingOperation() const { return getImpl()->supplyAirFlowRateMethodDuringHeatingOperation(); } @@ -1808,23 +1823,10 @@ namespace model { getImpl()->resetSupplementalHeatingCoil(); } - bool AirLoopHVACUnitarySystem::setSupplyAirFlowRateMethodDuringCoolingOperation(const std::string& supplyAirFlowRateMethodDuringCoolingOperation) { - return getImpl()->setSupplyAirFlowRateMethodDuringCoolingOperation( - supplyAirFlowRateMethodDuringCoolingOperation); - } - - void AirLoopHVACUnitarySystem::resetSupplyAirFlowRateMethodDuringCoolingOperation() { - getImpl()->resetSupplyAirFlowRateMethodDuringCoolingOperation(); - } - bool AirLoopHVACUnitarySystem::setSupplyAirFlowRateDuringCoolingOperation(double supplyAirFlowRateDuringCoolingOperation) { return getImpl()->setSupplyAirFlowRateDuringCoolingOperation(supplyAirFlowRateDuringCoolingOperation); } - void AirLoopHVACUnitarySystem::resetSupplyAirFlowRateDuringCoolingOperation() { - getImpl()->resetSupplyAirFlowRateDuringCoolingOperation(); - } - void AirLoopHVACUnitarySystem::autosizeSupplyAirFlowRateDuringCoolingOperation() { getImpl()->autosizeSupplyAirFlowRateDuringCoolingOperation(); } @@ -1834,46 +1836,21 @@ namespace model { supplyAirFlowRatePerFloorAreaDuringCoolingOperation); } - void AirLoopHVACUnitarySystem::resetSupplyAirFlowRatePerFloorAreaDuringCoolingOperation() { - getImpl()->resetSupplyAirFlowRatePerFloorAreaDuringCoolingOperation(); - } - bool AirLoopHVACUnitarySystem::setFractionofAutosizedDesignCoolingSupplyAirFlowRate(double fractionofAutosizedDesignCoolingSupplyAirFlowRate) { return getImpl()->setFractionofAutosizedDesignCoolingSupplyAirFlowRate( fractionofAutosizedDesignCoolingSupplyAirFlowRate); } - void AirLoopHVACUnitarySystem::resetFractionofAutosizedDesignCoolingSupplyAirFlowRate() { - getImpl()->resetFractionofAutosizedDesignCoolingSupplyAirFlowRate(); - } - bool AirLoopHVACUnitarySystem::setDesignSupplyAirFlowRatePerUnitofCapacityDuringCoolingOperation( double designSupplyAirFlowRatePerUnitofCapacityDuringCoolingOperation) { return getImpl()->setDesignSupplyAirFlowRatePerUnitofCapacityDuringCoolingOperation( designSupplyAirFlowRatePerUnitofCapacityDuringCoolingOperation); } - void AirLoopHVACUnitarySystem::resetDesignSupplyAirFlowRatePerUnitofCapacityDuringCoolingOperation() { - getImpl()->resetDesignSupplyAirFlowRatePerUnitofCapacityDuringCoolingOperation(); - } - - bool AirLoopHVACUnitarySystem::setSupplyAirFlowRateMethodDuringHeatingOperation(const std::string& supplyAirFlowRateMethodDuringHeatingOperation) { - return getImpl()->setSupplyAirFlowRateMethodDuringHeatingOperation( - supplyAirFlowRateMethodDuringHeatingOperation); - } - - void AirLoopHVACUnitarySystem::resetSupplyAirFlowRateMethodDuringHeatingOperation() { - getImpl()->resetSupplyAirFlowRateMethodDuringHeatingOperation(); - } - bool AirLoopHVACUnitarySystem::setSupplyAirFlowRateDuringHeatingOperation(double supplyAirFlowRateDuringHeatingOperation) { return getImpl()->setSupplyAirFlowRateDuringHeatingOperation(supplyAirFlowRateDuringHeatingOperation); } - void AirLoopHVACUnitarySystem::resetSupplyAirFlowRateDuringHeatingOperation() { - getImpl()->resetSupplyAirFlowRateDuringHeatingOperation(); - } - void AirLoopHVACUnitarySystem::autosizeSupplyAirFlowRateDuringHeatingOperation() { getImpl()->autosizeSupplyAirFlowRateDuringHeatingOperation(); } @@ -1883,29 +1860,17 @@ namespace model { supplyAirFlowRatePerFloorAreaduringHeatingOperation); } - void AirLoopHVACUnitarySystem::resetSupplyAirFlowRatePerFloorAreaduringHeatingOperation() { - getImpl()->resetSupplyAirFlowRatePerFloorAreaduringHeatingOperation(); - } - bool AirLoopHVACUnitarySystem::setFractionofAutosizedDesignHeatingSupplyAirFlowRate(double fractionofAutosizedDesignHeatingSupplyAirFlowRate) { return getImpl()->setFractionofAutosizedDesignHeatingSupplyAirFlowRate( fractionofAutosizedDesignHeatingSupplyAirFlowRate); } - void AirLoopHVACUnitarySystem::resetFractionofAutosizedDesignHeatingSupplyAirFlowRate() { - getImpl()->resetFractionofAutosizedDesignHeatingSupplyAirFlowRate(); - } - bool AirLoopHVACUnitarySystem::setDesignSupplyAirFlowRatePerUnitofCapacityDuringHeatingOperation( double designSupplyAirFlowRatePerUnitofCapacityDuringHeatingOperation) { return getImpl()->setDesignSupplyAirFlowRatePerUnitofCapacityDuringHeatingOperation( designSupplyAirFlowRatePerUnitofCapacityDuringHeatingOperation); } - void AirLoopHVACUnitarySystem::resetDesignSupplyAirFlowRatePerUnitofCapacityDuringHeatingOperation() { - getImpl()->resetDesignSupplyAirFlowRatePerUnitofCapacityDuringHeatingOperation(); - } - bool AirLoopHVACUnitarySystem::setSupplyAirFlowRateMethodWhenNoCoolingorHeatingisRequired( const std::string& supplyAirFlowRateMethodWhenNoCoolingorHeatingisRequired) { return getImpl()->setSupplyAirFlowRateMethodWhenNoCoolingorHeatingisRequired( @@ -2085,11 +2050,6 @@ namespace model { getImpl()->resetDesignSpecificationMultispeedObject(); } - /// @cond - AirLoopHVACUnitarySystem::AirLoopHVACUnitarySystem(std::shared_ptr impl) - : ZoneHVACComponent(std::move(impl)) {} - /// @endcond - boost::optional AirLoopHVACUnitarySystem::autosizedSupplyAirFlowRateDuringCoolingOperation() const { return getImpl()->autosizedSupplyAirFlowRateDuringCoolingOperation(); } @@ -2110,5 +2070,94 @@ namespace model { return getImpl()->autosizedDOASDXCoolingCoilLeavingMinimumAirTemperature(); } + /// @cond + AirLoopHVACUnitarySystem::AirLoopHVACUnitarySystem(std::shared_ptr impl) + : ZoneHVACComponent(std::move(impl)) {} + + // DEPRECATED + bool AirLoopHVACUnitarySystem::setSupplyAirFlowRateMethodDuringCoolingOperation(const std::string& supplyAirFlowRateMethodDuringCoolingOperation) { + DEPRECATED_AT_MSG(3, 7, 0, + "Use setSupplyAirFlowRateDuringCoolingOperation, autosizeSupplyAirFlowRateDuringCoolingOperation, " + "setSupplyAirFlowRatePerFloorAreaDuringCoolingOperation, setFractionofAutosizedDesignCoolingSupplyAirFlowRate, or " + "setDesignSupplyAirFlowRatePerUnitofCapacityDuringCoolingOperation instead."); + return false; + } + + void AirLoopHVACUnitarySystem::resetSupplyAirFlowRateMethodDuringCoolingOperation() { + DEPRECATED_AT_MSG(3, 7, 0, + "Use setSupplyAirFlowRateDuringCoolingOperation, autosizeSupplyAirFlowRateDuringCoolingOperation, " + "setSupplyAirFlowRatePerFloorAreaDuringCoolingOperation, setFractionofAutosizedDesignCoolingSupplyAirFlowRate, or " + "setDesignSupplyAirFlowRatePerUnitofCapacityDuringCoolingOperation instead."); + } + + void AirLoopHVACUnitarySystem::resetSupplyAirFlowRateDuringCoolingOperation() { + DEPRECATED_AT_MSG(3, 7, 0, + "Use setSupplyAirFlowRatePerFloorAreaDuringCoolingOperation, setFractionofAutosizedDesignCoolingSupplyAirFlowRate, or " + "setDesignSupplyAirFlowRatePerUnitofCapacityDuringCoolingOperation instead."); + } + + void AirLoopHVACUnitarySystem::resetSupplyAirFlowRatePerFloorAreaDuringCoolingOperation() { + DEPRECATED_AT_MSG( + 3, 7, 0, + "Use setSupplyAirFlowRateDuringCoolingOperation, autosizeSupplyAirFlowRateDuringCoolingOperation, " + "setFractionofAutosizedDesignCoolingSupplyAirFlowRate, or setDesignSupplyAirFlowRatePerUnitofCapacityDuringCoolingOperation instead."); + } + + void AirLoopHVACUnitarySystem::resetFractionofAutosizedDesignCoolingSupplyAirFlowRate() { + DEPRECATED_AT_MSG( + 3, 7, 0, + "Use setSupplyAirFlowRateDuringCoolingOperation, autosizeSupplyAirFlowRateDuringCoolingOperation, " + "setSupplyAirFlowRatePerFloorAreaDuringCoolingOperation, or setDesignSupplyAirFlowRatePerUnitofCapacityDuringCoolingOperation instead."); + } + + void AirLoopHVACUnitarySystem::resetDesignSupplyAirFlowRatePerUnitofCapacityDuringCoolingOperation() { + DEPRECATED_AT_MSG(3, 7, 0, + "Use setSupplyAirFlowRateDuringCoolingOperation, autosizeSupplyAirFlowRateDuringCoolingOperation, " + "setSupplyAirFlowRatePerFloorAreaDuringCoolingOperation, or setFractionofAutosizedDesignCoolingSupplyAirFlowRate instead."); + } + + bool AirLoopHVACUnitarySystem::setSupplyAirFlowRateMethodDuringHeatingOperation(const std::string& supplyAirFlowRateMethodDuringHeatingOperation) { + DEPRECATED_AT_MSG(3, 7, 0, + "Use setSupplyAirFlowRateDuringHeatingOperation, autosizeSupplyAirFlowRateDuringHeatingOperation, " + "setSupplyAirFlowRatePerFloorAreaduringHeatingOperation, setFractionofAutosizedDesignHeatingSupplyAirFlowRate, or " + "setDesignSupplyAirFlowRatePerUnitofCapacityDuringHeatingOperation instead."); + return false; + } + + void AirLoopHVACUnitarySystem::resetSupplyAirFlowRateMethodDuringHeatingOperation() { + DEPRECATED_AT_MSG(3, 7, 0, + "Use setSupplyAirFlowRateDuringHeatingOperation, autosizeSupplyAirFlowRateDuringHeatingOperation, " + "setSupplyAirFlowRatePerFloorAreaduringHeatingOperation, setFractionofAutosizedDesignHeatingSupplyAirFlowRate, or " + "setDesignSupplyAirFlowRatePerUnitofCapacityDuringHeatingOperation instead."); + } + + void AirLoopHVACUnitarySystem::resetSupplyAirFlowRateDuringHeatingOperation() { + DEPRECATED_AT_MSG(3, 7, 0, + "Use setSupplyAirFlowRatePerFloorAreaduringHeatingOperation, setFractionofAutosizedDesignHeatingSupplyAirFlowRate, or " + "setDesignSupplyAirFlowRatePerUnitofCapacityDuringHeatingOperation instead."); + } + + void AirLoopHVACUnitarySystem::resetSupplyAirFlowRatePerFloorAreaduringHeatingOperation() { + DEPRECATED_AT_MSG( + 3, 7, 0, + "Use setSupplyAirFlowRateDuringHeatingOperation, autosizeSupplyAirFlowRateDuringHeatingOperation, " + "setFractionofAutosizedDesignHeatingSupplyAirFlowRate, or setDesignSupplyAirFlowRatePerUnitofCapacityDuringHeatingOperation instead."); + } + + void AirLoopHVACUnitarySystem::resetFractionofAutosizedDesignHeatingSupplyAirFlowRate() { + DEPRECATED_AT_MSG( + 3, 7, 0, + "Use setSupplyAirFlowRateDuringHeatingOperation, autosizeSupplyAirFlowRateDuringHeatingOperation, " + "setSupplyAirFlowRatePerFloorAreaduringHeatingOperation, or setDesignSupplyAirFlowRatePerUnitofCapacityDuringHeatingOperation instead."); + } + + void AirLoopHVACUnitarySystem::resetDesignSupplyAirFlowRatePerUnitofCapacityDuringHeatingOperation() { + DEPRECATED_AT_MSG(3, 7, 0, + "Use setSupplyAirFlowRateDuringHeatingOperation, autosizeSupplyAirFlowRateDuringHeatingOperation, " + "setSupplyAirFlowRatePerFloorAreaduringHeatingOperation, or setFractionofAutosizedDesignHeatingSupplyAirFlowRate instead."); + } + + /// @endcond + } // namespace model } // namespace openstudio diff --git a/src/model/AirLoopHVACUnitarySystem.hpp b/src/model/AirLoopHVACUnitarySystem.hpp index 0233af0dea1..a906a23c165 100644 --- a/src/model/AirLoopHVACUnitarySystem.hpp +++ b/src/model/AirLoopHVACUnitarySystem.hpp @@ -9,6 +9,8 @@ #include "ModelAPI.hpp" #include "ZoneHVACComponent.hpp" +#include "../utilities/core/Deprecated.hpp" + namespace openstudio { namespace model { @@ -106,7 +108,7 @@ namespace model { boost::optional supplementalHeatingCoil() const; /** In EnergyPlus 8.3.0 and above this property maps to the EnergyPlus field "Cooling Supply Air Flow Rate Method" **/ - boost::optional supplyAirFlowRateMethodDuringCoolingOperation() const; + std::string supplyAirFlowRateMethodDuringCoolingOperation() const; /** In EnergyPlus 8.3.0 and above this property maps to the EnergyPlus field "Cooling Supply Air Flow Rate" **/ boost::optional supplyAirFlowRateDuringCoolingOperation() const; @@ -123,7 +125,7 @@ namespace model { boost::optional designSupplyAirFlowRatePerUnitofCapacityDuringCoolingOperation() const; /** In EnergyPlus 8.3.0 and above this property maps to the EnergyPlus field "Heating Supply Air Flow Rate Method" **/ - boost::optional supplyAirFlowRateMethodDuringHeatingOperation() const; + std::string supplyAirFlowRateMethodDuringHeatingOperation() const; /** In EnergyPlus 8.3.0 and above this property maps to the EnergyPlus field "Heating Supply Air Flow Rate" **/ boost::optional supplyAirFlowRateDuringHeatingOperation() const; @@ -274,49 +276,37 @@ namespace model { void resetSupplementalHeatingCoil(); - bool setSupplyAirFlowRateMethodDuringCoolingOperation(const std::string& supplyAirFlowRateMethodDuringCoolingOperation); - - void resetSupplyAirFlowRateMethodDuringCoolingOperation(); + OS_DEPRECATED(3, 7, 0) bool setSupplyAirFlowRateMethodDuringCoolingOperation(const std::string& supplyAirFlowRateMethodDuringCoolingOperation); + OS_DEPRECATED(3, 7, 0) void resetSupplyAirFlowRateMethodDuringCoolingOperation(); bool setSupplyAirFlowRateDuringCoolingOperation(double supplyAirFlowRateDuringCoolingOperation); - - void resetSupplyAirFlowRateDuringCoolingOperation(); - + OS_DEPRECATED(3, 7, 0) void resetSupplyAirFlowRateDuringCoolingOperation(); void autosizeSupplyAirFlowRateDuringCoolingOperation(); bool setSupplyAirFlowRatePerFloorAreaDuringCoolingOperation(double supplyAirFlowRatePerFloorAreaDuringCoolingOperation); - - void resetSupplyAirFlowRatePerFloorAreaDuringCoolingOperation(); + OS_DEPRECATED(3, 7, 0) void resetSupplyAirFlowRatePerFloorAreaDuringCoolingOperation(); bool setFractionofAutosizedDesignCoolingSupplyAirFlowRate(double fractionofAutosizedDesignCoolingSupplyAirFlowRate); - - void resetFractionofAutosizedDesignCoolingSupplyAirFlowRate(); + OS_DEPRECATED(3, 7, 0) void resetFractionofAutosizedDesignCoolingSupplyAirFlowRate(); bool setDesignSupplyAirFlowRatePerUnitofCapacityDuringCoolingOperation(double designSupplyAirFlowRatePerUnitofCapacityDuringCoolingOperation); + OS_DEPRECATED(3, 7, 0) void resetDesignSupplyAirFlowRatePerUnitofCapacityDuringCoolingOperation(); - void resetDesignSupplyAirFlowRatePerUnitofCapacityDuringCoolingOperation(); - - bool setSupplyAirFlowRateMethodDuringHeatingOperation(const std::string& supplyAirFlowRateMethodDuringHeatingOperation); - - void resetSupplyAirFlowRateMethodDuringHeatingOperation(); + OS_DEPRECATED(3, 7, 0) bool setSupplyAirFlowRateMethodDuringHeatingOperation(const std::string& supplyAirFlowRateMethodDuringHeatingOperation); + OS_DEPRECATED(3, 7, 0) void resetSupplyAirFlowRateMethodDuringHeatingOperation(); bool setSupplyAirFlowRateDuringHeatingOperation(double supplyAirFlowRateDuringHeatingOperation); - - void resetSupplyAirFlowRateDuringHeatingOperation(); - + OS_DEPRECATED(3, 7, 0) void resetSupplyAirFlowRateDuringHeatingOperation(); void autosizeSupplyAirFlowRateDuringHeatingOperation(); bool setSupplyAirFlowRatePerFloorAreaduringHeatingOperation(double supplyAirFlowRatePerFloorAreaduringHeatingOperation); - - void resetSupplyAirFlowRatePerFloorAreaduringHeatingOperation(); + OS_DEPRECATED(3, 7, 0) void resetSupplyAirFlowRatePerFloorAreaduringHeatingOperation(); bool setFractionofAutosizedDesignHeatingSupplyAirFlowRate(double fractionofAutosizedDesignHeatingSupplyAirFlowRate); - - void resetFractionofAutosizedDesignHeatingSupplyAirFlowRate(); + OS_DEPRECATED(3, 7, 0) void resetFractionofAutosizedDesignHeatingSupplyAirFlowRate(); bool setDesignSupplyAirFlowRatePerUnitofCapacityDuringHeatingOperation(double designSupplyAirFlowRatePerUnitofCapacityDuringHeatingOperation); - - void resetDesignSupplyAirFlowRatePerUnitofCapacityDuringHeatingOperation(); + OS_DEPRECATED(3, 7, 0) void resetDesignSupplyAirFlowRatePerUnitofCapacityDuringHeatingOperation(); bool setSupplyAirFlowRateMethodWhenNoCoolingorHeatingisRequired(const std::string& supplyAirFlowRateMethodWhenNoCoolingorHeatingisRequired); diff --git a/src/model/AirLoopHVACUnitarySystem_Impl.hpp b/src/model/AirLoopHVACUnitarySystem_Impl.hpp index e571b4a883f..f56ba5209a7 100644 --- a/src/model/AirLoopHVACUnitarySystem_Impl.hpp +++ b/src/model/AirLoopHVACUnitarySystem_Impl.hpp @@ -84,12 +84,14 @@ namespace model { boost::optional supplyAirFanOperatingModeSchedule() const; + bool hasHeatingCoil() const; // For speed boost::optional heatingCoil() const; double dXHeatingCoilSizingRatio() const; bool isDXHeatingCoilSizingRatioDefaulted() const; + bool hasCoolingCoil() const; // For speed boost::optional coolingCoil() const; bool useDOASDXCoolingCoil() const; @@ -108,7 +110,7 @@ namespace model { boost::optional supplementalHeatingCoil() const; - boost::optional supplyAirFlowRateMethodDuringCoolingOperation() const; + std::string supplyAirFlowRateMethodDuringCoolingOperation() const; boost::optional supplyAirFlowRateDuringCoolingOperation() const; @@ -120,7 +122,7 @@ namespace model { boost::optional designSupplyAirFlowRatePerUnitofCapacityDuringCoolingOperation() const; - boost::optional supplyAirFlowRateMethodDuringHeatingOperation() const; + std::string supplyAirFlowRateMethodDuringHeatingOperation() const; boost::optional supplyAirFlowRateDuringHeatingOperation() const; @@ -244,7 +246,7 @@ namespace model { void resetSupplyAirFanOperatingModeSchedule(); - bool setHeatingCoil(const boost::optional& heatingCoil); + bool setHeatingCoil(const HVACComponent& heatingCoil); void resetHeatingCoil(); @@ -252,7 +254,7 @@ namespace model { void resetDXHeatingCoilSizingRatio(); - bool setCoolingCoil(const boost::optional& coolingCoil); + bool setCoolingCoil(const HVACComponent& coolingCoil); void resetCoolingCoil(); @@ -274,49 +276,45 @@ namespace model { void resetSupplementalHeatingCoil(); - bool setSupplyAirFlowRateMethodDuringCoolingOperation(boost::optional supplyAirFlowRateMethodDuringCoolingOperation); + bool setSupplyAirFlowRateMethodDuringCoolingOperation(const std::string& supplyAirFlowRateMethodDuringCoolingOperation); - void resetSupplyAirFlowRateMethodDuringCoolingOperation(); - - bool setSupplyAirFlowRateDuringCoolingOperation(boost::optional supplyAirFlowRateDuringCoolingOperation); + bool setSupplyAirFlowRateDuringCoolingOperation(double supplyAirFlowRateDuringCoolingOperation); void resetSupplyAirFlowRateDuringCoolingOperation(); void autosizeSupplyAirFlowRateDuringCoolingOperation(); - bool setSupplyAirFlowRatePerFloorAreaDuringCoolingOperation(boost::optional supplyAirFlowRatePerFloorAreaDuringCoolingOperation); + bool setSupplyAirFlowRatePerFloorAreaDuringCoolingOperation(double supplyAirFlowRatePerFloorAreaDuringCoolingOperation); void resetSupplyAirFlowRatePerFloorAreaDuringCoolingOperation(); - bool setFractionofAutosizedDesignCoolingSupplyAirFlowRate(boost::optional fractionofAutosizedDesignCoolingSupplyAirFlowRate); + bool setFractionofAutosizedDesignCoolingSupplyAirFlowRate(double fractionofAutosizedDesignCoolingSupplyAirFlowRate); void resetFractionofAutosizedDesignCoolingSupplyAirFlowRate(); - bool setDesignSupplyAirFlowRatePerUnitofCapacityDuringCoolingOperation( - boost::optional designSupplyAirFlowRatePerUnitofCapacityDuringCoolingOperation); + bool setDesignSupplyAirFlowRatePerUnitofCapacityDuringCoolingOperation(double designSupplyAirFlowRatePerUnitofCapacityDuringCoolingOperation); void resetDesignSupplyAirFlowRatePerUnitofCapacityDuringCoolingOperation(); - bool setSupplyAirFlowRateMethodDuringHeatingOperation(boost::optional supplyAirFlowRateMethodDuringHeatingOperation); + bool setSupplyAirFlowRateMethodDuringHeatingOperation(const std::string& supplyAirFlowRateMethodDuringHeatingOperation); void resetSupplyAirFlowRateMethodDuringHeatingOperation(); - bool setSupplyAirFlowRateDuringHeatingOperation(boost::optional supplyAirFlowRateDuringHeatingOperation); + bool setSupplyAirFlowRateDuringHeatingOperation(double supplyAirFlowRateDuringHeatingOperation); void resetSupplyAirFlowRateDuringHeatingOperation(); void autosizeSupplyAirFlowRateDuringHeatingOperation(); - bool setSupplyAirFlowRatePerFloorAreaduringHeatingOperation(boost::optional supplyAirFlowRatePerFloorAreaduringHeatingOperation); + bool setSupplyAirFlowRatePerFloorAreaduringHeatingOperation(double supplyAirFlowRatePerFloorAreaduringHeatingOperation); void resetSupplyAirFlowRatePerFloorAreaduringHeatingOperation(); - bool setFractionofAutosizedDesignHeatingSupplyAirFlowRate(boost::optional fractionofAutosizedDesignHeatingSupplyAirFlowRate); + bool setFractionofAutosizedDesignHeatingSupplyAirFlowRate(double fractionofAutosizedDesignHeatingSupplyAirFlowRate); void resetFractionofAutosizedDesignHeatingSupplyAirFlowRate(); - bool setDesignSupplyAirFlowRatePerUnitofCapacityDuringHeatingOperation( - boost::optional designSupplyAirFlowRatePerUnitofCapacityDuringHeatingOperation); + bool setDesignSupplyAirFlowRatePerUnitofCapacityDuringHeatingOperation(double designSupplyAirFlowRatePerUnitofCapacityDuringHeatingOperation); void resetDesignSupplyAirFlowRatePerUnitofCapacityDuringHeatingOperation(); diff --git a/src/model/GroundHeatExchangerVertical.cpp b/src/model/GroundHeatExchangerVertical.cpp index 4adba7f9b5a..75ffb69dd9f 100644 --- a/src/model/GroundHeatExchangerVertical.cpp +++ b/src/model/GroundHeatExchangerVertical.cpp @@ -9,6 +9,8 @@ #include "Node_Impl.hpp" #include "Model.hpp" #include "Model_Impl.hpp" +#include "SiteGroundTemperatureUndisturbedKusudaAchenbach.hpp" +#include "SiteGroundTemperatureUndisturbedKusudaAchenbach_Impl.hpp" #include "../utilities/core/Assert.hpp" #include "../utilities/data/DataEnums.hpp" @@ -113,6 +115,14 @@ namespace model { return isEmpty(OS_GroundHeatExchanger_VerticalFields::GFunctionReferenceRatio); } + ModelObject GroundHeatExchangerVertical_Impl::undisturbedGroundTemperatureModel() const { + boost::optional modelObject; + modelObject = + getObject().getModelObjectTarget(OS_GroundHeatExchanger_VerticalFields::UndisturbedGroundTemperatureModel); + OS_ASSERT(modelObject); + return modelObject.get(); + } + bool GroundHeatExchangerVertical_Impl::setNumberofBoreHoles(boost::optional numberofBoreHoles) { bool result(false); if (numberofBoreHoles) { @@ -319,6 +329,11 @@ namespace model { OS_ASSERT(result); } + bool GroundHeatExchangerVertical_Impl::setUndisturbedGroundTemperatureModel(const ModelObject& undisturbedGroundTemperatureModel) { + bool result = setPointer(OS_GroundHeatExchanger_VerticalFields::UndisturbedGroundTemperatureModel, undisturbedGroundTemperatureModel.handle()); + return result; + } + unsigned GroundHeatExchangerVertical_Impl::inletPort() const { return OS_GroundHeatExchanger_VerticalFields::InletNodeName; } @@ -476,6 +491,76 @@ namespace model { addGFunction(2.028, 71.361); addGFunction(2.275, 71.79); addGFunction(3.003, 72.511); + + SiteGroundTemperatureUndisturbedKusudaAchenbach undisturbedGroundTemperatureModel(model); + undisturbedGroundTemperatureModel.setSoilThermalConductivity(groundThermalConductivity().get()); + undisturbedGroundTemperatureModel.setSoilDensity(920.0); + undisturbedGroundTemperatureModel.setSoilSpecificHeat(groundThermalHeatCapacity().get() / 920.0); + undisturbedGroundTemperatureModel.setAverageSoilSurfaceTemperature(groundTemperature().get()); + undisturbedGroundTemperatureModel.setAverageAmplitudeofSurfaceTemperature(3.2); + undisturbedGroundTemperatureModel.setPhaseShiftofMinimumSurfaceTemperature(8.0); + setUndisturbedGroundTemperatureModel(undisturbedGroundTemperatureModel); + } + + GroundHeatExchangerVertical::GroundHeatExchangerVertical(const Model& model, const ModelObject& undisturbedGroundTemperatureModel) + : StraightComponent(GroundHeatExchangerVertical::iddObjectType(), model) { + OS_ASSERT(getImpl()); + + bool ok = setUndisturbedGroundTemperatureModel(undisturbedGroundTemperatureModel); + if (!ok) { + remove(); + LOG_AND_THROW("Unable to set " << briefDescription() << "'s Undisturbed Ground Temperature Model to " + << undisturbedGroundTemperatureModel.briefDescription() << "."); + } + setNumberofBoreHoles(120); + setBoreHoleLength(76.2); + setBoreHoleRadius(0.635080E-01); + setGroundThermalConductivity(0.692626); + setGroundThermalHeatCapacity(0.234700E+07); + setGroundTemperature(13.375); + setDesignFlowRate(0.0033); + setGroutThermalConductivity(0.692626); + setPipeThermalConductivity(0.391312); + setPipeOutDiameter(2.66667E-02); + setUTubeDistance(2.53977E-02); + setPipeThickness(2.41285E-03); + setMaximumLengthofSimulation(2); + setGFunctionReferenceRatio(0.0005); + addGFunction(-15.2996, -0.348322); + addGFunction(-14.201, 0.022208); + addGFunction(-13.2202, 0.412345); + addGFunction(-12.2086, 0.867498); + addGFunction(-11.1888, 1.357839); + addGFunction(-10.1816, 1.852024); + addGFunction(-9.1815, 2.345656); + addGFunction(-8.6809, 2.593958); + addGFunction(-8.5, 2.679); + addGFunction(-7.8, 3.023); + addGFunction(-7.2, 3.32); + addGFunction(-6.5, 3.681); + addGFunction(-5.9, 4.071); + addGFunction(-5.2, 4.828); + addGFunction(-4.5, 6.253); + addGFunction(-3.963, 7.894); + addGFunction(-3.27, 11.82); + addGFunction(-2.864, 15.117); + addGFunction(-2.577, 18.006); + addGFunction(-2.171, 22.887); + addGFunction(-1.884, 26.924); + addGFunction(-1.191, 38.004); + addGFunction(-0.497, 49.919); + addGFunction(-0.274, 53.407); + addGFunction(-0.051, 56.632); + addGFunction(0.196, 59.825); + addGFunction(0.419, 62.349); + addGFunction(0.642, 64.524); + addGFunction(0.873, 66.412); + addGFunction(1.112, 67.993); + addGFunction(1.335, 69.162); + addGFunction(1.679, 70.476); + addGFunction(2.028, 71.361); + addGFunction(2.275, 71.79); + addGFunction(3.003, 72.511); } IddObjectType GroundHeatExchangerVertical::iddObjectType() { @@ -567,6 +652,10 @@ namespace model { return getImpl()->isGFunctionReferenceRatioDefaulted(); } + ModelObject GroundHeatExchangerVertical::undisturbedGroundTemperatureModel() const { + return getImpl()->undisturbedGroundTemperatureModel(); + } + bool GroundHeatExchangerVertical::setNumberofBoreHoles(int numberofBoreHoles) { return getImpl()->setNumberofBoreHoles(numberofBoreHoles); } @@ -675,6 +764,10 @@ namespace model { getImpl()->resetGFunctionReferenceRatio(); } + bool GroundHeatExchangerVertical::setUndisturbedGroundTemperatureModel(const ModelObject& undisturbedGroundTemperatureModel) { + return getImpl()->setUndisturbedGroundTemperatureModel(undisturbedGroundTemperatureModel); + } + /// @cond GroundHeatExchangerVertical::GroundHeatExchangerVertical(std::shared_ptr impl) : StraightComponent(std::move(impl)) {} diff --git a/src/model/GroundHeatExchangerVertical.hpp b/src/model/GroundHeatExchangerVertical.hpp index 19b5edecf23..54eb7e2c703 100644 --- a/src/model/GroundHeatExchangerVertical.hpp +++ b/src/model/GroundHeatExchangerVertical.hpp @@ -39,6 +39,8 @@ namespace model { explicit GroundHeatExchangerVertical(const Model& model); + explicit GroundHeatExchangerVertical(const Model& model, const ModelObject& undisturbedGroundTemperatureModel); + virtual ~GroundHeatExchangerVertical() = default; // Default the copy and move operators because the virtual dtor is explicit GroundHeatExchangerVertical(const GroundHeatExchangerVertical& other) = default; @@ -93,6 +95,8 @@ namespace model { bool isGFunctionReferenceRatioDefaulted() const; + ModelObject undisturbedGroundTemperatureModel() const; + //@} /** @name Setters */ @@ -152,6 +156,8 @@ namespace model { void resetGFunctionReferenceRatio(); + bool setUndisturbedGroundTemperatureModel(const ModelObject& undisturbedGroundTemperatureModel); + //@} /** @name Other */ //@{ diff --git a/src/model/GroundHeatExchangerVertical_Impl.hpp b/src/model/GroundHeatExchangerVertical_Impl.hpp index 2ea9d62a21c..20e318982bd 100644 --- a/src/model/GroundHeatExchangerVertical_Impl.hpp +++ b/src/model/GroundHeatExchangerVertical_Impl.hpp @@ -84,6 +84,8 @@ namespace model { bool isGFunctionReferenceRatioDefaulted() const; + ModelObject undisturbedGroundTemperatureModel() const; + //@} /** @name Setters */ //@{ @@ -142,6 +144,8 @@ namespace model { void resetGFunctionReferenceRatio(); + bool setUndisturbedGroundTemperatureModel(const ModelObject& undisturbedGroundTemperatureModel); + //@} /** @name Other */ //@{ diff --git a/src/model/RefrigerationAirChiller.hpp b/src/model/RefrigerationAirChiller.hpp index a35524d6150..b6b7431bc3d 100644 --- a/src/model/RefrigerationAirChiller.hpp +++ b/src/model/RefrigerationAirChiller.hpp @@ -25,7 +25,10 @@ namespace model { } // namespace detail - /** RefrigerationAirChiller is a ZoneHVACComponent that wraps the OpenStudio IDD object 'OS:ZoneHVAC:Refrigeration:AirChiller'. */ + /** RefrigerationAirChiller is a ZoneHVACComponent that wraps the OpenStudio IDD object 'OS:ZoneHVAC:Refrigeration:AirChiller'. + * + * This component is a ZoneHVACComponent, and you can call RefrigerationAirChiller::addToThermalZone(ThermalZone&) and the ForwardTranslator will + * produce a ZoneHVAC:RefrigerationAirChillerSet for you: a ZoneHVACRefrigrerationAirChillerSet class is not needed in the model SDK. */ class MODEL_API RefrigerationAirChiller : public ZoneHVACComponent { public: diff --git a/src/model/test/AirLoopHVACUnitarySystem_GTest.cpp b/src/model/test/AirLoopHVACUnitarySystem_GTest.cpp index 6cf608aec8f..43f275c1b8f 100644 --- a/src/model/test/AirLoopHVACUnitarySystem_GTest.cpp +++ b/src/model/test/AirLoopHVACUnitarySystem_GTest.cpp @@ -627,3 +627,172 @@ TEST_F(ModelFixture, AirLoopHVACUnitarySystem_cloneAirLoopHVAC_Nodes) { ASSERT_EQ(1u, a.supplyComponents(openstudio::IddObjectType::OS_AirLoopHVAC_UnitarySystem).size()); EXPECT_EQ(unitary, a.supplyComponents(openstudio::IddObjectType::OS_AirLoopHVAC_UnitarySystem)[0]); } + +TEST_F(ModelFixture, AirLoopHVACUnitarySystem_SupplyAirFlowRateMethodDuringOperation_Cooling) { + // Test for #4695 - AirLoopHVACUnitarySystem: Supply Air Flow Rate Method During Operation should be set via related setters/autosize + + Model m; + AirLoopHVACUnitarySystem unitary = AirLoopHVACUnitarySystem(m); + + EXPECT_EQ("None", unitary.supplyAirFlowRateMethodDuringCoolingOperation()); + + EXPECT_FALSE(unitary.isSupplyAirFlowRateDuringCoolingOperationAutosized()); + EXPECT_FALSE(unitary.supplyAirFlowRateDuringCoolingOperation()); + EXPECT_FALSE(unitary.supplyAirFlowRatePerFloorAreaDuringCoolingOperation()); + EXPECT_FALSE(unitary.fractionofAutosizedDesignCoolingSupplyAirFlowRate()); + EXPECT_FALSE(unitary.designSupplyAirFlowRatePerUnitofCapacityDuringCoolingOperation()); + + // Setting a coil changes things + CoilCoolingDXSingleSpeed cc(m); + EXPECT_TRUE(unitary.setCoolingCoil(cc)); + EXPECT_EQ("SupplyAirFlowRate", unitary.supplyAirFlowRateMethodDuringCoolingOperation()); + EXPECT_TRUE(unitary.isSupplyAirFlowRateDuringCoolingOperationAutosized()); + EXPECT_FALSE(unitary.supplyAirFlowRateDuringCoolingOperation()); + EXPECT_FALSE(unitary.supplyAirFlowRatePerFloorAreaDuringCoolingOperation()); + EXPECT_FALSE(unitary.fractionofAutosizedDesignCoolingSupplyAirFlowRate()); + EXPECT_FALSE(unitary.designSupplyAirFlowRatePerUnitofCapacityDuringCoolingOperation()); + + unitary.resetCoolingCoil(); + EXPECT_EQ("None", unitary.supplyAirFlowRateMethodDuringCoolingOperation()); + EXPECT_FALSE(unitary.isSupplyAirFlowRateDuringCoolingOperationAutosized()); + EXPECT_FALSE(unitary.supplyAirFlowRateDuringCoolingOperation()); + EXPECT_FALSE(unitary.supplyAirFlowRatePerFloorAreaDuringCoolingOperation()); + EXPECT_FALSE(unitary.fractionofAutosizedDesignCoolingSupplyAirFlowRate()); + EXPECT_FALSE(unitary.designSupplyAirFlowRatePerUnitofCapacityDuringCoolingOperation()); + // Put it back + EXPECT_TRUE(unitary.setCoolingCoil(cc)); + + // SupplyAirFlowRate + EXPECT_TRUE(unitary.setSupplyAirFlowRateDuringCoolingOperation(1.0)); + EXPECT_EQ("SupplyAirFlowRate", unitary.supplyAirFlowRateMethodDuringCoolingOperation()); + EXPECT_FALSE(unitary.isSupplyAirFlowRateDuringCoolingOperationAutosized()); + ASSERT_TRUE(unitary.supplyAirFlowRateDuringCoolingOperation()); + EXPECT_EQ(1.0, unitary.supplyAirFlowRateDuringCoolingOperation().get()); + EXPECT_FALSE(unitary.supplyAirFlowRatePerFloorAreaDuringCoolingOperation()); + EXPECT_FALSE(unitary.fractionofAutosizedDesignCoolingSupplyAirFlowRate()); + EXPECT_FALSE(unitary.designSupplyAirFlowRatePerUnitofCapacityDuringCoolingOperation()); + + // FlowPerFloorArea + EXPECT_TRUE(unitary.setSupplyAirFlowRatePerFloorAreaDuringCoolingOperation(1.0)); + EXPECT_EQ("FlowPerFloorArea", unitary.supplyAirFlowRateMethodDuringCoolingOperation()); + EXPECT_FALSE(unitary.isSupplyAirFlowRateDuringCoolingOperationAutosized()); + EXPECT_FALSE(unitary.supplyAirFlowRateDuringCoolingOperation()); + ASSERT_TRUE(unitary.supplyAirFlowRatePerFloorAreaDuringCoolingOperation()); + EXPECT_EQ(1.0, unitary.supplyAirFlowRatePerFloorAreaDuringCoolingOperation().get()); + EXPECT_FALSE(unitary.fractionofAutosizedDesignCoolingSupplyAirFlowRate()); + EXPECT_FALSE(unitary.designSupplyAirFlowRatePerUnitofCapacityDuringCoolingOperation()); + + // FractionOfAutosizedCoolingValue + EXPECT_TRUE(unitary.setFractionofAutosizedDesignCoolingSupplyAirFlowRate(1.0)); + EXPECT_EQ("FractionOfAutosizedCoolingValue", unitary.supplyAirFlowRateMethodDuringCoolingOperation()); + EXPECT_FALSE(unitary.isSupplyAirFlowRateDuringCoolingOperationAutosized()); + EXPECT_FALSE(unitary.supplyAirFlowRateDuringCoolingOperation()); + EXPECT_FALSE(unitary.supplyAirFlowRatePerFloorAreaDuringCoolingOperation()); + ASSERT_TRUE(unitary.fractionofAutosizedDesignCoolingSupplyAirFlowRate()); + EXPECT_EQ(1.0, unitary.fractionofAutosizedDesignCoolingSupplyAirFlowRate().get()); + EXPECT_FALSE(unitary.designSupplyAirFlowRatePerUnitofCapacityDuringCoolingOperation()); + + // FlowPerCoolingCapacity + EXPECT_TRUE(unitary.setDesignSupplyAirFlowRatePerUnitofCapacityDuringCoolingOperation(1.0)); + EXPECT_EQ("FlowPerCoolingCapacity", unitary.supplyAirFlowRateMethodDuringCoolingOperation()); + EXPECT_FALSE(unitary.isSupplyAirFlowRateDuringCoolingOperationAutosized()); + EXPECT_FALSE(unitary.supplyAirFlowRateDuringCoolingOperation()); + EXPECT_FALSE(unitary.supplyAirFlowRatePerFloorAreaDuringCoolingOperation()); + EXPECT_FALSE(unitary.fractionofAutosizedDesignCoolingSupplyAirFlowRate()); + ASSERT_TRUE(unitary.designSupplyAirFlowRatePerUnitofCapacityDuringCoolingOperation()); + EXPECT_EQ(1.0, unitary.designSupplyAirFlowRatePerUnitofCapacityDuringCoolingOperation().get()); +} + +TEST_F(ModelFixture, AirLoopHVACUnitarySystem_SupplyAirFlowRateMethodDuringOperation_Heating) { + // Test for #4695 - AirLoopHVACUnitarySystem: Supply Air Flow Rate Method During Operation should be set via related setters/autosize + + Model m; + AirLoopHVACUnitarySystem unitary = AirLoopHVACUnitarySystem(m); + + EXPECT_EQ("None", unitary.supplyAirFlowRateMethodDuringHeatingOperation()); + + EXPECT_FALSE(unitary.isSupplyAirFlowRateDuringHeatingOperationAutosized()); + EXPECT_FALSE(unitary.supplyAirFlowRateDuringHeatingOperation()); + EXPECT_FALSE(unitary.supplyAirFlowRatePerFloorAreaduringHeatingOperation()); + EXPECT_FALSE(unitary.fractionofAutosizedDesignHeatingSupplyAirFlowRate()); + EXPECT_FALSE(unitary.designSupplyAirFlowRatePerUnitofCapacityDuringHeatingOperation()); + + // Setting a coil changes things + CoilHeatingDXSingleSpeed cc(m); + EXPECT_TRUE(unitary.setHeatingCoil(cc)); + EXPECT_EQ("SupplyAirFlowRate", unitary.supplyAirFlowRateMethodDuringHeatingOperation()); + EXPECT_TRUE(unitary.isSupplyAirFlowRateDuringHeatingOperationAutosized()); + EXPECT_FALSE(unitary.supplyAirFlowRateDuringHeatingOperation()); + EXPECT_FALSE(unitary.supplyAirFlowRatePerFloorAreaduringHeatingOperation()); + EXPECT_FALSE(unitary.fractionofAutosizedDesignHeatingSupplyAirFlowRate()); + EXPECT_FALSE(unitary.designSupplyAirFlowRatePerUnitofCapacityDuringHeatingOperation()); + + unitary.resetHeatingCoil(); + EXPECT_EQ("None", unitary.supplyAirFlowRateMethodDuringHeatingOperation()); + EXPECT_FALSE(unitary.isSupplyAirFlowRateDuringHeatingOperationAutosized()); + EXPECT_FALSE(unitary.supplyAirFlowRateDuringHeatingOperation()); + EXPECT_FALSE(unitary.supplyAirFlowRatePerFloorAreaduringHeatingOperation()); + EXPECT_FALSE(unitary.fractionofAutosizedDesignHeatingSupplyAirFlowRate()); + EXPECT_FALSE(unitary.designSupplyAirFlowRatePerUnitofCapacityDuringHeatingOperation()); + // Put it back + EXPECT_TRUE(unitary.setHeatingCoil(cc)); + + // SupplyAirFlowRate + EXPECT_TRUE(unitary.setSupplyAirFlowRateDuringHeatingOperation(1.0)); + EXPECT_EQ("SupplyAirFlowRate", unitary.supplyAirFlowRateMethodDuringHeatingOperation()); + EXPECT_FALSE(unitary.isSupplyAirFlowRateDuringHeatingOperationAutosized()); + ASSERT_TRUE(unitary.supplyAirFlowRateDuringHeatingOperation()); + EXPECT_EQ(1.0, unitary.supplyAirFlowRateDuringHeatingOperation().get()); + EXPECT_FALSE(unitary.supplyAirFlowRatePerFloorAreaduringHeatingOperation()); + EXPECT_FALSE(unitary.fractionofAutosizedDesignHeatingSupplyAirFlowRate()); + EXPECT_FALSE(unitary.designSupplyAirFlowRatePerUnitofCapacityDuringHeatingOperation()); + + // FlowPerFloorArea + EXPECT_TRUE(unitary.setSupplyAirFlowRatePerFloorAreaduringHeatingOperation(1.0)); + EXPECT_EQ("FlowPerFloorArea", unitary.supplyAirFlowRateMethodDuringHeatingOperation()); + EXPECT_FALSE(unitary.isSupplyAirFlowRateDuringHeatingOperationAutosized()); + EXPECT_FALSE(unitary.supplyAirFlowRateDuringHeatingOperation()); + ASSERT_TRUE(unitary.supplyAirFlowRatePerFloorAreaduringHeatingOperation()); + EXPECT_EQ(1.0, unitary.supplyAirFlowRatePerFloorAreaduringHeatingOperation().get()); + EXPECT_FALSE(unitary.fractionofAutosizedDesignHeatingSupplyAirFlowRate()); + EXPECT_FALSE(unitary.designSupplyAirFlowRatePerUnitofCapacityDuringHeatingOperation()); + + // FractionOfAutosizedHeatingValue + EXPECT_TRUE(unitary.setFractionofAutosizedDesignHeatingSupplyAirFlowRate(1.0)); + EXPECT_EQ("FractionOfAutosizedHeatingValue", unitary.supplyAirFlowRateMethodDuringHeatingOperation()); + EXPECT_FALSE(unitary.isSupplyAirFlowRateDuringHeatingOperationAutosized()); + EXPECT_FALSE(unitary.supplyAirFlowRateDuringHeatingOperation()); + EXPECT_FALSE(unitary.supplyAirFlowRatePerFloorAreaduringHeatingOperation()); + ASSERT_TRUE(unitary.fractionofAutosizedDesignHeatingSupplyAirFlowRate()); + EXPECT_EQ(1.0, unitary.fractionofAutosizedDesignHeatingSupplyAirFlowRate().get()); + EXPECT_FALSE(unitary.designSupplyAirFlowRatePerUnitofCapacityDuringHeatingOperation()); + + // FlowPerHeatingCapacity + EXPECT_TRUE(unitary.setDesignSupplyAirFlowRatePerUnitofCapacityDuringHeatingOperation(1.0)); + EXPECT_EQ("FlowPerHeatingCapacity", unitary.supplyAirFlowRateMethodDuringHeatingOperation()); + EXPECT_FALSE(unitary.isSupplyAirFlowRateDuringHeatingOperationAutosized()); + EXPECT_FALSE(unitary.supplyAirFlowRateDuringHeatingOperation()); + EXPECT_FALSE(unitary.supplyAirFlowRatePerFloorAreaduringHeatingOperation()); + EXPECT_FALSE(unitary.fractionofAutosizedDesignHeatingSupplyAirFlowRate()); + ASSERT_TRUE(unitary.designSupplyAirFlowRatePerUnitofCapacityDuringHeatingOperation()); + EXPECT_EQ(1.0, unitary.designSupplyAirFlowRatePerUnitofCapacityDuringHeatingOperation().get()); +} + +TEST_F(ModelFixture, AirLoopHVACUnitarySystem_needToRemoveDeprecated) { + Model m; + AirLoopHVACUnitarySystem unitary = AirLoopHVACUnitarySystem(m); + + EXPECT_NO_THROW(unitary.setSupplyAirFlowRateMethodDuringCoolingOperation("")); + EXPECT_NO_THROW(unitary.resetSupplyAirFlowRateMethodDuringCoolingOperation()); + EXPECT_NO_THROW(unitary.resetSupplyAirFlowRateDuringCoolingOperation()); + EXPECT_NO_THROW(unitary.resetSupplyAirFlowRatePerFloorAreaDuringCoolingOperation()); + EXPECT_NO_THROW(unitary.resetFractionofAutosizedDesignCoolingSupplyAirFlowRate()); + EXPECT_NO_THROW(unitary.resetDesignSupplyAirFlowRatePerUnitofCapacityDuringCoolingOperation()); + + EXPECT_NO_THROW(unitary.setSupplyAirFlowRateMethodDuringHeatingOperation("")); + EXPECT_NO_THROW(unitary.resetSupplyAirFlowRateMethodDuringHeatingOperation()); + EXPECT_NO_THROW(unitary.resetSupplyAirFlowRateDuringHeatingOperation()); + EXPECT_NO_THROW(unitary.resetSupplyAirFlowRatePerFloorAreaduringHeatingOperation()); + EXPECT_NO_THROW(unitary.resetFractionofAutosizedDesignHeatingSupplyAirFlowRate()); + EXPECT_NO_THROW(unitary.resetDesignSupplyAirFlowRatePerUnitofCapacityDuringHeatingOperation()); +} diff --git a/src/model/test/GroundHeatExchangerVertical_GTest.cpp b/src/model/test/GroundHeatExchangerVertical_GTest.cpp index c974f15e6da..71d4db28d52 100644 --- a/src/model/test/GroundHeatExchangerVertical_GTest.cpp +++ b/src/model/test/GroundHeatExchangerVertical_GTest.cpp @@ -7,6 +7,10 @@ #include "ModelFixture.hpp" #include "../GroundHeatExchangerVertical.hpp" #include "../GroundHeatExchangerVertical_Impl.hpp" +#include "../SiteGroundTemperatureUndisturbedKusudaAchenbach.hpp" +#include "../SiteGroundTemperatureUndisturbedKusudaAchenbach_Impl.hpp" +#include "../SiteGroundTemperatureUndisturbedXing.hpp" +#include "../SiteGroundTemperatureUndisturbedXing_Impl.hpp" #include "../AirLoopHVAC.hpp" #include "../PlantLoop.hpp" #include "../Node.hpp" @@ -17,7 +21,7 @@ using namespace openstudio; using namespace openstudio::model; -TEST_F(ModelFixture, GroundHeatExchangerVertical_DefaultConstructor) { +TEST_F(ModelFixture, GroundHeatExchangerVertical_GroundHeatExchangerVertical) { ::testing::FLAGS_gtest_death_test_style = "threadsafe"; ASSERT_EXIT( @@ -28,6 +32,177 @@ TEST_F(ModelFixture, GroundHeatExchangerVertical_DefaultConstructor) { exit(0); }, ::testing::ExitedWithCode(0), ""); + + { + Model m; + GroundHeatExchangerVertical gh(m); + + ASSERT_TRUE(gh.designFlowRate()); + EXPECT_EQ(0.0033, gh.designFlowRate().get()); + ASSERT_TRUE(gh.numberofBoreHoles()); + EXPECT_EQ(120, gh.numberofBoreHoles().get()); + ASSERT_TRUE(gh.boreHoleLength()); + EXPECT_EQ(76.2, gh.boreHoleLength().get()); + ASSERT_TRUE(gh.boreHoleRadius()); + EXPECT_EQ(0.635080E-01, gh.boreHoleRadius().get()); + ASSERT_TRUE(gh.groundThermalConductivity()); + EXPECT_EQ(0.692626, gh.groundThermalConductivity().get()); + ASSERT_TRUE(gh.groundThermalHeatCapacity()); + EXPECT_EQ(0.234700E+07, gh.groundThermalHeatCapacity().get()); + ASSERT_TRUE(gh.groundTemperature()); + EXPECT_EQ(13.375, gh.groundTemperature().get()); + ASSERT_TRUE(gh.groutThermalConductivity()); + EXPECT_EQ(0.692626, gh.groutThermalConductivity().get()); + ASSERT_TRUE(gh.pipeThermalConductivity()); + EXPECT_EQ(0.391312, gh.pipeThermalConductivity().get()); + ASSERT_TRUE(gh.pipeOutDiameter()); + EXPECT_EQ(2.66667E-02, gh.pipeOutDiameter().get()); + ASSERT_TRUE(gh.uTubeDistance()); + EXPECT_EQ(2.53977E-02, gh.uTubeDistance().get()); + ASSERT_TRUE(gh.pipeThickness()); + EXPECT_EQ(2.41285E-03, gh.pipeThickness().get()); + ASSERT_TRUE(gh.maximumLengthofSimulation()); + EXPECT_EQ(2, gh.maximumLengthofSimulation().get()); + EXPECT_EQ(0.0005, gh.gFunctionReferenceRatio()); + EXPECT_FALSE(gh.isGFunctionReferenceRatioDefaulted()); + ModelObject undisturbedGroundTemperatureModel = gh.undisturbedGroundTemperatureModel(); + boost::optional uka = + undisturbedGroundTemperatureModel.optionalCast(); + ASSERT_TRUE(uka); + } + + { + Model m; + SiteGroundTemperatureUndisturbedKusudaAchenbach sgt(m); + GroundHeatExchangerVertical gh(m, sgt); + + ASSERT_TRUE(gh.designFlowRate()); + EXPECT_EQ(0.0033, gh.designFlowRate().get()); + ASSERT_TRUE(gh.numberofBoreHoles()); + EXPECT_EQ(120, gh.numberofBoreHoles().get()); + ASSERT_TRUE(gh.boreHoleLength()); + EXPECT_EQ(76.2, gh.boreHoleLength().get()); + ASSERT_TRUE(gh.boreHoleRadius()); + EXPECT_EQ(0.635080E-01, gh.boreHoleRadius().get()); + ASSERT_TRUE(gh.groundThermalConductivity()); + EXPECT_EQ(0.692626, gh.groundThermalConductivity().get()); + ASSERT_TRUE(gh.groundThermalHeatCapacity()); + EXPECT_EQ(0.234700E+07, gh.groundThermalHeatCapacity().get()); + ASSERT_TRUE(gh.groundTemperature()); + EXPECT_EQ(13.375, gh.groundTemperature().get()); + ASSERT_TRUE(gh.groutThermalConductivity()); + EXPECT_EQ(0.692626, gh.groutThermalConductivity().get()); + ASSERT_TRUE(gh.pipeThermalConductivity()); + EXPECT_EQ(0.391312, gh.pipeThermalConductivity().get()); + ASSERT_TRUE(gh.pipeOutDiameter()); + EXPECT_EQ(2.66667E-02, gh.pipeOutDiameter().get()); + ASSERT_TRUE(gh.uTubeDistance()); + EXPECT_EQ(2.53977E-02, gh.uTubeDistance().get()); + ASSERT_TRUE(gh.pipeThickness()); + EXPECT_EQ(2.41285E-03, gh.pipeThickness().get()); + ASSERT_TRUE(gh.maximumLengthofSimulation()); + EXPECT_EQ(2, gh.maximumLengthofSimulation().get()); + EXPECT_EQ(0.0005, gh.gFunctionReferenceRatio()); + EXPECT_FALSE(gh.isGFunctionReferenceRatioDefaulted()); + ModelObject undisturbedGroundTemperatureModel = gh.undisturbedGroundTemperatureModel(); + boost::optional uka = + undisturbedGroundTemperatureModel.optionalCast(); + ASSERT_TRUE(uka); + EXPECT_EQ(sgt, uka.get()); + } +} + +TEST_F(ModelFixture, GroundHeatExchangerVertical_SetGetFields) { + Model m; + GroundHeatExchangerVertical gh(m); + + EXPECT_TRUE(gh.setDesignFlowRate(0.004)); + EXPECT_TRUE(gh.setNumberofBoreHoles(100)); + EXPECT_TRUE(gh.setBoreHoleLength(80.0)); + EXPECT_TRUE(gh.setBoreHoleRadius(0.7E-01)); + EXPECT_TRUE(gh.setGroundThermalConductivity(0.7)); + EXPECT_TRUE(gh.setGroundThermalHeatCapacity(0.3E+07)); + EXPECT_TRUE(gh.setGroundTemperature(14.0)); + EXPECT_TRUE(gh.setGroutThermalConductivity(0.7)); + EXPECT_TRUE(gh.setPipeThermalConductivity(0.4)); + EXPECT_TRUE(gh.setPipeOutDiameter(2.7E-02)); + EXPECT_TRUE(gh.setUTubeDistance(2.6E-02)); + EXPECT_TRUE(gh.setPipeThickness(2.5E-03)); + EXPECT_TRUE(gh.setMaximumLengthofSimulation(3)); + EXPECT_TRUE(gh.setGFunctionReferenceRatio(0.001)); + + SiteGroundTemperatureUndisturbedKusudaAchenbach sgt(m); + EXPECT_TRUE(gh.setUndisturbedGroundTemperatureModel(sgt)); + + ASSERT_TRUE(gh.designFlowRate()); + EXPECT_EQ(0.004, gh.designFlowRate().get()); + ASSERT_TRUE(gh.numberofBoreHoles()); + EXPECT_EQ(100, gh.numberofBoreHoles().get()); + ASSERT_TRUE(gh.boreHoleLength()); + EXPECT_EQ(80.0, gh.boreHoleLength().get()); + ASSERT_TRUE(gh.boreHoleRadius()); + EXPECT_EQ(0.7E-01, gh.boreHoleRadius().get()); + ASSERT_TRUE(gh.groundThermalConductivity()); + EXPECT_EQ(0.7, gh.groundThermalConductivity().get()); + ASSERT_TRUE(gh.groundThermalHeatCapacity()); + EXPECT_EQ(0.3E+07, gh.groundThermalHeatCapacity().get()); + ASSERT_TRUE(gh.groundTemperature()); + EXPECT_EQ(14.0, gh.groundTemperature().get()); + ASSERT_TRUE(gh.groutThermalConductivity()); + EXPECT_EQ(0.7, gh.groutThermalConductivity().get()); + ASSERT_TRUE(gh.pipeThermalConductivity()); + EXPECT_EQ(0.4, gh.pipeThermalConductivity().get()); + ASSERT_TRUE(gh.pipeOutDiameter()); + EXPECT_EQ(2.7E-02, gh.pipeOutDiameter().get()); + ASSERT_TRUE(gh.uTubeDistance()); + EXPECT_EQ(2.6E-02, gh.uTubeDistance().get()); + ASSERT_TRUE(gh.pipeThickness()); + EXPECT_EQ(2.5E-03, gh.pipeThickness().get()); + ASSERT_TRUE(gh.maximumLengthofSimulation()); + EXPECT_EQ(3, gh.maximumLengthofSimulation().get()); + EXPECT_EQ(0.001, gh.gFunctionReferenceRatio()); + EXPECT_FALSE(gh.isGFunctionReferenceRatioDefaulted()); + ModelObject undisturbedGroundTemperatureModel = gh.undisturbedGroundTemperatureModel(); + boost::optional uka = + undisturbedGroundTemperatureModel.optionalCast(); + ASSERT_TRUE(uka); + EXPECT_EQ(sgt, uka.get()); + + SiteGroundTemperatureUndisturbedXing sgt2(m); + EXPECT_TRUE(gh.setUndisturbedGroundTemperatureModel(sgt2)); + + ASSERT_TRUE(gh.designFlowRate()); + EXPECT_EQ(0.004, gh.designFlowRate().get()); + ASSERT_TRUE(gh.numberofBoreHoles()); + EXPECT_EQ(100, gh.numberofBoreHoles().get()); + ASSERT_TRUE(gh.boreHoleLength()); + EXPECT_EQ(80.0, gh.boreHoleLength().get()); + ASSERT_TRUE(gh.boreHoleRadius()); + EXPECT_EQ(0.7E-01, gh.boreHoleRadius().get()); + ASSERT_TRUE(gh.groundThermalConductivity()); + EXPECT_EQ(0.7, gh.groundThermalConductivity().get()); + ASSERT_TRUE(gh.groundThermalHeatCapacity()); + EXPECT_EQ(0.3E+07, gh.groundThermalHeatCapacity().get()); + ASSERT_TRUE(gh.groundTemperature()); + EXPECT_EQ(14.0, gh.groundTemperature().get()); + ASSERT_TRUE(gh.groutThermalConductivity()); + EXPECT_EQ(0.7, gh.groutThermalConductivity().get()); + ASSERT_TRUE(gh.pipeThermalConductivity()); + EXPECT_EQ(0.4, gh.pipeThermalConductivity().get()); + ASSERT_TRUE(gh.pipeOutDiameter()); + EXPECT_EQ(2.7E-02, gh.pipeOutDiameter().get()); + ASSERT_TRUE(gh.uTubeDistance()); + EXPECT_EQ(2.6E-02, gh.uTubeDistance().get()); + ASSERT_TRUE(gh.pipeThickness()); + EXPECT_EQ(2.5E-03, gh.pipeThickness().get()); + ASSERT_TRUE(gh.maximumLengthofSimulation()); + EXPECT_EQ(3, gh.maximumLengthofSimulation().get()); + EXPECT_EQ(0.001, gh.gFunctionReferenceRatio()); + EXPECT_FALSE(gh.isGFunctionReferenceRatioDefaulted()); + ModelObject undisturbedGroundTemperatureModel2 = gh.undisturbedGroundTemperatureModel(); + boost::optional ux = undisturbedGroundTemperatureModel2.optionalCast(); + ASSERT_TRUE(ux); + EXPECT_EQ(sgt2, ux.get()); } TEST_F(ModelFixture, GroundHeatExchangerVertical_Connections) { diff --git a/src/osversion/VersionTranslator.cpp b/src/osversion/VersionTranslator.cpp index 996e94aefb9..74567e4c2d7 100644 --- a/src/osversion/VersionTranslator.cpp +++ b/src/osversion/VersionTranslator.cpp @@ -135,7 +135,8 @@ namespace osversion { m_updateMethods[VersionString("3.5.0")] = &VersionTranslator::update_3_4_0_to_3_5_0; m_updateMethods[VersionString("3.5.1")] = &VersionTranslator::update_3_5_0_to_3_5_1; m_updateMethods[VersionString("3.6.0")] = &VersionTranslator::update_3_5_1_to_3_6_0; - m_updateMethods[VersionString("3.7.0")] = &VersionTranslator::defaultUpdate; + m_updateMethods[VersionString("3.7.0")] = &VersionTranslator::update_3_6_1_to_3_7_0; + // m_updateMethods[VersionString("3.7.0")] = &VersionTranslator::defaultUpdate; // List of previous versions that may be updated to this one. // - To increment the translator, add an entry for the version just released (branched for @@ -7607,11 +7608,71 @@ namespace osversion { } // end update_3_5_1_to_3_6_0 - /* - std::string VersionTranslator::update_3_6_1_to_3_7_0(const IdfFile& idf_3_6_1, const IddFileAndFactoryWrapper& idd_3_7_0) + std::string VersionTranslator::update_3_6_1_to_3_7_0(const IdfFile& idf_3_6_1, const IddFileAndFactoryWrapper& idd_3_7_0) { + std::stringstream ss; + boost::optional value; + + ss << idf_3_6_1.header() << '\n' << '\n'; + IdfFile targetIdf(idd_3_7_0.iddFile()); + ss << targetIdf.versionObject().get(); + + for (const IdfObject& object : idf_3_6_1.objects()) { + auto iddname = object.iddObject().name(); + + if (iddname == "OS:GroundHeatExchanger:Vertical") { + + // 1 Field has been added from 3.6.1 to 3.7.0: + // ------------------------------------------- + // * Undisturbed Ground Temperature Model * 17 + auto iddObject = idd_3_7_0.getObject(iddname); + IdfObject ghxObject(iddObject.get()); + IdfObject kusudaObject(idd_3_7_0.getObject("OS:Site:GroundTemperature:Undisturbed:KusudaAchenbach").get()); + + for (size_t i = 0; i < object.numFields(); ++i) { + if (i < 17) { + if ((value = object.getString(i))) { + ghxObject.setString(i, value.get()); + if (i == 8) { // Soil Thermal Conductivity + kusudaObject.setString(i - 6, value.get()); + } + if (i == 10) { // Average Soil Surface Temperature + kusudaObject.setString(i - 5, value.get()); + } + } + if (boost::optional _value = object.getDouble(i)) { + if (i == 9) { // Soil Specific Heat + kusudaObject.setDouble(i - 5, _value.get() / 920.0); + } + } + } else { + if (i == 17) { // Undisturbed Ground Temperature Model + ghxObject.setString(i, kusudaObject.getString(0).get()); + } + if ((value = object.getString(i))) { + ghxObject.setString(i + 1, value.get()); + } + } + } + + kusudaObject.setDouble(3, 920.0); // Soil Density + kusudaObject.setDouble(6, 3.2); // Average Amplitude of Surface Temperature + kusudaObject.setDouble(7, 8.0); // Phase Shift of Minimum Surface Temperature + + m_refactored.push_back(RefactoredObjectData(object, ghxObject)); + m_new.push_back(kusudaObject); + + ss << ghxObject; + ss << kusudaObject; + + // No-op + } else { + ss << object; + } + } + + return ss.str(); } // end update_3_6_1_to_3_7_0 - */ } // namespace osversion } // namespace openstudio diff --git a/src/osversion/VersionTranslator.hpp b/src/osversion/VersionTranslator.hpp index 258d4aafe69..ca4a4d3b8a6 100644 --- a/src/osversion/VersionTranslator.hpp +++ b/src/osversion/VersionTranslator.hpp @@ -234,7 +234,7 @@ namespace osversion { std::string update_3_4_0_to_3_5_0(const IdfFile& idf_3_4_0, const IddFileAndFactoryWrapper& idd_3_5_0); std::string update_3_5_0_to_3_5_1(const IdfFile& idf_3_5_0, const IddFileAndFactoryWrapper& idd_3_5_1); std::string update_3_5_1_to_3_6_0(const IdfFile& idf_3_5_1, const IddFileAndFactoryWrapper& idd_3_6_0); - // std::string update_3_6_1_to_3_7_0(const IdfFile& idf_3_6_1, const IddFileAndFactoryWrapper& idd_3_7_0); + std::string update_3_6_1_to_3_7_0(const IdfFile& idf_3_6_1, const IddFileAndFactoryWrapper& idd_3_7_0); IdfObject updateUrlField_0_7_1_to_0_7_2(const IdfObject& object, unsigned index); diff --git a/src/osversion/test/3_7_0/test_vt_GroundHeatExchangerVertical.osm b/src/osversion/test/3_7_0/test_vt_GroundHeatExchangerVertical.osm new file mode 100644 index 00000000000..7cc50fec2d9 --- /dev/null +++ b/src/osversion/test/3_7_0/test_vt_GroundHeatExchangerVertical.osm @@ -0,0 +1,95 @@ + +OS:Version, + {44a788f8-5d7b-4751-a46e-fa7b6694d6fc}, !- Handle + 3.6.1; !- Version Identifier + +OS:GroundHeatExchanger:Vertical, + {780db985-9f76-43b6-97b0-a146527f06ac}, !- Handle + Ground Heat Exchanger Vertical 1, !- Name + , !- Inlet Node Name + , !- Outlet Node Name + 0.0033, !- Design Flow Rate {m3/s} + 120, !- Number of Bore Holes + 76.2, !- Bore Hole Length {m} + 0.063508, !- Bore Hole Radius {m} + 0.692626, !- Ground Thermal Conductivity {W/m-K} + 2347000, !- Ground Thermal Heat Capacity {J/m3-K} + 13.375, !- Ground Temperature {C} + 0.692626, !- Grout Thermal Conductivity {W/m-K} + 0.391312, !- Pipe Thermal Conductivity {W/m-K} + 0.0266667, !- Pipe Out Diameter {m} + 0.0253977, !- U-Tube Distance {m} + 0.00241285, !- Pipe Thickness {m} + 2, !- Maximum Length of Simulation + 0.0005, !- G-Function Reference Ratio {dimensionless} + -15.2996, !- G-Function Ln(T/Ts) Value 1 + -0.348322, !- G-Function G Value 1 + -14.201, !- G-Function Ln(T/Ts) Value 2 + 0.022208, !- G-Function G Value 2 + -13.2202, !- G-Function Ln(T/Ts) Value 3 + 0.412345, !- G-Function G Value 3 + -12.2086, !- G-Function Ln(T/Ts) Value 4 + 0.867498, !- G-Function G Value 4 + -11.1888, !- G-Function Ln(T/Ts) Value 5 + 1.357839, !- G-Function G Value 5 + -10.1816, !- G-Function Ln(T/Ts) Value 6 + 1.852024, !- G-Function G Value 6 + -9.1815, !- G-Function Ln(T/Ts) Value 7 + 2.345656, !- G-Function G Value 7 + -8.6809, !- G-Function Ln(T/Ts) Value 8 + 2.593958, !- G-Function G Value 8 + -8.5, !- G-Function Ln(T/Ts) Value 9 + 2.679, !- G-Function G Value 9 + -7.8, !- G-Function Ln(T/Ts) Value 10 + 3.023, !- G-Function G Value 10 + -7.2, !- G-Function Ln(T/Ts) Value 11 + 3.32, !- G-Function G Value 11 + -6.5, !- G-Function Ln(T/Ts) Value 12 + 3.681, !- G-Function G Value 12 + -5.9, !- G-Function Ln(T/Ts) Value 13 + 4.071, !- G-Function G Value 13 + -5.2, !- G-Function Ln(T/Ts) Value 14 + 4.828, !- G-Function G Value 14 + -4.5, !- G-Function Ln(T/Ts) Value 15 + 6.253, !- G-Function G Value 15 + -3.963, !- G-Function Ln(T/Ts) Value 16 + 7.894, !- G-Function G Value 16 + -3.27, !- G-Function Ln(T/Ts) Value 17 + 11.82, !- G-Function G Value 17 + -2.864, !- G-Function Ln(T/Ts) Value 18 + 15.117, !- G-Function G Value 18 + -2.577, !- G-Function Ln(T/Ts) Value 19 + 18.006, !- G-Function G Value 19 + -2.171, !- G-Function Ln(T/Ts) Value 20 + 22.887, !- G-Function G Value 20 + -1.884, !- G-Function Ln(T/Ts) Value 21 + 26.924, !- G-Function G Value 21 + -1.191, !- G-Function Ln(T/Ts) Value 22 + 38.004, !- G-Function G Value 22 + -0.497, !- G-Function Ln(T/Ts) Value 23 + 49.919, !- G-Function G Value 23 + -0.274, !- G-Function Ln(T/Ts) Value 24 + 53.407, !- G-Function G Value 24 + -0.051, !- G-Function Ln(T/Ts) Value 25 + 56.632, !- G-Function G Value 25 + 0.196, !- G-Function Ln(T/Ts) Value 26 + 59.825, !- G-Function G Value 26 + 0.419, !- G-Function Ln(T/Ts) Value 27 + 62.349, !- G-Function G Value 27 + 0.642, !- G-Function Ln(T/Ts) Value 28 + 64.524, !- G-Function G Value 28 + 0.873, !- G-Function Ln(T/Ts) Value 29 + 66.412, !- G-Function G Value 29 + 1.112, !- G-Function Ln(T/Ts) Value 30 + 67.993, !- G-Function G Value 30 + 1.335, !- G-Function Ln(T/Ts) Value 31 + 69.162, !- G-Function G Value 31 + 1.679, !- G-Function Ln(T/Ts) Value 32 + 70.476, !- G-Function G Value 32 + 2.028, !- G-Function Ln(T/Ts) Value 33 + 71.361, !- G-Function G Value 33 + 2.275, !- G-Function Ln(T/Ts) Value 34 + 71.79, !- G-Function G Value 34 + 3.003, !- G-Function Ln(T/Ts) Value 35 + 72.511; !- G-Function G Value 35 + diff --git a/src/osversion/test/3_7_0/test_vt_GroundHeatExchangerVertical.rb b/src/osversion/test/3_7_0/test_vt_GroundHeatExchangerVertical.rb new file mode 100644 index 00000000000..ae35d298e32 --- /dev/null +++ b/src/osversion/test/3_7_0/test_vt_GroundHeatExchangerVertical.rb @@ -0,0 +1,9 @@ +#require '/usr/local/openstudio-3.6.1/Ruby/openstudio' + +include OpenStudio::Model + +m = Model.new + +coil = GroundHeatExchangerVertical.new(m) + +m.save('test_vt_GroundHeatExchangerVertical.osm', true) diff --git a/src/osversion/test/VersionTranslator_GTest.cpp b/src/osversion/test/VersionTranslator_GTest.cpp index 89f617d00e8..dfacbb21b60 100644 --- a/src/osversion/test/VersionTranslator_GTest.cpp +++ b/src/osversion/test/VersionTranslator_GTest.cpp @@ -2492,3 +2492,59 @@ TEST_F(OSVersionFixture, update_3_5_1_to_3_6_0_GroundHeatExchangerHorizontalTren EXPECT_EQ(12.8, uka.getDouble(6).get()); // Average Amplitude of Surface Temperature EXPECT_EQ(17.3, uka.getDouble(7).get()); // Phase Shift of Minimum Surface Temperature } + +TEST_F(OSVersionFixture, update_3_6_1_to_3_7_0_GroundHeatExchangerVertical) { + openstudio::path path = resourcesPath() / toPath("osversion/3_7_0/test_vt_GroundHeatExchangerVertical.osm"); + osversion::VersionTranslator vt; + boost::optional model = vt.loadModel(path); + ASSERT_TRUE(model) << "Failed to load " << path; + + openstudio::path outPath = resourcesPath() / toPath("osversion/3_7_0/test_vt_GroundHeatExchangerVertical_updated.osm"); + model->save(outPath, true); + + std::vector ghxs = model->getObjectsByType("OS:GroundHeatExchanger:Vertical"); + ASSERT_EQ(1u, ghxs.size()); + WorkspaceObject ghx = ghxs[0]; + + EXPECT_EQ("Ground Heat Exchanger Vertical 1", ghx.getString(1).get()); // Name + EXPECT_TRUE(ghx.isEmpty(2)); // Inlet Node Name + EXPECT_TRUE(ghx.isEmpty(3)); // Outlet Node Name + EXPECT_EQ(0.0033, ghx.getDouble(4).get()); // Design Flow Rate + EXPECT_EQ(120, ghx.getInt(5).get()); // Number of Bore Holes + EXPECT_EQ(76.2, ghx.getDouble(6).get()); // Bore Hole Length + EXPECT_EQ(0.063508, ghx.getDouble(7).get()); // Bore Hole Radius + EXPECT_EQ(0.692626, ghx.getDouble(8).get()); // Ground Thermal Conductivity + EXPECT_EQ(2347000, ghx.getDouble(9).get()); // Ground Thermal Heat Capacity + EXPECT_EQ(13.375, ghx.getDouble(10).get()); // Ground Temperature + EXPECT_EQ(0.692626, ghx.getDouble(11).get()); // Grout Thermal Conductivity + EXPECT_EQ(0.391312, ghx.getDouble(12).get()); // Pipe Thermal Conductivity + EXPECT_EQ(0.0266667, ghx.getDouble(13).get()); // Pipe Out Diameter + EXPECT_EQ(0.0253977, ghx.getDouble(14).get()); // U-Tube Distance + EXPECT_EQ(0.00241285, ghx.getDouble(15).get()); // Pipe Thickness + EXPECT_EQ(2, ghx.getInt(16).get()); // Maximum Length of Simulation + EXPECT_NE("", ghx.getString(17).get()); // Undisturbed Ground Temperature Model + EXPECT_EQ(0.0005, ghx.getDouble(18).get()); // G-Function Reference Ratio {dimensionless} + + EXPECT_EQ(35u, ghx.numExtensibleGroups()); + auto eg1 = ghx.extensibleGroups()[0]; + EXPECT_EQ(-15.2996, eg1.getDouble(0, false).get()); // G-Function Ln(T/Ts) Value 1 + EXPECT_EQ(-0.348322, eg1.getDouble(1, false).get()); // G-Function G Value 1 + auto eg35 = ghx.extensibleGroups()[34]; + EXPECT_EQ(3.003, eg35.getDouble(0, false).get()); // G-Function Ln(T/Ts) Value 35 + EXPECT_EQ(72.511, eg35.getDouble(1, false).get()); // G-Function G Value 35 + + std::vector ukas = model->getObjectsByType("OS:Site:GroundTemperature:Undisturbed:KusudaAchenbach"); + ASSERT_EQ(1u, ukas.size()); + + ASSERT_TRUE(ghx.getTarget(17)); + WorkspaceObject uka = ghx.getTarget(17).get(); + EXPECT_EQ(uka.nameString(), ghx.getTarget(17)->nameString()); + EXPECT_EQ(IddObjectType(IddObjectType::OS_Site_GroundTemperature_Undisturbed_KusudaAchenbach), uka.iddObject().type()); + EXPECT_EQ("Site Ground Temperature Undisturbed Kusuda Achenbach 1", uka.getString(1).get()); // Name + EXPECT_EQ(0.692626, uka.getDouble(2).get()); // Soil Thermal Conductivity + EXPECT_EQ(920.0, uka.getDouble(3).get()); // Soil Density + EXPECT_DOUBLE_EQ(2347000.0 / 920.0, uka.getDouble(4).get()); // Soil Specific Heat + EXPECT_EQ(13.375, uka.getDouble(5).get()); // Average Soil Surface Temperature + EXPECT_EQ(3.2, uka.getDouble(6).get()); // Average Amplitude of Surface Temperature + EXPECT_EQ(8.0, uka.getDouble(7).get()); // Phase Shift of Minimum Surface Temperature +} diff --git a/src/scriptengine/ScriptEngine.hpp b/src/scriptengine/ScriptEngine.hpp index 60d5cb620be..51dc8b8f395 100644 --- a/src/scriptengine/ScriptEngine.hpp +++ b/src/scriptengine/ScriptEngine.hpp @@ -61,7 +61,7 @@ class ScriptEngine const openstudio::path& gemHomeDir, const openstudio::path& bundleGemFilePath, const openstudio::path& bundleGemDirPath, const std::string& bundleWithoutGroups){}; - virtual void setupPythonPath(const std::vector& includeDirs, const openstudio::path& pythonHomeDir){}; + virtual void setupPythonPath(const std::vector& includeDirs){}; template T getAs(ScriptObject& obj) { diff --git a/src/utilities/core/CommonInclude.i b/src/utilities/core/CommonInclude.i index 022db8f576f..2a28296ad26 100644 --- a/src/utilities/core/CommonInclude.i +++ b/src/utilities/core/CommonInclude.i @@ -66,7 +66,7 @@ // and nested classes and "nothing known about " // also ignoring #509, shadowed method. Its a red herring for all of our cases //#pragma SWIG nowarn=401,362,365,366,368,378,503,801,312 -#pragma SWIG nowarn=362,365,366,368,378,503,801,312,509,401 +#pragma SWIG nowarn=362,365,366,368,378,503,801,312,509,401,516 // Todo: Remove this one after other swig warnings have been cleared up #pragma SWIG nowarn=315 diff --git a/src/utilities/core/DynamicLibraryPOSIX.hpp b/src/utilities/core/DynamicLibraryPOSIX.hpp index d9eaa976524..f3043d3e85f 100644 --- a/src/utilities/core/DynamicLibraryPOSIX.hpp +++ b/src/utilities/core/DynamicLibraryPOSIX.hpp @@ -31,8 +31,17 @@ struct DynamicLibrary return symbol; } - explicit DynamicLibrary(openstudio::path location) - : m_location{std::move(location)}, m_handle{dlopen(m_location.c_str(), RTLD_LAZY | RTLD_LOCAL), m_handle_deleter} { + explicit DynamicLibrary(openstudio::path location) : m_location{std::move(location)} { + int flags = RTLD_LAZY | RTLD_LOCAL; // NOLINT(misc-const-correctness, hicpp-signed-bitwise) + + // This seems to work on Mac without RTLD_GLOBAL... +#ifdef __linux__ + if (m_location.filename().generic_string().find("python") != std::string::npos) { + // https://stackoverflow.com/questions/67891197/ctypes-cpython-39-x86-64-linux-gnu-so-undefined-symbol-pyfloat-type-in-embedd + flags = RTLD_LAZY | RTLD_GLOBAL; + } +#endif + m_handle = {dlopen(m_location.c_str(), flags), m_handle_deleter}; if (!m_handle) { throw std::runtime_error(fmt::format("Unable to load library '{}', reason: '{}'", m_location.string(), dlerror())); } diff --git a/src/utilities/core/csharp/LanguageSpecific.i b/src/utilities/core/csharp/LanguageSpecific.i index 0a1ec1cf90d..20d7b16f470 100644 --- a/src/utilities/core/csharp/LanguageSpecific.i +++ b/src/utilities/core/csharp/LanguageSpecific.i @@ -5,7 +5,7 @@ // Not implemented for this target: %include %include -%rename(Path) openstudio::path; // For consistancy with other class names and to avoid conflicts +%rename(Path) openstudio::path; // For consistency with other class names and to avoid conflicts %rename(ZeroException) Exception; %rename(ReportingFrequencyEnum) ReportingFrequency; %ignore openstudio::SqlFile::dataDictionary(); diff --git a/src/utilities/core/jsoncpp.i b/src/utilities/core/jsoncpp.i index fb71b0bcca1..4ebf7aa1c51 100644 --- a/src/utilities/core/jsoncpp.i +++ b/src/utilities/core/jsoncpp.i @@ -2,7 +2,9 @@ #define JSONCPP_I #if defined SWIGCSHARP -%ignore openstudio::*::toJSON() const; + // ignores toJSON/fromJSON globally + %rename("$ignore", regextarget=1, fullname=1) "openstudio::.*::toJSON$"; + %rename("$ignore", regextarget=1, fullname=1) "openstudio::.*::fromJSON$"; #else %{ #include diff --git a/src/utilities/filetypes/Filetypes.i b/src/utilities/filetypes/Filetypes.i index 5f6c561d053..ada9cbd2de8 100644 --- a/src/utilities/filetypes/Filetypes.i +++ b/src/utilities/filetypes/Filetypes.i @@ -18,9 +18,12 @@ %ignore openstudio::WorkflowStepValue::WorkflowStepValue(std::string const&, char const*); %ignore openstudio::MeasureStep::setArgument(std::string const&, char const*); - // Ignore Json::Value return type + // Ignore Json::Value return type (toJSON / fromJSON are globally ignored already) %ignore openstudio::StandardsJSON::getPrimaryKey; + %ignore openstudio::CustomOutputAdapter::CustomOutputAdapter; + %ignore openstudio::CustomOutputAdapter::optionsJSON; + #endif