Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #4896 - SPM:MixedAir creation for CoilSystemCoolingWaterHeatExchangerAssisted does not work with FanSystemModel #4899

Merged
merged 1 commit into from
Jun 29, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@
#include "../../model/FanVariableVolume_Impl.hpp"
#include "../../model/FanConstantVolume.hpp"
#include "../../model/FanConstantVolume_Impl.hpp"
#include "../../model/FanOnOff.hpp"
#include "../../model/FanOnOff_Impl.hpp"
#include "../../model/FanSystemModel.hpp"
#include "../../model/FanSystemModel_Impl.hpp"

#include "../../model/Model.hpp"
#include "../../utilities/core/Assert.hpp"
Expand All @@ -63,40 +67,35 @@ namespace energyplus {

boost::optional<IdfObject>
ForwardTranslator::translateCoilSystemCoolingWaterHeatExchangerAssisted(CoilSystemCoolingWaterHeatExchangerAssisted& modelObject) {
IdfObject idfObject(IddObjectType::CoilSystem_Cooling_Water_HeatExchangerAssisted);
m_idfObjects.push_back(idfObject);

// Name
if (auto s = modelObject.name()) {
idfObject.setName(*s);
}
IdfObject idfObject = createRegisterAndNameIdfObject(openstudio::IddObjectType::CoilSystem_Cooling_Water_HeatExchangerAssisted, modelObject);

std::string hxSupplyAirInletNodeName;
// InletNodeName
if (auto mo = modelObject.inletModelObject()) {
if (auto node = mo->optionalCast<Node>()) {
hxSupplyAirInletNodeName = node->name().get();
hxSupplyAirInletNodeName = node->nameString();
}
}

std::string hxExhaustAirOutletNodeName;
// OutletNodeName
if (auto mo = modelObject.outletModelObject()) {
if (auto node = mo->optionalCast<Node>()) {
hxExhaustAirOutletNodeName = node->name().get();
hxExhaustAirOutletNodeName = node->nameString();
}
}

std::string hxSupplyAirOutletNodeName = modelObject.name().get() + " HX Supply Air Outlet - Cooling Inlet Node";
std::string hxExhaustAirInletNodeName = modelObject.name().get() + " HX Exhaust Air Inlet - Cooling Outlet Node";
std::string hxSupplyAirOutletNodeName = modelObject.nameString() + " HX Supply Air Outlet - Cooling Inlet Node";
std::string hxExhaustAirInletNodeName = modelObject.nameString() + " HX Exhaust Air Inlet - Cooling Outlet Node";

// HeatExchangerObjectType
// HeatExchangerName
{
auto hx = modelObject.heatExchanger();
if (auto idf = translateAndMapModelObject(hx)) {
idfObject.setString(CoilSystem_Cooling_Water_HeatExchangerAssistedFields::HeatExchangerObjectType, idf->iddObject().name());
idfObject.setString(CoilSystem_Cooling_Water_HeatExchangerAssistedFields::HeatExchangerName, idf->name().get());
idfObject.setString(CoilSystem_Cooling_Water_HeatExchangerAssistedFields::HeatExchangerName, idf->nameString());
if (idf->iddObject().type() == IddObjectType::HeatExchanger_AirToAir_SensibleAndLatent) {
idf->setString(HeatExchanger_AirToAir_SensibleAndLatentFields::SupplyAirInletNodeName, hxSupplyAirInletNodeName);
idf->setString(HeatExchanger_AirToAir_SensibleAndLatentFields::SupplyAirOutletNodeName, hxSupplyAirOutletNodeName);
Expand All @@ -112,7 +111,7 @@ namespace energyplus {
auto coolingCoil = modelObject.coolingCoil();
if (auto idf = translateAndMapModelObject(coolingCoil)) {
idfObject.setString(CoilSystem_Cooling_Water_HeatExchangerAssistedFields::CoolingCoilObjectType, idf->iddObject().name());
idfObject.setString(CoilSystem_Cooling_Water_HeatExchangerAssistedFields::CoolingCoilName, idf->name().get());
idfObject.setString(CoilSystem_Cooling_Water_HeatExchangerAssistedFields::CoolingCoilName, idf->nameString());
if (idf->iddObject().type() == IddObjectType::Coil_Cooling_Water) {
idf->setString(Coil_Cooling_WaterFields::AirInletNodeName, hxSupplyAirOutletNodeName);
idf->setString(Coil_Cooling_WaterFields::AirOutletNodeName, hxExhaustAirInletNodeName);
Expand All @@ -135,15 +134,19 @@ namespace energyplus {

// Need a SPM:MixedAir on the Coil:Cooling:Water outlet node (that we **created** just above in IDF directly, so it won't get picked up by the
// ForwardTranslateAirLoopHVAC method)
if (boost::optional<AirLoopHVAC> _airLoop = modelObject.airLoopHVAC()) {
if (boost::optional<AirLoopHVAC> airLoop_ = modelObject.airLoopHVAC()) {
std::vector<StraightComponent> fans;
std::vector<ModelObject> supplyComponents = _airLoop->supplyComponents();
std::vector<ModelObject> supplyComponents = airLoop_->supplyComponents();

for (auto it = supplyComponents.begin(); it != supplyComponents.end(); ++it) {
if (boost::optional<FanVariableVolume> variableFan = it->optionalCast<FanVariableVolume>()) {
fans.insert(fans.begin(), *variableFan);
} else if (boost::optional<FanConstantVolume> constantFan = it->optionalCast<FanConstantVolume>()) {
fans.insert(fans.begin(), *constantFan);
if (auto fan_ = it->optionalCast<FanVariableVolume>()) {
fans.insert(fans.begin(), std::move(*fan_));
} else if (auto fan_ = it->optionalCast<FanConstantVolume>()) {
fans.insert(fans.begin(), std::move(*fan_));
} else if (auto fan_ = it->optionalCast<FanSystemModel>()) {
fans.insert(fans.begin(), std::move(*fan_));
} else if (auto fan_ = it->optionalCast<FanOnOff>()) {
fans.insert(fans.begin(), std::move(*fan_));
Comment on lines +142 to +149
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adding FanSystemModel and FanOnOff here

}
}

Expand All @@ -161,11 +164,11 @@ namespace energyplus {
idf_spm.setString(SetpointManager_MixedAirFields::Name, hxExhaustAirInletNodeName + " OS Default SPM");
idf_spm.setString(SetpointManager_MixedAirFields::ControlVariable, "Temperature");

Node supplyOutletNode = _airLoop->supplyOutletNode();
idf_spm.setString(SetpointManager_MixedAirFields::ReferenceSetpointNodeName, supplyOutletNode.name().get());
Node supplyOutletNode = airLoop_->supplyOutletNode();
idf_spm.setString(SetpointManager_MixedAirFields::ReferenceSetpointNodeName, supplyOutletNode.nameString());

idf_spm.setString(SetpointManager_MixedAirFields::FanInletNodeName, inletNode->name().get());
idf_spm.setString(SetpointManager_MixedAirFields::FanOutletNodeName, outletNode->name().get());
idf_spm.setString(SetpointManager_MixedAirFields::FanInletNodeName, inletNode->nameString());
idf_spm.setString(SetpointManager_MixedAirFields::FanOutletNodeName, outletNode->nameString());

idf_spm.setString(SetpointManager_MixedAirFields::SetpointNodeorNodeListName, hxExhaustAirInletNodeName);

Expand Down