Skip to content

Commit

Permalink
Fix ft and tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
joseph-robertson authored and jmarrec committed Jan 9, 2025
1 parent 1ea9054 commit 84bb380
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,8 @@ namespace energyplus {
IdfObject idfObject = createRegisterAndNameIdfObject(openstudio::IddObjectType::ZoneHVAC_EvaporativeCoolerUnit, modelObject);

// Availability Schedule Name: Required Object
if (boost::optional<IdfObject> wo_ = translateAndMapModelObject(modelObject.availabilitySchedule())) {
Schedule availabilitySchedule_ = modelObject.availabilitySchedule();
if (boost::optional<IdfObject> wo_ = translateAndMapModelObject(availabilitySchedule_)) {
idfObject.setString(ZoneHVAC_EvaporativeCoolerUnitFields::AvailabilityScheduleName, wo_->nameString());
}

Expand All @@ -79,7 +80,8 @@ namespace energyplus {

// Supply Air Fan Object Type
// Supply Air Fan Name
boost::optional<IdfObject> fan_ = translateAndMapModelObject(modelObject.supplyAirFan().get());
HVACComponent supplyAirFan_ = modelObject.supplyAirFan();
boost::optional<IdfObject> fan_ = translateAndMapModelObject(supplyAirFan_);

if (fan_ && fan_->name()) {
idfObject.setString(ZoneHVAC_EvaporativeCoolerUnitFields::SupplyAirFanObjectType, fan_->iddObject().name());
Expand Down
26 changes: 16 additions & 10 deletions src/model/test/ZoneHVACEvaporativeCoolerUnit_GTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@
#include "../AirLoopHVACZoneSplitter_Impl.hpp"
#include "../PlantLoop.hpp"
#include "../PlantLoop_Impl.hpp"
#include "../ThermalZone.hpp"
#include "../ThermalZone_Impl.hpp"

using namespace openstudio;
using namespace openstudio::model;
Expand Down Expand Up @@ -147,6 +149,8 @@ TEST_F(ModelFixture, ZoneHVACEvaporativeCoolerUnit_addToThermalZone) {

ThermalZone tz(m);
ASSERT_TRUE(zonehvac.addToThermalZone(tz));
EXPECT_TRUE(zonehvac.inletNode());
EXPECT_TRUE(zonehvac.outletNode());
ASSERT_TRUE(zonehvac.thermalZone());
ASSERT_EQ(tz, zonehvac.thermalZone().get());
ASSERT_EQ(1u, tz.equipment().size());
Expand All @@ -163,41 +167,43 @@ TEST_F(ModelFixture, ZoneHVACEvaporativeCoolerUnit_clone) {
Model m;
FanComponentModel fan(m);
Schedule availabilitySchedule = m.alwaysOnDiscreteSchedule();
EvaporativeCoolerDirectResearchSpecial firstEvaporativeCooler(model, availabilitySchedule);
EvaporativeCoolerDirectResearchSpecial firstEvaporativeCooler(m, availabilitySchedule);
ZoneHVACEvaporativeCoolerUnit zonehvac(m, availabilitySchedule, fan, firstEvaporativeCooler);
EvaporativeCoolerIndirectResearchSpecial secondEvaporativeCooler(m);
EXPECT_TRUE(zoneHVACEvaporativeCoolerUnit.setSecondEvaporativeCooler(secondEvaporativeCooler));
EXPECT_TRUE(zonehvac.setSecondEvaporativeCooler(secondEvaporativeCooler));
EXPECT_EQ(1u, m.getConcreteModelObjects<FanComponentModel>().size());
EXPECT_EQ(1u, m.getConcreteModelObjects<EvaporativeCoolerDirectResearchSpecial>().size());
EXPECT_EQ(1u, m.getConcreteModelObjects<EvaporativeCoolerIndirectResearchSpecial>().size());

ThermalZone tz(m);
EXPECT_TRUE(zonehvac.addToThermalZone(tz));
EXPECT_TRUE(zonehvac.inletModelObject());
EXPECT_TRUE(zonehvac.outletModelObject());
EXPECT_TRUE(zonehvac.inletNode());
EXPECT_TRUE(zonehvac.outletNode());
EXPECT_TRUE(zonehvac.thermalZone());
{
Model m2;
auto zonehvacClone = zonehvac.clone(m2).cast<ZoneHVACEvaporativeCoolerUnit>();
EXPECT_FALSE(zonehvacClone.inletModelObject());
EXPECT_FALSE(zonehvacClone.outletModelObject());
EXPECT_FALSE(zonehvacClone.inletNode());
EXPECT_FALSE(zonehvacClone.outletNode());
EXPECT_FALSE(zonehvacClone.thermalZone());
EXPECT_NE(fan.handle(), zonehvacClone.supplyAirFan().handle());
EXPECT_NE(firstEvaporativeCooler.handle(), zonehvacClone.firstEvaporativeCooler().handle());
EXPECT_NE(secondEvaporativeCooler.handle(), zonehvacClone.secondEvaporativeCooler().handle());
ASSERT_TRUE(zonehvacClone.secondEvaporativeCooler());
EXPECT_NE(secondEvaporativeCooler.handle(), zonehvacClone.secondEvaporativeCooler().get().handle());
EXPECT_EQ(1u, m2.getConcreteModelObjects<FanComponentModel>().size());
EXPECT_EQ(1u, m2.getConcreteModelObjects<EvaporativeCoolerDirectResearchSpecial>().size());
EXPECT_EQ(1u, m2.getConcreteModelObjects<EvaporativeCoolerIndirectResearchSpecial>().size());
}

{
auto zonehvacClone = zonehvac.clone(m).cast<ZoneHVACEvaporativeCoolerUnit>();
EXPECT_FALSE(zonehvacClone.inletModelObject());
EXPECT_FALSE(zonehvacClone.outletModelObject());
EXPECT_FALSE(zonehvacClone.inletNode());
EXPECT_FALSE(zonehvacClone.outletNode());
EXPECT_FALSE(zonehvacClone.thermalZone());
EXPECT_NE(fan.handle(), zonehvacClone.supplyAirFan().handle());
EXPECT_NE(firstEvaporativeCooler.handle(), zonehvacClone.firstEvaporativeCooler().handle());
EXPECT_NE(secondEvaporativeCooler.handle(), zonehvacClone.secondEvaporativeCooler().handle());
ASSERT_TRUE(zonehvacClone.secondEvaporativeCooler());
EXPECT_NE(secondEvaporativeCooler.handle(), zonehvacClone.secondEvaporativeCooler().get().handle());
EXPECT_EQ(1u, m.getConcreteModelObjects<FanComponentModel>().size());
EXPECT_EQ(1u, m.getConcreteModelObjects<EvaporativeCoolerDirectResearchSpecial>().size());
EXPECT_EQ(1u, m.getConcreteModelObjects<EvaporativeCoolerIndirectResearchSpecial>().size());
Expand Down

0 comments on commit 84bb380

Please sign in to comment.