ModelObject AirTerminalSingleDuctParallelPIUReheat_Impl::clone(Model model) const
  {
    AirTerminalSingleDuctParallelPIUReheat modelObjectClone = StraightComponent_Impl::clone(model).cast<AirTerminalSingleDuctParallelPIUReheat>();

    modelObjectClone.setString(modelObjectClone.secondaryAirInletPort(),""); 

    // clone coil

    HVACComponent coil = this->reheatCoil();

    HVACComponent coilClone = coil.clone(model).cast<HVACComponent>();
    
    modelObjectClone.setReheatCoil(coilClone);

    // clone fan

    HVACComponent fan = this->fan();

    HVACComponent fanClone = fan.clone(model).cast<HVACComponent>();

    modelObjectClone.setFan(fanClone);


    return modelObjectClone;
  }
  void AirTerminalSingleDuctParallelPIUReheat_Impl::setFan( HVACComponent & hvacComponent )
  {
    bool isTypeCorrect = false;

    if( hvacComponent.iddObjectType() == IddObjectType::OS_Fan_ConstantVolume )
    {
      isTypeCorrect = true;
    }

    if( isTypeCorrect )
    {
      setPointer(OS_AirTerminal_SingleDuct_ParallelPIU_ReheatFields::FanName,hvacComponent.handle());
    }
  }
Example #3
0
PortList::PortList(const HVACComponent& comp)
  : ModelObject(PortList::iddObjectType(),comp.model())
{
  OS_ASSERT(getImpl<detail::PortList_Impl>());

  getImpl<detail::PortList_Impl>()->setHVACComponent(comp);
}
// Some plant components air in a containingHVACComponent() and it is that
// container which needs to go on the plant operation scheme. Here is a filter to 
// figure that out. 
HVACComponent operationSchemeComponent(const HVACComponent & component) {
    boost::optional<HVACComponent> result;

    switch(component.iddObject().type().value())
    {
      case openstudio::IddObjectType::OS_WaterHeater_Mixed :
      {
        auto waterHeater = component.cast<WaterHeaterMixed>();
        if( auto hpwh = waterHeater.containingZoneHVACComponent() ) {
          result = hpwh;
        }
        break;
      }
      case openstudio::IddObjectType::OS_WaterHeater_Stratified :
      {
        auto waterHeater = component.cast<WaterHeaterStratified>();
        if( auto hpwh = waterHeater.containingZoneHVACComponent() ) {
          result = hpwh;
        }
        break;
      }
      default:
      {
        break;
      }
    }

  if( result ) {
    return result.get();
  }

  return component;
}
  void AirTerminalSingleDuctParallelPIUReheat_Impl::setReheatCoil( HVACComponent & hvacComponent )
  {
    bool isTypeCorrect = false;

    if( hvacComponent.iddObjectType() == IddObjectType::OS_Coil_Heating_Electric )
    {
      isTypeCorrect = true;
    }
    else if( hvacComponent.iddObjectType() == IddObjectType::OS_Coil_Heating_Gas )
    {
      isTypeCorrect = true;
    }
    else if( hvacComponent.iddObjectType() == IddObjectType::OS_Coil_Heating_Water )
    {
      isTypeCorrect = true;
    }

    if( isTypeCorrect )
    {
      setPointer(OS_AirTerminal_SingleDuct_ParallelPIU_ReheatFields::ReheatCoilName,hvacComponent.handle());
    }
  }
bool ZoneHVACTerminalUnitVariableRefrigerantFlow_Impl::setSupplyAirFan(const HVACComponent & component)
{
    return setPointer(OS_ZoneHVAC_TerminalUnit_VariableRefrigerantFlowFields::SupplyAirFan,component.handle());
}
void ControllerWaterCoil_Impl::setWaterCoil( const HVACComponent & comp )
{
  auto result = setPointer(OS_Controller_WaterCoilFields::WaterCoilName,comp.handle());
  OS_ASSERT(result);
}
 bool ZoneHVACUnitHeater_Impl::setHeatingCoil(const HVACComponent & heatingCoil) 
 {
   bool result = setPointer(OS_ZoneHVAC_UnitHeaterFields::HeatingCoilName, heatingCoil.handle());
   return result;
 }
 bool ZoneHVACUnitHeater_Impl::setSupplyAirFan(const HVACComponent& HVACComponent) 
 {
   bool result = setPointer(OS_ZoneHVAC_UnitHeaterFields::SupplyAirFanName, HVACComponent.handle());
   return result;
 }
 bool AirTerminalSingleDuctConstantVolumeFourPipeBeam_Impl::setHeatingCoil(const HVACComponent& coilHeatingFourPipeBeam) {
   bool result = setPointer(OS_AirTerminal_SingleDuct_ConstantVolume_FourPipeBeamFields::HeatingCoilName, coilHeatingFourPipeBeam.handle());
   if (!result) {
     if ( !coilHeatingFourPipeBeam.optionalCast<CoilHeatingFourPipeBeam>() ) {
       LOG(Error, "Cannot set the heating coil to something else than CoilHeatingFourPipeBeam for " << briefDescription());
     }
   }
   return result;
 }
Example #11
0
  bool HVACComponent_Impl::removeFromLoop( const HVACComponent & systemStartComponent, 
    const HVACComponent & systemEndComponent,
    unsigned componentInletPort,
    unsigned componentOutletPort )
  {
    auto _model = model();
    auto thisObject = getObject<HVACComponent>();
    
    if( systemStartComponent.model() != _model ) return false;
    if( systemEndComponent.model() != _model ) return false;

    auto inletComponent = connectedObject( componentInletPort );
    auto outletComponent = connectedObject( componentOutletPort );
    auto inletComponentOutletPort = connectedObjectPort( componentInletPort );
    auto outletComponentInletPort = connectedObjectPort( componentOutletPort );

    if( ! inletComponent ) return false;
    if( ! outletComponent ) return false;
    if( ! inletComponentOutletPort ) return false;
    if( ! outletComponentInletPort ) return false;

    auto inletNode = inletComponent->optionalCast<Node>();
    auto outletNode = outletComponent->optionalCast<Node>();
    boost::optional<Splitter> splitter;
    boost::optional<Mixer> mixer;

    if( inletNode ) {
      if( auto mo = inletNode->inletModelObject() ) {
        splitter = mo->optionalCast<Splitter>();
      }
    }
    if( outletNode ) {
      if( auto mo = outletNode->outletModelObject() ) {
        mixer = mo->optionalCast<Mixer>();
      }
    }

    if( systemStartComponent.handle() == inletComponent->handle() 
        && systemEndComponent.handle() == outletComponent->handle() ) {
      // This component is between the systemStartComponent and the systemEndComponent
      // ie. the supply or demand inlet or outlet Nodes,
      // or the oa system end points on either the relief or inlet air streams.
      _model.disconnect(thisObject,componentInletPort); 
      _model.disconnect(thisObject,componentOutletPort); 

      _model.connect( inletComponent.get(), inletComponentOutletPort.get(), 
                       outletComponent.get(), outletComponentInletPort.get() );
      
      return true;
    } else if( systemEndComponent.handle() == outletComponent->handle() ) {
      // Here the systemEndComponent is immediately downstream of this component,
      // but there are other components (besides systemStartComponent) upstream.
      boost::optional<ModelObject> newInletComponent;
      boost::optional<unsigned> newInletComponentOutletPort;

      // Make sure we don't end up with two nodes next to each other after this component is removed
      if( inletNode && outletNode ) {
        newInletComponent = inletNode->inletModelObject();
        newInletComponentOutletPort = inletNode->connectedObjectPort(inletNode->inletPort());
        OS_ASSERT(newInletComponent);
        OS_ASSERT(newInletComponentOutletPort);
      } else {
        newInletComponent = inletComponent;
        newInletComponentOutletPort = inletComponentOutletPort;
      }

      _model.disconnect(thisObject,componentInletPort); 
      _model.disconnect(thisObject,componentOutletPort); 

      // inletNode->remove() would have failed if we did it before the disconnect
      if( inletNode && outletNode ) {
        inletNode->remove();
      }

      _model.connect( newInletComponent.get(), newInletComponentOutletPort.get(), 
                       outletComponent.get(), outletComponentInletPort.get() );
      return true;
    } else if( splitter && mixer ) {
      // If the component is the only component (except nodes) between a splitter mixer pair
      OS_ASSERT(inletNode);
      OS_ASSERT(outletNode);

      int i = splitter->branchIndexForOutletModelObject(inletNode.get());
      int j = mixer->branchIndexForInletModelObject(outletNode.get());

      OS_ASSERT(i == j);

      splitter->removePortForBranch(i);
      mixer->removePortForBranch(i);

      _model.disconnect(thisObject,componentInletPort); 
      _model.disconnect(thisObject,componentOutletPort); 

      inletNode->remove();
      outletNode->remove();

      if( ! splitter->lastOutletModelObject() )
      {
        Node newNode(_model);
        _model.connect(splitter.get(),splitter->nextOutletPort(),newNode,newNode.inletPort());
        _model.connect(newNode,newNode.outletPort(),mixer.get(),mixer->nextInletPort());
      }

      return true;
    } else {
      boost::optional<ModelObject> newOutletComponent; 
      boost::optional<unsigned> newOutletComponentInletPort;

      if( inletNode && outletNode ) {
        newOutletComponent = outletNode->outletModelObject();
        newOutletComponentInletPort = outletNode->connectedObjectPort(outletNode->outletPort());
      }

      if( ! newOutletComponent ) newOutletComponent = outletComponent;
      if( ! newOutletComponentInletPort ) newOutletComponentInletPort = outletComponentInletPort;

      _model.disconnect(thisObject,componentInletPort); 
      _model.disconnect(thisObject,componentOutletPort); 

      // outletNode->remove() would have failed if we did it before the disconnect
      if( inletNode && outletNode ) {
        outletNode->remove();
      }

      model().connect( inletComponent.get(), inletComponentOutletPort.get(), 
                       newOutletComponent.get(), newOutletComponentInletPort.get() );

      return true;
    }

    return false;
  }
boost::optional<IdfObject> ForwardTranslator::translateAirTerminalSingleDuctParallelPIUReheat( AirTerminalSingleDuctParallelPIUReheat & modelObject )
{
  OptionalModelObject temp;
  OptionalString optS;
  boost::optional<std::string> s;
  boost::optional<double> value;

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

  IdfObject idfObject(openstudio::IddObjectType::AirTerminal_SingleDuct_ParallelPIU_Reheat);
  idfObject.setName(modelObject.name().get());
  m_idfObjects.push_back(idfObject);

  HVACComponent coil = modelObject.reheatCoil();

  boost::optional<IdfObject> _reheatCoil = translateAndMapModelObject(coil);

  HVACComponent fan = modelObject.fan();

  boost::optional<IdfObject> _fan = translateAndMapModelObject(fan);

  std::string fanOutletNodeName = modelObject.name().get() + " Fan Outlet";

  std::string mixerOutletNodeName = modelObject.name().get() + " Mixer Outlet";

  boost::optional<std::string> inletNodeName;
  boost::optional<std::string> secondaryAirInletNodeName;
  boost::optional<std::string> outletNodeName;

  if( boost::optional<ModelObject> inletModelObject = modelObject.inletModelObject() )
  {
    if( boost::optional<Node> inletNode = inletModelObject->optionalCast<Node>() )
    {
      inletNodeName = inletNode->name().get();
    }
  }

  if( boost::optional<ModelObject> outletModelObject = modelObject.outletModelObject() )
  {
    if( boost::optional<Node> outletNode = outletModelObject->optionalCast<Node>() )
    {
      outletNodeName = outletNode->name().get();
    }
  }

  if( boost::optional<Node> secondaryInletNode = modelObject.secondaryAirInletNode() )
  {
    if( secondaryInletNode )
    {
      secondaryAirInletNodeName = secondaryInletNode->name().get();
    }
  }

  if( outletNodeName )
  {
    idfObject.setString(AirTerminal_SingleDuct_ParallelPIU_ReheatFields::OutletNodeName,outletNodeName.get());
  }

  if( inletNodeName )
  {
    idfObject.setString(AirTerminal_SingleDuct_ParallelPIU_ReheatFields::SupplyAirInletNodeName,inletNodeName.get());
  }

  if( secondaryAirInletNodeName )
  {
    idfObject.setString(AirTerminal_SingleDuct_ParallelPIU_ReheatFields::SecondaryAirInletNodeName,secondaryAirInletNodeName.get());
  }

  // Populate fields for AirDistributionUnit
  if( outletNodeName )
  {
    _airDistributionUnit.setString(ZoneHVAC_AirDistributionUnitFields::AirDistributionUnitOutletNodeName,outletNodeName.get());
  }
  _airDistributionUnit.setString(ZoneHVAC_AirDistributionUnitFields::AirTerminalObjectType,idfObject.iddObject().name());
  _airDistributionUnit.setString(ZoneHVAC_AirDistributionUnitFields::AirTerminalName,idfObject.name().get());

  // MixerName
  IdfObject _mixer(IddObjectType::AirLoopHVAC_ZoneMixer);
  _mixer.setName(modelObject.name().get() + " Mixer");
  m_idfObjects.push_back(_mixer);
  _mixer.clearExtensibleGroups();

  _mixer.setString(AirLoopHVAC_ZoneMixerFields::OutletNodeName,mixerOutletNodeName);

  IdfExtensibleGroup eg = _mixer.pushExtensibleGroup();
  eg.setString(AirLoopHVAC_ZoneMixerExtensibleFields::InletNodeName,fanOutletNodeName);

  if( inletNodeName )
  {
    eg = _mixer.pushExtensibleGroup();
    eg.setString(AirLoopHVAC_ZoneMixerExtensibleFields::InletNodeName,inletNodeName.get());
  }
  
  idfObject.setString(AirTerminal_SingleDuct_ParallelPIU_ReheatFields::ZoneMixerName,_mixer.name().get());

  // FanName
  if( _fan || _fan->name() )
  {
    idfObject.setString(AirTerminal_SingleDuct_ParallelPIU_ReheatFields::FanName,_fan->name().get());

    if( secondaryAirInletNodeName )
    {
      _fan->setString(Fan_ConstantVolumeFields::AirInletNodeName,secondaryAirInletNodeName.get());
    }

    _fan->setString(Fan_ConstantVolumeFields::AirOutletNodeName,fanOutletNodeName);
  } 

  // ReheatCoilName
  if( _reheatCoil && _reheatCoil->name() )
  {
    // Reheat Coil Name
    idfObject.setString(AirTerminal_SingleDuct_ParallelPIU_ReheatFields::ReheatCoilName,_reheatCoil->name().get());

    // Reheat Coil Type
    idfObject.setString(AirTerminal_SingleDuct_ParallelPIU_ReheatFields::ReheatCoilObjectType,_reheatCoil->iddObject().name());

    idfObject.setString(AirTerminal_SingleDuct_ParallelPIU_ReheatFields::ReheatCoilAirInletNodeName,mixerOutletNodeName);

    if( outletNodeName && inletNodeName )
    {
      if( _reheatCoil->iddObject().type() == IddObjectType::Coil_Heating_Gas )
      {
        _reheatCoil->setString(Coil_Heating_GasFields::AirInletNodeName,mixerOutletNodeName);
        _reheatCoil->setString(Coil_Heating_GasFields::AirOutletNodeName,outletNodeName.get());
      }
      else if( _reheatCoil->iddObject().type() == IddObjectType::Coil_Heating_Electric )
      {
        _reheatCoil->setString(Coil_Heating_ElectricFields::AirInletNodeName,mixerOutletNodeName);
        _reheatCoil->setString(Coil_Heating_ElectricFields::AirOutletNodeName,outletNodeName.get());
      }
      else if( _reheatCoil->iddObject().type() == IddObjectType::Coil_Heating_Water )
      {
        _reheatCoil->setString(Coil_Heating_WaterFields::AirInletNodeName,mixerOutletNodeName);
        _reheatCoil->setString(Coil_Heating_WaterFields::AirOutletNodeName,outletNodeName.get());
      }
    }
  }

  // AvailabilityScheduleName
  Schedule availabilitySchedule = modelObject.availabilitySchedule();

  boost::optional<IdfObject> _availabilitySchedule = translateAndMapModelObject(availabilitySchedule);

  if( _availabilitySchedule && _availabilitySchedule->name() )
  {
    idfObject.setString(AirTerminal_SingleDuct_ParallelPIU_ReheatFields::AvailabilityScheduleName,_availabilitySchedule->name().get());
  }

  // MaximumPrimaryAirFlowRate
  if( modelObject.isMaximumPrimaryAirFlowRateAutosized() )
  {
    idfObject.setString(AirTerminal_SingleDuct_ParallelPIU_ReheatFields::MaximumPrimaryAirFlowRate,"Autosize");
  }
  else if( (value = modelObject.maximumPrimaryAirFlowRate()) )
  {
    idfObject.setDouble(AirTerminal_SingleDuct_ParallelPIU_ReheatFields::MaximumPrimaryAirFlowRate,value.get());
  }

  // MaximumSecondaryAirFlowRate
  if( modelObject.isMaximumSecondaryAirFlowRateAutosized() )
  {
    idfObject.setString(AirTerminal_SingleDuct_ParallelPIU_ReheatFields::MaximumSecondaryAirFlowRate,"Autosize");
  }
  else if( (value = modelObject.maximumSecondaryAirFlowRate()) )
  {
    idfObject.setDouble(AirTerminal_SingleDuct_ParallelPIU_ReheatFields::MaximumSecondaryAirFlowRate,value.get());
  }

  // MinimumPrimaryAirFlowFraction
  if( modelObject.isMinimumPrimaryAirFlowFractionAutosized() )
  {
    idfObject.setString(AirTerminal_SingleDuct_ParallelPIU_ReheatFields::MinimumPrimaryAirFlowFraction,"Autosize");
  }
  else if( (value = modelObject.minimumPrimaryAirFlowFraction()) )
  {
    idfObject.setDouble(AirTerminal_SingleDuct_ParallelPIU_ReheatFields::MinimumPrimaryAirFlowFraction,value.get());
  }

  // FanOnFlowFraction
  if( modelObject.isFanOnFlowFractionAutosized() )
  {
    idfObject.setString(AirTerminal_SingleDuct_ParallelPIU_ReheatFields::FanOnFlowFraction,"Autosize");
  }
  else if( (value = modelObject.fanOnFlowFraction()) )
  {
    idfObject.setDouble(AirTerminal_SingleDuct_ParallelPIU_ReheatFields::FanOnFlowFraction,value.get());
  }

  // MaximumHotWaterorSteamFlowRate
  if( modelObject.isMaximumHotWaterorSteamFlowRateAutosized() )
  {
    idfObject.setString(AirTerminal_SingleDuct_ParallelPIU_ReheatFields::MaximumHotWaterorSteamFlowRate,"Autosize");
  }
  else if( (value = modelObject.maximumHotWaterorSteamFlowRate()) )
  {
    idfObject.setDouble(AirTerminal_SingleDuct_ParallelPIU_ReheatFields::MaximumHotWaterorSteamFlowRate,value.get());
  }

  // MinimumHotWaterorSteamFlowRate
  if( (value = modelObject.minimumHotWaterorSteamFlowRate()) )
  {
    idfObject.setDouble(AirTerminal_SingleDuct_ParallelPIU_ReheatFields::MinimumHotWaterorSteamFlowRate,value.get());
  }

  // HotWaterorSteamInletNodeName
  if( boost::optional<CoilHeatingWater> coil = modelObject.reheatCoil().optionalCast<CoilHeatingWater>() )
  {
    if( boost::optional<ModelObject> mo = coil->waterInletModelObject() )
    {
      if( boost::optional<Node> node = mo->optionalCast<Node>() )
      {
        idfObject.setString(AirTerminal_SingleDuct_ParallelPIU_ReheatFields::HotWaterorSteamInletNodeName,node->name().get());
      }
    }
  }

  // ConvergenceTolerance
  if( (value = modelObject.convergenceTolerance()) )
  {
    idfObject.setDouble(AirTerminal_SingleDuct_ParallelPIU_ReheatFields::ConvergenceTolerance,value.get());
  }
  
  return _airDistributionUnit;
}
 bool ZoneHVACEnergyRecoveryVentilator_Impl::setExhaustAirFan(const HVACComponent& exhaustAirFan) {
   bool result = setPointer(OS_ZoneHVAC_EnergyRecoveryVentilatorFields::ExhaustAirFanName, exhaustAirFan.handle());
   return result;
 }
 bool ZoneHVACEnergyRecoveryVentilator_Impl::setHeatExchanger(const HVACComponent& hxAirToAirSensibleAndLatent) {
   bool result = setPointer(OS_ZoneHVAC_EnergyRecoveryVentilatorFields::HeatExchangerName, hxAirToAirSensibleAndLatent.handle());
   return result;
 }
boost::optional<double> flowrate(const HVACComponent & component)
{
  boost::optional<double> result;
  switch(component.iddObject().type().value()) {
    case openstudio::IddObjectType::OS_Boiler_HotWater :
    {
      auto boiler = component.cast<BoilerHotWater>();
      result = boiler.designWaterFlowRate();
      break;
    }
    case openstudio::IddObjectType::OS_WaterHeater_Mixed :
    {
      auto waterHeater = component.cast<WaterHeaterMixed>();
      result = waterHeater.useSideDesignFlowRate();
      break;
    }
    case openstudio::IddObjectType::OS_WaterHeater_Stratified :
    {
      auto waterHeater = component.cast<WaterHeaterStratified>();
      result = waterHeater.useSideDesignFlowRate();
      break;
    }
    case openstudio::IddObjectType::OS_DistrictHeating :
    {
      break;
    }      
    case openstudio::IddObjectType::OS_Chiller_Electric_EIR :
    {
      auto chiller = component.cast<ChillerElectricEIR>();
      result = chiller.referenceChilledWaterFlowRate();
      break;
    }
    case openstudio::IddObjectType::OS_Chiller_Absorption_Indirect :
    {
      auto chiller = component.cast<ChillerAbsorptionIndirect>();
      result = chiller.designChilledWaterFlowRate();
      break;
    }
    case openstudio::IddObjectType::OS_Chiller_Absorption :
    {
      auto chiller = component.cast<ChillerAbsorption>();
      result = chiller.designChilledWaterFlowRate();
      break;
    }
    case openstudio::IddObjectType::OS_ThermalStorage_Ice_Detailed :
    {
      break;
    }
    case openstudio::IddObjectType::OS_DistrictCooling :
    {
      break;
    }      
    case openstudio::IddObjectType::OS_CoolingTower_SingleSpeed :
    {
      auto tower = component.cast<CoolingTowerSingleSpeed>();
      result = tower.designWaterFlowRate();
      break;
    }
    case openstudio::IddObjectType::OS_CoolingTower_VariableSpeed :
    {
      auto tower = component.cast<CoolingTowerVariableSpeed>();
      result = tower.designWaterFlowRate();
      break;
    }
    case openstudio::IddObjectType::OS_CoolingTower_TwoSpeed:
    {
      auto tower = component.cast<CoolingTowerTwoSpeed>();
      result = tower.designWaterFlowRate();
      break;
    }
    case openstudio::IddObjectType::OS_EvaporativeFluidCooler_SingleSpeed:
    {
      auto mo = component.cast<EvaporativeFluidCoolerSingleSpeed>();
      result = mo.designWaterFlowRate();
      break;
    }
    case openstudio::IddObjectType::OS_FluidCooler_SingleSpeed:
    {
      auto mo = component.cast<FluidCoolerSingleSpeed>();
      result = mo.designWaterFlowRate();
      break;
    }
    case openstudio::IddObjectType::OS_FluidCooler_TwoSpeed:
    {
      auto mo = component.cast<FluidCoolerTwoSpeed>();
      result = mo.designWaterFlowRate();
      break;
    }
    case openstudio::IddObjectType::OS_GroundHeatExchanger_Vertical :
    {
      auto hx = component.cast<GroundHeatExchangerVertical>();
      result = hx.maximumFlowRate();
      break;
    }
    case openstudio::IddObjectType::OS_GroundHeatExchanger_HorizontalTrench :
    {
      auto hx = component.cast<GroundHeatExchangerHorizontalTrench>();
      result = hx.designFlowRate();
      break;
    }
    case openstudio::IddObjectType::OS_HeatExchanger_FluidToFluid :
    {
      auto hx = component.cast<HeatExchangerFluidToFluid>();
      result = hx.loopSupplySideDesignFlowRate();
      break;
    }
    case openstudio::IddObjectType::OS_SolarCollector_FlatPlate_PhotovoltaicThermal :
    {
      auto mo = component.cast<SolarCollectorFlatPlatePhotovoltaicThermal>();
      result = mo.designFlowRate();
      break;
    }
    case openstudio::IddObjectType::OS_SolarCollector_FlatPlate_Water :
    {
      auto mo = component.cast<SolarCollectorFlatPlateWater>();
      result = mo.maximumFlowRate();
      break;
    }
    case openstudio::IddObjectType::OS_SolarCollector_IntegralCollectorStorage :
    {
      auto mo = component.cast<SolarCollectorIntegralCollectorStorage>();
      result = mo.maximumFlowRate();
      break;
    }
    case openstudio::IddObjectType::OS_PlantComponent_TemperatureSource :
    {
      auto mo = component.cast<PlantComponentTemperatureSource>();
      result = mo.designVolumeFlowRate();
      break;
    }
    case openstudio::IddObjectType::OS_HeatPump_WaterToWater_EquationFit_Cooling :
    {
      auto mo = component.cast<HeatPumpWaterToWaterEquationFitCooling>();
      result = mo.ratedLoadSideFlowRate();
      break;
    }
    case openstudio::IddObjectType::OS_HeatPump_WaterToWater_EquationFit_Heating :
    {
      auto mo = component.cast<HeatPumpWaterToWaterEquationFitHeating>();
      result = mo.ratedLoadSideFlowRate();
      break;
    }
    default:
    {
      break;
    }
  }

  return result;
}
Example #16
0
  bool HVACComponent_Impl::addToNode(Node & node, 
    const HVACComponent & systemStartComponent, 
    const HVACComponent & systemEndComponent,
    unsigned componentInletPort,
    unsigned componentOutletPort)
  {
    Model _model = model();
    ModelObject thisModelObject = getObject<ModelObject>();

    if( node.model() != _model ) return false;
    if( systemStartComponent.model() != _model ) return false;
    if( systemEndComponent.model() != _model ) return false;

    if( (node == systemEndComponent) && (node.inletModelObject().get() == systemStartComponent) ) {
      unsigned oldOutletPort = node.connectedObjectPort( node.inletPort() ).get();
      unsigned oldInletPort = node.inletPort();
      ModelObject oldSourceModelObject = node.connectedObject( node.inletPort() ).get();
      ModelObject oldTargetModelObject = node;

      // If systemStartComponent is not a node we need to insert one so that there
      // is a node between systemStartComponent and this component we are adding
      // This situation occurs in the oa system relief stream.
      if( ! systemStartComponent.optionalCast<Node>() ) {
        Node newNode(_model);
        _model.connect(oldSourceModelObject,oldOutletPort,
                       newNode,newNode.inletPort());
        oldOutletPort = newNode.outletPort();
        oldSourceModelObject = newNode;
      }

      _model.connect( oldSourceModelObject, oldOutletPort,
                      thisModelObject, componentInletPort );
      _model.connect( thisModelObject, componentOutletPort,
                      oldTargetModelObject, oldInletPort );
      return true;
    } else if( (node == systemStartComponent) && (node.outletModelObject().get() == systemEndComponent) ) {
      unsigned oldInletPort = node.connectedObjectPort( node.outletPort() ).get();
      unsigned oldOutletPort = node.outletPort();
      ModelObject oldTargetModelObject = node.connectedObject( node.outletPort() ).get();
      ModelObject oldSourceModelObject = node;

      // If systemEndComponent is not a node we need to insert one so that there
      // is a node between systemEndComponent and this component we are adding
      // This situation occurs in the oa system outdoor air stream.
      if( ! systemEndComponent.optionalCast<Node>() ) {
        Node newNode(_model);
        _model.connect(newNode,newNode.outletPort(),
                       oldTargetModelObject,oldInletPort);
        oldInletPort = newNode.inletPort();
        oldTargetModelObject = newNode;
      }

      _model.connect( oldSourceModelObject, oldOutletPort,
                      thisModelObject, componentInletPort );
      _model.connect( thisModelObject, componentOutletPort,
                      oldTargetModelObject, oldInletPort );
      return true;
    } else if( node == systemEndComponent ) {
      unsigned oldOutletPort = node.connectedObjectPort( node.inletPort() ).get();
      unsigned oldInletPort = node.inletPort();
      ModelObject oldSourceModelObject = node.connectedObject( node.inletPort() ).get();
      ModelObject oldTargetModelObject = node;

      Node newNode( _model );
      _model.connect( oldSourceModelObject, oldOutletPort,
                      newNode, newNode.inletPort() );
      _model.connect( newNode, newNode.outletPort(),
                      thisModelObject, componentInletPort );                        
      _model.connect( thisModelObject, componentOutletPort,
                      oldTargetModelObject, oldInletPort );
      return true;
    } else {
      unsigned oldOutletPort = node.outletPort();
      unsigned oldInletPort = node.connectedObjectPort( node.outletPort() ).get();
      ModelObject oldSourceModelObject = node;
      ModelObject oldTargetModelObject = node.connectedObject( node.outletPort() ).get();
    
      Node newNode( _model );
      _model.connect( oldSourceModelObject, oldOutletPort,
                      thisModelObject, componentInletPort );
      _model.connect( thisModelObject, componentOutletPort,
                      newNode, newNode.inletPort() );
      _model.connect( newNode, newNode.outletPort(),
                      oldTargetModelObject, oldInletPort );
      return true;
    }

    return false;
  }
ComponentType componentType(const HVACComponent & component)
{
  switch(component.iddObject().type().value())
  {
    case openstudio::IddObjectType::OS_Boiler_HotWater :
    {
      return ComponentType::HEATING;
    }
    case openstudio::IddObjectType::OS_WaterHeater_Mixed :
    {
      return ComponentType::HEATING;
    }
    case openstudio::IddObjectType::OS_WaterHeater_Stratified :
    {
      return ComponentType::HEATING;
    }
    case openstudio::IddObjectType::OS_DistrictHeating :
    {
      return ComponentType::HEATING;
    }      
    case openstudio::IddObjectType::OS_Chiller_Electric_EIR :
    {
      return ComponentType::COOLING;
    }
    case openstudio::IddObjectType::OS_Chiller_Absorption_Indirect :
    {
      return ComponentType::COOLING;
    }
    case openstudio::IddObjectType::OS_Chiller_Absorption :
    {
      return ComponentType::COOLING;
    }
    case openstudio::IddObjectType::OS_ThermalStorage_Ice_Detailed :
    {
      return ComponentType::BOTH;
    }
    case openstudio::IddObjectType::OS_DistrictCooling :
    {
      return ComponentType::COOLING;
    }      
    case openstudio::IddObjectType::OS_CoolingTower_SingleSpeed :
    {
      return ComponentType::COOLING;
    }
    case openstudio::IddObjectType::OS_CoolingTower_VariableSpeed :
    {
      return ComponentType::COOLING;
    }
    case openstudio::IddObjectType::OS_CoolingTower_TwoSpeed:
    {
      return ComponentType::COOLING;
    }
    case openstudio::IddObjectType::OS_EvaporativeFluidCooler_SingleSpeed:
    {
      return ComponentType::COOLING;
    }
    case openstudio::IddObjectType::OS_FluidCooler_SingleSpeed:
    {
      return ComponentType::COOLING;
    }
    case openstudio::IddObjectType::OS_FluidCooler_TwoSpeed:
    {
      return ComponentType::COOLING;
    }
    case openstudio::IddObjectType::OS_GroundHeatExchanger_Vertical :
    {
      return ComponentType::BOTH;
    }
    case openstudio::IddObjectType::OS_GroundHeatExchanger_HorizontalTrench :
    {
      return ComponentType::BOTH;
    }
    case openstudio::IddObjectType::OS_HeatExchanger_FluidToFluid :
    {
      return ComponentType::BOTH;
    }
    case openstudio::IddObjectType::OS_SolarCollector_FlatPlate_PhotovoltaicThermal :
    {
      return ComponentType::HEATING;
    }
    case openstudio::IddObjectType::OS_SolarCollector_FlatPlate_Water :
    {
      return ComponentType::HEATING;
    }
    case openstudio::IddObjectType::OS_SolarCollector_IntegralCollectorStorage :
    {
      return ComponentType::HEATING;
    }
    case openstudio::IddObjectType::OS_PlantComponent_TemperatureSource :
    {
      return ComponentType::BOTH;
    }
    case openstudio::IddObjectType::OS_HeatPump_WaterToWater_EquationFit_Heating :
    {
      return ComponentType::HEATING;
    }
    case openstudio::IddObjectType::OS_HeatPump_WaterToWater_EquationFit_Cooling :
    {
      return ComponentType::COOLING;
    }
    default:
    {
      return ComponentType::NONE;
    }
  }
}
 bool ZoneHVACLowTempRadiantVarFlow_Impl::setCoolingCoil(HVACComponent& coolingCoil) 
 {
   bool result = setPointer(OS_ZoneHVAC_LowTemperatureRadiant_VariableFlowFields::LowTempRadiantVariableFlowCoolingCoilName, coolingCoil.handle());
   return result;
 }
boost::optional<IdfObject> ForwardTranslator::translateZoneHVACPackagedTerminalAirConditioner( 
    ZoneHVACPackagedTerminalAirConditioner & modelObject )
{
  boost::optional<std::string> s;
  boost::optional<double> value;

  IdfObject idfObject(IddObjectType::ZoneHVAC_PackagedTerminalAirConditioner);

  m_idfObjects.push_back(idfObject);

  // Name

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

  idfObject.setName(baseName);

  std::string mixedAirNodeName = baseName + " Mixed Air Node";

  std::string coolingCoilOutletNodeName = baseName + " Cooling Coil Outlet Node";

  std::string heatingCoilOutletNodeName = baseName + " Heating Coil Outlet Node";

  std::string reliefAirNodeName = baseName + " Relief Air Node";

  std::string oaNodeName = baseName + " OA Node";

  // AvailabilityScheduleName

  if( boost::optional<Schedule> schedule = modelObject.availabilitySchedule() )
  {
    if( boost::optional<IdfObject> _schedule = translateAndMapModelObject(schedule.get()) )
    {
      idfObject.setString(ZoneHVAC_PackagedTerminalAirConditionerFields::AvailabilityScheduleName,_schedule->name().get());
    }
  }

  // AirInletNodeName

  boost::optional<std::string> airInletNodeName;

  if( boost::optional<Node> node = modelObject.inletNode() )
  {
    if( (s = node->name()) )
    {
      airInletNodeName = s;

      idfObject.setString(ZoneHVAC_PackagedTerminalAirConditionerFields::AirInletNodeName,s.get());
    }
  }

  // AirOutletNodeName

  boost::optional<std::string> airOutletNodeName;

  if( boost::optional<Node> node = modelObject.outletNode() )
  {
    if( (s = node->name()) )
    {
      airOutletNodeName = s;

      idfObject.setString(ZoneHVAC_PackagedTerminalAirConditionerFields::AirOutletNodeName,s.get());
    }
  }

  // OutdoorAirMixerObjectType
  idfObject.setString(ZoneHVAC_PackagedTerminalAirConditionerFields::OutdoorAirMixerObjectType,
                      modelObject.outdoorAirMixerObjectType());

  // OutdoorAirMixerName
  
  std::string oaMixerName = modelObject.name().get() + " OA Mixer";  

  idfObject.setString(ZoneHVAC_PackagedTerminalAirConditionerFields::OutdoorAirMixerName,oaMixerName);

  IdfObject _outdoorAirMixer(IddObjectType::OutdoorAir_Mixer);
  _outdoorAirMixer.setName(oaMixerName);
  m_idfObjects.push_back(_outdoorAirMixer);

  _outdoorAirMixer.setString(OutdoorAir_MixerFields::MixedAirNodeName,mixedAirNodeName);

  _outdoorAirMixer.setString(OutdoorAir_MixerFields::OutdoorAirStreamNodeName,oaNodeName);

  IdfObject _oaNodeList(openstudio::IddObjectType::OutdoorAir_NodeList);
  _oaNodeList.setString(0,oaNodeName);
  m_idfObjects.push_back(_oaNodeList);

  _outdoorAirMixer.setString(OutdoorAir_MixerFields::ReliefAirStreamNodeName,reliefAirNodeName);

  if(airInletNodeName)
  {
    _outdoorAirMixer.setString(OutdoorAir_MixerFields::ReturnAirStreamNodeName,airInletNodeName.get());
  }

  // SupplyAirFlowRateDuringCoolingOperation

  if( modelObject.isSupplyAirFlowRateDuringCoolingOperationAutosized() )
  {
    idfObject.setString(ZoneHVAC_PackagedTerminalAirConditionerFields::SupplyAirFlowRateDuringCoolingOperation,"Autosize");
  }
  else if( (value = modelObject.supplyAirFlowRateDuringCoolingOperation()) )
  {
    idfObject.setDouble(ZoneHVAC_PackagedTerminalAirConditionerFields::SupplyAirFlowRateDuringCoolingOperation,value.get());
  }

  // SupplyAirFlowRateDuringHeatingOperation

  if( modelObject.isSupplyAirFlowRateDuringHeatingOperationAutosized() )
  {
    idfObject.setString(ZoneHVAC_PackagedTerminalAirConditionerFields::SupplyAirFlowRateDuringHeatingOperation,"Autosize");
  }
  else if( (value = modelObject.supplyAirFlowRateDuringHeatingOperation()) )
  {
    idfObject.setDouble(ZoneHVAC_PackagedTerminalAirConditionerFields::SupplyAirFlowRateDuringHeatingOperation,value.get());
  }

  // SupplyAirFlowRateWhenNoCoolingorHeatingisNeeded

  if( modelObject.isSupplyAirFlowRateWhenNoCoolingorHeatingisNeededAutosized() )
  {
    idfObject.setString(ZoneHVAC_PackagedTerminalAirConditionerFields::SupplyAirFlowRateWhenNoCoolingorHeatingisNeeded,"Autosize");
  } 
  else if( (value = modelObject.supplyAirFlowRateWhenNoCoolingorHeatingisNeeded()) )
  {
    idfObject.setDouble(ZoneHVAC_PackagedTerminalAirConditionerFields::SupplyAirFlowRateWhenNoCoolingorHeatingisNeeded,value.get());
  }

  // OutdoorAirFlowRateDuringCoolingOperation
  
  if( modelObject.isOutdoorAirFlowRateDuringCoolingOperationAutosized() )
  {
    idfObject.setString(ZoneHVAC_PackagedTerminalAirConditionerFields::OutdoorAirFlowRateDuringCoolingOperation,"Autosize");
  }
  else if( (value = modelObject.outdoorAirFlowRateDuringCoolingOperation()) )
  {
    idfObject.setDouble(ZoneHVAC_PackagedTerminalAirConditionerFields::OutdoorAirFlowRateDuringCoolingOperation,value.get());
  }

  // OutdoorAirFlowRateDuringHeatingOperation
  
  if( modelObject.isOutdoorAirFlowRateDuringHeatingOperationAutosized() )
  {
    idfObject.setString(ZoneHVAC_PackagedTerminalAirConditionerFields::OutdoorAirFlowRateDuringHeatingOperation,"Autosize");
  }
  else if( (value = modelObject.outdoorAirFlowRateDuringHeatingOperation()) )
  {
    idfObject.setDouble(ZoneHVAC_PackagedTerminalAirConditionerFields::OutdoorAirFlowRateDuringHeatingOperation,value.get());
  }

  // OutdoorAirFlowRateWhenNoCoolingorHeatingisNeeded
  
  if( modelObject.isOutdoorAirFlowRateWhenNoCoolingorHeatingisNeededAutosized() )
  {
    idfObject.setString(ZoneHVAC_PackagedTerminalAirConditionerFields::OutdoorAirFlowRateWhenNoCoolingorHeatingisNeeded,"Autosize");
  }
  else if( (value = modelObject.outdoorAirFlowRateWhenNoCoolingorHeatingisNeeded()) )
  {
    idfObject.setDouble(ZoneHVAC_PackagedTerminalAirConditionerFields::OutdoorAirFlowRateWhenNoCoolingorHeatingisNeeded,value.get());
  }

  // SupplyAirFanObjectType

  HVACComponent supplyAirFan = modelObject.supplyAirFan();

  if( boost::optional<IdfObject> _supplyAirFan = translateAndMapModelObject(supplyAirFan) )
  {
    idfObject.setString(ZoneHVAC_PackagedTerminalAirConditionerFields::SupplyAirFanObjectType,_supplyAirFan->iddObject().name() );

    idfObject.setString(ZoneHVAC_PackagedTerminalAirConditionerFields::SupplyAirFanName,_supplyAirFan->name().get());

    if( airOutletNodeName )
    {
      if( _supplyAirFan->iddObject().type() == IddObjectType::Fan_ConstantVolume )
      {
        _supplyAirFan->setString(Fan_ConstantVolumeFields::AirInletNodeName,heatingCoilOutletNodeName);

        _supplyAirFan->setString(Fan_ConstantVolumeFields::AirOutletNodeName,airOutletNodeName.get());
      }
    }
  }

  // HeatingCoilObjectType
  
  HVACComponent heatingCoil = modelObject.heatingCoil();

  if( boost::optional<IdfObject> _heatingCoil = translateAndMapModelObject(heatingCoil) )
  {
    idfObject.setString(ZoneHVAC_PackagedTerminalAirConditionerFields::HeatingCoilObjectType,_heatingCoil->iddObject().name() );

    idfObject.setString(ZoneHVAC_PackagedTerminalAirConditionerFields::HeatingCoilName,_heatingCoil->name().get() ); 

    if( _heatingCoil->iddObject().type() == IddObjectType::Coil_Heating_Water )
    {
      _heatingCoil->setString(Coil_Heating_WaterFields::AirInletNodeName,coolingCoilOutletNodeName);

      _heatingCoil->setString(Coil_Heating_WaterFields::AirOutletNodeName,heatingCoilOutletNodeName);
    }
    else if( _heatingCoil->iddObject().type() == IddObjectType::Coil_Heating_Gas )
    {
      _heatingCoil->setString(Coil_Heating_GasFields::AirInletNodeName,coolingCoilOutletNodeName);

      _heatingCoil->setString(Coil_Heating_GasFields::AirOutletNodeName,heatingCoilOutletNodeName);
    }
    else if( _heatingCoil->iddObject().type() == IddObjectType::Coil_Heating_Electric )
    {
      _heatingCoil->setString(Coil_Heating_ElectricFields::AirInletNodeName,coolingCoilOutletNodeName);

      _heatingCoil->setString(Coil_Heating_ElectricFields::AirOutletNodeName,heatingCoilOutletNodeName);
    }
  }

  // CoolingCoilObjectType

  HVACComponent coolingCoil = modelObject.coolingCoil();

  boost::optional<IdfObject> _coolingCoil;

  if( boost::optional<CoilCoolingDXSingleSpeed> dxCoil = coolingCoil.optionalCast<CoilCoolingDXSingleSpeed>() )
  {
    _coolingCoil = translateCoilCoolingDXSingleSpeedWithoutUnitary(dxCoil.get());

    m_map.insert(std::make_pair(coolingCoil.handle(),_coolingCoil.get()));
  }
  else
  {
    _coolingCoil = translateAndMapModelObject(coolingCoil);
  }

  if( _coolingCoil )
  {
    idfObject.setString(ZoneHVAC_PackagedTerminalAirConditionerFields::CoolingCoilObjectType,_coolingCoil->iddObject().name() );

    idfObject.setString(ZoneHVAC_PackagedTerminalAirConditionerFields::CoolingCoilName,_coolingCoil->name().get() );

    if( _coolingCoil->iddObject().type() == IddObjectType::Coil_Cooling_DX_SingleSpeed )
    {
      _coolingCoil->setString(Coil_Cooling_DX_SingleSpeedFields::AirInletNodeName,mixedAirNodeName);

      _coolingCoil->setString(Coil_Cooling_DX_SingleSpeedFields::AirOutletNodeName,coolingCoilOutletNodeName);
    }
  }

  // FanPlacement

  idfObject.setString(ZoneHVAC_PackagedTerminalAirConditionerFields::FanPlacement,modelObject.fanPlacement());

  // SupplyAirFanOperatingModeScheduleName
  
  if( boost::optional<Schedule> schedule = modelObject.supplyAirFanOperatingModeSchedule() )
  {
    if( boost::optional<IdfObject> _schedule = translateAndMapModelObject(schedule.get()) )
    {
      idfObject.setString(ZoneHVAC_PackagedTerminalAirConditionerFields::SupplyAirFanOperatingModeScheduleName,_schedule->name().get());
    }
  }

  return idfObject;
}
Example #20
0
bool PortList_Impl::setHVACComponent(const HVACComponent & hvacComponent)
{
  return setPointer(OS_PortListFields::HVACComponent,hvacComponent.handle());
}