public static InternalCondition ToSAM_InternalCondtion(this ProgramType programType) { if (programType == null) { return(null); } InternalCondition result = new InternalCondition(programType.DisplayName); People people = programType.People; if (people != null) { result.SetValue(Analytical.InternalConditionParameter.OccupancyProfileName, Core.LadybugTools.Query.Identifier(people.OccupancySchedule)); } Lighting lighting = programType.Lighting; if (lighting != null) { result.SetValue(Analytical.InternalConditionParameter.LightingProfileName, Core.LadybugTools.Query.Identifier(lighting.Schedule)); } ElectricEquipment electricEquipment = programType.ElectricEquipment; if (electricEquipment != null) { result.SetValue(Analytical.InternalConditionParameter.EquipmentSensibleProfileName, Core.LadybugTools.Query.Identifier(electricEquipment.Schedule)); } Infiltration infiltration = programType.Infiltration; if (infiltration != null) { result.SetValue(Analytical.InternalConditionParameter.InfiltrationProfileName, Core.LadybugTools.Query.Identifier(infiltration.Schedule)); } Setpoint setPoint = programType.Setpoint; if (setPoint != null) { result.SetValue(Analytical.InternalConditionParameter.CoolingProfileName, Core.LadybugTools.Query.Identifier(setPoint.CoolingSchedule)); result.SetValue(Analytical.InternalConditionParameter.HeatingProfileName, Core.LadybugTools.Query.Identifier(setPoint.HeatingSchedule)); } return(result); }
public static Space ToSAM(this Room room, IEnumerable <InternalCondition> internalConditions = null) { if (room == null) { return(null); } Geometry.Spatial.Point3D location = null; double area = double.NaN; double volume = double.NaN; Geometry.Spatial.Shell shell = Geometry.LadybugTools.Query.Shell(room); if (shell != null) { location = shell.InternalPoint3D(); area = Geometry.Spatial.Query.Area(shell, 0.1); volume = Geometry.Spatial.Query.Volume(shell); } Space result = new Space(room.DisplayName, location); if (!double.IsNaN(area)) { result.SetValue(SpaceParameter.Area, area); } if (!double.IsNaN(volume)) { result.SetValue(SpaceParameter.Volume, volume); } result.SetValue(SpaceParameter.LevelName, room.Story); string programType = room.Properties?.Energy?.ProgramType; if (!string.IsNullOrWhiteSpace(programType)) { InternalCondition internalCondition = null; if (internalConditions != null) { foreach (InternalCondition internalCondition_Temp in internalConditions) { if (internalCondition_Temp.Name == programType) { internalCondition = internalCondition_Temp; break; } } } if (internalCondition == null) { internalCondition = new InternalCondition(programType); } if (internalCondition != null && !double.IsNaN(volume)) { if (internalCondition.TryGetValue(InternalConditionParameter.FlowPerExteriorArea, out double flowPerExteriorArea)) { internalCondition = new InternalCondition(System.Guid.NewGuid(), internalCondition); double exteriorArea = Geometry.LadybugTools.Query.ExteriorArea(room); double flow = flowPerExteriorArea * exteriorArea; internalCondition.SetValue(Analytical.InternalConditionParameter.InfiltrationAirChangesPerHour, flow / volume * 3600); } } if (!double.IsNaN(area) && internalCondition.TryGetValue(InternalConditionParameter.TotalMetabolicRatePerPerson, out double totalMetabolicRate) && internalCondition.TryGetValue(Analytical.InternalConditionParameter.AreaPerPerson, out double areaPerPerson)) { double people = area / areaPerPerson; double occupancyLatentGainPerPerson = 0; double occupancySensibleGainPerPerson = 0; if (internalCondition.TryGetValue(InternalConditionParameter.LatentFraction, out double latentFraction)) { occupancyLatentGainPerPerson = totalMetabolicRate * latentFraction; occupancySensibleGainPerPerson = totalMetabolicRate * (1 - latentFraction); } else { //2021-XI-16 if latent is missin or autocalcutlate zero will be used in Tas! custom specific settings occupancySensibleGainPerPerson = totalMetabolicRate; } internalCondition.SetValue(Analytical.InternalConditionParameter.OccupancyLatentGainPerPerson, occupancyLatentGainPerPerson); internalCondition.SetValue(Analytical.InternalConditionParameter.OccupancySensibleGainPerPerson, occupancySensibleGainPerPerson); } result.InternalCondition = internalCondition; } return(result); }
public static InternalCondition ToSAM_InternalCondition(this ProgramTypeAbridged programTypeAbridged, ModelEnergyProperties modelEnergyProperties) { if (programTypeAbridged == null) { return(null); } InternalCondition result = new InternalCondition(programTypeAbridged.Identifier); PeopleAbridged peopleAbridged = programTypeAbridged.People; if (peopleAbridged != null) { result.SetValue(Analytical.InternalConditionParameter.OccupancyProfileName, peopleAbridged.OccupancySchedule); result.SetValue(Analytical.InternalConditionParameter.AreaPerPerson, 1 / peopleAbridged.PeoplePerArea); if (modelEnergyProperties != null) { IEnumerable <HoneybeeSchema.Energy.ISchedule> schedules = modelEnergyProperties.ScheduleList; if (schedules != null) { foreach (HoneybeeSchema.Energy.ISchedule schedule in schedules) { if (schedule.Identifier == peopleAbridged.ActivitySchedule) { Profile profile = schedule.ToSAM(ProfileType.Other); if (profile != null) { result.SetValue(InternalConditionParameter.TotalMetabolicRatePerPerson, profile.MaxValue); } } } } } result.SetValue(Analytical.InternalConditionParameter.OccupancyRadiantProportion, peopleAbridged.RadiantFraction); result.SetValue(Analytical.InternalConditionParameter.OccupancyViewCoefficient, 0.227); //TODDO: Implement proper OccupancyViewCoefficient if (peopleAbridged.LatentFraction != null && peopleAbridged.LatentFraction.Obj is double) { result.SetValue(InternalConditionParameter.LatentFraction, (double)peopleAbridged.LatentFraction.Obj); //TODO: Recalculate value per space } } LightingAbridged lightingAbridged = programTypeAbridged.Lighting; if (lightingAbridged != null) { result.SetValue(Analytical.InternalConditionParameter.LightingProfileName, lightingAbridged.Schedule); result.SetValue(Analytical.InternalConditionParameter.LightingGainPerArea, lightingAbridged.WattsPerArea); result.SetValue(Analytical.InternalConditionParameter.LightingRadiantProportion, lightingAbridged.RadiantFraction); result.SetValue(Analytical.InternalConditionParameter.LightingViewCoefficient, lightingAbridged.VisibleFraction); } ElectricEquipmentAbridged electricEquipmentAbridged = programTypeAbridged.ElectricEquipment; if (electricEquipmentAbridged != null) { result.SetValue(Analytical.InternalConditionParameter.EquipmentSensibleProfileName, electricEquipmentAbridged.Schedule); result.SetValue(Analytical.InternalConditionParameter.EquipmentSensibleGainPerArea, electricEquipmentAbridged.WattsPerArea); result.SetValue(Analytical.InternalConditionParameter.EquipmentRadiantProportion, electricEquipmentAbridged.RadiantFraction); result.SetValue(Analytical.InternalConditionParameter.EquipmentViewCoefficient, 0.372); //TODDO: Implement proper EquipmentViewCoefficient } InfiltrationAbridged infiltrationAbridged = programTypeAbridged.Infiltration; if (infiltrationAbridged != null) { result.SetValue(Analytical.InternalConditionParameter.InfiltrationProfileName, infiltrationAbridged.Schedule); result.SetValue(InternalConditionParameter.FlowPerExteriorArea, infiltrationAbridged.FlowPerExteriorArea); //TODO: Recalculate value per space } SetpointAbridged setPoint = programTypeAbridged.Setpoint; if (setPoint != null) { result.SetValue(Analytical.InternalConditionParameter.CoolingProfileName, setPoint.CoolingSchedule); result.SetValue(Analytical.InternalConditionParameter.HeatingProfileName, setPoint.HeatingSchedule); } VentilationAbridged ventilationAbridged = programTypeAbridged.Ventilation; if (ventilationAbridged != null) { result.SetValue(Analytical.InternalConditionParameter.SupplyAirFlow, ventilationAbridged.FlowPerZone); result.SetValue(Analytical.InternalConditionParameter.SupplyAirFlowPerArea, ventilationAbridged.FlowPerArea); result.SetValue(Analytical.InternalConditionParameter.SupplyAirFlowPerPerson, ventilationAbridged.FlowPerPerson); result.SetValue(Analytical.InternalConditionParameter.ExhaustAirFlow, ventilationAbridged.FlowPerZone); result.SetValue(Analytical.InternalConditionParameter.ExhaustAirFlowPerArea, ventilationAbridged.FlowPerArea); result.SetValue(Analytical.InternalConditionParameter.ExhaustAirFlowPerPerson, ventilationAbridged.FlowPerPerson); } return(result); }
public static InternalCondition ToSAM(this TBD.InternalCondition internalCondition, double area = double.NaN) { if (internalCondition == null) { return(null); } InternalCondition result = new InternalCondition(internalCondition.name); TBD.Emitter emitter = null; emitter = internalCondition.GetHeatingEmitter(); if (emitter != null) { result.SetValue(InternalConditionParameter.HeatingEmitterRadiantProportion, emitter.radiantProportion); result.SetValue(InternalConditionParameter.HeatingEmitterCoefficient, emitter.viewCoefficient); } emitter = internalCondition.GetCoolingEmitter(); if (emitter != null) { result.SetValue(InternalConditionParameter.CoolingEmitterRadiantProportion, emitter.radiantProportion); result.SetValue(InternalConditionParameter.CoolingEmitterCoefficient, emitter.viewCoefficient); } TBD.InternalGain internalGain = internalCondition.GetInternalGain(); if (internalGain != null) { result.SetValue(InternalConditionParameter.LightingRadiantProportion, internalGain.lightingRadProp); result.SetValue(InternalConditionParameter.OccupancyRadiantProportion, internalGain.occupantRadProp); result.SetValue(InternalConditionParameter.EquipmentRadiantProportion, internalGain.equipmentRadProp); result.SetValue(InternalConditionParameter.LightingViewCoefficient, internalGain.lightingViewCoefficient); result.SetValue(InternalConditionParameter.OccupancyViewCoefficient, internalGain.occupantViewCoefficient); result.SetValue(InternalConditionParameter.EquipmentViewCoefficient, internalGain.equipmentViewCoefficient); TBD.profile profile_TBD = null; profile_TBD = internalGain.GetProfile((int)TBD.Profiles.ticI); if (profile_TBD != null) { result.SetValue(InternalConditionParameter.InfiltrationProfileName, string.Format("{0} [{1}]", internalCondition.name, profile_TBD.name)); result.SetValue(InternalConditionParameter.InfiltrationAirChangesPerHour, profile_TBD.GetExtremeValue(true)); } profile_TBD = internalGain.GetProfile((int)TBD.Profiles.ticLG); if (profile_TBD != null) { result.SetValue(InternalConditionParameter.LightingProfileName, string.Format("{0} [{1}]", internalCondition.name, profile_TBD.name)); result.SetValue(InternalConditionParameter.LightingGainPerArea, profile_TBD.GetExtremeValue(true)); result.SetValue(InternalConditionParameter.LightingLevel, internalGain.targetIlluminance); } double personGain = internalGain.personGain; double gain = 0; profile_TBD = internalGain.GetProfile((int)TBD.Profiles.ticOSG); if (profile_TBD != null) { double value = profile_TBD.GetExtremeValue(true); result.SetValue(InternalConditionParameter.OccupancySensibleGainPerPerson, value); gain += value; } profile_TBD = internalGain.GetProfile((int)TBD.Profiles.ticOLG); if (profile_TBD != null) { double value = profile_TBD.GetExtremeValue(true); result.SetValue(InternalConditionParameter.OccupancyProfileName, string.Format("{0} [{1}]", internalCondition.name, profile_TBD.name)); result.SetValue(InternalConditionParameter.OccupancyLatentGainPerPerson, value); gain += value; } if (!double.IsNaN(area) && !double.IsNaN(gain)) { double occupancy = (gain * area) / personGain; result.SetValue(InternalConditionParameter.AreaPerPerson, area / occupancy); } profile_TBD = internalGain.GetProfile((int)TBD.Profiles.ticESG); if (profile_TBD != null) { result.SetValue(InternalConditionParameter.EquipmentSensibleProfileName, string.Format("{0} [{1}]", internalCondition.name, profile_TBD.name)); result.SetValue(InternalConditionParameter.EquipmentSensibleGainPerArea, profile_TBD.GetExtremeValue(true)); } profile_TBD = internalGain.GetProfile((int)TBD.Profiles.ticELG); if (profile_TBD != null) { result.SetValue(InternalConditionParameter.EquipmentLatentProfileName, string.Format("{0} [{1}]", internalCondition.name, profile_TBD.name)); result.SetValue(InternalConditionParameter.EquipmentLatentGainPerArea, profile_TBD.GetExtremeValue(true)); } profile_TBD = internalGain.GetProfile((int)TBD.Profiles.ticCOG); if (profile_TBD != null) { result.SetValue(InternalConditionParameter.PollutantProfileName, string.Format("{0} [{1}]", internalCondition.name, profile_TBD.name)); result.SetValue(InternalConditionParameter.PollutantGenerationPerArea, profile_TBD.GetExtremeValue(true)); } } TBD.Thermostat thermostat = internalCondition.GetThermostat(); if (internalGain != null) { TBD.profile profile_TBD = null; profile_TBD = thermostat.GetProfile((int)TBD.Profiles.ticUL); if (profile_TBD != null) { result.SetValue(InternalConditionParameter.CoolingProfileName, string.Format("{0} [{1}]", internalCondition.name, profile_TBD.name)); } profile_TBD = thermostat.GetProfile((int)TBD.Profiles.ticLL); if (profile_TBD != null) { result.SetValue(InternalConditionParameter.HeatingProfileName, string.Format("{0} [{1}]", internalCondition.name, profile_TBD.name)); } profile_TBD = thermostat.GetProfile((int)TBD.Profiles.ticHLL); if (profile_TBD != null) { result.SetValue(InternalConditionParameter.HumidificationProfileName, string.Format("{0} [{1}]", internalCondition.name, profile_TBD.name)); } profile_TBD = thermostat.GetProfile((int)TBD.Profiles.ticHUL); if (profile_TBD != null) { result.SetValue(InternalConditionParameter.DehumidificationProfileName, string.Format("{0} [{1}]", internalCondition.name, profile_TBD.name)); } } return(result); }