Skip to content

Commit

Permalink
Merge pull request #3095 from NREL/PlantComponentUserDefined
Browse files Browse the repository at this point in the history
Plant component user defined
  • Loading branch information
kbenne authored Apr 27, 2018
2 parents 81b82a4 + f86ec14 commit c1c4504
Show file tree
Hide file tree
Showing 24 changed files with 2,040 additions and 12 deletions.
15 changes: 9 additions & 6 deletions developer/ruby/MakeModelObjects.rb
Original file line number Diff line number Diff line change
Expand Up @@ -106,15 +106,18 @@
#objects << ["OS:ExternalInterface:FunctionalMockupUnitImport:From:Variable", "ExternalInterfaceFunctionalMockupUnitImportFromVariable", "ModelObject"]
#objects << ["OS:ExternalInterface:FunctionalMockupUnitImport:To:Schedule", "ExternalInterfaceFunctionalMockupUnitImportToSchedule", "ModelObject"]
#objects << ["OS:ExternalInterface:FunctionalMockupUnitImport:To:Actuator", "ExternalInterfaceFunctionalMockupUnitImportToActuator", "ModelObject"]
objects << ["OS:ExternalInterface:FunctionalMockupUnitImport:To:Variable", "ExternalInterfaceFunctionalMockupUnitImportToVariable", "ModelObject"]
objects << ["OS:ExternalInterface:FunctionalMockupUnitExport:From:Variable", "ExternalInterfaceFunctionalMockupUnitExportFromVariable", "ModelObject"]
objects << ["OS:ExternalInterface:FunctionalMockupUnitExport:To:Schedule", "ExternalInterfaceFunctionalMockupUnitExportToSchedule", "ModelObject"]
objects << ["OS:ExternalInterface:FunctionalMockupUnitExport:To:Actuator", "ExternalInterfaceFunctionalMockupUnitExportToActuator", "ModelObject"]
objects << ["OS:ExternalInterface:FunctionalMockupUnitExport:To:Variable", "ExternalInterfaceFunctionalMockupUnitExportToVariable", "ModelObject"]
#objects << ["OS:ExternalInterface:FunctionalMockupUnitImport:To:Variable", "ExternalInterfaceFunctionalMockupUnitImportToVariable", "ModelObject"]
#objects << ["OS:ExternalInterface:FunctionalMockupUnitExport:From:Variable", "ExternalInterfaceFunctionalMockupUnitExportFromVariable", "ModelObject"]
#objects << ["OS:ExternalInterface:FunctionalMockupUnitExport:To:Schedule", "ExternalInterfaceFunctionalMockupUnitExportToSchedule", "ModelObject"]
#objects << ["OS:ExternalInterface:FunctionalMockupUnitExport:To:Actuator", "ExternalInterfaceFunctionalMockupUnitExportToActuator", "ModelObject"]
#objects << ["OS:ExternalInterface:FunctionalMockupUnitExport:To:Variable", "ExternalInterfaceFunctionalMockupUnitExportToVariable", "ModelObject"]

objects << ["OS:PlantComponent:UserDefined", "PlantComponentUserDefined", "ModelObject"]

includePath = nil
if /mswin/.match(RUBY_PLATFORM) || /mingw/.match(RUBY_PLATFORM)
includePath = "../../build/OSCore-prefix/src/OSCore-build/ruby/Debug"
#includePath = "../../build/OSCore-prefix/src/OSCore-build/ruby/Debug"
includePath = "../../build/Products/ruby/Debug"
#includePath = "../../build/OSCore-prefix/src/OSCore-build/ruby/Release"
else
includePath = "../../build/OSCore-prefix/src/OSCore-build/ruby"
Expand Down
86 changes: 82 additions & 4 deletions openstudiocore/resources/model/OpenStudio.idd
Original file line number Diff line number Diff line change
Expand Up @@ -28580,7 +28580,6 @@ OS:EnergyManagementSystem:Sensor,
\note This name becomes a variable for use in Erl programs
\note No spaces allowed in names for ErlVariableNames
\reference ErlVariableNames
\reference AllObjects
A3, \field Output Variable or Output Meter Index Key Name
\type alpha
\note key name listed here will override key name in Output:Variable or Output:Meter
Expand All @@ -28600,7 +28599,7 @@ OS:EnergyManagementSystem:Actuator,
\note This name becomes a variable for use in Erl programs
\note No spaces allowed in names for ErlVariableNames
\reference ErlVariableNames
\reference AllObjects
\reference ErlActuatorNames
A3, \field Actuated Component Name
\required-field
\type object-list
Expand Down Expand Up @@ -30131,7 +30130,6 @@ OS:ExternalInterface:Actuator,
\required-field
\type alpha
\reference ErlVariableNames
\reference AllObjects
\note This name becomes a variable for use in Erl programs
\note no spaces allowed in name
A3 , \field Actuated Component Unique Name
Expand Down Expand Up @@ -30254,7 +30252,6 @@ OS:ExternalInterface:FunctionalMockupUnitImport:To:Actuator,
\note This name becomes a read-only variable for use in Erl programs
\note no spaces allowed in name
\reference ErlVariableNames
\reference AllObjects
A3 , \field Actuated Component Unique Name
\required-field
\type object-list
Expand Down Expand Up @@ -30412,4 +30409,85 @@ OS:ExternalInterface:FunctionalMockupUnitExport:To:Variable,
\required-field
\note Used during the first call of EnergyPlus.

\group User Defined HVAC and Plant Component Models

OS:PlantComponent:UserDefined,
\memo Defines a generic plant component for custom modeling
\memo using Energy Management System or External Interface
\min-fields 6
A1, \field Handle
\type handle
\required-field
A2, \field Name
\required-field
\type alpha
\reference ConnectionObject
A3, \field Main Model Program Calling Manager Name
\type object-list
\object-list ErlProgramCallingManagerNames
A4, \field Main Model Program Name
\type object-list
\object-list ErlProgramNames
A5, \field Plant Inlet Node Name
\type object-list
\object-list ConnectionNames
\required-field
A6, \field Plant Outlet Node Name
\type object-list
\object-list ConnectionNames
\required-field
A7, \field Plant Loading Mode
\type choice
\key DemandsLoad
\key MeetsLoadWithPassiveCapacity
\key MeetsLoadWithNominalCapacity
\key MeetsLoadWithNominalCapacityLowOutLimit
\key MeetsLoadWithNominalCapacityHiOutLimit
\required-field
A8, \field Plant Loop Flow Request Mode
\type choice
\key NeedsFlowIfLoopOn
\key NeedsFlowAndTurnsLoopOn
\key ReceivesWhateverFlowAvailable
\required-field
A9, \field Plant Initialization Program Calling Manager Name
\type object-list
\object-list ErlProgramCallingManagerNames
A10, \field Plant Initialization Program Name
\type object-list
\object-list ErlProgramNames
A11, \field Plant Simulation Program Calling Manager Name
\type object-list
\object-list ErlProgramCallingManagerNames
A12, \field Plant Simulation Program Name
\type object-list
\object-list ErlProgramNames
A13, \field Design Volume Flow Rate Actuator
\type object-list
\object-list ErlActuatorNames
A14, \field Minimum Mass Flow Rate Actuator
\type object-list
\object-list ErlActuatorNames
A15, \field Maximum Mass Flow Rate Actuator
\type object-list
\object-list ErlActuatorNames
A16, \field Minimum Loading Capacity Actuator
\type object-list
\object-list ErlActuatorNames
A17, \field Maximum Loading Capacity Actuator
\type object-list
\object-list ErlActuatorNames
A18, \field Optimal Loading Capacity Actuator
\type object-list
\object-list ErlActuatorNames
A19, \field Outlet Temperature Actuator
\type object-list
\object-list ErlActuatorNames
A20, \field Mass Flow Rate Actuator
\type object-list
\object-list ErlActuatorNames
A21; \field Ambient Zone Name
\type object-list
\object-list ThermalZoneNames
\note Used for modeling device losses to surrounding zone

3 changes: 2 additions & 1 deletion openstudiocore/src/energyplus/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,7 @@ set(${target_name}_src
ForwardTranslator/ForwardTranslatePipeOutdoor.cpp
ForwardTranslator/ForwardTranslatePlantLoop.cpp
ForwardTranslator/ForwardTranslatePlantComponentTemperatureSource.cpp
ForwardTranslator/ForwardTranslatePlantComponentUserDefined.cpp
ForwardTranslator/ForwardTranslatePlantEquipmentOperationSchemes.cpp
ForwardTranslator/ForwardTranslatePlantEquipmentOperationCoolingLoad.cpp
ForwardTranslator/ForwardTranslatePlantEquipmentOperationHeatingLoad.cpp
Expand Down Expand Up @@ -576,7 +577,7 @@ set(${target_name}_test_src
Test/Meter_GTest.cpp
Test/People_GTest.cpp
Test/PlantEquipmentOperationSchemes_GTest.cpp

Test/PlantComponentUserDefined_GTest.cpp
Test/RunPeriodControlDaylightSavingTime_GTest.cpp
Test/ScheduleInterval_GTest.cpp
Test/ScheduleRuleset_GTest.cpp
Expand Down
6 changes: 6 additions & 0 deletions openstudiocore/src/energyplus/ForwardTranslator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2147,6 +2147,12 @@ boost::optional<IdfObject> ForwardTranslator::translateAndMapModelObject(ModelOb
retVal = translatePlantComponentTemperatureSource(mo);
break;
}
case openstudio::IddObjectType::OS_PlantComponent_UserDefined:
{
model::PlantComponentUserDefined mo = modelObject.cast<PlantComponentUserDefined>();
retVal = translatePlantComponentUserDefined(mo);
break;
}
case openstudio::IddObjectType::OS_PlantEquipmentOperation_CoolingLoad :
{
auto mo = modelObject.cast<PlantEquipmentOperationCoolingLoad>();
Expand Down
3 changes: 3 additions & 0 deletions openstudiocore/src/energyplus/ForwardTranslator.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,7 @@ class PipeIndoor;
class PipeOutdoor;
class PlantLoop;
class PlantComponentTemperatureSource;
class PlantComponentUserDefined;
class PlantEquipmentOperationCoolingLoad;
class PlantEquipmentOperationHeatingLoad;
class PlantEquipmentOperationOutdoorDryBulb;
Expand Down Expand Up @@ -990,6 +991,8 @@ class ENERGYPLUS_API ForwardTranslator {

boost::optional<IdfObject> translatePlantComponentTemperatureSource( model::PlantComponentTemperatureSource & modelObject );

boost::optional<IdfObject> translatePlantComponentUserDefined(model::PlantComponentUserDefined & modelObject);

boost::optional<IdfObject> translatePlantEquipmentOperationSchemes( model::PlantLoop & plantLoop );

boost::optional<IdfObject> translatePlantEquipmentOperationCoolingLoad( model::PlantEquipmentOperationCoolingLoad & modelObject );
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,139 @@
/***********************************************************************************************************************
* OpenStudio(R), Copyright (c) 2008-2017, Alliance for Sustainable Energy, LLC. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the
* following conditions are met:
*
* (1) Redistributions of source code must retain the above copyright notice, this list of conditions and the following
* disclaimer.
*
* (2) Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the
* following disclaimer in the documentation and/or other materials provided with the distribution.
*
* (3) Neither the name of the copyright holder nor the names of any contributors may be used to endorse or promote
* products derived from this software without specific prior written permission from the respective party.
*
* (4) Other than as required in clauses (1) and (2), distributions in any form of modifications or other derivative
* works may not use the "OpenStudio" trademark, "OS", "os", or any other confusingly similar designation without
* specific prior written permission from Alliance for Sustainable Energy, LLC.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER, THE UNITED STATES GOVERNMENT, OR ANY CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
**********************************************************************************************************************/

#include "../ForwardTranslator.hpp"
#include "../../model/Model.hpp"
#include "../../model/Node.hpp"
#include "../../model/Node_Impl.hpp"
#include "../../model/ThermalZone.hpp"
#include "../../model/ThermalZone_Impl.hpp"
#include "../../model/PlantComponentUserDefined.hpp"
#include "../../model/PlantComponentUserDefined_Impl.hpp"
#include "../../model/EnergyManagementSystemProgramCallingManager.hpp"
#include "../../model/EnergyManagementSystemProgramCallingManager_Impl.hpp"
#include "../../utilities/core/Logger.hpp"
#include "../../utilities/core/Assert.hpp"
#include <utilities/idd/PlantComponent_UserDefined_FieldEnums.hxx>
#include "../../utilities/idd/IddEnums.hpp"
#include <utilities/idd/IddEnums.hxx>
#include <utilities/idd/IddFactory.hxx>

using namespace openstudio::model;

using namespace std;

namespace openstudio {

namespace energyplus {

boost::optional<IdfObject> ForwardTranslator::translatePlantComponentUserDefined( PlantComponentUserDefined & modelObject )
{
boost::optional<std::string> s;

IdfObject idfObject(IddObjectType::PlantComponent_UserDefined);

m_idfObjects.push_back(idfObject);

// Name

s = modelObject.name();
if( s )
{
idfObject.setName(*s);
}

// PlantConnection1LoadingMode

if ((s = modelObject.plantLoadingMode()))
{
idfObject.setString(PlantComponent_UserDefinedFields::PlantConnection1LoadingMode, s.get());
}

// PlantConnection1LoopFlowRequestMode

if ((s = modelObject.plantLoopFlowRequestMode())) {
idfObject.setString(PlantComponent_UserDefinedFields::PlantConnection1LoopFlowRequestMode, s.get());
}

// NumberofPlantLoopConnections
// value is 1 since its a StraightComponent
idfObject.setInt(PlantComponent_UserDefinedFields::NumberofPlantLoopConnections, 1);


// MainModelProgramCallingManagerName

if (boost::optional<EnergyManagementSystemProgramCallingManager> pcm = modelObject.mainModelProgramCallingManager()) {
idfObject.setString(PlantComponent_UserDefinedFields::MainModelProgramCallingManagerName, pcm->name().get());
}

// PlantConnection1InitializationProgramCallingManagerName

if (boost::optional<EnergyManagementSystemProgramCallingManager> pcm = modelObject.plantInitializationProgramCallingManager())
{
idfObject.setString(PlantComponent_UserDefinedFields::PlantConnection1InitializationProgramCallingManagerName, pcm->name().get());
}

// PlantConnection1SimulationProgramCallingManagerName

if (boost::optional<EnergyManagementSystemProgramCallingManager> pcm = modelObject.plantSimulationProgramCallingManager()) {
idfObject.setString(PlantComponent_UserDefinedFields::PlantConnection1SimulationProgramCallingManagerName, pcm->name().get());
}

// PlantConnection1InletNodeName

if( boost::optional<ModelObject> mo = modelObject.inletModelObject() )
{
if( boost::optional<Node> node = mo->optionalCast<Node>() )
{
idfObject.setString(PlantComponent_UserDefinedFields::PlantConnection1InletNodeName, node->name().get());
}
}

// PlantConnection1OutletNodeName

if( boost::optional<ModelObject> mo = modelObject.outletModelObject() )
{
if( boost::optional<Node> node = mo->optionalCast<Node>() )
{
idfObject.setString(PlantComponent_UserDefinedFields::PlantConnection1OutletNodeName, node->name().get());
}
}

// AmbientZoneName

if (boost::optional<ThermalZone> tz = modelObject.ambientZone()) {
idfObject.setString(PlantComponent_UserDefinedFields::AmbientZoneName, tz->name().get());
}

return boost::optional<IdfObject>(idfObject);
}

} // energyplus

} // openstudio

Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,8 @@
#include "../../model/SolarCollectorFlatPlatePhotovoltaicThermal_Impl.hpp"
#include "../../model/PlantComponentTemperatureSource.hpp"
#include "../../model/PlantComponentTemperatureSource_Impl.hpp"
#include "../../model/PlantComponentUserDefined.hpp"
#include "../../model/PlantComponentUserDefined_Impl.hpp"
#include "../../model/HeatPumpWaterToWaterEquationFitHeating.hpp"
#include "../../model/HeatPumpWaterToWaterEquationFitHeating_Impl.hpp"
#include "../../model/HeatPumpWaterToWaterEquationFitCooling.hpp"
Expand Down Expand Up @@ -323,6 +325,13 @@ boost::optional<double> flowrate(const HVACComponent & component)
result = mo.designVolumeFlowRate();
break;
}
case openstudio::IddObjectType::OS_PlantComponent_UserDefined:
{
auto mo = component.cast<PlantComponentUserDefined>();
//TODO use Design Volume Flow Rate Actuator for PlantLoop 1
//result = mo.designVolumeFlowRateActuator().get();
break;
}
case openstudio::IddObjectType::OS_HeatPump_WaterToWater_EquationFit_Cooling :
{
auto mo = component.cast<HeatPumpWaterToWaterEquationFitCooling>();
Expand Down Expand Up @@ -587,6 +596,11 @@ ComponentType componentType(const HVACComponent & component)
return ComponentType::HEATING;
}
case openstudio::IddObjectType::OS_PlantComponent_TemperatureSource :
{
//TODO can this be inferred from PlantLoadingMode?
return ComponentType::BOTH;
}
case openstudio::IddObjectType::OS_PlantComponent_UserDefined:
{
return ComponentType::BOTH;
}
Expand Down
Loading

0 comments on commit c1c4504

Please sign in to comment.