Example #1
0
  std::string WindowGroup::shadingControlSetpoint() const
  {
    std::string result = "n/a";
    if (m_shadingControl){
      std::string shadingControlType = this->shadingControlType();

      if (istringEqual("AlwaysOff", shadingControlType)){
        result = "n/a";
      } else if (istringEqual("AlwaysOn", shadingControlType)){
        result = "n/a";
      } else if (istringEqual("OnIfHighSolarOnWindow", shadingControlType)){
        boost::optional<double> d = m_shadingControl->setpoint();
        if (d){
          std::stringstream ss;
          ss << *d;
          result = ss.str();
        } else{
        	// setting default in lux
          result = "5000";
        }
      } else if (istringEqual("OnIfScheduleAllows", shadingControlType)){
        boost::optional<openstudio::model::Schedule> schedule = m_shadingControl->schedule();
        if (schedule){
          result = schedule->name().get();
        } else{
          result = "";
        }
      } else{
        result = "n/a";
        LOG(Warn, "Unknown shadingControlType '" << shadingControlType << "' for ShadingControl '" << m_shadingControl->name().get() << "'.");
      }
    }

    return result;
  }
  openstudio::Transformation ShadingSurfaceGroup_Impl::buildingTransformation() const
  {
    Transformation transformation;

    if (istringEqual("Space", this->shadingSurfaceType())){

      boost::optional<Space> space = this->space();
      if (space){
        transformation = space->transformation() * this->transformation();
      }else{
        transformation = this->transformation();
      }

    }else if (istringEqual("Building", this->shadingSurfaceType())){

      transformation = this->transformation();

    }else if (istringEqual("Site", this->shadingSurfaceType())){

      boost::optional<Building> building = this->model().building();
      if (building){
        transformation = building->transformation().inverse() * this->transformation();
      }else{
        transformation = this->transformation();
      }

    }

    return transformation;
  }
Example #3
0
std::string ClimateZones::getDefaultDocumentName(const std::string& institution) {
  std::string result;
  if (istringEqual(institution,ClimateZones::ashraeInstitutionName())) {
    result = ClimateZones::ashraeDocumentName();
  }
  if (istringEqual(institution,ClimateZones::cecInstitutionName())) {
    result = ClimateZones::cecDocumentName();
  }
  return result;
}
Example #4
0
unsigned ClimateZones::getDefaultYear(const std::string& institution) {
  unsigned result(0);
  if (istringEqual(institution,ClimateZones::ashraeInstitutionName())) {
    result = ClimateZones::ashraeDefaultYear();
  }
  if (istringEqual(institution,ClimateZones::cecInstitutionName())) {
    result = ClimateZones::cecDefaultYear();
  }
  return result;
}
Example #5
0
  std::string WindowGroup::interiorShadeBSDF() const
  {
    std::string result = "air.xml";
    if (m_shadingControl){

      std::string shadingType = m_shadingControl->shadingType();
      if (istringEqual("InteriorShade", shadingType)){
        result = "05_shadecloth_light.xml";
      } else if (istringEqual("ExteriorShade", shadingType)){
        // shouldn't get here but use air if we do
      } else if (istringEqual("ExteriorScreen", shadingType)){
        // shouldn't get here but use air if we do
      } else if (istringEqual("InteriorBlind", shadingType)){
        result = "blinds.xml";
      } else if (istringEqual("ExteriorBlind", shadingType)){
        // shouldn't get here but use air if we do
      } else if (istringEqual("BetweenGlassShade", shadingType)){
        // shouldn't get here but use air if we do
      } else if (istringEqual("BetweenGlassBlind", shadingType)){
        // shouldn't get here but use air if we do
      } else if (istringEqual("SwitchableGlazing", shadingType)){
        // shouldn't get here but use air if we do
      } else if (istringEqual("InteriorDaylightRedirectionDevice", shadingType)){
        result = "1xliloX.xml";
      }else{
        LOG(Warn, "Unknown shadingType '" << shadingType << "' found for ShadingControl '" << m_shadingControl->name().get() << "'");
      }

    }
    return result;
  }
 void SetpointManagerFollowOutdoorAirTemperature_Impl::setReferenceTemperatureType(const std::string & value)
 {
   if( istringEqual(value,"OutdoorAirWetBulb") )
   {
     this->setString(OS_SetpointManager_FollowOutdoorAirTemperatureFields::ReferenceTemperatureType,"OutdoorAirWetBulb");
   }
   else if( istringEqual(value,"OutdoorAirDryBulb") )
   {
     this->setString(OS_SetpointManager_FollowOutdoorAirTemperatureFields::ReferenceTemperatureType,"OutdoorAirDryBulb");
   }
 }
  boost::optional<ParentObject> ShadingSurfaceGroup_Impl::parent() const
  {
    boost::optional<ParentObject> result;

    std::string shadingSurfaceType = this->shadingSurfaceType();
    if (istringEqual("Site", shadingSurfaceType)){
      result = this->model().getOptionalUniqueModelObject<Site>();
    }else if (istringEqual("Building", shadingSurfaceType)){
      result = this->model().building();
    }else if (istringEqual("Space", shadingSurfaceType)){
      result = this->space();
    }
    return result;
  }
 void SetpointManagerFollowOutdoorAirTemperature_Impl::setControlVariable(const std::string & value)
 {
   if( istringEqual(value,"Temperature") )
   {
     this->setString(OS_SetpointManager_FollowOutdoorAirTemperatureFields::ControlVariable,"Temperature");
   }
   else if( istringEqual(value,"MaximumTemperature") )
   {
     this->setString(OS_SetpointManager_FollowOutdoorAirTemperatureFields::ControlVariable,"MaximumTemperature");
   }
   else if( istringEqual(value,"MinimumTemperature") )
   {
     this->setString(OS_SetpointManager_FollowOutdoorAirTemperatureFields::ControlVariable,"MinimumTemperature");
   }
 }
Example #9
0
bool isCompatible(const ScheduleTypeLimits &parentLimits,
                  const ScheduleTypeLimits &candidate)
{
  if (candidate == parentLimits) {
    return true;
  }

  // check continuous/discrete
  if (OptionalString numericType = parentLimits.numericType()) {
    if (!candidate.numericType() || !istringEqual(candidate.numericType().get(),*numericType)) {
      return false;
    }
  }

  // check unit type
  std::string unitType = parentLimits.unitType();
  if (parentLimits.isUnitTypeDefaulted() || istringEqual("Dimensionless",unitType)) {
    if (!(candidate.isUnitTypeDefaulted() || (istringEqual("Dimensionless",candidate.unitType())))) {
      return false;
    }
  }
  else {
    if (!istringEqual(candidate.unitType(),unitType)) {
      return false;
    }
  }

  // check lower limit
  if (parentLimits.lowerLimitValue()) {
    if (!candidate.lowerLimitValue() ||
        (candidate.lowerLimitValue().get() < parentLimits.lowerLimitValue().get()))
    {
      return false;
    }
  }

  // check upper limit
  if (parentLimits.upperLimitValue()) {
    if (!candidate.upperLimitValue() ||
        (candidate.upperLimitValue().get() > parentLimits.upperLimitValue().get()))
    {
      return false;
    }
  }

  // passed all checks
  return true;
}
 boost::optional<double> PeopleDefinition_Impl::spaceFloorAreaperPerson() const {
   OptionalDouble value = getDouble(OS_People_DefinitionFields::SpaceFloorAreaperPerson,true);
   if (istringEqual("Area/Person", this->numberofPeopleCalculationMethod())) {
     OS_ASSERT(value);
   }
   return value;
 }
Example #11
0
void OSComboBox::onModelObjectChanged()
{
  OS_ASSERT(m_modelObject);

  QVariant variant = m_modelObject->getImpl<openstudio::model::detail::ModelObject_Impl>()->property(m_property.c_str());

  OS_ASSERT( variant.canConvert<std::string>() );

  std::string value = variant.value<std::string>();

  int i = 0;
  for( std::vector<std::string>::iterator it = m_values.begin();
       it < m_values.end();
       it++ )
  {
    if( istringEqual(*it,value) )
    {
      this->blockSignals(true);
      setCurrentIndex(i);
      this->blockSignals(false);
      break;
    }

    i++;
  }
}
boost::optional<IdfObject> ForwardTranslator::translateGas( Gas & modelObject )
{
  IdfObject idfObject( openstudio::IddObjectType::WindowMaterial_Gas);

  m_idfObjects.push_back(idfObject);

  idfObject.setString(WindowMaterial_GasFields::Name, modelObject.name().get());

  idfObject.setString(WindowMaterial_GasFields::GasType, modelObject.gasType());

  idfObject.setDouble(WindowMaterial_GasFields::Thickness, modelObject.thickness());

  if (istringEqual("Custom", modelObject.gasType())){

    if (modelObject.customConductivityCoefficientA()){
      idfObject.setDouble(WindowMaterial_GasFields::ConductivityCoefficientA, modelObject.customConductivityCoefficientA().get());
    }else{
      LOG(Error, "Missing required input 'Conductivity Coefficient A' for WindowMaterial:Gas named '" << modelObject.name().get() << "'");
    }

    if (modelObject.customConductivityCoefficientB()){
      idfObject.setDouble(WindowMaterial_GasFields::ConductivityCoefficientB, modelObject.customConductivityCoefficientB().get());
    }else{
      LOG(Error, "Missing required input 'Conductivity Coefficient B' for WindowMaterial:Gas named '" << modelObject.name().get() << "'");
    }

    if (modelObject.customViscosityCoefficientA()){
      idfObject.setDouble(WindowMaterial_GasFields::ViscosityCoefficientA, modelObject.customViscosityCoefficientA().get());
    }else{
      LOG(Error, "Missing required input 'Viscosity Coefficient A' for WindowMaterial:Gas named '" << modelObject.name().get() << "'");
    }

    if (modelObject.customViscosityCoefficientB()){
      idfObject.setDouble(WindowMaterial_GasFields::ViscosityCoefficientB, modelObject.customViscosityCoefficientB().get());
    }else{
      LOG(Error, "Missing required input 'Viscosity Coefficient B' for WindowMaterial:Gas named '" << modelObject.name().get() << "'");
    }

    if (modelObject.customSpecificHeatCoefficientA()){
      idfObject.setDouble(WindowMaterial_GasFields::SpecificHeatCoefficientA, modelObject.customSpecificHeatCoefficientA().get());
    }else{
      LOG(Error, "Missing required input 'Specific Heat Coefficient A' for WindowMaterial:Gas named '" << modelObject.name().get() << "'");
    }

    if (modelObject.customSpecificHeatCoefficientB()){
      idfObject.setDouble(WindowMaterial_GasFields::SpecificHeatCoefficientB, modelObject.customSpecificHeatCoefficientB().get());
    }else{
      LOG(Error, "Missing required input 'Specific Heat Coefficient B' for WindowMaterial:Gas named '" << modelObject.name().get() << "'");
    }

    if (modelObject.customMolecularWeight()){
      idfObject.setDouble(WindowMaterial_GasFields::MolecularWeight, modelObject.customMolecularWeight().get());
    }else{
      LOG(Error, "Missing required input 'Molecular Weight' for WindowMaterial:Gas named '" << modelObject.name().get() << "'");
    }

  }

  return boost::optional<IdfObject>(idfObject);
}
 boost::optional<double> PeopleDefinition_Impl::peopleperSpaceFloorArea() const {
   OptionalDouble value = getDouble(OS_People_DefinitionFields::PeopleperSpaceFloorArea,true);
   if (istringEqual("People/Area", this->numberofPeopleCalculationMethod())) {    
     OS_ASSERT(value);
   }
   return value;
 }
Example #14
0
  bool SetpointManager_Impl::addToNode(Node & node)
  {
    if( node.model() != this->model() )
    {
      return false;
    }

    std::vector<SetpointManager> _setpointManagers = node.setpointManagers();
    if( !_setpointManagers.empty() )
    {
      for(auto it = _setpointManagers.begin();
        it != _setpointManagers.end();
        ++it)
      {
        if( istringEqual(this->controlVariable(), it->controlVariable()) )
        {
          it->remove();
        }
      }
    }

    if( OptionalAirLoopHVAC airLoop = node.airLoopHVAC() )
    {
      if( airLoop->supplyComponent(node.handle()) )
      {
        return this->setSetpointNode(node);
      }
      if(OptionalAirLoopHVACOutdoorAirSystem oaSystem = airLoop->airLoopHVACOutdoorAirSystem())
      {
        return this->setSetpointNode(node);
      }
    }
    return false;
  }
Example #15
0
  boost::optional<double> Building_Impl::conditionedFloorArea() const
  {
    boost::optional<double> result;

    for (const ThermalZone& thermalZone : thermalZones()){
      boost::optional<std::string> isConditioned = thermalZone.isConditioned();

      if (isConditioned) {

        if (!result){
          result = 0;
        }

        if (istringEqual("Yes", *isConditioned)){
          for (const Space& space : thermalZone.spaces()){
            bool partofTotalFloorArea = space.partofTotalFloorArea();
            if (partofTotalFloorArea) {
              result = *result + space.multiplier() * space.floorArea();
            }
          }
        }
      }
    }

    return result;
  }
  OptionalModelObject ReverseTranslator::translateZoneAirMassFlowConservation(const WorkspaceObject & workspaceObject)
{
  if (workspaceObject.iddObject().type() != IddObjectType::ZoneAirMassFlowConservation){
    LOG(Error, "WorkspaceObject is not IddObjectType: ZoneAirMassFlowConservation");
    return boost::none;
  }

  openstudio::model::ZoneAirMassFlowConservation result = m_model.getUniqueModelObject<ZoneAirMassFlowConservation>();

  OptionalString s = workspaceObject.getString(openstudio::ZoneAirMassFlowConservationFields::AdjustZoneMixingForZoneAirMassFlowBalance, true);
  if (s){
    if (istringEqual("Yes", *s)){
      result.setAdjustZoneMixingForZoneAirMassFlowBalance(true);
    } else{
      result.setAdjustZoneMixingForZoneAirMassFlowBalance(false);
    }
  }

  s = workspaceObject.getString(openstudio::ZoneAirMassFlowConservationFields::InfiltrationBalancingMethod, true);
  if (s){
    result.setSourceZoneInfiltrationTreatment(*s);
  }

  return result;
}
 boost::optional<Schedule> SolarCollectorPerformancePhotovoltaicThermalSimple_Impl::thermalConversionEfficiencySchedule() const {
   boost::optional<Schedule> result;
   if (istringEqual("Scheduled", thermalConversionEfficiencyInputModeType())){
     result = getObject<ModelObject>().getModelObjectTarget<Schedule>(OS_SolarCollectorPerformance_PhotovoltaicThermal_SimpleFields::ThermalConversionEfficiencyScheduleName);
   }
   return result;
 }
Example #18
0
void OSComboBox2::onModelObjectChanged() {
  OS_ASSERT(m_modelObject);

  OptionalString oValue;
  if (m_get) {
    oValue = (*m_get)();
  }
  else {
    OS_ASSERT(m_getOptional);
    oValue = (*m_getOptional)();
  }

  std::string value;
  if (oValue) {
    value = *oValue;
  }

  int i = 0;
  for( std::vector<std::string>::iterator it = m_values.begin();
       it < m_values.end();
       it++ )
  {
    if( istringEqual(*it,value) )
    {
      this->blockSignals(true);
      setCurrentIndex(i);
      this->blockSignals(false);
      break;
    }

    i++;
  }
}
Example #19
0
void OSComboBox2::onCurrentIndexChanged(const QString & text)
{
  OS_ASSERT(m_modelObject);
  OS_ASSERT(m_set); // should only be enabled if there is a setter

  std::string value = text.toStdString();
  (*m_set)(value);

  // test if property changed
  OptionalString oValue;
  if (m_get) {
    oValue = (*m_get)();
  }
  else {
    OS_ASSERT(m_getOptional);
    oValue = (*m_getOptional)();
  }
  std::string actualValue;
  if (oValue) {
    actualValue = *oValue;
  }

  if (!istringEqual(actualValue, value)) {
    // failed, reset combo box
    onModelObjectChanged();
  }
}
Example #20
0
std::vector<std::string> ClimateZones::validClimateZoneValues(const std::string& institution, 
                                                              unsigned year) 
{
  StringVector result;
  if (istringEqual(institution,ashraeInstitutionName())) {
    if (year == 2006) {
      result.push_back("1A");
      result.push_back("1B");
      result.push_back("2A");
      result.push_back("2B");
      result.push_back("3A");
      result.push_back("3B");
      result.push_back("3C");
      result.push_back("4A");
      result.push_back("4B");
      result.push_back("4C");
      result.push_back("5A");
      result.push_back("5B");
      result.push_back("5C");
      result.push_back("6A");
      result.push_back("6B");
      result.push_back("7");
      result.push_back("8");
    }
  }

  if (istringEqual(institution,cecInstitutionName())) {
    result.push_back("1");
    result.push_back("2");
    result.push_back("3");
    result.push_back("4");
    result.push_back("5");
    result.push_back("6");
    result.push_back("7");
    result.push_back("8");
    result.push_back("9");
    result.push_back("10");
    result.push_back("11");
    result.push_back("12");
    result.push_back("13");
    result.push_back("14");
    result.push_back("15");
    result.push_back("16");
  }

  return result;
}
OptionalModelObject ReverseTranslator::translateAirTerminalSingleDuctUncontrolled( const WorkspaceObject & workspaceObject )
{
  if( workspaceObject.iddObject().type() != IddObjectType::AirTerminal_SingleDuct_Uncontrolled )
  {
     LOG(Error, "WorkspaceObject is not IddObjectType: AirTerminal_SingleDuct_Uncontrolled");
     return boost::none;
  }

  boost::optional<WorkspaceObject> wo = workspaceObject.getTarget(AirTerminal_SingleDuct_UncontrolledFields::AvailabilityScheduleName);
  boost::optional<Schedule> schedule;
  boost::optional<AirTerminalSingleDuctUncontrolled> airTerminal;
  boost::optional<double> value;

  if( wo )
  {
    boost::optional<ModelObject> mo = translateAndMapWorkspaceObject(wo.get());
    if( mo )
    {
      if( ! (schedule = mo->optionalCast<Schedule>()) )
      {
        LOG(Error, workspaceObject.briefDescription() << " does not have an associated availability schedule");

        return boost::none;
      }
    }
  }

  if( schedule )
  {
    airTerminal = AirTerminalSingleDuctUncontrolled(m_model,schedule.get());
  }

  if( airTerminal )
  {
    boost::optional<std::string> s = workspaceObject.getString(AirTerminal_SingleDuct_UncontrolledFields::Name);
    if( s )
    {
      airTerminal->setName(s.get());
    }

    s = workspaceObject.getString(AirTerminal_SingleDuct_UncontrolledFields::MaximumAirFlowRate);
    if( s && istringEqual(s.get(),"AutoSize") )
    {
      airTerminal->autosizeMaximumAirFlowRate();
    }
    else if( (value = workspaceObject.getDouble(AirTerminal_SingleDuct_UncontrolledFields::MaximumAirFlowRate)) )
    {
      airTerminal->setMaximumAirFlowRate(value.get());
    }

    return airTerminal.get();
  }
  else
  {
    LOG(Error, "Unknown error translating " << workspaceObject.briefDescription());

    return boost::none;
  }
}
 boost::optional<double> InternalMassDefinition_Impl::surfaceAreaperSpaceFloorArea() const {
   boost::optional<double> result;
   if (istringEqual("SurfaceArea/Area", this->designLevelCalculationMethod())){
     result = getDouble(OS_InternalMass_DefinitionFields::SurfaceAreaperSpaceFloorArea, true);
     //OS_ASSERT(result);
   }
   return result;
 }
 boost::optional<double> LightsDefinition_Impl::wattsperPerson() const {
   boost::optional<double> result;
   if (istringEqual("Watts/Person", this->designLevelCalculationMethod())){
     result = getDouble(OS_Lights_DefinitionFields::WattsperPerson,true);
     //OS_ASSERT(result);
   }
   return result;
 }
 boost::optional<double> LightsDefinition_Impl::lightingLevel() const {
   boost::optional<double> result;
   if (istringEqual("LightingLevel", this->designLevelCalculationMethod())){
     result = getDouble(OS_Lights_DefinitionFields::LightingLevel,true);
     //OS_ASSERT(result);
   }
   return result;
 }
 boost::optional<double> ElectricEquipmentDefinition_Impl::designLevel() const {
   boost::optional<double> result;
   if (istringEqual("EquipmentLevel", this->designLevelCalculationMethod())){
     result = getDouble(OS_ElectricEquipment_DefinitionFields::DesignLevel,true);
     //OS_ASSERT(result);
   }
   return result;
 }
 boost::optional<double> ElectricEquipmentDefinition_Impl::wattsperSpaceFloorArea() const {
   boost::optional<double> result;
   if (istringEqual("Watts/Area", this->designLevelCalculationMethod())){
     result = getDouble(OS_ElectricEquipment_DefinitionFields::WattsperSpaceFloorArea,true);
     //OS_ASSERT(result);
   }
   return result;
 }
Example #27
0
bool IstringFind::operator()(const std::string& other) const
{
  for (const std::string& target : m_targets){
    if (istringEqual(target, other)){
      return true;
    }
  }
  return false;
}
Example #28
0
  bool ScheduleRule_Impl::containsDate(const openstudio::Date& date) {
    bool result = false;

    // need to check or adjust assumed base year on input date?

    boost::optional<std::string> dateSpecificationType = this->getString(OS_Schedule_RuleFields::DateSpecificationType, true);
    OS_ASSERT(dateSpecificationType);
    if (istringEqual("DateRange", *dateSpecificationType)){
      boost::optional<openstudio::Date> startDate = this->startDate();
      OS_ASSERT(startDate);
      boost::optional<openstudio::Date> endDate = this->endDate();
      OS_ASSERT(endDate);
      if (*startDate <= *endDate){
        result = ((date >= *startDate) && (date <= *endDate));
      }else{
        result = ((date >= *startDate) || (date <= *endDate));
      }
    }else{
      std::vector<openstudio::Date> specificDates = this->specificDates();
      for (const openstudio::Date& specificDate : specificDates){
        if (specificDate == date){
          result = true;
          break;
        }
      }
    }

    if (result){
      switch (date.dayOfWeek().value()){
        case DayOfWeek::Sunday:
          result = this->applySunday();
          break;
        case DayOfWeek::Monday:
          result = this->applyMonday();
          break;
        case DayOfWeek::Tuesday:
          result = this->applyTuesday();
          break;
        case DayOfWeek::Wednesday:
          result = this->applyWednesday();
          break;
        case DayOfWeek::Thursday:
          result = this->applyThursday();
          break;
        case DayOfWeek::Friday:
          result = this->applyFriday();
          break;
        case DayOfWeek::Saturday:
          result = this->applySaturday();
          break;
        default:
          OS_ASSERT(false);
      }
    }

    return result;
  }
Example #29
0
 std::vector<IddObject> IddFile_Impl::getObjectsInGroup(const std::string& group) const {
   IddObjectVector result;
   for (const IddObject& object : m_objects){
     if(istringEqual(object.group(), group)){
       result.push_back(object);
     }
   }
   return result;
 }
Example #30
0
  TIDItem(const QDomElement & element, TIDItem * parent = nullptr)
  {
    m_parentItem = parent;

    QString tagName = element.tagName();

    if( istringEqual(tagName.toStdString(),"term") )
    {
      QString tidName = element.firstChildElement("name").text();

      m_itemData.push_back(tidName);

      int tid = element.firstChildElement("tid").text().toInt();

      m_itemData.push_back(tid);
    }
    else if( istringEqual(tagName.toStdString(),"taxonomy") )
    {
      m_itemData.push_back("Taxonomy");

      m_itemData.push_back(0);
    }

    QDomNodeList children = element.childNodes();

    for( int i = 0;
         i < children.length();
         i++ )
    {
      QDomNode childNode = children.at(i);

      if( childNode.isElement() )
      {
        QDomElement childElement = childNode.toElement();

        if( istringEqual(childElement.tagName().toStdString(),"term") )
        {
          auto childItem = new TIDItem(childElement,this);

          m_childItems.append(childItem);
        }
      }
    }
  }