ZoneHVACEnergyRecoveryVentilator::ZoneHVACEnergyRecoveryVentilator(
  const Model& model,
  const HVACComponent& heatExchanger,
  const HVACComponent& supplyAirFan,
  const HVACComponent& exhaustAirFan
  )
  : ZoneHVACComponent(ZoneHVACEnergyRecoveryVentilator::iddObjectType(),model)
{
  OS_ASSERT(getImpl<detail::ZoneHVACEnergyRecoveryVentilator_Impl>());

  bool ok = true;
  auto alwaysOn = model.alwaysOnDiscreteSchedule();
  ok = setAvailabilitySchedule( alwaysOn );
  OS_ASSERT(ok);
  if ( auto _heatExchanger = heatExchanger.optionalCast<HeatExchangerAirToAirSensibleAndLatent>() ) {
    // The Supply Air Outlet Temperature Control must be "No" in the heat exchanger, otherwise
    // we need to add a Setpoint Manager on the Supply Air Outlet Node of the heat exchanger.
    _heatExchanger->setSupplyAirOutletTemperatureControl( false );
  }
  ok = setHeatExchanger( heatExchanger );
  OS_ASSERT(ok);
  autosizeSupplyAirFlowRate();
  autosizeExhaustAirFlowRate();
  ok = setSupplyAirFan( supplyAirFan );
  OS_ASSERT(ok);
  ok = setExhaustAirFan( exhaustAirFan );
  OS_ASSERT(ok);
  ok = setVentilationRateperUnitFloorArea( 0.000508 );
  OS_ASSERT(ok);
  ok = setVentilationRateperOccupant( 0.00236 );
  OS_ASSERT(ok);
}
CoilSystemCoolingWaterHeatExchangerAssisted::CoilSystemCoolingWaterHeatExchangerAssisted(const Model& model)
  : StraightComponent(CoilSystemCoolingWaterHeatExchangerAssisted::iddObjectType(),model)
{
  OS_ASSERT(getImpl<detail::CoilSystemCoolingWaterHeatExchangerAssisted_Impl>());

  CoilCoolingWater coolingCoil(model);
  setCoolingCoil(coolingCoil);

  HeatExchangerAirToAirSensibleAndLatent heatExchanger(model);
  heatExchanger.setSupplyAirOutletTemperatureControl(false);
  setHeatExchanger(heatExchanger);
}
  ModelObject ZoneHVACEnergyRecoveryVentilator_Impl::clone(Model model) const
  {
    auto cloneObject = ZoneHVACComponent_Impl::clone(model).cast<ZoneHVACEnergyRecoveryVentilator>();

    auto const supplyFanClone = supplyAirFan().clone(model).cast<HVACComponent>();
    cloneObject.setSupplyAirFan(supplyFanClone);

    auto const exhaustFanClone = exhaustAirFan().clone(model).cast<HVACComponent>();
    cloneObject.setExhaustAirFan(exhaustFanClone);

    auto const heatExchangerClone = heatExchanger().clone(model).cast<HVACComponent>();
    cloneObject.setHeatExchanger(heatExchangerClone);

    if (auto const controllerObj = controller()) {
      auto const controllerClone = controllerObj->clone(model).cast<ZoneHVACEnergyRecoveryVentilatorController>();
      cloneObject.setController(controllerClone);
    }

    return cloneObject;
  }