コード例 #1
0
boost::optional<IdfObject> ForwardTranslator::translateCoilCoolingDXSingleSpeed( CoilCoolingDXSingleSpeed& modelObject )
{
  IdfObject coilSystemCoolingDXIdf(IddObjectType::CoilSystem_Cooling_DX);
    
  m_idfObjects.push_back(coilSystemCoolingDXIdf);

  boost::optional<IdfObject> oIdfObject = translateCoilCoolingDXSingleSpeedWithoutUnitary(modelObject);

  if( ! oIdfObject ) { return boost::none; }

  IdfObject idfObject = oIdfObject.get();

  OptionalString s;

  s = modelObject.name();
  if( s )
  {
    coilSystemCoolingDXIdf.setString(CoilSystem_Cooling_DXFields::CoolingCoilObjectType,idfObject.iddObject().name());

    coilSystemCoolingDXIdf.setString(CoilSystem_Cooling_DXFields::CoolingCoilName,*s);

    coilSystemCoolingDXIdf.setName(*s + " CoilSystem");
  }

  Schedule sched = modelObject.getAvailabilitySchedule();
  translateAndMapModelObject(sched);

  coilSystemCoolingDXIdf.setString(CoilSystem_Cooling_DXFields::AvailabilityScheduleName,sched.name().get());

  OptionalModelObject omo = modelObject.inletModelObject();
  if( omo )
  {
    translateAndMapModelObject(*omo);
    s = omo->name();
    if(s)
    {
      coilSystemCoolingDXIdf.setString(CoilSystem_Cooling_DXFields::DXCoolingCoilSystemInletNodeName,*s);
    }
  }

  omo= modelObject.outletModelObject();
  if( omo )
  {
    translateAndMapModelObject(*omo);
    s = omo->name();
    if(s)
    {
      coilSystemCoolingDXIdf.setString(CoilSystem_Cooling_DXFields::DXCoolingCoilSystemOutletNodeName,*s);

      coilSystemCoolingDXIdf.setString(CoilSystem_Cooling_DXFields::DXCoolingCoilSystemSensorNodeName,*s);
    }
  }

  return coilSystemCoolingDXIdf;
}
コード例 #2
0
TEST_F(ModelFixture,CoilCoolingDXSingleSpeed_addToNode) {
    Model m;
    Schedule s = m.alwaysOnDiscreteSchedule();
    CurveBiquadratic totalCoolingCapacityFunctionofTemperatureCurve(m);
    CurveQuadratic totalCoolingCapacityFunctionofFlowFractionCurve(m);
    CurveBiquadratic energyInputRatioFunctionofTemperatureCurve(m);
    CurveQuadratic energyInputRatioFunctionofFlowFractionCurve(m);
    CurveQuadratic partLoadFractionCorrelationCurve(m);

    CoilCoolingDXSingleSpeed testObject(m, s,
                                        totalCoolingCapacityFunctionofTemperatureCurve,
                                        totalCoolingCapacityFunctionofFlowFractionCurve,
                                        energyInputRatioFunctionofTemperatureCurve,
                                        energyInputRatioFunctionofFlowFractionCurve,
                                        partLoadFractionCorrelationCurve);

    AirLoopHVAC airLoop(m);
    ControllerOutdoorAir controllerOutdoorAir(m);
    AirLoopHVACOutdoorAirSystem outdoorAirSystem(m,controllerOutdoorAir);

    Node supplyOutletNode = airLoop.supplyOutletNode();
    outdoorAirSystem.addToNode(supplyOutletNode);

    EXPECT_TRUE(testObject.addToNode(supplyOutletNode));
    EXPECT_EQ( (unsigned)5, airLoop.supplyComponents().size() );

    Node inletNode = airLoop.zoneSplitter().lastOutletModelObject()->cast<Node>();

    EXPECT_FALSE(testObject.addToNode(inletNode));
    EXPECT_EQ((unsigned)5, airLoop.demandComponents().size());

    PlantLoop plantLoop(m);
    supplyOutletNode = plantLoop.supplyOutletNode();
    EXPECT_FALSE(testObject.addToNode(supplyOutletNode));
    EXPECT_EQ( (unsigned)5, plantLoop.supplyComponents().size() );

    Node demandOutletNode = plantLoop.demandOutletNode();
    EXPECT_FALSE(testObject.addToNode(demandOutletNode));
    EXPECT_EQ( (unsigned)5, plantLoop.demandComponents().size() );

    CurveBiquadratic  c1(m);
    CurveQuadratic  c2(m);
    CurveBiquadratic  c3(m);
    CurveQuadratic  c4(m);
    CurveQuadratic  c5(m);

    CoilCoolingDXSingleSpeed testObject2(m, s, c1, c2, c3, c4, c5);

    if( boost::optional<Node> OANode = outdoorAirSystem.outboardOANode() ) {
        EXPECT_TRUE(testObject2.addToNode(*OANode));
        EXPECT_EQ( (unsigned)5, airLoop.supplyComponents().size() );
        EXPECT_EQ( (unsigned)3, outdoorAirSystem.oaComponents().size() );
    }

    CurveBiquadratic  c1_2(m);
    CurveQuadratic  c2_2(m);
    CurveBiquadratic  c3_2(m);
    CurveQuadratic  c4_2(m);
    CurveQuadratic  c5_2(m);

    CoilCoolingDXSingleSpeed testObject3(m, s, c1_2, c2_2, c3_2, c4_2, c5_2);

    if( boost::optional<Node> reliefNode = outdoorAirSystem.outboardReliefNode() ) {
        EXPECT_TRUE(testObject3.addToNode(*reliefNode));
        EXPECT_EQ( (unsigned)5, airLoop.supplyComponents().size() );
        EXPECT_EQ( (unsigned)3, outdoorAirSystem.reliefComponents().size() );
    }

    // tests and checks to figure out clone bug
    // resolution: Due to using ModelObject::clone instead of StraightComponent::clone in reimplementation
    AirLoopHVAC airLoop2(m);
    EXPECT_EQ( (unsigned)5, airLoop.supplyComponents().size() );
    CoilCoolingDXSingleSpeed testObjectClone = testObject.clone(m).cast<CoilCoolingDXSingleSpeed>();
    CoilCoolingDXSingleSpeed testObjectClone2 = testObject.clone(m).cast<CoilCoolingDXSingleSpeed>();
    EXPECT_EQ( (unsigned)5, airLoop.supplyComponents().size() );
    Node supplyOutletNode2 = airLoop2.supplyOutletNode();
    supplyOutletNode = airLoop.supplyOutletNode();

    EXPECT_NE(testObject, testObjectClone);
    EXPECT_FALSE(testObjectClone.loop());
    EXPECT_FALSE(testObjectClone.airLoopHVAC());
    EXPECT_NE(testObject.totalCoolingCapacityFunctionOfTemperatureCurve(), testObjectClone.totalCoolingCapacityFunctionOfTemperatureCurve());
    EXPECT_NE(testObject.totalCoolingCapacityFunctionOfFlowFractionCurve(), testObjectClone.totalCoolingCapacityFunctionOfFlowFractionCurve());
    EXPECT_NE(testObject.energyInputRatioFunctionOfTemperatureCurve(), testObjectClone.energyInputRatioFunctionOfTemperatureCurve());
    EXPECT_NE(testObject.energyInputRatioFunctionOfFlowFractionCurve(), testObjectClone.energyInputRatioFunctionOfFlowFractionCurve());
    EXPECT_NE(testObject.partLoadFractionCorrelationCurve(), testObjectClone.partLoadFractionCorrelationCurve());
    EXPECT_TRUE(testObject.inletModelObject());
    EXPECT_TRUE(testObject.outletModelObject());
    EXPECT_FALSE(testObjectClone.inletModelObject());
    EXPECT_FALSE(testObjectClone.outletModelObject());

    EXPECT_TRUE(testObjectClone.addToNode(supplyOutletNode2));
    EXPECT_EQ( (unsigned)5, airLoop.supplyComponents().size() );
    EXPECT_EQ( (unsigned)3, airLoop2.supplyComponents().size() );
    EXPECT_TRUE(testObjectClone2.addToNode(supplyOutletNode));
    EXPECT_EQ( (unsigned)7, airLoop.supplyComponents().size() );
}