ModelObject ZoneHVACLowTempRadiantVarFlow_Impl::clone(Model model) const
  {
    ZoneHVACLowTempRadiantVarFlow lowTempRadiantVarFlowClone = ZoneHVACComponent_Impl::clone(model).cast<ZoneHVACLowTempRadiantVarFlow>();

    auto t_coolingCoil = coolingCoil();
    HVACComponent coolingCoilClone = t_coolingCoil.clone(model).cast<HVACComponent>();

    auto t_heatingCoil = heatingCoil();
    HVACComponent heatingCoilClone = t_heatingCoil.clone(model).cast<HVACComponent>();

    lowTempRadiantVarFlowClone.setHeatingCoil(heatingCoilClone);

    lowTempRadiantVarFlowClone.setCoolingCoil(coolingCoilClone);

    if( model == this->model() ) {
      if( auto waterToAirComponent = t_coolingCoil.optionalCast<WaterToAirComponent>() ) {
        if( auto plant = waterToAirComponent->plantLoop() ) {
          plant->addDemandBranchForComponent(coolingCoilClone);
        }
      }
      if( auto waterToAirComponent = t_heatingCoil.optionalCast<WaterToAirComponent>() ) {
        if( auto plant = waterToAirComponent->plantLoop() ) {
          plant->addDemandBranchForComponent(heatingCoilClone);
        }
      }
    }

    return lowTempRadiantVarFlowClone;
  }
 boost::optional<Node> AirTerminalSingleDuctConstantVolumeFourPipeBeam_Impl::hotWaterOutletNode() const {
   boost::optional<Node> node;
   if ( boost::optional<HVACComponent> _comp = heatingCoil() ) {
     if ( boost::optional<CoilHeatingFourPipeBeam> _hc = _comp->optionalCast<CoilHeatingFourPipeBeam>() ) {
       node = _hc->hotWaterOutletNode();
     }
   }
   return node;
 }
 /* Convenience method to return the hot water PlantLoop */
 boost::optional<PlantLoop> AirTerminalSingleDuctConstantVolumeFourPipeBeam_Impl::hotWaterPlantLoop() const {
   boost::optional<PlantLoop> plantLoop;
   if ( boost::optional<HVACComponent> _comp = heatingCoil() ) {
     if ( boost::optional<CoilHeatingFourPipeBeam> _hc = _comp->optionalCast<CoilHeatingFourPipeBeam>() ) {
       plantLoop = _hc->plantLoop();
     }
   }
   return plantLoop;
 }
std::vector<ModelObject> ZoneHVACTerminalUnitVariableRefrigerantFlow_Impl::children() const
{
    std::vector<ModelObject> result;

    result.push_back(supplyAirFan());
    result.push_back(coolingCoil());
    result.push_back(heatingCoil());

    return result;
}
 std::vector<IdfObject> ZoneHVACUnitHeater_Impl::remove()
 {
   if( boost::optional<CoilHeatingWater> waterHeatingCoil =
         heatingCoil().optionalCast<CoilHeatingWater>() )
   {
     if( boost::optional<PlantLoop> plantLoop = waterHeatingCoil->plantLoop() )
     {
       plantLoop->removeDemandBranchWithComponent( waterHeatingCoil.get() );
     }
   }
   return ZoneHVACComponent_Impl::remove();
 }
 /* Children are the (optional) subclasses corresponding to the cooling and heating water side */
 std::vector<ModelObject> AirTerminalSingleDuctConstantVolumeFourPipeBeam_Impl::children() const
 {
   std::vector<ModelObject> result;
   if (boost::optional<HVACComponent> cc = coolingCoil())
   {
     result.push_back(*cc);
   }
   if (boost::optional<HVACComponent> hc = heatingCoil())
   {
     result.push_back(*hc);
   }
   return result;
 }
  /* Clone this + any cooling and heating coils */
  ModelObject AirTerminalSingleDuctConstantVolumeFourPipeBeam_Impl::clone(Model model) const
  {
    AirTerminalSingleDuctConstantVolumeFourPipeBeam airTerminalCVFourPipeBeamClone = StraightComponent_Impl::clone(model).cast<AirTerminalSingleDuctConstantVolumeFourPipeBeam>();

    if (boost::optional<HVACComponent> cc = coolingCoil()) {
      HVACComponent coilCoolingClone = cc->clone(model).cast<HVACComponent>();
      airTerminalCVFourPipeBeamClone.setCoolingCoil(coilCoolingClone);
    }

    if (boost::optional<HVACComponent> hc = heatingCoil()) {
      HVACComponent coilHeatingClone = hc->clone(model).cast<HVACComponent>();
      airTerminalCVFourPipeBeamClone.setHeatingCoil(coilHeatingClone);
    }

    return airTerminalCVFourPipeBeamClone;
  }
ModelObject ZoneHVACTerminalUnitVariableRefrigerantFlow_Impl::clone(Model & model) const
{
    ModelObject terminalClone = ZoneHVACComponent_Impl::clone(model);

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

    CoilCoolingDXVariableRefrigerantFlow coolingCoilClone = coolingCoil().clone(model).cast<CoilCoolingDXVariableRefrigerantFlow>();

    CoilHeatingDXVariableRefrigerantFlow heatingCoilClone = heatingCoil().clone(model).cast<CoilHeatingDXVariableRefrigerantFlow>();

    terminalClone.getImpl<detail::ZoneHVACTerminalUnitVariableRefrigerantFlow_Impl>()->setSupplyAirFan(fanClone);

    terminalClone.getImpl<detail::ZoneHVACTerminalUnitVariableRefrigerantFlow_Impl>()->setCoolingCoil(coolingCoilClone);

    terminalClone.getImpl<detail::ZoneHVACTerminalUnitVariableRefrigerantFlow_Impl>()->setHeatingCoil(heatingCoilClone);

    return terminalClone;
}
ZoneHVACTerminalUnitVariableRefrigerantFlow::ZoneHVACTerminalUnitVariableRefrigerantFlow(const Model& model)
    : ZoneHVACComponent(ZoneHVACTerminalUnitVariableRefrigerantFlow::iddObjectType(),model)
{
    OS_ASSERT(getImpl<detail::ZoneHVACTerminalUnitVariableRefrigerantFlow_Impl>());

    Schedule alwaysOnSchedule = model.alwaysOnDiscreteSchedule();
    setTerminalUnitAvailabilityschedule(alwaysOnSchedule);

    autosizeSupplyAirFlowRateDuringCoolingOperation();

    autosizeSupplyAirFlowRateWhenNoCoolingisNeeded();

    autosizeSupplyAirFlowRateDuringHeatingOperation();

    autosizeSupplyAirFlowRateWhenNoHeatingisNeeded();

    autosizeOutdoorAirFlowRateDuringCoolingOperation();

    autosizeOutdoorAirFlowRateDuringHeatingOperation();

    autosizeOutdoorAirFlowRateWhenNoCoolingorHeatingisNeeded();

    setSupplyAirFanOperatingModeSchedule(alwaysOnSchedule);

    setZoneTerminalUnitOnParasiticElectricEnergyUse(30);

    setZoneTerminalUnitOffParasiticElectricEnergyUse(20);

    setRatedTotalHeatingCapacitySizingRatio(1.0);

    CoilCoolingDXVariableRefrigerantFlow coolingCoil(model);
    coolingCoil.setName(name().get() + " Cooling Coil");
    getImpl<detail::ZoneHVACTerminalUnitVariableRefrigerantFlow_Impl>()->setCoolingCoil(coolingCoil);

    CoilHeatingDXVariableRefrigerantFlow heatingCoil(model);
    heatingCoil.setName(name().get() + " Heating Coil");
    getImpl<detail::ZoneHVACTerminalUnitVariableRefrigerantFlow_Impl>()->setHeatingCoil(heatingCoil);

    FanOnOff fan(model,alwaysOnSchedule);
    fan.setName(name().get() + " Fan");
    getImpl<detail::ZoneHVACTerminalUnitVariableRefrigerantFlow_Impl>()->setSupplyAirFan(fan);
}
 std::vector<IdfObject> ZoneHVACLowTempRadiantVarFlow_Impl::remove() 
 {
   if( boost::optional<CoilHeatingLowTempRadiantVarFlow> waterHeatingCoil =
         heatingCoil().optionalCast<CoilHeatingLowTempRadiantVarFlow>() )
   {
     if( boost::optional<PlantLoop> plantLoop = waterHeatingCoil->plantLoop() )
     {
       plantLoop->removeDemandBranchWithComponent( waterHeatingCoil.get() );
     }
   }
   if( boost::optional<CoilCoolingLowTempRadiantVarFlow> waterCoolingCoil =
         coolingCoil().optionalCast<CoilCoolingLowTempRadiantVarFlow>() )
   {
     if( boost::optional<PlantLoop> plantLoop = waterCoolingCoil->plantLoop() )
     {
       plantLoop->removeDemandBranchWithComponent( waterCoolingCoil.get() );
     }
   }
   return ZoneHVACComponent_Impl::remove();
 }
  ModelObject ZoneHVACTerminalUnitVariableRefrigerantFlow_Impl::clone(Model model) const
  {
    ModelObject terminalClone = ZoneHVACComponent_Impl::clone(model);

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

    CoilCoolingDXVariableRefrigerantFlow coolingCoilClone = coolingCoil().clone(model).cast<CoilCoolingDXVariableRefrigerantFlow>();

    CoilHeatingDXVariableRefrigerantFlow heatingCoilClone = heatingCoil().clone(model).cast<CoilHeatingDXVariableRefrigerantFlow>();

    terminalClone.getImpl<detail::ZoneHVACTerminalUnitVariableRefrigerantFlow_Impl>()->setSupplyAirFan(fanClone);

    terminalClone.getImpl<detail::ZoneHVACTerminalUnitVariableRefrigerantFlow_Impl>()->setCoolingCoil(coolingCoilClone);

    terminalClone.getImpl<detail::ZoneHVACTerminalUnitVariableRefrigerantFlow_Impl>()->setHeatingCoil(heatingCoilClone);

    // TODO Move this into base clase
    terminalClone.setString(OS_ZoneHVAC_TerminalUnit_VariableRefrigerantFlowFields::TerminalUnitAirInletNode,"");
    terminalClone.setString(OS_ZoneHVAC_TerminalUnit_VariableRefrigerantFlowFields::TerminalUnitAirOutletNode,"");

    return terminalClone;
  }
 boost::optional<ModelObject> ZoneHVACUnitHeater_Impl::heatingCoilAsModelObject() const 
 {
   OptionalModelObject result = heatingCoil();
   return result;
 }