示例#1
0
TEST_F(IdfFixture, IdfObject_NameGetterWithReturnDefaultOption) {
  // OBJECT WITH DEFAULT NAME
  std::stringstream text;
  text << "Building," << std::endl
    << "," << std::endl
    << "," << std::endl
    << "," << std::endl
    << "," << std::endl
    << "," << std::endl
    << "," << std::endl
    << ";";
  OptionalIdfObject oObj = IdfObject::load(text.str());
  ASSERT_TRUE(oObj);
  IdfObject object = *oObj;
  OptionalString name = object.name();
  ASSERT_TRUE(name);
  EXPECT_TRUE(name->empty());
  name = object.name(true);
  ASSERT_TRUE(name);
  EXPECT_EQ("NONE",*name);
  object.setName("MyBuilding");
  name = object.name();
  ASSERT_TRUE(name);
  EXPECT_EQ("MyBuilding",*name);
  OptionalString name2 = object.name(true);
  ASSERT_TRUE(name2);
  EXPECT_EQ(*name,*name2);
}
TEST_F(EnergyPlusFixture,ForwardTranslatorTest_TranslateConstruction) {
  openstudio::model::Model model;

  openstudio::model::StandardOpaqueMaterial mat1(model);
  mat1.setName("test layer0");
  mat1.setRoughness("MediumRough");
  mat1.setThickness(0.02);
  mat1.setThermalConductivity(1.5);
  mat1.setDensity(20.0);
  mat1.setSpecificHeat(2.0);

  openstudio::model::StandardOpaqueMaterial mat2(model);
  mat2.setName("test layer1");
  mat2.setRoughness("MediumSmooth");
  mat2.setThickness(0.005);
  mat2.setThermalConductivity(0.3);
  mat2.setDensity(3.0);
  mat2.setSpecificHeat(0.3);

  openstudio::model::Construction construction(model);
  construction.setName("test construction");
  construction.insertLayer(0, mat1);
  construction.insertLayer(1, mat2);

  ForwardTranslator trans;
  Workspace workspace = trans.translateModelObject(construction);
  ASSERT_EQ(1u, workspace.numObjectsOfType(IddObjectType::Construction));

  IdfObject constructionIdf = workspace.getObjectsByType(IddObjectType::Construction)[0];

  EXPECT_EQ(unsigned(3), constructionIdf.numFields());
  EXPECT_EQ("test construction", *(constructionIdf.name()) );
  EXPECT_EQ("test layer0", *(constructionIdf.getString(1)) );
  EXPECT_EQ("test layer1", *(constructionIdf.getString(2)) );
}
示例#3
0
ValidityReport::ValidityReport(StrictnessLevel level,const IdfObject& object)
  : m_level(level), 
    m_scope(Scope::Object), 
    m_objectType(object.iddObject().type())
{
  m_currentError = m_errors.end();
  OptionalString oName = object.name();
  if (oName) { m_objectName = *oName; }
}
  boost::optional<IdfObject> ForwardTranslator::translateSolarCollectorFlatPlateWater(SolarCollectorFlatPlateWater & modelObject)
{
  boost::optional<std::string> s;
  boost::optional<double> value;

  IdfObject idfObject(IddObjectType::SolarCollector_FlatPlate_Water);

  m_idfObjects.push_back(idfObject);

  // Name
  std::string name = modelObject.name().get();
  idfObject.setName(name);

  // SolarCollectorPerformanceFlatPlate
  {
    auto mo = modelObject.solarCollectorPerformance();
    IdfObject performance = translateAndMapModelObject(mo).get();
    idfObject.setString(SolarCollector_FlatPlate_WaterFields::SolarCollectorPerformanceName, performance.name().get());
  }

  OptionalPlanarSurface surface = modelObject.surface();
  if (surface){
    IdfObject surf = translateAndMapModelObject(*surface).get();
    idfObject.setString(SolarCollector_FlatPlate_WaterFields::SurfaceName, surf.name().get());
  } else{
    LOG(Error, "SolarCollector:FlatPlate:Water '" << name << "' does not reference a surface.");
  }

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

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

  // MaximumFlowRate
  boost::optional<double> maximumFlowRate = modelObject.maximumFlowRate();
  if (maximumFlowRate){
    idfObject.setDouble(SolarCollector_FlatPlate_WaterFields::MaximumFlowRate, *maximumFlowRate);
  }

  return boost::optional<IdfObject>(idfObject);
}
示例#5
0
DataError::DataError(const IdfObject& object, DataErrorType errorType) 
  : m_scope(Scope::Object),
    m_type(errorType),
    m_fieldIndex(0),
    m_objectHandle(object.handle()),
    m_objectType(object.iddObject().type())
{
  // construct object-level error
  OptionalString oName = object.name();
  if (oName) { m_objectName = *oName; }
}
示例#6
0
TEST_F(IdfFixture, IdfObject_CopyConstructor)
{
  std::string text = "Building,                !- Building \n\
                      Building,                !- Name \n\
                      30.,                     !- North Axis {deg} \n\
                      City,                    !- Terrain \n\
                      0.04,                    !- Loads Convergence Tolerance Value \n\
                      0.4,                     !- Temperature Convergence Tolerance Value {deltaC} \n\
                      FullExterior,            !- Solar Distribution \n\
                      25;                      !- Maximum Number of Warmup Days";

  // make an idf object
  OptionalIdfObject oObj = IdfObject::load(text);
  ASSERT_TRUE(oObj);
  IdfObject building = *oObj;
  EXPECT_TRUE(building.iddObject().type() == IddObjectType::Building);
  EXPECT_TRUE(building.isValid(StrictnessLevel::Final));
  ASSERT_TRUE(building.name());
  EXPECT_EQ("Building", *(building.name()));

  // copy idf object
  IdfObject building2(building);
  EXPECT_TRUE(building2.isValid(StrictnessLevel::Final));
  ASSERT_TRUE(building2.name());
  EXPECT_EQ("Building", *(building2.name()));

  // change building2's name
  building2.setString(0, "New Building");
  EXPECT_TRUE(building2.isValid(StrictnessLevel::Final));
  ASSERT_TRUE(building2.name());
  EXPECT_EQ("New Building", *(building2.name()));

  // also changed first building's name
  EXPECT_TRUE(building.isValid(StrictnessLevel::Final));
  ASSERT_TRUE(building.name());
  EXPECT_EQ("New Building", *(building.name()));
}
TEST_F(EnergyPlusFixture,ForwardTranslatorTest_TranslateSite) {
  openstudio::model::Model model;
  openstudio::model::Site site = model.getUniqueModelObject<openstudio::model::Site>();

  site.setName("Test Site");
  site.setLatitude(39.6);
  site.setLongitude(105.2);
  site.setTimeZone(-7.0);
  site.setElevation(1729.74);

  ForwardTranslator trans;
  Workspace workspace = trans.translateModelObject(site);
  ASSERT_EQ(1u, workspace.numObjectsOfType(IddObjectType::Site_Location));
    
  IdfObject siteIdf = workspace.getObjectsByType(IddObjectType::Site_Location)[0];
  EXPECT_EQ(unsigned(5), siteIdf.numFields());

  EXPECT_EQ( "Test Site", *(siteIdf.name()) );
  EXPECT_EQ( 39.6, *(siteIdf.getDouble(1)) );
  EXPECT_EQ( 105.2, *(siteIdf.getDouble(2)) );
  EXPECT_EQ( -7.0, *(siteIdf.getDouble(3)) );
  EXPECT_EQ( 1729.74, *(siteIdf.getDouble(4)) );
}
boost::optional<IdfObject> ForwardTranslator::translateAirTerminalSingleDuctConstantVolumeFourPipeInduction( AirTerminalSingleDuctConstantVolumeFourPipeInduction & modelObject )
{
  OptionalString s;
  OptionalDouble d;
  OptionalModelObject temp;

  IdfObject _airDistributionUnit(openstudio::IddObjectType::ZoneHVAC_AirDistributionUnit);
  _airDistributionUnit.setName(modelObject.name().get() + " Air Distribution Unit");
  m_idfObjects.push_back(_airDistributionUnit);

  // Name
  IdfObject idfObject = createRegisterAndNameIdfObject(openstudio::IddObjectType::AirTerminal_SingleDuct_ConstantVolume_FourPipeInduction, modelObject);

  // Availability Schedule Name
  if( (temp = modelObject.availabilitySchedule()) )
  {
    if( boost::optional<IdfObject> _schedule = translateAndMapModelObject(temp.get()) )
    {
      idfObject.setString(AirTerminal_SingleDuct_ConstantVolume_FourPipeInductionFields::AvailabilityScheduleName,_schedule->name().get());
    }
  }

  // Maximum Total Air Flow Rate
  if( (d = modelObject.maximumTotalAirFlowRate()) )
  {
    idfObject.setDouble(AirTerminal_SingleDuct_ConstantVolume_FourPipeInductionFields::MaximumTotalAirFlowRate,d.get());
  }
  else if( modelObject.isMaximumTotalAirFlowRateAutosized() )
  {
    idfObject.setString(AirTerminal_SingleDuct_ConstantVolume_FourPipeInductionFields::MaximumTotalAirFlowRate,"Autosize");
  }

  // Induction Ratio
  if( (d = modelObject.inductionRatio()) )
  {
    idfObject.setDouble(AirTerminal_SingleDuct_ConstantVolume_FourPipeInductionFields::InductionRatio,d.get());
  }

  // Supply Air Inlet Node Name
  if( auto node = modelObject.inletModelObject() ) {
    idfObject.setString(AirTerminal_SingleDuct_ConstantVolume_FourPipeInductionFields::SupplyAirInletNodeName,node->name().get());
  }

  // Induced Air Inlet Node Name
  if( auto node = modelObject.inducedAirInletNode() ) {
    idfObject.setString(AirTerminal_SingleDuct_ConstantVolume_FourPipeInductionFields::InducedAirInletNodeName,node->name().get());
  }

  // Air Outlet Node Name
  if( auto node = modelObject.outletModelObject() ) {
    idfObject.setString(AirTerminal_SingleDuct_ConstantVolume_FourPipeInductionFields::AirOutletNodeName,node->name().get());
  }

  // Hot Water Inlet Node Name
  // deprecated

  // Cold Water Inlet Node Name
  //deprecated

  // Heating Coil Object Type
  // Heating Coil Name
  boost::optional<IdfObject> _heatingCoil;
  {
    auto heatingCoil = modelObject.heatingCoil();
    if( (_heatingCoil = translateAndMapModelObject(heatingCoil)) ) {
      idfObject.setString(AirTerminal_SingleDuct_ConstantVolume_FourPipeInductionFields::HeatingCoilObjectType,_heatingCoil->iddObject().name());
      idfObject.setString(AirTerminal_SingleDuct_ConstantVolume_FourPipeInductionFields::HeatingCoilName,_heatingCoil->name().get());
    }
  }

  // Maximum Hot Water Flow Rate
  if( (d = modelObject.maximumHotWaterFlowRate()) )
  {
    idfObject.setDouble(AirTerminal_SingleDuct_ConstantVolume_FourPipeInductionFields::MaximumHotWaterFlowRate,d.get());
  }
  else if( modelObject.isMaximumHotWaterFlowRateAutosized() )
  {
    idfObject.setString(AirTerminal_SingleDuct_ConstantVolume_FourPipeInductionFields::MaximumHotWaterFlowRate,"Autosize");
  }

  // Minimum Hot Water Flow Rate
  if( (d = modelObject.minimumHotWaterFlowRate()) )
  {
    idfObject.setDouble(AirTerminal_SingleDuct_ConstantVolume_FourPipeInductionFields::MinimumHotWaterFlowRate,d.get());
  }

  // Heating Convergence Tolerance
  if( (d = modelObject.heatingConvergenceTolerance()) )
  {
    idfObject.setDouble(AirTerminal_SingleDuct_ConstantVolume_FourPipeInductionFields::HeatingConvergenceTolerance,d.get());
  }

  // Cooling Coil Object Type
  // Cooling Coil Name
  boost::optional<IdfObject> _coolingCoil;
  if( auto coolingCoil = modelObject.coolingCoil() ) {
    if( (_coolingCoil = translateAndMapModelObject(coolingCoil.get())) ) {
      idfObject.setString(AirTerminal_SingleDuct_ConstantVolume_FourPipeInductionFields::CoolingCoilObjectType,_coolingCoil->iddObject().name());
      idfObject.setString(AirTerminal_SingleDuct_ConstantVolume_FourPipeInductionFields::CoolingCoilName,_coolingCoil->name().get());
    }
  }
  
  // Maximum Cold Water Flow Rate
  if( (d = modelObject.maximumColdWaterFlowRate()) )
  {
    idfObject.setDouble(AirTerminal_SingleDuct_ConstantVolume_FourPipeInductionFields::MaximumColdWaterFlowRate,d.get());
  }
  else if( modelObject.isMaximumColdWaterFlowRateAutosized() )
  {
    idfObject.setString(AirTerminal_SingleDuct_ConstantVolume_FourPipeInductionFields::MaximumColdWaterFlowRate,"Autosize");
  }

  // Minimum Cold Water Flow Rate
  if( (d = modelObject.minimumColdWaterFlowRate()) )
  {
    idfObject.setDouble(AirTerminal_SingleDuct_ConstantVolume_FourPipeInductionFields::MinimumColdWaterFlowRate,d.get());
  }

  // Cooling Convergence Tolerance
  if( (d = modelObject.coolingConvergenceTolerance()) )
  {
    idfObject.setDouble(AirTerminal_SingleDuct_ConstantVolume_FourPipeInductionFields::CoolingConvergenceTolerance,d.get());
  }

  // Zone Mixer Name
  IdfObject _mixer(IddObjectType::AirLoopHVAC_ZoneMixer);
  _mixer.setName(modelObject.name().get() + " Mixer");
  m_idfObjects.push_back(_mixer);
  _mixer.clearExtensibleGroups();
  idfObject.setString(AirTerminal_SingleDuct_ConstantVolume_FourPipeInductionFields::ZoneMixerName,_mixer.name().get());

  std::string baseName = modelObject.name().get();

  std::string heatingCoilInlet;
  std::string heatingCoilOutlet;
  std::string coolingCoilInlet;
  std::string coolingCoilOutlet;
  std::string mixerAirSystemInlet;
  std::string mixerInducedInlet;
  std::string mixerOutlet;

  if( auto inducedAirInletNode = modelObject.inducedAirInletNode() ) {
    heatingCoilInlet = inducedAirInletNode->name().get();
  }
  heatingCoilOutlet = baseName + " Heating Coil Outlet";

  if( _coolingCoil ) {
    coolingCoilInlet = heatingCoilOutlet;
    coolingCoilOutlet = baseName + " Cooling Coil Outlet";

    mixerInducedInlet = coolingCoilOutlet;
  } else {
    mixerInducedInlet = heatingCoilOutlet;
  }

  if( auto node = modelObject.inletModelObject() ) {
    mixerAirSystemInlet = node->name().get();
  }
  if( auto node = modelObject.outletModelObject() ) {
    mixerOutlet = node->name().get();
  }

  if( _heatingCoil && (_heatingCoil->iddObject().type() == IddObjectType::Coil_Heating_Water) ) {
    _heatingCoil->setString(Coil_Heating_WaterFields::AirInletNodeName,heatingCoilInlet);
    _heatingCoil->setString(Coil_Heating_WaterFields::AirOutletNodeName,heatingCoilOutlet);
  }

  if( _coolingCoil && (_coolingCoil->iddObject().type() == IddObjectType::Coil_Cooling_Water) ) {
    _coolingCoil->setString(Coil_Cooling_WaterFields::AirInletNodeName,coolingCoilInlet);
    _coolingCoil->setString(Coil_Cooling_WaterFields::AirOutletNodeName,coolingCoilOutlet);
  }

  _mixer.setString(AirLoopHVAC_ZoneMixerFields::OutletNodeName,mixerOutlet);
  IdfExtensibleGroup eg = _mixer.pushExtensibleGroup();
  eg.setString(AirLoopHVAC_ZoneMixerExtensibleFields::InletNodeName,mixerAirSystemInlet);
  eg = _mixer.pushExtensibleGroup();
  eg.setString(AirLoopHVAC_ZoneMixerExtensibleFields::InletNodeName,mixerInducedInlet);

  if( auto node = modelObject.outletModelObject() ) {
    _airDistributionUnit.setString(ZoneHVAC_AirDistributionUnitFields::AirDistributionUnitOutletNodeName,node->name().get());
  }
  _airDistributionUnit.setString(ZoneHVAC_AirDistributionUnitFields::AirTerminalObjectType,idfObject.iddObject().name());
  _airDistributionUnit.setString(ZoneHVAC_AirDistributionUnitFields::AirTerminalName,idfObject.name().get());

  return _airDistributionUnit;
}
boost::optional<IdfObject> ForwardTranslator::translateRefrigerationTranscriticalSystem( RefrigerationTranscriticalSystem & modelObject )
{
  OptionalModelObject temp;
  boost::optional<std::string> s;
  boost::optional<double> d;
  std::string name;

// Name
  IdfObject idfObject = createRegisterAndNameIdfObject(openstudio::IddObjectType::Refrigeration_TranscriticalSystem, modelObject);

//MediumTemperatureRefrigeratedCaseAndWalkInListName
  std::vector<RefrigerationCase> mediumTemperatureCases = modelObject.mediumTemperatureCases();
  std::vector<RefrigerationWalkIn> mediumTemperatureWalkins = modelObject.mediumTemperatureWalkins();

  if( !mediumTemperatureCases.empty() || !mediumTemperatureWalkins.empty() )
  {
    // Name
    name = " Medium Temperature Case and Walkin List";
    idfObject.setString(Refrigeration_TranscriticalSystemFields::MediumTemperatureRefrigeratedCaseorWalkinorCaseAndWalkInListName, idfObject.name().get() + name);

    IdfObject _caseAndWalkinList(IddObjectType::Refrigeration_CaseAndWalkInList);

    m_idfObjects.push_back(_caseAndWalkinList);

    _caseAndWalkinList.setName(idfObject.name().get() + name);

    for( auto & mediumTemperatureCase : mediumTemperatureCases )
    {
      boost::optional<IdfObject> _case = translateAndMapModelObject(mediumTemperatureCase);

      if( _case )
      {
        IdfExtensibleGroup eg = _caseAndWalkinList.pushExtensibleGroup();

        eg.setString(Refrigeration_CaseAndWalkInListExtensibleFields::CaseorWalkInName,_case->name().get()); 
      }
    }

    for( auto & mediumTemperatureWalkin : mediumTemperatureWalkins )
    {
      boost::optional<IdfObject> _walkin = translateAndMapModelObject(mediumTemperatureWalkin);

      if( _walkin )
      {
        IdfExtensibleGroup eg = _caseAndWalkinList.pushExtensibleGroup();

        eg.setString(Refrigeration_CaseAndWalkInListExtensibleFields::CaseorWalkInName,_walkin->name().get()); 
      }
    }
  }

//LowTemperatureRefrigeratedCaseAndWalkInListName
  std::vector<RefrigerationCase> lowTemperatureCases = modelObject.lowTemperatureCases();
  std::vector<RefrigerationWalkIn> lowTemperatureWalkins = modelObject.lowTemperatureWalkins();

  if( !lowTemperatureCases.empty() || !lowTemperatureWalkins.empty() )
  {
    // Name
    name = " Low Temperature Case and Walkin List";
    idfObject.setString(Refrigeration_TranscriticalSystemFields::LowTemperatureRefrigeratedCaseorWalkinorCaseAndWalkInListName, idfObject.name().get() + name);

    IdfObject _caseAndWalkinList(IddObjectType::Refrigeration_CaseAndWalkInList);

    m_idfObjects.push_back(_caseAndWalkinList);

    _caseAndWalkinList.setName(idfObject.name().get() + name);

    for( auto & lowTemperatureCase : lowTemperatureCases )
    {
      boost::optional<IdfObject> _case = translateAndMapModelObject(lowTemperatureCase);

      if( _case )
      {
        IdfExtensibleGroup eg = _caseAndWalkinList.pushExtensibleGroup();

        eg.setString(Refrigeration_CaseAndWalkInListExtensibleFields::CaseorWalkInName,_case->name().get()); 
      }
    }

    for( auto & lowTemperatureWalkin : lowTemperatureWalkins )
    {
      boost::optional<IdfObject> _walkin = translateAndMapModelObject(lowTemperatureWalkin);

      if( _walkin )
      {
        IdfExtensibleGroup eg = _caseAndWalkinList.pushExtensibleGroup();

        eg.setString(Refrigeration_CaseAndWalkInListExtensibleFields::CaseorWalkInName,_walkin->name().get()); 
      }
    }
  }

// SystemType
  if ( (!mediumTemperatureCases.empty() || !mediumTemperatureWalkins.empty()) &&
       (!lowTemperatureCases.empty() || !lowTemperatureWalkins.empty()) ) {
    idfObject.setString(Refrigeration_TranscriticalSystemFields::SystemType,"TwoStage");
  }
  else {
    idfObject.setString(Refrigeration_TranscriticalSystemFields::SystemType,"SingleStage");
  }

// RefrigerationGasCoolerName
  if( boost::optional<RefrigerationGasCoolerAirCooled> refrigerationGasCooler = modelObject.refrigerationGasCooler() )
  {
    boost::optional<IdfObject> _refrigerationGasCooler = translateAndMapModelObject(refrigerationGasCooler.get());

    if( _refrigerationGasCooler && _refrigerationGasCooler->name() )
    {
      idfObject.setString(Refrigeration_TranscriticalSystemFields::RefrigerationGasCoolerName,_refrigerationGasCooler->name().get());
    }
  }

//HighPressureCompressorListName
  std::vector<RefrigerationCompressor> highPressureCompressors = modelObject.highPressureCompressors();

  if( !highPressureCompressors.empty() )
  {
    // Name
    name = " High Pressure Compressor List";
    idfObject.setString(Refrigeration_TranscriticalSystemFields::HighPressureCompressororCompressorListName, idfObject.name().get() + name);

    IdfObject _compressorList(IddObjectType::Refrigeration_CompressorList);

    m_idfObjects.push_back(_compressorList);

    _compressorList.setName(idfObject.name().get() + name);

    for( auto & highPressureCompressor :  highPressureCompressors )
    {
      boost::optional<IdfObject> _compressor = translateAndMapModelObject(highPressureCompressor);

      if( _compressor )
      {
        IdfExtensibleGroup eg = _compressorList.pushExtensibleGroup();

        eg.setString(Refrigeration_CompressorListExtensibleFields::RefrigerationCompressorName,_compressor->name().get()); 
      }
    }
  }

//LowPressureCompressorListName
  std::vector<RefrigerationCompressor> lowPressureCompressors = modelObject.lowPressureCompressors();

  if( !lowPressureCompressors.empty() )
  {
    // Name
    name = " Low Pressure Compressor List";
    idfObject.setString(Refrigeration_TranscriticalSystemFields::LowPressureCompressororCompressorListName, idfObject.name().get() + name);

    IdfObject _compressorList(IddObjectType::Refrigeration_CompressorList);

    m_idfObjects.push_back(_compressorList);

    _compressorList.setName(idfObject.name().get() + name);

    for( auto & lowPressureCompressor : lowPressureCompressors )
    {
      boost::optional<IdfObject> _compressor = translateAndMapModelObject(lowPressureCompressor);

      if( _compressor )
      {
        IdfExtensibleGroup eg = _compressorList.pushExtensibleGroup();

        eg.setString(Refrigeration_CompressorListExtensibleFields::RefrigerationCompressorName,_compressor->name().get()); 
      }
    }
  }

// ReceiverPressure
  d = modelObject.receiverPressure();
  if (d) {
    idfObject.setDouble(Refrigeration_TranscriticalSystemFields::ReceiverPressure,d.get());
  }

// SubcoolerEffectiveness
  d = modelObject.subcoolerEffectiveness();
  if (d) {
    idfObject.setDouble(Refrigeration_TranscriticalSystemFields::SubcoolerEffectiveness,d.get());
  }

// RefrigerationSystemWorkingFluidType
  s = modelObject.refrigerationSystemWorkingFluidType();
  if (s) {
    boost::optional<IdfObject> fluidProperties = createFluidProperties(s.get());
    if( fluidProperties ) {
      boost::optional<std::string> value = fluidProperties.get().getString(FluidProperties_NameFields::FluidName,true);
      if( value ) {
        idfObject.setString(Refrigeration_TranscriticalSystemFields::RefrigerationSystemWorkingFluidType,value.get());
      }
    }
  }

// SumUASuctionPipingforMediumTemperatureLoads
  d = modelObject.sumUASuctionPipingforMediumTemperatureLoads();
  if (d) {
    idfObject.setDouble(Refrigeration_TranscriticalSystemFields::SumUASuctionPipingforMediumTemperatureLoads,d.get());
  }

// MediumTemperatureSuctionPipingZoneName
  if( boost::optional<ThermalZone> mediumTemperatureSuctionPipingZone = modelObject.mediumTemperatureSuctionPipingZone() )
  {
    boost::optional<IdfObject> _mediumTemperatureSuctionPipingZone = translateAndMapModelObject(mediumTemperatureSuctionPipingZone.get());

    if( _mediumTemperatureSuctionPipingZone && _mediumTemperatureSuctionPipingZone->name() )
    {
      idfObject.setString(Refrigeration_TranscriticalSystemFields::MediumTemperatureSuctionPipingZoneName,_mediumTemperatureSuctionPipingZone->name().get());
    }
  }

// SumUASuctionPipingforLowTemperatureLoads
  d = modelObject.sumUASuctionPipingforLowTemperatureLoads();
  if (d) {
    idfObject.setDouble(Refrigeration_TranscriticalSystemFields::SumUASuctionPipingforLowTemperatureLoads,d.get());
  }

// LowTemperatureSuctionPipingZoneName
  if( boost::optional<ThermalZone> lowTemperatureSuctionPipingZone = modelObject.lowTemperatureSuctionPipingZone() )
  {
    boost::optional<IdfObject> _lowTemperatureSuctionPipingZone = translateAndMapModelObject(lowTemperatureSuctionPipingZone.get());

    if( _lowTemperatureSuctionPipingZone && _lowTemperatureSuctionPipingZone->name() )
    {
      idfObject.setString(Refrigeration_TranscriticalSystemFields::LowTemperatureSuctionPipingZoneName,_lowTemperatureSuctionPipingZone->name().get());
    }
  }

// EndUseSubcategory
  s = modelObject.endUseSubcategory();
  if (s) {
    idfObject.setString(Refrigeration_TranscriticalSystemFields::EndUseSubcategory,s.get());
  }

  return idfObject;

}
boost::optional<IdfObject> ForwardTranslator::translateAirLoopHVACOutdoorAirSystem( AirLoopHVACOutdoorAirSystem & modelObject )
{
  OptionalString s;
  IdfObject idfObject(IddObjectType::AirLoopHVAC_OutdoorAirSystem);

  m_idfObjects.push_back(idfObject);

  // Name
  std::string name = modelObject.name().get();
  idfObject.setString(openstudio::AirLoopHVAC_OutdoorAirSystemFields::Name,name);
 

  // Controller List
  IdfObject _controllerList(IddObjectType::AirLoopHVAC_ControllerList);
  _controllerList.setName(name + " Controller List");
  _controllerList.clearExtensibleGroups();
  m_idfObjects.push_back(_controllerList);

  ControllerOutdoorAir controllerOutdoorAir = modelObject.getControllerOutdoorAir();
  boost::optional<IdfObject> _controllerOutdoorAir = translateAndMapModelObject(controllerOutdoorAir);
  OS_ASSERT(_controllerOutdoorAir);

  idfObject.setString(openstudio::AirLoopHVAC_OutdoorAirSystemFields::ControllerListName,_controllerList.name().get());

  IdfExtensibleGroup eg = _controllerList.pushExtensibleGroup();
  eg.setString(AirLoopHVAC_ControllerListExtensibleFields::ControllerObjectType,_controllerOutdoorAir->iddObject().name());
  eg.setString(AirLoopHVAC_ControllerListExtensibleFields::ControllerName,_controllerOutdoorAir->name().get());

  std::vector<ModelObject> controllers;
  auto components = modelObject.components();
  for( const auto & component : components ) {
    boost::optional<ControllerWaterCoil> controller;

    if( auto coil = component.optionalCast<CoilCoolingWater>() ) {
      controller = coil->controllerWaterCoil();
    } else if ( auto coil = component.optionalCast<CoilHeatingWater>() ) {
      controller = coil->controllerWaterCoil();
    }

    if( controller ) {
      controllers.push_back(controller.get());
    }
  } 
  
  for( auto & controller: controllers ) {
    auto _controller = translateAndMapModelObject(controller);
    if( _controller ) {
      IdfExtensibleGroup eg = _controllerList.pushExtensibleGroup();
      eg.setString(AirLoopHVAC_ControllerListExtensibleFields::ControllerObjectType,_controller->iddObject().name());
      eg.setString(AirLoopHVAC_ControllerListExtensibleFields::ControllerName,_controller->name().get());
    }
  }

  // Field: Availability Manager List Name //////////////////////////////////
  IdfObject availabilityManagerListIdf(IddObjectType::AvailabilityManagerAssignmentList);
  availabilityManagerListIdf.setName(name + " Availability Manager List");
  m_idfObjects.push_back(availabilityManagerListIdf);

  IdfObject availabilityManagerScheduledIdf = IdfObject(openstudio::IddObjectType::AvailabilityManager_Scheduled);
  availabilityManagerScheduledIdf.setName(name + " Availability Manager");
  m_idfObjects.push_back(availabilityManagerScheduledIdf);

  Schedule alwaysOn = modelObject.model().alwaysOnDiscreteSchedule();
  IdfObject alwaysOnIdf = translateAndMapModelObject(alwaysOn).get();

  s = availabilityManagerListIdf.getString(openstudio::AvailabilityManagerAssignmentListFields::Name);
  if(s)
  {
    idfObject.setString(openstudio::AirLoopHVAC_OutdoorAirSystemFields::AvailabilityManagerListName,*s);
  }

  availabilityManagerListIdf.setString(1 + openstudio::AvailabilityManagerAssignmentListExtensibleFields::AvailabilityManagerObjectType,
                                       availabilityManagerScheduledIdf.iddObject().name());
  availabilityManagerListIdf.setString(1 + openstudio::AvailabilityManagerAssignmentListExtensibleFields::AvailabilityManagerName,
                                       availabilityManagerScheduledIdf.name().get());
  availabilityManagerScheduledIdf.setString(openstudio::AvailabilityManager_ScheduledFields::ScheduleName,alwaysOnIdf.name().get());

  // OA Node List
  s = modelObject.outboardOANode()->name();
  IdfObject oaNodeListIdf(openstudio::IddObjectType::OutdoorAir_NodeList);
  if(s)
  {
    oaNodeListIdf.setString(0,*s);
  }
  m_idfObjects.push_back(oaNodeListIdf);

  ///////////////////////////////////////////////////////////////////////////
  // Field: Outdoor Air Equipment List Name /////////////////////////////////
  IdfObject equipmentListIdf(IddObjectType::AirLoopHVAC_OutdoorAirSystem_EquipmentList);
  equipmentListIdf.setName(name + " Equipment List");

  m_idfObjects.push_back(equipmentListIdf);

  IdfObject outdoorAirMixerIdf(IddObjectType::OutdoorAir_Mixer);
  outdoorAirMixerIdf.setName(name + " Outdoor Air Mixer");
  m_idfObjects.push_back(outdoorAirMixerIdf);

  s = modelObject.mixedAirModelObject()->name();
  if(s)
  {
    outdoorAirMixerIdf.setString(OutdoorAir_MixerFields::MixedAirNodeName,*s);
  }
  s = modelObject.outdoorAirModelObject()->name();
  if(s)
  {
    outdoorAirMixerIdf.setString(OutdoorAir_MixerFields::OutdoorAirStreamNodeName,*s);
  }

  s = modelObject.reliefAirModelObject()->name();
  if(s)
  {
    outdoorAirMixerIdf.setString(OutdoorAir_MixerFields::ReliefAirStreamNodeName,*s);
  }

  s = modelObject.returnAirModelObject()->name();
  if(s)
  {
    outdoorAirMixerIdf.setString(OutdoorAir_MixerFields::ReturnAirStreamNodeName,*s);
  }

  s = outdoorAirMixerIdf.iddObject().name();
  equipmentListIdf.setString(1,*s);
  s = outdoorAirMixerIdf.name();
  equipmentListIdf.setString(2,*s);

  unsigned i = 3;
  ModelObjectVector oaModelObjects = modelObject.oaComponents();
  for( ModelObjectVector::iterator oaIt = oaModelObjects.begin();
       oaIt != oaModelObjects.end();
       ++oaIt )
  {
    if( ! oaIt->optionalCast<Node>() )
    {
      if( boost::optional<IdfObject> idfObject = translateAndMapModelObject(*oaIt) )
      {
        equipmentListIdf.setString(i,idfObject->iddObject().name());
        i++;
        equipmentListIdf.setString(i,idfObject->name().get());
        i++;
      }
    }
  }

  ModelObjectVector reliefModelObjects = modelObject.reliefComponents();
  for( ModelObjectVector::iterator reliefIt = reliefModelObjects.begin();
       reliefIt != reliefModelObjects.end();
       ++reliefIt )
  {
    if( (! reliefIt->optionalCast<Node>()) && (! reliefIt->optionalCast<AirToAirComponent>()) )
    {
      if( boost::optional<IdfObject> idfObject = translateAndMapModelObject(*reliefIt) )
      {
        equipmentListIdf.setString(i,idfObject->iddObject().name());
        i++;
        equipmentListIdf.setString(i,idfObject->name().get());
        i++;
      }
    }
  }

  s = equipmentListIdf.name();
  if(s)
  {
    idfObject.setString(openstudio::AirLoopHVAC_OutdoorAirSystemFields::OutdoorAirEquipmentListName,*s);
  }

  return boost::optional<IdfObject>(idfObject);
}
boost::optional<IdfObject> ForwardTranslator::translateRefrigerationSecondarySystem( RefrigerationSecondarySystem & modelObject )
{
  OptionalModelObject temp;
  boost::optional<std::string> s;
  boost::optional<double> d;
  boost::optional<int> i;
  std::string name;

// Name
  IdfObject refrigerationSecondarySystem = createRegisterAndNameIdfObject(openstudio::IddObjectType::Refrigeration_SecondarySystem,
                                                          modelObject);

//RefrigeratedCaseorWalkinorCaseAndWalkInListName
  std::vector<RefrigerationCase> cases = modelObject.cases();
  std::vector<RefrigerationWalkIn> walkins = modelObject.walkins();
  std::vector<RefrigerationAirChiller> airChillers = modelObject.airChillers();

  if( !cases.empty() || !walkins.empty() || !airChillers.empty() )
  {
    // Name
    name = " Case and Walkin List";
    refrigerationSecondarySystem.setString(Refrigeration_SecondarySystemFields::RefrigeratedCaseorWalkinorCaseAndWalkInListName, refrigerationSecondarySystem.name().get() + name);

    IdfObject _caseAndWalkinList(IddObjectType::Refrigeration_CaseAndWalkInList);

    m_idfObjects.push_back(_caseAndWalkinList);

    _caseAndWalkinList.setName(refrigerationSecondarySystem.name().get() + name);

    for( auto & elem : cases )
    {
      boost::optional<IdfObject> _case = translateAndMapModelObject(elem);

      if( _case )
      {
        IdfExtensibleGroup eg = _caseAndWalkinList.pushExtensibleGroup();

        eg.setString(Refrigeration_CaseAndWalkInListExtensibleFields::CaseorWalkInName,_case->name().get()); 
      }
    }

    for( auto & elem : walkins )
    {
      boost::optional<IdfObject> _walkin = translateAndMapModelObject(elem);

      if( _walkin )
      {
        IdfExtensibleGroup eg = _caseAndWalkinList.pushExtensibleGroup();

        eg.setString(Refrigeration_CaseAndWalkInListExtensibleFields::CaseorWalkInName,_walkin->name().get()); 
      }
    }

    for( auto & elem : airChillers )
    {
      boost::optional<IdfObject> _airChiller = translateAndMapModelObject(elem);

      if( _airChiller )
      {
        IdfExtensibleGroup eg = _caseAndWalkinList.pushExtensibleGroup();

        eg.setString(Refrigeration_CaseAndWalkInListExtensibleFields::CaseorWalkInName,_airChiller->name().get()); 
      }
    }
  }

//CirculatingFluidType
//CirculatingFluidName
  s = modelObject.circulatingFluidName();
  if (s) {
    i = modelObject.glycolConcentration();
    boost::optional<IdfObject> fluidProperties;
    if ( i && (istringEqual(s.get(), "PropyleneGlycol") || istringEqual(s.get(), "EthyleneGlycol")) ) {
      fluidProperties = createFluidProperties(s.get(), i.get());
      refrigerationSecondarySystem.setString(Refrigeration_SecondarySystemFields::CirculatingFluidType,"FluidAlwaysLiquid");
    } else {
      fluidProperties = createFluidProperties(s.get());
      refrigerationSecondarySystem.setString(Refrigeration_SecondarySystemFields::CirculatingFluidType,"FluidPhaseChange");
    }
    if( fluidProperties ) {
      boost::optional<std::string> value = fluidProperties.get().getString(FluidProperties_NameFields::FluidName,true);
      if( value ) {
        refrigerationSecondarySystem.setString(Refrigeration_SecondarySystemFields::CirculatingFluidName,value.get());
      }
    }
  }

//EvaporatorCapacity
  d = modelObject.evaporatorCapacity();
  if (d) {
    refrigerationSecondarySystem.setDouble(Refrigeration_SecondarySystemFields::EvaporatorCapacity,d.get());
  }

//EvaporatorFlowRateforSecondaryFluid
  d = modelObject.evaporatorFlowRateforSecondaryFluid();
  if (d) {
    refrigerationSecondarySystem.setDouble(Refrigeration_SecondarySystemFields::EvaporatorFlowRateforSecondaryFluid,d.get());
  }

//EvaporatorEvaporatingTemperature
  d = modelObject.evaporatorEvaporatingTemperature();
  if (d) {
    refrigerationSecondarySystem.setDouble(Refrigeration_SecondarySystemFields::EvaporatorEvaporatingTemperature,d.get());
  }

//EvaporatorApproachTemperatureDifference
  d = modelObject.evaporatorApproachTemperatureDifference();
  if (d) {
    refrigerationSecondarySystem.setDouble(Refrigeration_SecondarySystemFields::EvaporatorApproachTemperatureDifference,d.get());
  }

//EvaporatorRangeTemperatureDifference
  d = modelObject.evaporatorRangeTemperatureDifference();
  if (d) {
    refrigerationSecondarySystem.setDouble(Refrigeration_SecondarySystemFields::EvaporatorRangeTemperatureDifference,d.get());
  }

//NumberofPumpsinLoop
  i = modelObject.numberofPumpsinLoop();
  if (i) {
    refrigerationSecondarySystem.setInt(Refrigeration_SecondarySystemFields::NumberofPumpsinLoop,d.get());
  }

//TotalPumpFlowRate
  d = modelObject.totalPumpFlowRate();
  if (d) {
    refrigerationSecondarySystem.setDouble(Refrigeration_SecondarySystemFields::TotalPumpFlowRate,d.get());
  }

//TotalPumpPower
  d = modelObject.totalPumpPower();
  if (d) {
    refrigerationSecondarySystem.setDouble(Refrigeration_SecondarySystemFields::TotalPumpPower,d.get());
  }

//TotalPumpHead
  d = modelObject.totalPumpHead();
  if (d) {
    refrigerationSecondarySystem.setDouble(Refrigeration_SecondarySystemFields::TotalPumpHead,d.get());
  }

//PhaseChangeCirculatingRate
  d = modelObject.phaseChangeCirculatingRate();
  if (d) {
    refrigerationSecondarySystem.setDouble(Refrigeration_SecondarySystemFields::PhaseChangeCirculatingRate,d.get());
  }

//PumpDriveType
  s = modelObject.pumpDriveType();
  if (s) {
    refrigerationSecondarySystem.setString(Refrigeration_SecondarySystemFields::PumpDriveType,s.get());
  }

//VariableSpeedPumpCubicCurveName
  boost::optional<CurveCubic> variableSpeedPumpCubicCurve = modelObject.variableSpeedPumpCubicCurve();

  if( variableSpeedPumpCubicCurve )
  {
    boost::optional<IdfObject> _variableSpeedPumpCubicCurve = translateAndMapModelObject(variableSpeedPumpCubicCurve.get());

    if( _variableSpeedPumpCubicCurve && _variableSpeedPumpCubicCurve->name() )
    {
      refrigerationSecondarySystem.setString(Refrigeration_SecondarySystemFields::VariableSpeedPumpCubicCurveName,_variableSpeedPumpCubicCurve->name().get());
    }
  }

//PumpMotorHeattoFluid
  d = modelObject.pumpMotorHeattoFluid();
  if (d) {
    refrigerationSecondarySystem.setDouble(Refrigeration_SecondarySystemFields::PumpMotorHeattoFluid,d.get());
  }

//SumUADistributionPiping
  d = modelObject.sumUADistributionPiping();
  if (d) {
    refrigerationSecondarySystem.setDouble(Refrigeration_SecondarySystemFields::SumUADistributionPiping,d.get());
  }

//DistributionPipingZoneName
  boost::optional<ThermalZone> distributionPipingZone = modelObject.distributionPipingZone();

  if( distributionPipingZone )
  {
    boost::optional<IdfObject> _distributionPipingZone = translateAndMapModelObject(distributionPipingZone.get());

    if( _distributionPipingZone && _distributionPipingZone->name() )
    {
      refrigerationSecondarySystem.setString(Refrigeration_SecondarySystemFields::DistributionPipingZoneName,_distributionPipingZone->name().get());
    }
  }

//SumUAReceiver_SeparatorShell
  d = modelObject.sumUAReceiverSeparatorShell();
  if (d) {
    refrigerationSecondarySystem.setDouble(Refrigeration_SecondarySystemFields::SumUAReceiver_SeparatorShell,d.get());
  }

//Receiver_SeparatorZoneName
  boost::optional<ThermalZone> receiverSeparatorZone = modelObject.receiverSeparatorZone();

  if( receiverSeparatorZone )
  {
    boost::optional<IdfObject> _receiverSeparatorZone = translateAndMapModelObject(receiverSeparatorZone.get());

    if( _receiverSeparatorZone && _receiverSeparatorZone->name() )
    {
      refrigerationSecondarySystem.setString(Refrigeration_SecondarySystemFields::Receiver_SeparatorZoneName,_receiverSeparatorZone->name().get());
    }
  }

//EvaporatorRefrigerantInventory
  d = modelObject.evaporatorRefrigerantInventory();
  if (d) {
    refrigerationSecondarySystem.setDouble(Refrigeration_SecondarySystemFields::EvaporatorRefrigerantInventory,d.get());
  }

//EndUseSubcategory
  s = modelObject.endUseSubcategory();
  if (s) {
    refrigerationSecondarySystem.setString(Refrigeration_SecondarySystemFields::EndUseSubcategory,s.get());
  }

  return refrigerationSecondarySystem;

}
boost::optional<IdfObject> ForwardTranslator::translateAirLoopHVACOutdoorAirSystem( AirLoopHVACOutdoorAirSystem & modelObject )
{
  OptionalString s;
  IdfObject idfObject(IddObjectType::AirLoopHVAC_OutdoorAirSystem);

  m_idfObjects.push_back(idfObject);

  // Name
  std::string name = modelObject.name().get();
  idfObject.setString(openstudio::AirLoopHVAC_OutdoorAirSystemFields::Name,name);
 

  // Controller List
  IdfObject controllerListIdf(IddObjectType::AirLoopHVAC_ControllerList);
  controllerListIdf.setName(name + " Controller List");
  controllerListIdf.clearExtensibleGroups();

  m_idfObjects.push_back(controllerListIdf);

  ControllerOutdoorAir controllerOutdoorAir = modelObject.getControllerOutdoorAir();
  boost::optional<IdfObject> temp = translateAndMapModelObject(controllerOutdoorAir);

  s = controllerListIdf.name();
  if(s)
  {
    idfObject.setString(openstudio::AirLoopHVAC_OutdoorAirSystemFields::ControllerListName,*s);
  }

  s = temp->iddObject().name();
  StringVector groupFields(2u);
  bool addGroup(false);
  if(s)
  {
    groupFields[0] = *s;
    addGroup = true;
  }

  s = temp->name();
  if(s)
  {
    groupFields[1] = *s;
    addGroup = true;
  }

  if (addGroup) {
    IdfExtensibleGroup eg = controllerListIdf.pushExtensibleGroup(groupFields);
    OS_ASSERT(!eg.empty());
  }

  // Field: Availability Manager List Name //////////////////////////////////
  IdfObject availabilityManagerListIdf(IddObjectType::AvailabilityManagerAssignmentList);
  availabilityManagerListIdf.setName(name + " Availability Manager");
  m_idfObjects.push_back(availabilityManagerListIdf);

  IdfObject availabilityManagerScheduledIdf = IdfObject(openstudio::IddObjectType::AvailabilityManager_Scheduled);
  availabilityManagerScheduledIdf.createName();
  m_idfObjects.push_back(availabilityManagerScheduledIdf);

  Schedule alwaysOn = modelObject.model().alwaysOnDiscreteSchedule();
  IdfObject alwaysOnIdf = translateAndMapModelObject(alwaysOn).get();

  s = availabilityManagerListIdf.getString(openstudio::AvailabilityManagerAssignmentListFields::Name);
  if(s)
  {
    idfObject.setString(openstudio::AirLoopHVAC_OutdoorAirSystemFields::AvailabilityManagerListName,*s);
  }

  availabilityManagerListIdf.setString(1 + openstudio::AvailabilityManagerAssignmentListExtensibleFields::AvailabilityManagerObjectType,
                                       availabilityManagerScheduledIdf.iddObject().name());
  availabilityManagerListIdf.setString(1 + openstudio::AvailabilityManagerAssignmentListExtensibleFields::AvailabilityManagerName,
                                       availabilityManagerScheduledIdf.name().get());
  availabilityManagerScheduledIdf.setString(openstudio::AvailabilityManager_ScheduledFields::ScheduleName,alwaysOnIdf.name().get());

  // OA Node List
  s = modelObject.outboardOANode()->name();
  IdfObject oaNodeListIdf(openstudio::IddObjectType::OutdoorAir_NodeList);
  if(s)
  {
    oaNodeListIdf.setString(0,*s);
  }
  m_idfObjects.push_back(oaNodeListIdf);

  ///////////////////////////////////////////////////////////////////////////
  // Field: Outdoor Air Equipment List Name /////////////////////////////////
  IdfObject equipmentListIdf(IddObjectType::AirLoopHVAC_OutdoorAirSystem_EquipmentList);
  equipmentListIdf.setName(name + " Equipment List");

  m_idfObjects.push_back(equipmentListIdf);

  IdfObject outdoorAirMixerIdf(IddObjectType::OutdoorAir_Mixer);
  outdoorAirMixerIdf.setName(name + " Outdoor Air Mixer");
  m_idfObjects.push_back(outdoorAirMixerIdf);

  s = modelObject.mixedAirModelObject()->name();
  if(s)
  {
    outdoorAirMixerIdf.setString(OutdoorAir_MixerFields::MixedAirNodeName,*s);
  }
  s = modelObject.outdoorAirModelObject()->name();
  if(s)
  {
    outdoorAirMixerIdf.setString(OutdoorAir_MixerFields::OutdoorAirStreamNodeName,*s);
  }

  s = modelObject.reliefAirModelObject()->name();
  if(s)
  {
    outdoorAirMixerIdf.setString(OutdoorAir_MixerFields::ReliefAirStreamNodeName,*s);
  }

  s = modelObject.returnAirModelObject()->name();
  if(s)
  {
    outdoorAirMixerIdf.setString(OutdoorAir_MixerFields::ReturnAirStreamNodeName,*s);
  }

  s = outdoorAirMixerIdf.iddObject().name();
  equipmentListIdf.setString(1,*s);
  s = outdoorAirMixerIdf.name();
  equipmentListIdf.setString(2,*s);

  ModelObjectVector oaModelObjects = modelObject.oaComponents();
  ModelObjectVector::iterator oaIt;
  unsigned i = 3;
  for( oaIt = oaModelObjects.begin();
       oaIt != oaModelObjects.end();
       ++oaIt )
  {
    if( ! oaIt->optionalCast<Node>() )
    {
      s = stripOS2(oaIt->iddObject().name());
      if(s)
        equipmentListIdf.setString(i,*s);
      i++;
      s = oaIt->name();
      if(s)
        equipmentListIdf.setString(i,*s);
      i++;
    }
  }

  s = equipmentListIdf.name();
  if(s)
  {
    idfObject.setString(openstudio::AirLoopHVAC_OutdoorAirSystemFields::OutdoorAirEquipmentListName,*s);
  }

  for( oaIt = oaModelObjects.begin();
       oaIt != oaModelObjects.end();
       ++oaIt )
  {
    translateAndMapModelObject(*oaIt);
  }

  return boost::optional<IdfObject>(idfObject);
}
boost::optional<IdfObject> ForwardTranslator::translateRefrigerationSystem( RefrigerationSystem & modelObject )
{
  OptionalModelObject temp;
  OptionalString optS;
  boost::optional<std::string> s;
  boost::optional<double> d;
  std::string name;

// Name
  IdfObject refrigerationSystem = createRegisterAndNameIdfObject(openstudio::IddObjectType::Refrigeration_System,
                                                          modelObject);

//Refrigerated Case or Walkin or CaseAndWalkInList Name
  std::vector<RefrigerationCase> cases = modelObject.cases();
  std::vector<RefrigerationWalkIn> walkins = modelObject.walkins();
  std::vector<RefrigerationAirChiller> airChillers = modelObject.airChillers();

  if( !cases.empty() || !walkins.empty() || !airChillers.empty() )
  {
  	// Name
  	name = " Case and Walkin List";
  	refrigerationSystem.setString(Refrigeration_SystemFields::RefrigeratedCaseorWalkinorCaseAndWalkInListName, refrigerationSystem.name().get() + name);

  	IdfObject _caseAndWalkinList(IddObjectType::Refrigeration_CaseAndWalkInList);

  	m_idfObjects.push_back(_caseAndWalkinList);

  	_caseAndWalkinList.setName(refrigerationSystem.name().get() + name);

  	for( std::vector<RefrigerationCase>::iterator it = cases.begin();
  	   it != cases.end();
  	   ++it )
  	{
  		boost::optional<IdfObject> _case = translateAndMapModelObject(*it);

  		if( _case )
  		{
  		  IdfExtensibleGroup eg = _caseAndWalkinList.pushExtensibleGroup();

  		  eg.setString(Refrigeration_CaseAndWalkInListExtensibleFields::CaseorWalkInName,_case->name().get()); 
  		}
  	}

  	for( std::vector<RefrigerationWalkIn>::iterator it = walkins.begin();
  	   it != walkins.end();
  	   ++it )
  	{
  		boost::optional<IdfObject> _walkin = translateAndMapModelObject(*it);

  		if( _walkin )
  		{
  		  IdfExtensibleGroup eg = _caseAndWalkinList.pushExtensibleGroup();

  		  eg.setString(Refrigeration_CaseAndWalkInListExtensibleFields::CaseorWalkInName,_walkin->name().get()); 
  		}
  	}

    for( std::vector<RefrigerationAirChiller>::iterator it = airChillers.begin();
       it != airChillers.end();
       it++ )
    {
      boost::optional<IdfObject> _airChiller = translateAndMapModelObject(*it);

      if( _airChiller )
      {
        IdfExtensibleGroup eg = _caseAndWalkinList.pushExtensibleGroup();

        eg.setString(Refrigeration_CaseAndWalkInListExtensibleFields::CaseorWalkInName,_airChiller->name().get()); 
      }
    }
  }

//Refrigeration Transfer Load or TransferLoad List Name
  std::vector<RefrigerationSecondarySystem> secondarySystemLoads = modelObject.secondarySystemLoads();
  std::vector<RefrigerationCondenserCascade> cascadeCondenserLoads = modelObject.cascadeCondenserLoads();

  if( !secondarySystemLoads.empty() || !cascadeCondenserLoads.empty() )
  {
    // Name
    name = " Transfer Load List";
    refrigerationSystem.setString(Refrigeration_SystemFields::RefrigerationTransferLoadorTransferLoadListName, refrigerationSystem.name().get() + name);

    IdfObject _transferLoadList(IddObjectType::Refrigeration_TransferLoadList);

    m_idfObjects.push_back(_transferLoadList);

    _transferLoadList.setName(refrigerationSystem.name().get() + name);

    for( std::vector<RefrigerationSecondarySystem>::iterator it = secondarySystemLoads.begin();
       it != secondarySystemLoads.end();
       ++it )
    {
      boost::optional<IdfObject> _secondarySystemLoad = translateAndMapModelObject(*it);

      if( _secondarySystemLoad )
      {
        IdfExtensibleGroup eg = _transferLoadList.pushExtensibleGroup();

        eg.setString(Refrigeration_TransferLoadListExtensibleFields::CascadeCondenserNameorSecondarySystemName,_secondarySystemLoad->name().get()); 
      }
    }

    for( std::vector<RefrigerationCondenserCascade>::iterator it = cascadeCondenserLoads.begin();
       it != cascadeCondenserLoads.end();
       ++it )
    {
      boost::optional<IdfObject> _cascadeCondenserLoad = translateAndMapModelObject(*it);

      if( _cascadeCondenserLoad )
      {
        IdfExtensibleGroup eg = _transferLoadList.pushExtensibleGroup();

        eg.setString(Refrigeration_TransferLoadListExtensibleFields::CascadeCondenserNameorSecondarySystemName,_cascadeCondenserLoad->name().get()); 
      }
    }
  }

//Refrigeration Condenser Name
  boost::optional<ModelObject> refrigerationCondenser = modelObject.refrigerationCondenser();

  if( refrigerationCondenser )
  {
    boost::optional<IdfObject> _refrigerationCondenser = translateAndMapModelObject(refrigerationCondenser.get());

    if( _refrigerationCondenser && _refrigerationCondenser->name() )
    {
      refrigerationSystem.setString(Refrigeration_SystemFields::RefrigerationCondenserName,_refrigerationCondenser->name().get());
    }
  }

//Compressor or CompressorList Name
  std::vector<RefrigerationCompressor> compressors = modelObject.compressors();

  if( !compressors.empty() )
  {
    // Name
    name = " Compressor List";
    refrigerationSystem.setString(Refrigeration_SystemFields::CompressororCompressorListName, refrigerationSystem.name().get() + name);

    IdfObject _compressorList(IddObjectType::Refrigeration_CompressorList);

    m_idfObjects.push_back(_compressorList);

    _compressorList.setName(refrigerationSystem.name().get() + name);

    for( std::vector<RefrigerationCompressor>::iterator it = compressors.begin();
       it != compressors.end();
       ++it )
    {
      boost::optional<IdfObject> _compressor = translateAndMapModelObject(*it);

      if( _compressor )
      {
        IdfExtensibleGroup eg = _compressorList.pushExtensibleGroup();

        eg.setString(Refrigeration_CompressorListExtensibleFields::RefrigerationCompressorName,_compressor->name().get()); 
      }
    }
  }

//Minimum Condensing Temperature
  d = modelObject.minimumCondensingTemperature();
  if (d) {
    refrigerationSystem.setDouble(Refrigeration_SystemFields::MinimumCondensingTemperature,d.get());
  }

//Refrigeration System Working Fluid Type
  s = modelObject.refrigerationSystemWorkingFluidType();
  if (s) {
    boost::optional<IdfObject> fluidProperties = createFluidProperties(s.get());
    if( fluidProperties ) {
      boost::optional<std::string> value = fluidProperties.get().getString(FluidProperties_NameFields::FluidName,true);
      if( value ) {
        refrigerationSystem.setString(Refrigeration_SystemFields::RefrigerationSystemWorkingFluidType,value.get());
      }
    }
  }

//Suction Temperature Control Type
  s = modelObject.suctionTemperatureControlType();
  if (s) {
    refrigerationSystem.setString(Refrigeration_SystemFields::SuctionTemperatureControlType,s.get());
  }

//Mechanical Subcooler Name
  boost::optional<RefrigerationSubcoolerMechanical> mechanicalSubcooler = modelObject.mechanicalSubcooler();

  if( mechanicalSubcooler )
  {
    boost::optional<IdfObject> _mechanicalSubcooler = translateAndMapModelObject(mechanicalSubcooler.get());

    if( _mechanicalSubcooler && _mechanicalSubcooler->name() )
    {
      refrigerationSystem.setString(Refrigeration_SystemFields::MechanicalSubcoolerName,_mechanicalSubcooler->name().get());
    }
  }

//Liquid Suction Heat Exchanger Subcooler Name
  boost::optional<RefrigerationSubcoolerLiquidSuction> liquidSuctionHeatExchangerSubcooler = modelObject.liquidSuctionHeatExchangerSubcooler();

  if( liquidSuctionHeatExchangerSubcooler )
  {
    boost::optional<IdfObject> _liquidSuctionHeatExchangerSubcooler = translateAndMapModelObject(liquidSuctionHeatExchangerSubcooler.get());

    if( _liquidSuctionHeatExchangerSubcooler && _liquidSuctionHeatExchangerSubcooler->name() )
    {
      refrigerationSystem.setString(Refrigeration_SystemFields::LiquidSuctionHeatExchangerSubcoolerName,_liquidSuctionHeatExchangerSubcooler->name().get());
    }
  }

//Sum UA Suction Piping
  d = modelObject.sumUASuctionPiping();
  if (d) {
    refrigerationSystem.setDouble(Refrigeration_SystemFields::SumUASuctionPiping,d.get());
  }

//Suction Piping Zone Name
  boost::optional<ThermalZone> suctionPipingZone = modelObject.suctionPipingZone();

  if( suctionPipingZone )
  {
    boost::optional<IdfObject> _suctionPipingZone = translateAndMapModelObject(suctionPipingZone.get());

    if( _suctionPipingZone && _suctionPipingZone->name() )
    {
      refrigerationSystem.setString(Refrigeration_SystemFields::SuctionPipingZoneName,_suctionPipingZone->name().get());
    }
  }

//End-Use Subcategory
  s = modelObject.endUseSubcategory();
  if (s) {
    refrigerationSystem.setString(Refrigeration_SystemFields::EndUseSubcategory,s.get());
  }

//Number of Compressor Stages 
  s = modelObject.numberofCompressorStages();
  if (s) {
    refrigerationSystem.setString(Refrigeration_SystemFields::NumberofCompressorStages,s.get());
  }

//Intercooler Type 
  s = modelObject.intercoolerType();
  if (s) {
    refrigerationSystem.setString(Refrigeration_SystemFields::IntercoolerType,s.get());
  }

//Shell-and-Coil Intercooler Effectiveness 
  d = modelObject.shellandCoilIntercoolerEffectiveness();
  if (d) {
    refrigerationSystem.setDouble(Refrigeration_SystemFields::ShellandCoilIntercoolerEffectiveness,d.get());
  }

//High-Stage Compressor or CompressorList Name
  std::vector<RefrigerationCompressor> highStageCompressors = modelObject.highStageCompressors();

  if( !highStageCompressors.empty() )
  {
    // Name
    name = " High Stage Compressor List";
    refrigerationSystem.setString(Refrigeration_SystemFields::HighStageCompressororCompressorListName, refrigerationSystem.name().get() + name);

    IdfObject _highStageCompressorList(IddObjectType::Refrigeration_CompressorList);

    m_idfObjects.push_back(_highStageCompressorList);

    _highStageCompressorList.setName(refrigerationSystem.name().get() + name);

    for( std::vector<RefrigerationCompressor>::iterator it = highStageCompressors.begin();
       it != highStageCompressors.end();
       it++ )
    {
      boost::optional<IdfObject> _highStageCompressor = translateAndMapModelObject(*it);

      if( _highStageCompressor )
      {
        IdfExtensibleGroup eg = _highStageCompressorList.pushExtensibleGroup();

        eg.setString(Refrigeration_CompressorListExtensibleFields::RefrigerationCompressorName,_highStageCompressor->name().get()); 
      }
    }
  }

  return refrigerationSystem;

}
  boost::optional<IdfObject> ForwardTranslator::translateSolarCollectorFlatPlatePhotovoltaicThermal(SolarCollectorFlatPlatePhotovoltaicThermal & modelObject)
{
  boost::optional<std::string> s;
  boost::optional<double> value;

  IdfObject idfObject(IddObjectType::SolarCollector_FlatPlate_PhotovoltaicThermal);

  m_idfObjects.push_back(idfObject);

  // Name
  std::string name = modelObject.name().get();
  idfObject.setName(name);

  // SolarCollectorPerformanceFlatPlate
  {
    auto mo = modelObject.solarCollectorPerformance();
    IdfObject performance = translateAndMapModelObject(mo).get();
    idfObject.setString(SolarCollector_FlatPlate_PhotovoltaicThermalFields::PhotovoltaicThermalModelPerformanceName, performance.name().get());
  }

  // SurfaceName
  OptionalPlanarSurface surface = modelObject.surface();
  if (surface){
    IdfObject surf = translateAndMapModelObject(*surface).get();
    idfObject.setString(SolarCollector_FlatPlate_PhotovoltaicThermalFields::SurfaceName, surf.name().get());
  } else{
    LOG(Error, "SolarCollector:FlatPlate:PhotovoltaicThermal '" << name << "' does not reference a surface.");
  }

  // PhotovoltaicName
  OptionalGeneratorPhotovoltaic generatorPhotovoltaic = modelObject.generatorPhotovoltaic();
  if (generatorPhotovoltaic){
    // generator will be translated with the other generators
    idfObject.setString(SolarCollector_FlatPlate_PhotovoltaicThermalFields::PhotovoltaicName, generatorPhotovoltaic->name().get());
  } else{
    LOG(Warn, "SolarCollector:FlatPlate:PhotovoltaicThermal '" << name << "' does not reference a GeneratorPhotovoltaic.");
  }

  // figure out if this is on an air loop or plant loop
  boost::optional<AirLoopHVAC> airLoopHVAC = modelObject.airLoopHVAC();
  boost::optional<PlantLoop> plantLoop = modelObject.plantLoop();

  // ThermalWorkingFluidType
  if (airLoopHVAC){
    idfObject.setString(SolarCollector_FlatPlate_PhotovoltaicThermalFields::ThermalWorkingFluidType, "Air");
  } else if (plantLoop){
    idfObject.setString(SolarCollector_FlatPlate_PhotovoltaicThermalFields::ThermalWorkingFluidType, "Water");
  }

  // InletNodeName
  if (boost::optional<ModelObject> mo = modelObject.inletModelObject())
  {
    if (boost::optional<Node> node = mo->optionalCast<Node>())
    {
      if (airLoopHVAC){
        idfObject.setString(SolarCollector_FlatPlate_PhotovoltaicThermalFields::AirInletNodeName, node->name().get());
      } else if (plantLoop){
        idfObject.setString(SolarCollector_FlatPlate_PhotovoltaicThermalFields::WaterInletNodeName, node->name().get());
      }
    }
  }

  // OutletNodeName
  if (boost::optional<ModelObject> mo = modelObject.outletModelObject())
  {
    if (boost::optional<Node> node = mo->optionalCast<Node>())
    {
      if (airLoopHVAC){
        idfObject.setString(SolarCollector_FlatPlate_PhotovoltaicThermalFields::AirOutletNodeName, node->name().get());
      } else if (plantLoop){
        idfObject.setString(SolarCollector_FlatPlate_PhotovoltaicThermalFields::WaterOutletNodeName, node->name().get());
      }
    }
  }

  // DesignFlowRate
  boost::optional<double> designFlowRate = modelObject.designFlowRate();
  if (designFlowRate){
    idfObject.setDouble(SolarCollector_FlatPlate_PhotovoltaicThermalFields::DesignFlowRate, *designFlowRate);
  }

  return idfObject;
}