public override void Process() { result = new BoolResult(); result.Result = false; try { result.Result = ProfileLibrary.GenerateProfileData(featureClass, profileSource, tableName); } catch (Exception ex) { result.Exception = ex; } }
// create a list of questions asked public void Awake() { if (Instance == null) { Instance = this; this.characters = CharacterLibrary.LoadCharacters(); ProfileLibrary.AssignProfiles(this.characters.Values.ToList()); CharacterLibrary.AssignAffinities(characters.Values.ToList()); debugs = new InspectorCharacter[7]; this.rounds = new MurderProfile[3]; this.currentRound = 0; askedQuestions = new List <AskedQuestion>(); } }
public static ProfileLibrary ToSAM_ProfileLibrary(this TBD.Building building) { List <Profile> profiles = building?.ToSAM_Profiles(); if (profiles == null) { return(null); } ProfileLibrary result = new ProfileLibrary(building.name); profiles.ForEach(x => result.Add(x)); return(result); }
public string GetAnswerText() { if (type == QuestionType.tool) { return(ProfileLibrary.GetWeapon(answerID)); } else if (type == QuestionType.place) { return(ProfileLibrary.GetLocation(answerID)); } else { return(ProfileLibrary.GetOpccupation(answerID)); } }
public static AnalyticalModel ToSAM_AnalyticalModel(this TBD.Building building) { if (building == null) { return(null); } ProfileLibrary profileLibrary = building.ToSAM_ProfileLibrary(); Core.MaterialLibrary materialLibrary = building.ToSAM_MaterialLibrary(); Core.Location location = new Core.Location(building.name, building.longitude, building.latitude, 0); location.SetValue(Core.LocationParameter.TimeZone, Core.Query.Description(Core.Query.UTC(building.timeZone))); Core.Address address = new Core.Address(null, null, null, Core.CountryCode.Undefined); return(new AnalyticalModel(building.name, null, location, address, ToSAM(building), materialLibrary, profileLibrary)); }
public override void Process() { result = new BoolResult(); result.Result = false; try { IEnumerable <string> mesasges = null; result.Result = ProfileLibrary.GenerateProfileData(featureClass, profileSource, tableName, mesasges); if (mesasges != null && mesasges.Any()) { mesasges.ToList().ForEach(m => logger.InfoEx(m)); } } catch (Exception ex) { result.Exception = ex; } }
public static ProfileLibrary ToSAM_ProfileLibrary(this ModelEnergyProperties modelEnergyProperties) { if (modelEnergyProperties == null) { return(null); } IEnumerable <IProgramtype> programTypes = modelEnergyProperties.ProgramTypeList; if (programTypes == null) { return(null); } IEnumerable <ISchedule> schedules = modelEnergyProperties.ScheduleList; ProfileLibrary result = new ProfileLibrary(string.Empty); foreach (IProgramtype programType in programTypes) { List <Profile> profiles = null; if (programType is ProgramTypeAbridged) { profiles = ((ProgramTypeAbridged)programType).ToSAM_Profiles(schedules); } else if (programType is ProgramType) { profiles = ((ProgramType)programType).ToSAM_Profiles(); } if (profiles != null) { foreach (Profile profile in profiles) { result.Add(profile); } } } return(result); }
public static TBD.zone UpdateZone(this TBD.Building building, TBD.zone zone, Space space, ProfileLibrary profileLibrary) { if (space == null || profileLibrary == null || building == null || zone == null) { return(null); } TBD.InternalCondition internalCondition_TBD = AddInternalCondition(building, space, profileLibrary); if (internalCondition_TBD == null) { return(null); } zone.AssignIC(internalCondition_TBD, true); List <string> values = new List <string>(); //TODO: Update [Id] to [Element Id] if (space.TryGetValue("Element Id", out string id)) { if (!string.IsNullOrWhiteSpace(id)) { values.Add(string.Format("[Id]={0}", id)); } } //TODO: Update [LevelName] to [Level Name] if (space.TryGetValue(SpaceParameter.LevelName, out string levelName)) { if (!string.IsNullOrWhiteSpace(levelName)) { values.Add(string.Format("[LevelName]={0}", levelName)); } } if (values != null && values.Count > 0) { zone.description = string.Join("; ", values); } return(zone); }
public static Model ToLadybugTools(this AnalyticalModel analyticalModel, double silverSpacing = Tolerance.MacroDistance, double tolerance = Tolerance.Distance) { if (analyticalModel == null) { return(null); } AnalyticalModel analyticalModel_Temp = new AnalyticalModel(analyticalModel); analyticalModel_Temp.OffsetAperturesOnEdge(0.1, tolerance); analyticalModel_Temp.ReplaceTransparentPanels(0.1); string uniqueName = Core.LadybugTools.Query.UniqueName(analyticalModel_Temp); AdjacencyCluster adjacencyCluster = analyticalModel_Temp.AdjacencyCluster; List <Room> rooms = null; List <AnyOf <IdealAirSystemAbridged, VAV, PVAV, PSZ, PTAC, ForcedAirFurnace, FCUwithDOASAbridged, WSHPwithDOASAbridged, VRFwithDOASAbridged, FCU, WSHP, VRF, Baseboard, EvaporativeCooler, Residential, WindowAC, GasUnitHeater> > hvacs = null; List <Space> spaces = adjacencyCluster?.GetSpaces(); if (spaces != null) { hvacs = new List <AnyOf <IdealAirSystemAbridged, VAV, PVAV, PSZ, PTAC, ForcedAirFurnace, FCUwithDOASAbridged, WSHPwithDOASAbridged, VRFwithDOASAbridged, FCU, WSHP, VRF, Baseboard, EvaporativeCooler, Residential, WindowAC, GasUnitHeater> >(); rooms = new List <Room>(); Dictionary <double, List <Panel> > dictionary_elevations = Analytical.Query.MinElevationDictionary(adjacencyCluster.GetPanels(), true); List <Level> levels = dictionary_elevations?.Keys.ToList().ConvertAll(x => Architectural.Create.Level(x)); for (int i = 0; i < spaces.Count; i++) { Space space = spaces[i]; if (space == null) { continue; } Room room = space.ToLadybugTools(analyticalModel_Temp, silverSpacing, tolerance); if (room == null) { continue; } if (levels != null && levels.Count > 0) { double elevation_Min = space.MinElevation(adjacencyCluster); if (!double.IsNaN(elevation_Min)) { double difference_Min = double.MaxValue; Level level_Min = null; foreach (Level level in levels) { double difference = System.Math.Abs(elevation_Min - level.Elevation); if (difference < difference_Min) { difference_Min = difference; level_Min = level; } } room.Story = level_Min.Name; } } InternalCondition internalCondition = space.InternalCondition; if (internalCondition != null) { //Michal Idea of filtering Uncondition Spaces string name_InternalCondition = internalCondition.Name; if (name_InternalCondition == null || (name_InternalCondition != null && !name_InternalCondition.ToLower().Contains("unconditioned") && !name_InternalCondition.ToLower().Contains("external"))) { IdealAirSystemAbridged idealAirSystemAbridged = new IdealAirSystemAbridged(string.Format("{0}__{1}", i.ToString(), "IdealAir"), string.Format("Ideal Air System Abridged {0}", space.Name)); hvacs.Add(idealAirSystemAbridged); if (room.Properties == null) { room.Properties = new RoomPropertiesAbridged(); } if (room.Properties.Energy == null) { room.Properties.Energy = new RoomEnergyPropertiesAbridged(); } room.Properties.Energy.Hvac = idealAirSystemAbridged.Identifier; } } rooms.Add(room); } } List <Shade> shades = null; List <Face> faces_Orphaned = null; List <Panel> panels_Shading = adjacencyCluster.GetShadingPanels(); if (panels_Shading != null) { foreach (Panel panel_Shading in panels_Shading) { if (panels_Shading == null) { continue; } if (panel_Shading.PanelType == PanelType.Shade) { Shade shade = panel_Shading.ToLadybugTools_Shade(); if (shade == null) { continue; } if (shades == null) { shades = new List <Shade>(); } shades.Add(shade); } else { Face face_Orphaned = panel_Shading.ToLadybugTools_Face(); if (face_Orphaned == null) { continue; } if (faces_Orphaned == null) { faces_Orphaned = new List <Face>(); } faces_Orphaned.Add(face_Orphaned); } } } MaterialLibrary materialLibrary = analyticalModel_Temp?.MaterialLibrary; List <Construction> constructions_AdjacencyCluster = adjacencyCluster.GetConstructions(); List <ApertureConstruction> apertureConstructions_AdjacencyCluster = adjacencyCluster.GetApertureConstructions(); ConstructionSetAbridged constructionSetAbridged = Core.LadybugTools.Query.DefaultConstructionSetAbridged(); List <HoneybeeSchema.AnyOf <ConstructionSetAbridged, ConstructionSet> > constructionSets = new List <HoneybeeSchema.AnyOf <ConstructionSetAbridged, ConstructionSet> >();// { constructionSetAbridged }; List <AnyOf <OpaqueConstructionAbridged, WindowConstructionAbridged, WindowConstructionShadeAbridged, AirBoundaryConstructionAbridged, OpaqueConstruction, WindowConstruction, WindowConstructionShade, WindowConstructionDynamicAbridged, WindowConstructionDynamic, AirBoundaryConstruction, ShadeConstruction> > constructions = new List <AnyOf <OpaqueConstructionAbridged, WindowConstructionAbridged, WindowConstructionShadeAbridged, AirBoundaryConstructionAbridged, OpaqueConstruction, WindowConstruction, WindowConstructionShade, WindowConstructionDynamicAbridged, WindowConstructionDynamic, AirBoundaryConstruction, ShadeConstruction> >(); Dictionary <string, HoneybeeSchema.Energy.IMaterial> dictionary_Materials = new Dictionary <string, HoneybeeSchema.Energy.IMaterial>(); if (constructions_AdjacencyCluster != null) { foreach (Construction construction in constructions_AdjacencyCluster) { List <ConstructionLayer> constructionLayers = construction.ConstructionLayers; if (constructionLayers == null) { continue; } constructions.Add(construction.ToLadybugTools()); constructions.Add(construction.ToLadybugTools(false)); foreach (ConstructionLayer constructionLayer in constructionLayers) { IMaterial material = constructionLayer.Material(materialLibrary); if (material == null) { continue; } if (dictionary_Materials.ContainsKey(material.Name)) { continue; } if (material is GasMaterial) { List <Panel> panels = Analytical.Query.Panels(adjacencyCluster, construction); List <double> tilts = panels.ConvertAll(x => Analytical.Query.Tilt(x).Round(Tolerance.MacroDistance)); double tilt = tilts.Distinct().ToList().Average(); tilt = Units.Convert.ToRadians(tilt); dictionary_Materials[material.Name] = ((GasMaterial)material).ToLadybugTools(tilt, constructionLayer.Thickness); } else if (material is OpaqueMaterial) { EnergyMaterial energyMaterial = ((OpaqueMaterial)material).ToLadybugTools(); dictionary_Materials[material.Name] = energyMaterial; if (!double.IsNaN(constructionLayer.Thickness)) { energyMaterial.Thickness = constructionLayer.Thickness; } } } } } if (apertureConstructions_AdjacencyCluster != null) { foreach (ApertureConstruction apertureConstruction in apertureConstructions_AdjacencyCluster) { List <ConstructionLayer> constructionLayers = null; constructionLayers = apertureConstruction.PaneConstructionLayers; if (constructionLayers != null) { MaterialType materialType = Analytical.Query.MaterialType(constructionLayers, materialLibrary); if (materialType != MaterialType.Undefined && materialType != MaterialType.Gas) { if (materialType == MaterialType.Opaque) { constructions.Add(apertureConstruction.ToLadybugTools()); constructions.Add(apertureConstruction.ToLadybugTools(false)); } else { constructions.Add(apertureConstruction.ToLadybugTools_WindowConstructionAbridged()); constructions.Add(apertureConstruction.ToLadybugTools_WindowConstructionAbridged(false)); } foreach (ConstructionLayer constructionLayer in constructionLayers) { IMaterial material = constructionLayer.Material(materialLibrary); if (material == null) { continue; } string name = material.Name; if (dictionary_Materials.ContainsKey(name)) { continue; } if (material is TransparentMaterial) { dictionary_Materials[name] = ((TransparentMaterial)material).ToLadybugTools(); } else if (material is GasMaterial) { dictionary_Materials[name] = ((GasMaterial)material).ToLadybugTools_EnergyWindowMaterialGas(); } else { dictionary_Materials[name] = ((OpaqueMaterial)material).ToLadybugTools(); } } } } } } ProfileLibrary profileLibrary = analyticalModel.ProfileLibrary; Dictionary <System.Guid, ProgramType> dictionary_InternalConditions = new Dictionary <System.Guid, ProgramType>(); if (spaces != null) { foreach (Space space in spaces) { InternalCondition internalCondition = space?.InternalCondition; if (internalCondition == null) { continue; } if (dictionary_InternalConditions.ContainsKey(internalCondition.Guid)) { continue; } ProgramType programType = space.ToLadybugTools(adjacencyCluster, profileLibrary); if (programType != null) { dictionary_InternalConditions[internalCondition.Guid] = programType; } } } List <AnyOf <EnergyMaterial, EnergyMaterialNoMass, EnergyWindowMaterialGas, EnergyWindowMaterialGasCustom, EnergyWindowMaterialGasMixture, EnergyWindowMaterialSimpleGlazSys, EnergyWindowMaterialBlind, EnergyWindowMaterialGlazing, EnergyWindowMaterialShade> > materials = new List <AnyOf <EnergyMaterial, EnergyMaterialNoMass, EnergyWindowMaterialGas, EnergyWindowMaterialGasCustom, EnergyWindowMaterialGasMixture, EnergyWindowMaterialSimpleGlazSys, EnergyWindowMaterialBlind, EnergyWindowMaterialGlazing, EnergyWindowMaterialShade> >(); HoneybeeSchema.Helper.EnergyLibrary.DefaultMaterials?.ToList().ForEach(x => materials.Add(x as dynamic)); dictionary_Materials.Values.ToList().ForEach(x => materials.Add(x as dynamic)); List <AnyOf <ScheduleRulesetAbridged, ScheduleFixedIntervalAbridged, ScheduleRuleset, ScheduleFixedInterval> > schedules = new List <AnyOf <ScheduleRulesetAbridged, ScheduleFixedIntervalAbridged, ScheduleRuleset, ScheduleFixedInterval> >(); HoneybeeSchema.Helper.EnergyLibrary.DefaultScheduleRuleset?.ToList().ForEach(x => schedules.Add(x)); List <HoneybeeSchema.AnyOf <ProgramTypeAbridged, ProgramType> > programTypes = new List <HoneybeeSchema.AnyOf <ProgramTypeAbridged, ProgramType> >(); HoneybeeSchema.Helper.EnergyLibrary.DefaultProgramTypes?.ToList().ForEach(x => programTypes.Add(x)); dictionary_InternalConditions.Values.ToList().ForEach(x => programTypes.Add(x)); List <ScheduleTypeLimit> scheduleTypeLimits = new List <ScheduleTypeLimit>(); HoneybeeSchema.Helper.EnergyLibrary.DefaultScheduleTypeLimit?.ToList().ForEach(x => scheduleTypeLimits.Add(x)); constructionSets.RemoveAll(x => x == null); constructions.RemoveAll(x => x == null); materials.RemoveAll(x => x == null); ModelEnergyProperties modelEnergyProperties = new ModelEnergyProperties(constructionSets, constructions, materials, hvacs, null, programTypes, schedules, scheduleTypeLimits); ModelProperties modelProperties = new ModelProperties(modelEnergyProperties); Model model = new Model(uniqueName, modelProperties, adjacencyCluster.Name, null, rooms, faces_Orphaned, shades); model.AngleTolerance = Units.Convert.ToDegrees(Tolerance.Angle);// 2; model.Tolerance = Tolerance.MacroDistance; return(model); }
public static AnalyticalModel ToSAM_AnalyticalModel(this Document document, ConvertSettings convertSettings) { if (document == null) { return(null); } ProjectInfo projectInfo = document.ProjectInformation; AnalyticalModel result = convertSettings?.GetObject <AnalyticalModel>(projectInfo?.Id); if (result != null) { return(result); } Core.Location location = Core.Revit.Query.Location(document); Address address = null; if (projectInfo != null) { address = new Address(Guid.NewGuid(), projectInfo.BuildingName, projectInfo.Address, null, null, CountryCode.Undefined); } AdjacencyCluster adjacencyCluster = new AdjacencyCluster(); EnergyAnalysisDetailModelOptions energyAnalysisDetailModelOptions = new EnergyAnalysisDetailModelOptions(); energyAnalysisDetailModelOptions.Tier = EnergyAnalysisDetailModelTier.SecondLevelBoundaries; energyAnalysisDetailModelOptions.EnergyModelType = EnergyModelType.SpatialElement; energyAnalysisDetailModelOptions.ExportMullions = true; energyAnalysisDetailModelOptions.IncludeShadingSurfaces = true; energyAnalysisDetailModelOptions.SimplifyCurtainSystems = false; EnergyDataSettings energyDataSettings = EnergyDataSettings.GetFromDocument(document); energyDataSettings.ExportComplexity = gbXMLExportComplexity.ComplexWithMullionsAndShadingSurfaces; energyDataSettings.ExportDefaults = false; #if Revit2017 || Revit2018 || Revit2019 || Revit2020 energyDataSettings.SliverSpaceTolerance = UnitUtils.ConvertToInternalUnits(0.005, DisplayUnitType.DUT_METERS); #else energyDataSettings.SliverSpaceTolerance = UnitUtils.ConvertToInternalUnits(0.005, UnitTypeId.Meters); #endif energyDataSettings.AnalysisType = AnalysisMode.BuildingElements; energyDataSettings.EnergyModel = false; //Reseting Project Base Point IEnumerable <Element> elements = new FilteredElementCollector(document).OfCategory(BuiltInCategory.OST_ProjectBasePoint); foreach (Element element in elements) { if (element.Pinned) { element.Pinned = false; } Parameter parameter = null; parameter = element.get_Parameter(BuiltInParameter.BASEPOINT_EASTWEST_PARAM); if (parameter != null && !parameter.IsReadOnly) { parameter.Set(0.0); } parameter = element.get_Parameter(BuiltInParameter.BASEPOINT_NORTHSOUTH_PARAM); if (parameter != null && !parameter.IsReadOnly) { parameter.Set(0.0); } parameter = element.get_Parameter(BuiltInParameter.BASEPOINT_ELEVATION_PARAM); if (parameter != null && !parameter.IsReadOnly) { parameter.Set(0.0); } parameter = element.get_Parameter(BuiltInParameter.BASEPOINT_ELEVATION_PARAM); if (parameter != null && !parameter.IsReadOnly) { parameter.Set(0.0); } parameter = element.get_Parameter(BuiltInParameter.BASEPOINT_ANGLETON_PARAM); if (parameter != null && !parameter.IsReadOnly) { parameter.Set(0.0); } } //AnalyticalSpaces EnergyAnalysisDetailModel energyAnalysisDetailModel = EnergyAnalysisDetailModel.Create(document, energyAnalysisDetailModelOptions); IList <EnergyAnalysisSpace> energyAnalysisSpaces = energyAnalysisDetailModel.GetAnalyticalSpaces(); Dictionary <string, Tuple <Panel, List <Space> > > dictionary = new Dictionary <string, Tuple <Panel, List <Space> > >(); foreach (EnergyAnalysisSpace energyAnalysisSpace in energyAnalysisSpaces) { try { if (energyAnalysisSpace.Area <= Core.Tolerance.MacroDistance) { continue; } Space space = energyAnalysisSpace.ToSAM(convertSettings); if (space == null) { continue; } Shell shell = Geometry.Revit.Convert.ToSAM(energyAnalysisSpace.GetClosedShell()); if (shell == null) { continue; } adjacencyCluster.AddObject(space); foreach (EnergyAnalysisSurface energyAnalysisSurface in energyAnalysisSpace.GetAnalyticalSurfaces()) { Tuple <Panel, List <Space> > tuple; if (!dictionary.TryGetValue(energyAnalysisSurface.SurfaceName, out tuple)) { Panel panel = energyAnalysisSurface.ToSAM(convertSettings, shell); if (panel == null) { continue; } tuple = new Tuple <Panel, List <Space> >(panel, new List <Space>()); dictionary[energyAnalysisSurface.SurfaceName] = tuple; } tuple.Item2.Add(space); } } catch { } } #region Additional Checks (WIP) //Additional Check for wrongly recoginzed internal panels (WIP) List <Tuple <string, Panel, Space, Face3D> > tuples_External = new List <Tuple <string, Panel, Space, Face3D> >(); foreach (KeyValuePair <string, Tuple <Panel, List <Space> > > keyValuePair in dictionary) { Tuple <Panel, List <Space> > tuple = keyValuePair.Value; if (tuple.Item1 != null && tuple.Item2 != null && tuple.Item2.Count == 1) { Face3D face3D = tuple.Item1.GetFace3D(); if (face3D != null) { tuples_External.Add(new Tuple <string, Panel, Space, Face3D>(keyValuePair.Key, tuple.Item1, tuple.Item2[0], face3D)); } } } while (tuples_External.Count > 0) { Tuple <string, Panel, Space, Face3D> tuple = tuples_External[0]; tuples_External.RemoveAt(0); Point3D point3D = tuple.Item4.InternalPoint3D(); if (point3D == null) { continue; } List <Tuple <string, Panel, Space, Face3D> > tuples_Overlap = tuples_External.FindAll(x => x.Item4.Inside(point3D)); if (tuples_Overlap.Count != 1) { continue; } tuples_Overlap.Add(tuple); tuples_Overlap.Sort((x, y) => y.Item4.GetArea().CompareTo(x.Item4.GetArea())); tuple = tuples_Overlap[0]; Tuple <string, Panel, Space, Face3D> tuple_Overlap = tuples_Overlap[1]; dictionary[tuple.Item1].Item2.Add(tuple_Overlap.Item3); dictionary[tuple_Overlap.Item1] = new Tuple <Panel, List <Space> >(Analytical.Create.Panel(dictionary[tuple_Overlap.Item1].Item1, PanelType.Shade), null); int index = tuples_External.IndexOf(tuple_Overlap); if (index != -1) { tuples_External.RemoveAt(index); } } #endregion foreach (Tuple <Panel, List <Space> > tuple in dictionary.Values) { Panel panel = tuple.Item1; adjacencyCluster.AddObject(panel); tuple.Item2?.ForEach(x => adjacencyCluster.AddRelation(x, panel)); } //AnalyticalShadingSurfaces IList <EnergyAnalysisSurface> analyticalShadingSurfaces = energyAnalysisDetailModel.GetAnalyticalShadingSurfaces(); foreach (EnergyAnalysisSurface energyAnalysisSurface in analyticalShadingSurfaces) { try { Panel panel = energyAnalysisSurface.ToSAM(convertSettings); if (panel == null) { continue; } panel = Analytical.Create.Panel(panel, PanelType.Shade); adjacencyCluster.AddObject(panel); } catch { } } adjacencyCluster.MapZones(); IEnumerable <IMaterial> materials = Analytical.Query.Materials(adjacencyCluster, Analytical.ActiveSetting.Setting.GetValue <MaterialLibrary>(AnalyticalSettingParameter.DefaultMaterialLibrary)); MaterialLibrary materialLibrary = Core.Create.MaterialLibrary("Default Material Library", materials); IEnumerable <Profile> profiles = Analytical.Query.Profiles(adjacencyCluster, Analytical.ActiveSetting.Setting.GetValue <ProfileLibrary>(AnalyticalSettingParameter.DefaultProfileLibrary)); ProfileLibrary profileLibrary = new ProfileLibrary("Default Profile Library", profiles); result = new AnalyticalModel(document.Title, null, location, address, adjacencyCluster, materialLibrary, profileLibrary); result.UpdateParameterSets(document.ProjectInformation, ActiveSetting.Setting.GetValue <TypeMap>(Core.Revit.ActiveSetting.Name.ParameterMap)); convertSettings?.Add(projectInfo.Id, result); return(result); }
/// <summary> /// Updates TBD.zones in given TBD.Buiding based on provided spaces and profileLibrary /// </summary> /// <param name="building">TBD.Buidling</param> /// <param name="spaces">SAM Analytical Spaces</param> /// <param name="profileLibrary">ProfileLibrary which contains information about profiles used in spaces</param> /// <param name="includeHDD">Include Heating Design Day in the process</param> /// <returns>TBD.zones have been used in update process</returns> public static bool UpdateZones(this TBD.Building building, AdjacencyCluster adjacencyCluster, ProfileLibrary profileLibrary, bool includeHDD = false) { if (building == null || adjacencyCluster == null || profileLibrary == null) { return(false); } List <Space> spaces = adjacencyCluster?.GetSpaces(); if (spaces == null || spaces.Count == 0) { return(false); } //Zone Dictionary <- Dictionary constains zone.name as a key and TBD.zone as Value. Dictionary helps to match TBD.zone with SAM.Analytical.Space Dictionary <string, TBD.zone> dictionary_Zones = building.ZoneDictionary(); if (dictionary_Zones == null) { return(false); } //Space Dictionary <- Dictionary constains Space.Name as a key and SAM.Analytical.Space as Value. Assumption: InternalCondition Name equals to Space Name. It also holds names for HDD Spaces/InternalConditions Dictionary <string, Space> dictionary_Spaces = new Dictionary <string, Space>(); foreach (Space space in spaces) { string name = space.Name; if (name == null) { continue; } dictionary_Spaces[name] = space; if (includeHDD) { dictionary_Spaces[space.Name + " - HDD"] = space; } } //Removes Internal Conditions with given names. Names are taken from Space Name (assumption Space Name equals InternalCondtion Name) RemoveInternalConditions(building, dictionary_Spaces.Keys); List <TBD.zone> result = new List <TBD.zone>(); foreach (Space space in spaces) { string name = space?.Name; if (name == null) { continue; } //Matching Space with TBD.zone via name TBD.zone zone = null; if (!dictionary_Zones.TryGetValue(name, out zone) || zone == null) { continue; } zone = building.UpdateZone(zone, space, profileLibrary); VentilationSystem ventilationSystem = adjacencyCluster.GetRelatedObjects <VentilationSystem>(space)?.FirstOrDefault(); if (ventilationSystem != null) { string ventilationSystemTypeName = (ventilationSystem.Type as VentilationSystemType)?.Name; if (!string.IsNullOrWhiteSpace(ventilationSystemTypeName)) { TBD.ZoneGroup zoneGroup = Query.ZoneGroups(building)?.Find(x => ventilationSystemTypeName.Equals(x.name)); if (zoneGroup == null) { zoneGroup = building.AddZoneGroup(); zoneGroup.name = ventilationSystemTypeName; zoneGroup.type = (int)TBD.ZoneGroupType.tbdHVACZG; } if (zoneGroup != null) { zoneGroup.InsertZone(zone); } } } //Update TBD.zone using data stored in space and ProfileLibrary result.Add(zone); //Include HDD if includeHDD input set to true if (includeHDD) { building.UpdateZone_HDD(zone, space, profileLibrary); } } //Updating Builidng Information building.description = string.Format("Delivered by SAM https://github.com/HoareLea/SAM [{0}]", System.DateTime.Now.ToString("yyyy/MM/dd")); TBD.GeneralDetails generaldetails = building.GetGeneralDetails(); if (generaldetails != null) { if (generaldetails.engineer1 == "") { generaldetails.engineer1 = System.Environment.UserName; } else if (generaldetails.engineer1 != System.Environment.UserName) { generaldetails.engineer2 = System.Environment.UserName; } if (generaldetails.externalPollutant == 315) //600 { generaldetails.externalPollutant = 415; } generaldetails.TerrainType = TBD.TerrainType.tbdCity; } //Returning TBD.zones have been used in update process return(result != null && result.Count > 0); }
public static bool UpdateInternalCondition_HDD(this TBD.InternalCondition internalCondition_TBD, InternalCondition internalCondition, ProfileLibrary profileLibrary) { if (internalCondition_TBD == null || internalCondition == null) { return(false); } internalCondition_TBD.description = internalCondition.Name + " - HDD"; internalCondition_TBD.includeSolarInMRT = 0; TBD.Emitter emitter = null; double value = double.NaN; emitter = internalCondition_TBD.GetHeatingEmitter(); if (emitter != null) { if (internalCondition.TryGetValue(InternalConditionParameter.HeatingEmitterRadiantProportion, out value)) { emitter.radiantProportion = System.Convert.ToSingle(value); } if (internalCondition.TryGetValue(InternalConditionParameter.HeatingEmitterCoefficient, out value)) { emitter.viewCoefficient = System.Convert.ToSingle(value); } } emitter = internalCondition_TBD.GetCoolingEmitter(); if (emitter != null) { if (internalCondition.TryGetValue(InternalConditionParameter.CoolingEmitterRadiantProportion, out value)) { emitter.radiantProportion = System.Convert.ToSingle(value); } if (internalCondition.TryGetValue(InternalConditionParameter.CoolingEmitterCoefficient, out value)) { emitter.viewCoefficient = System.Convert.ToSingle(value); } } TBD.InternalGain internalGain = internalCondition_TBD.GetInternalGain(); internalGain.name = internalCondition.Name + " - HDD"; Profile profile = null; profile = internalCondition.GetProfile(ProfileType.Infiltration, profileLibrary); if (profile != null) { if (internalCondition.TryGetValue(InternalConditionParameter.InfiltrationAirChangesPerHour, out value)) { TBD.profile profile_TBD = internalGain.GetProfile((int)TBD.Profiles.ticI); if (profile_TBD != null) { profile_TBD.name = profile.Name; profile_TBD.type = TBD.ProfileTypes.ticValueProfile; profile_TBD.factor = 1; profile_TBD.value = System.Convert.ToSingle(value); } } } TBD.Thermostat thermostat = internalCondition_TBD.GetThermostat(); if (thermostat != null) { thermostat.controlRange = 0; thermostat.proportionalControl = 0; profile = internalCondition.GetProfile(ProfileType.Heating, profileLibrary); if (profile != null) { thermostat.name = profile.Name; TBD.profile profile_TBD = thermostat.GetProfile((int)TBD.Profiles.ticLL); if (profile_TBD != null) { value = profile.MaxValue; if (!double.IsNaN(value)) { profile_TBD.name = profile.Name; profile_TBD.type = TBD.ProfileTypes.ticValueProfile; profile_TBD.factor = 1; profile_TBD.value = System.Convert.ToSingle(value); } } } } return(true); }
public static bool UpdateInternalCondition_HDD(this TBD.InternalCondition internalCondition_TBD, Space space, ProfileLibrary profileLibrary) { if (internalCondition_TBD == null || space == null) { return(false); } InternalCondition internalCondition = space.InternalCondition; if (internalCondition == null) { return(false); } internalCondition_TBD.name = space.Name + " - HDD"; return(UpdateInternalCondition_HDD(internalCondition_TBD, internalCondition, profileLibrary)); }
public static TBD.InternalCondition AddInternalCondition_HDD(this TBD.Building building, Space space, ProfileLibrary profileLibrary) { if (building == null || space == null || profileLibrary == null) { return(null); } TBD.InternalCondition internalCondition = building.AddIC(null); if (internalCondition == null) { return(null); } List <TBD.dayType> dayTypes = building.DayTypes(); if (dayTypes != null) { dayTypes.RemoveAll(x => !x.name.Equals("HDD")); foreach (TBD.dayType dayType in dayTypes) { internalCondition.SetDayType(dayType, true); } } UpdateInternalCondition_HDD(internalCondition, space, profileLibrary); return(internalCondition); }
public static TBD.zone UpdateZone_HDD(this TBD.Building building, TBD.zone zone, Space space, ProfileLibrary profileLibrary) { if (space == null || profileLibrary == null || zone == null || building == null) { return(null); } TBD.InternalCondition internalCondition_TBD = AddInternalCondition_HDD(building, space, profileLibrary); if (internalCondition_TBD == null) { return(null); } zone.AssignIC(internalCondition_TBD, true); return(zone); }
public static AnalyticalModel ToSAM(this Model model) { if (model == null) { return(null); } MaterialLibrary materialLibrary = null; ProfileLibrary profileLibrary = null; List <Construction> constructions = null; List <ApertureConstruction> apertureConstructions = null; List <InternalCondition> internalConditions = null; ModelEnergyProperties modelEnergyProperties = model.Properties?.Energy; if (modelEnergyProperties != null) { materialLibrary = modelEnergyProperties.ToSAM_MaterialLibrary(); constructions = modelEnergyProperties.ToSAM_Constructions(); apertureConstructions = modelEnergyProperties.ToSAM_ApertureConstructions(); internalConditions = modelEnergyProperties.ToSAM_InternalConditions(); profileLibrary = modelEnergyProperties.ToSAM_ProfileLibrary(); } if (materialLibrary == null) { materialLibrary = new MaterialLibrary(string.Empty); } if (constructions == null) { constructions = new List <Construction>(); } if (apertureConstructions == null) { apertureConstructions = new List <ApertureConstruction>(); } List <Tuple <Panel, Geometry.Spatial.BoundingBox3D> > tuples = new List <Tuple <Panel, Geometry.Spatial.BoundingBox3D> >(); AdjacencyCluster adjacencyCluster = new AdjacencyCluster(); List <Room> rooms = model.Rooms; if (rooms != null) { foreach (Room room in rooms) { room.IndoorShades?.ConvertAll(x => x.ToSAM(constructions))?.ForEach(x => adjacencyCluster.AddObject(x)); room.OutdoorShades?.ConvertAll(x => x.ToSAM(constructions))?.ForEach(x => adjacencyCluster.AddObject(x)); List <Face> faces = room.Faces; if (faces == null) { continue; } List <Panel> panels = new List <Panel>(); foreach (Face face in faces) { Panel panel = face.ToSAM(constructions, apertureConstructions); if (panel == null) { continue; } Geometry.Spatial.Point3D point3D = panel.GetFace3D().GetInternalPoint3D(); if (point3D == null) { continue; } Panel panel_Existing = tuples.FindAll(x => x.Item2.Inside(point3D, true))?.Find(x => x.Item1.GetFace3D().On(point3D))?.Item1; if (panel_Existing != null) { panel = panel_Existing; } else { tuples.Add(new Tuple <Panel, Geometry.Spatial.BoundingBox3D>(panel, panel.GetFace3D().GetBoundingBox())); face.IndoorShades?.ConvertAll(x => x.ToSAM(constructions))?.ForEach(x => adjacencyCluster.AddObject(x)); face.OutdoorShades?.ConvertAll(x => x.ToSAM(constructions))?.ForEach(x => adjacencyCluster.AddObject(x)); Construction construction = panel.Construction; if (construction != null) { if (constructions.Find(x => x.Name.Equals(construction.Name)) == null) { constructions.Add(construction); } materialLibrary.AddDefaultMaterials(construction); } List <Aperture> apertures = panel.Apertures; if (apertures != null) { foreach (Aperture aperture in apertures) { ApertureConstruction apertureConstruction = aperture.ApertureConstruction; if (apertureConstruction != null) { if (apertureConstructions.Find(x => x.Name.Equals(apertureConstruction.Name)) == null) { apertureConstructions.Add(apertureConstruction); } materialLibrary.AddDefaultMaterials(apertureConstruction); } } } List <HoneybeeSchema.Aperture> apertures_HoneybeeSchema = face.Apertures; if (apertures_HoneybeeSchema != null) { foreach (HoneybeeSchema.Aperture aperture_HoneybeeSchema in apertures_HoneybeeSchema) { aperture_HoneybeeSchema.IndoorShades?.ConvertAll(x => x.ToSAM(constructions))?.ForEach(x => adjacencyCluster.AddObject(x)); aperture_HoneybeeSchema.OutdoorShades?.ConvertAll(x => x.ToSAM(constructions))?.ForEach(x => adjacencyCluster.AddObject(x)); } } List <HoneybeeSchema.Door> doors_HoneybeeSchema = face.Doors; if (doors_HoneybeeSchema != null) { foreach (HoneybeeSchema.Door door_HoneybeeSchema in doors_HoneybeeSchema) { door_HoneybeeSchema.IndoorShades?.ConvertAll(x => x.ToSAM(constructions))?.ForEach(x => adjacencyCluster.AddObject(x)); door_HoneybeeSchema.OutdoorShades?.ConvertAll(x => x.ToSAM(constructions))?.ForEach(x => adjacencyCluster.AddObject(x)); } } } panels.Add(panel); } Space space = room.ToSAM(internalConditions); adjacencyCluster.AddObject(space); if (panels != null) { foreach (Panel panel in panels) { adjacencyCluster.AddObject(panel); adjacencyCluster.AddRelation(space, panel); } } } } List <Shade> shades = model.OrphanedShades; if (shades != null && shades.Count != 0) { foreach (Shade shade in shades) { Panel panel = shade?.ToSAM(constructions); if (panel != null) { Construction construction = panel.Construction; if (construction != null) { if (constructions.Find(x => x.Name.Equals(construction.Name)) == null) { constructions.Add(construction); } materialLibrary.AddDefaultMaterials(construction); } List <Aperture> apertures = panel.Apertures; if (apertures != null) { foreach (Aperture aperture in apertures) { ApertureConstruction apertureConstruction = aperture.ApertureConstruction; if (apertureConstruction != null) { if (apertureConstructions.Find(x => x.Name.Equals(apertureConstruction.Name)) == null) { apertureConstructions.Add(apertureConstruction); } materialLibrary.AddDefaultMaterials(apertureConstruction); } } } adjacencyCluster.AddObject(panel); } } } AnalyticalModel result = new AnalyticalModel(model.DisplayName, null, null, null, adjacencyCluster, materialLibrary, profileLibrary); return(result); }
public static ProgramType ToLadybugTools(this Space space, AdjacencyCluster adjacencyCluster, ProfileLibrary profileLibrary) { InternalCondition internalCondition = space.InternalCondition; if (internalCondition == null) { return(null); } string uniqueName = Core.LadybugTools.Query.UniqueName(internalCondition); if (string.IsNullOrWhiteSpace(uniqueName)) { return(null); } People people = null; Lighting lighting = null; ElectricEquipment electricEquipment = null; Infiltration infiltration = null; Setpoint setpoint = null; if (profileLibrary != null) { double area = double.NaN; if (!space.TryGetValue(SpaceParameter.Area, out area)) { area = double.NaN; } Dictionary <ProfileType, Profile> dictionary = internalCondition.GetProfileDictionary(profileLibrary); if (dictionary.ContainsKey(ProfileType.Occupancy)) { Profile profile = dictionary[ProfileType.Occupancy]; if (profile != null) { double gain = Analytical.Query.OccupancyGain(space); if (double.IsNaN(gain)) { gain = 0; } ScheduleRuleset scheduleRuleset = profile.ToLadybugTools(); if (scheduleRuleset != null) { double gainPerPeople = gain; if (double.IsNaN(gainPerPeople)) { gainPerPeople = 0; } double occupancy = Analytical.Query.CalculatedOccupancy(space); if (!double.IsNaN(occupancy) && occupancy != 0) { gainPerPeople = gainPerPeople / occupancy; } ScheduleRuleset scheduleRuleset_ActivityLevel = profile.ToLadybugTools_ActivityLevel(gainPerPeople); if (scheduleRuleset_ActivityLevel != null) { double peoplePerArea = Analytical.Query.CalculatedPeoplePerArea(space); if (double.IsNaN(peoplePerArea)) { peoplePerArea = 0; } double latentFraction = double.NaN; double sensibleOccupancyGain = Analytical.Query.OccupancySensibleGain(space); double latentOccupancyGain = Analytical.Query.OccupancyLatentGain(space); if (!double.IsNaN(sensibleOccupancyGain) || !double.IsNaN(latentOccupancyGain)) { latentFraction = latentOccupancyGain / (latentOccupancyGain + sensibleOccupancyGain); } if (!internalCondition.TryGetValue(Analytical.InternalConditionParameter.OccupancyRadiantProportion, out double occuplancyRadiantProportion)) { occuplancyRadiantProportion = 0.3; } if (double.IsNaN(latentFraction)) { latentFraction = 0; } people = new People( identifier: string.Format("{0}_People", uniqueName), peoplePerArea: peoplePerArea, occupancySchedule: scheduleRuleset, displayName: profile.Name, userData: null, activitySchedule: scheduleRuleset_ActivityLevel, radiantFraction: occuplancyRadiantProportion, latentFraction: latentFraction); } } } } if (dictionary.ContainsKey(ProfileType.Lighting)) { Profile profile = dictionary[ProfileType.Lighting]; if (profile != null) { double gain = Analytical.Query.CalculatedLightingGain(space); if (double.IsNaN(gain)) { gain = 0; } ScheduleRuleset scheduleRuleset = profile.ToLadybugTools(); if (scheduleRuleset != null) { double gainPerArea = gain; if (double.IsNaN(gainPerArea)) { gainPerArea = 0; } if (!double.IsNaN(area) && area != 0) { gainPerArea = gainPerArea / area; } if (!internalCondition.TryGetValue(Analytical.InternalConditionParameter.LightingRadiantProportion, out double lightingRadiantProportion)) { lightingRadiantProportion = 0.32; } if (!internalCondition.TryGetValue(Analytical.InternalConditionParameter.LightingViewCoefficient, out double lightingViewCoefficient)) { lightingViewCoefficient = 0.25; } lighting = new Lighting( identifier: string.Format("{0}_Lighting", uniqueName), wattsPerArea: gainPerArea, schedule: scheduleRuleset, visibleFraction: lightingViewCoefficient, radiantFraction: lightingRadiantProportion, displayName: profile.Name); } } } if (dictionary.ContainsKey(ProfileType.EquipmentSensible)) { double gain = Analytical.Query.CalculatedEquipmentSensibleGain(space); if (double.IsNaN(gain)) { gain = 0; } Profile profile = dictionary[ProfileType.EquipmentSensible]; if (profile != null) { ScheduleRuleset scheduleRuleset = profile.ToLadybugTools(); if (scheduleRuleset != null) { double gainPerArea = gain; if (double.IsNaN(gainPerArea)) { gainPerArea = 0; } if (!double.IsNaN(area) && area != 0) { gainPerArea = gainPerArea / area; } if (!internalCondition.TryGetValue(Analytical.InternalConditionParameter.EquipmentRadiantProportion, out double equipmentRadiantProportion)) { equipmentRadiantProportion = 0; } electricEquipment = new ElectricEquipment( identifier: string.Format("{0}_ElectricEquipment", uniqueName), wattsPerArea: gainPerArea, schedule: scheduleRuleset, radiantFraction: equipmentRadiantProportion, displayName: profile.Name); } } } if (dictionary.ContainsKey(ProfileType.Infiltration)) { Profile profile = dictionary[ProfileType.Infiltration]; if (profile != null) { ScheduleRuleset scheduleRuleset = profile.ToLadybugTools(); if (scheduleRuleset != null) { double airFlowPerExteriorArea = Query.InfiltrationAirFlowPerExteriorArea(adjacencyCluster, space); infiltration = new Infiltration( identifier: string.Format("{0}_Infiltration", uniqueName), flowPerExteriorArea: airFlowPerExteriorArea, schedule: scheduleRuleset, displayName: profile.Name); } } } if (dictionary.ContainsKey(ProfileType.Cooling) && dictionary.ContainsKey(ProfileType.Heating)) { Profile profile_Cooling = dictionary[ProfileType.Cooling]; Profile profile_Heating = dictionary[ProfileType.Heating]; if (profile_Cooling != null && profile_Heating != null) { ScheduleRuleset scheduleRuleset_Cooling = profile_Cooling.ToLadybugTools(); ScheduleRuleset scheduleRuleset_Heating = profile_Heating.ToLadybugTools(); if (scheduleRuleset_Cooling != null && scheduleRuleset_Heating != null) { setpoint = new Setpoint(string.Format("{0}_Setpoint", uniqueName), scheduleRuleset_Cooling, scheduleRuleset_Heating, string.Format("Heating {0} Cooling {1}", profile_Heating.Name, profile_Cooling.Name)); Profile profile; if (dictionary.TryGetValue(ProfileType.Humidification, out profile)) { ScheduleRuleset scheduleRuleset = profile.ToLadybugTools(); if (scheduleRuleset != null) { setpoint.HumidifyingSchedule = scheduleRuleset; } } if (dictionary.TryGetValue(ProfileType.Dehumidification, out profile)) { ScheduleRuleset scheduleRuleset = profile.ToLadybugTools(); if (scheduleRuleset != null) { setpoint.DehumidifyingSchedule = scheduleRuleset; } } } } } } ProgramType result = new ProgramType( identifier: uniqueName, displayName: internalCondition.Name, userData: null, people: people, lighting: lighting, electricEquipment: electricEquipment, infiltration: infiltration, setpoint: setpoint); return(result); }
public static bool UpdateInternalCondition(this TBD.InternalCondition internalCondition_TBD, Space space, ProfileLibrary profileLibrary) { if (space == null || internalCondition_TBD == null) { return(false); } InternalCondition internalCondition = space.InternalCondition; if (internalCondition == null) { return(false); } internalCondition_TBD.name = space.Name; internalCondition_TBD.description = internalCondition.Name; internalCondition_TBD.includeSolarInMRT = 1; TBD.Emitter emitter = null; double value = double.NaN; emitter = internalCondition_TBD.GetHeatingEmitter(); if (emitter != null) { emitter.name = internalCondition.GetSystemTypeName <HeatingSystemType>(); if (internalCondition.TryGetValue(InternalConditionParameter.HeatingEmitterRadiantProportion, out value)) { emitter.radiantProportion = System.Convert.ToSingle(value); } if (internalCondition.TryGetValue(InternalConditionParameter.HeatingEmitterCoefficient, out value)) { emitter.viewCoefficient = System.Convert.ToSingle(value); } } emitter = internalCondition_TBD.GetCoolingEmitter(); if (emitter != null) { emitter.name = internalCondition.GetSystemTypeName <CoolingSystemType>(); if (internalCondition.TryGetValue(InternalConditionParameter.CoolingEmitterRadiantProportion, out value)) { emitter.radiantProportion = System.Convert.ToSingle(value); } if (internalCondition.TryGetValue(InternalConditionParameter.CoolingEmitterCoefficient, out value)) { emitter.viewCoefficient = System.Convert.ToSingle(value); } } TBD.InternalGain internalGain = internalCondition_TBD.GetInternalGain(); if (internalCondition.TryGetValue(InternalConditionParameter.LightingRadiantProportion, out value)) { internalGain.lightingRadProp = System.Convert.ToSingle(value); } if (internalCondition.TryGetValue(InternalConditionParameter.OccupancyRadiantProportion, out value)) { internalGain.occupantRadProp = System.Convert.ToSingle(value); } if (internalCondition.TryGetValue(InternalConditionParameter.EquipmentRadiantProportion, out value)) { internalGain.equipmentRadProp = System.Convert.ToSingle(value); } if (internalCondition.TryGetValue(InternalConditionParameter.LightingViewCoefficient, out value)) { internalGain.lightingViewCoefficient = System.Convert.ToSingle(value); } if (internalCondition.TryGetValue(InternalConditionParameter.OccupancyViewCoefficient, out value)) { internalGain.occupantViewCoefficient = System.Convert.ToSingle(value); } if (internalCondition.TryGetValue(InternalConditionParameter.EquipmentViewCoefficient, out value)) { internalGain.equipmentViewCoefficient = System.Convert.ToSingle(value); } internalGain.domesticHotWater = (float)0.197; internalGain.name = internalCondition.Name; internalGain.description = internalCondition.GetSystemTypeName <VentilationSystemType>(); if (internalCondition.TryGetValue(InternalConditionParameter.LightingLevel, out value)) { internalGain.targetIlluminance = System.Convert.ToSingle(value); } internalGain.personGain = 0; double occupancyGainPerPerson = Analytical.Query.OccupancyGainPerPerson(space); if (!double.IsNaN(occupancyGainPerPerson)) { internalGain.personGain = System.Convert.ToSingle(occupancyGainPerPerson); } Profile profile = null; profile = internalCondition.GetProfile(ProfileType.Infiltration, profileLibrary); if (profile != null) { if (internalCondition.TryGetValue(InternalConditionParameter.InfiltrationAirChangesPerHour, out value)) { TBD.profile profile_TBD = internalGain.GetProfile((int)TBD.Profiles.ticI); if (profile_TBD != null) { Update(profile_TBD, profile, value); } } } double area = double.NaN; if (!space.TryGetValue(SpaceParameter.Area, out area)) { area = double.NaN; } profile = internalCondition.GetProfile(ProfileType.Lighting, profileLibrary); if (profile != null) { TBD.profile profile_TBD = internalGain.GetProfile((int)TBD.Profiles.ticLG); if (profile_TBD != null) { double gain = Analytical.Query.CalculatedLightingGain(space); if (double.IsNaN(area) || area == 0 || double.IsNaN(gain)) { gain = 0; } else { gain = gain / area; } Update(profile_TBD, profile, gain); } } profile = internalCondition.GetProfile(ProfileType.Occupancy, profileLibrary); if (profile != null) { TBD.profile profile_TBD = null; profile_TBD = internalGain.GetProfile((int)TBD.Profiles.ticOLG); if (profile_TBD != null) { double gain = Analytical.Query.OccupancyLatentGain(space); if (double.IsNaN(area) || area == 0 || double.IsNaN(gain)) { gain = 0; } else { gain = gain / area; } Update(profile_TBD, profile, gain); } profile_TBD = internalGain.GetProfile((int)TBD.Profiles.ticOSG); if (profile_TBD != null) { double gain = Analytical.Query.OccupancySensibleGain(space); if (double.IsNaN(area) || area == 0 || double.IsNaN(gain)) { gain = 0; } else { gain = gain / area; } Update(profile_TBD, profile, gain); } } profile = internalCondition.GetProfile(ProfileType.EquipmentSensible, profileLibrary); if (profile != null) { TBD.profile profile_TBD = internalGain.GetProfile((int)TBD.Profiles.ticESG); if (profile_TBD != null) { double gain = Analytical.Query.CalculatedEquipmentSensibleGain(space); if (double.IsNaN(area) || area == 0 || double.IsNaN(gain)) { gain = 0; } else { gain = gain / area; } Update(profile_TBD, profile, gain); } } profile = internalCondition.GetProfile(ProfileType.EquipmentLatent, profileLibrary); if (profile != null) { TBD.profile profile_TBD = internalGain.GetProfile((int)TBD.Profiles.ticELG); if (profile_TBD != null) { double gain = Analytical.Query.CalculatedEquipmentLatentGain(space); if (double.IsNaN(area) || area == 0 || double.IsNaN(gain)) { gain = 0; } else { gain = gain / area; } Update(profile_TBD, profile, gain); } } profile = internalCondition.GetProfile(ProfileType.Pollutant, profileLibrary); if (profile != null) { TBD.profile profile_TBD = internalGain.GetProfile((int)TBD.Profiles.ticCOG); if (profile_TBD != null) { double generation = Analytical.Query.CalculatedPollutantGeneration(space); if (double.IsNaN(area) || area == 0 || double.IsNaN(generation)) { generation = 0; } else { generation = generation / area; } Update(profile_TBD, profile, generation); } } TBD.Thermostat thermostat = internalCondition_TBD.GetThermostat(); if (thermostat != null) { List <string> names = new List <string>(); thermostat.controlRange = 0; thermostat.proportionalControl = 0; profile = internalCondition.GetProfile(ProfileType.Cooling, profileLibrary); if (profile != null) { names.Add(profile.Name); TBD.profile profile_TBD = thermostat.GetProfile((int)TBD.Profiles.ticUL); if (profile_TBD != null) { Update(profile_TBD, profile, 1); } } profile = internalCondition.GetProfile(ProfileType.Heating, profileLibrary); if (profile != null) { names.Add(profile.Name); TBD.profile profile_TBD = thermostat.GetProfile((int)TBD.Profiles.ticLL); if (profile_TBD != null) { Update(profile_TBD, profile, 1); } } profile = internalCondition.GetProfile(ProfileType.Humidification, profileLibrary); if (profile != null) { names.Add(profile.Name); TBD.profile profile_TBD = thermostat.GetProfile((int)TBD.Profiles.ticHLL); if (profile_TBD != null) { Update(profile_TBD, profile, 1); } } profile = internalCondition.GetProfile(ProfileType.Dehumidification, profileLibrary); if (profile != null) { names.Add(profile.Name); TBD.profile profile_TBD = thermostat.GetProfile((int)TBD.Profiles.ticHUL); if (profile_TBD != null) { Update(profile_TBD, profile, 1); } } names.RemoveAll(x => string.IsNullOrWhiteSpace(x)); if (names.Count != 0) { thermostat.name = string.Join(" & ", names); } } return(true); }