public static AnalyticalModel UpdateFacingExternal(this AnalyticalModel analyticalModel, TBD.TBDDocument tBDDocument) { if (analyticalModel == null || tBDDocument == null) { return(null); } Dictionary <string, TBD.zone> zones = tBDDocument.Building?.ZoneDictionary(); if (zones == null) { return(null); } AdjacencyCluster adjacencyCluster = analyticalModel.AdjacencyCluster; if (adjacencyCluster == null) { return(null); } Dictionary <string, Space> spaces = adjacencyCluster.SpaceDictionary(); if (spaces == null) { return(null); } if (zones.Count == 0 || spaces.Count == 0) { return(new AnalyticalModel(analyticalModel)); } foreach (KeyValuePair <string, Space> keyValuePair in spaces) { TBD.zone zone = null; if (!zones.TryGetValue(keyValuePair.Key, out zone)) { continue; } if (zone == null) { continue; } Space space_New = UpdateFacingExternal(keyValuePair.Value, zone); if (space_New == null) { continue; } adjacencyCluster.AddObject(space_New); } return(new AnalyticalModel(analyticalModel, adjacencyCluster)); }
public static Space UpdateFacingExternal(this Space space, TBD.zone zone) { if (space == null || zone == null) { return(null); } int index = 0; TBD.zoneSurface zoneSurface = zone.GetSurface(index); bool facingExternal = false; bool facingExternalGlazing = false; while (zoneSurface != null) { if (zoneSurface.buildingElement != null) { string name = zoneSurface.buildingElement.name; if (!string.IsNullOrEmpty(name) && name.ToUpper().Contains("ADIABATIC")) { zoneSurface.type = TBD.SurfaceType.tbdNullLink; } if (!facingExternal) { facingExternal = !string.IsNullOrEmpty(name) && name.ToUpper().Contains("EXT") && !name.ToUpper().Contains("GRD"); } if (!facingExternalGlazing) { facingExternalGlazing = !string.IsNullOrEmpty(name) && name.ToUpper().Contains("EXT_GLZ"); } } if (facingExternal && facingExternalGlazing) { zoneSurface = null; } else { index++; zoneSurface = zone.GetSurface(index); } } Space space_New = new Space(space); space_New.SetValue(SpaceParameter.FacingExternal, facingExternal); space_New.SetValue(SpaceParameter.FacingExternalGlazing, facingExternalGlazing); return(space_New); }
/// <summary> /// Gets TAS Building zones /// </summary> /// <param name="Building">TAS Building</param> /// <returns name="Zones">Zone List</returns> /// <search> /// TAS, Building, Zones, Get Zones, tas, builidng, zones, get zones /// </search> public static List <Zone> Zones(Building Building) { List <Zone> aZoneList = new List <Zone>(); int aIndex = 0; TBD.zone aZone = Building.pBuilding.GetZone(aIndex); while (aZone != null) { aZoneList.Add(new Zone(aZone)); aIndex++; aZone = Building.pBuilding.GetZone(aIndex); } return(aZoneList); }
/// <summary> /// Gets TAS Zone Group zones /// </summary> /// <param name="ZoneGroup">TAS Zone Group</param> /// <returns name="Zones">Zone List</returns> /// <search> /// TAS, ZoneGroup, Zones, Get Zones, tas, builidng, zones, get zones /// </search> public static List <Zone> Zones(ZoneGroup ZoneGroup) { List <Zone> aZoneList = new List <Zone>(); int aIndex = 0; TBD.zone aZone = ZoneGroup.pZoneGroup.GetZone(aIndex); while (aZone != null) { aZoneList.Add(new Zone(aZone)); aIndex++; aZone = ZoneGroup.pZoneGroup.GetZone(aIndex); } return(aZoneList); }
/// <summary> /// Gets TAS Internal Condition Zones /// </summary> /// <param name="InternalCondition">TAS Internal Condition</param> /// <returns name="Zones">Zone List</returns> /// <search> /// TAS, InternalCondition, Zones, Get Zones, tas, internalcondition, zones, get zones, Internal Condition /// </search> public static List <Zone> Zones(InternalCondition InternalCondition) { List <Zone> aZoneList = new List <Zone>(); int aIndex = 0; TBD.zone aZone = InternalCondition.pInternalCondition.GetZone(aIndex); while (aZone != null) { aZoneList.Add(new Zone(aZone)); aIndex++; aZone = InternalCondition.pInternalCondition.GetZone(aIndex); } return(aZoneList); }
public static TBD.zone ToTAS(this BHE.Space space, TBD.zone tbdSpace) { //TODO:Assign Internal Conditions to Zones //TODO:Assign Building Elements (Surfaces) to Zones if (space == null) { return(tbdSpace); } tbdSpace.name = space.Name; BHP.LoadFragment loads = space.FindFragment <BHP.LoadFragment>(typeof(BHP.LoadFragment)); if (loads != null) { tbdSpace.maxHeatingLoad = (float)loads.HeatingLoad; tbdSpace.maxCoolingLoad = (float)loads.CoolingLoad; } TASSpaceData tasFragment = space.FindFragment <TASSpaceData>(typeof(TASSpaceData)); if (tasFragment != null) { tbdSpace.colour = tasFragment.Colour; tbdSpace.daylightFactor = (float)tasFragment.DaylightFactor; tbdSpace.exposedPerimeter = (float)tasFragment.ExposedPerimeter; tbdSpace.external = tasFragment.External; tbdSpace.facadeLength = (float)tasFragment.FacadeLength; tbdSpace.fixedConvectionCoefficient = (float)tasFragment.FixedConvectionCoefficient; tbdSpace.floorArea = (float)tasFragment.FloorArea; tbdSpace.GUID = tasFragment.TASID; tbdSpace.length = (float)tasFragment.Length; tbdSpace.sizeCooling = tasFragment.SizeCooling; tbdSpace.sizeHeating = tasFragment.SizeHeating; tbdSpace.volume = (float)tasFragment.Volume; tbdSpace.wallFloorAreaRatio = (float)tasFragment.WallFloorAreaRatio; } TASDescription tasDescription = space.FindFragment <TASDescription>(typeof(TASDescription)); if (tasFragment != null) { tbdSpace.description = tasDescription.Description; } return(tbdSpace); }
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); }
/***************************************************/ /**** Private Methods ****/ /***************************************************/ private List <Space> ReadSpaces(List <string> ids = null) { TBD.Building building = m_tbdDocument.Building; List <Space> spaces = new List <Space>(); int zoneIndex = 0; while (building.GetZone(zoneIndex) != null) { TBD.zone zone = m_tbdDocument.Building.GetZone(zoneIndex); spaces.Add(BH.Engine.Adapters.TAS.Convert.FromTAS(zone, m_tbdDocument)); zoneIndex++; } return(spaces); }
public static List <TBD.room> Rooms(this TBD.zone zone) { List <TBD.room> result = new List <TBD.room>(); int index = 0; TBD.room room = zone.GetRoom(index); while (room != null) { result.Add(room); index++; room = zone.GetRoom(index); } return(result); }
public static List <TBD.IZoneSurface> ZoneSurfaces(this TBD.zone zone) { List <TBD.IZoneSurface> result = new List <TBD.IZoneSurface>(); int index = 0; TBD.IZoneSurface zoneSurface = zone.GetSurface(index); while (zoneSurface != null) { result.Add(zoneSurface); index++; zoneSurface = zone.GetSurface(index); } return(result); }
public static List <TBD.zone> Zones(this TBD.Building building) { if (building == null) { return(null); } List <TBD.zone> result = new List <TBD.zone>(); TBD.zone aZone = building.GetZone(result.Count); while (aZone != null) { result.Add(aZone); aZone = building.GetZone(result.Count); } return(result); }
public static List <TBD.zone> Zones(this TBD.InternalCondition internalCondition) { if (internalCondition == null) { return(null); } List <TBD.zone> result = new List <TBD.zone>(); TBD.zone zone = internalCondition.GetZone(result.Count); while (zone != null) { result.Add(zone); zone = internalCondition.GetZone(result.Count); } 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 List <TBD.zone> GetZones(TBD.TBDDocument tbdDocument) { if (tbdDocument == null) { return(null); } List <TBD.zone> aZoneList = new List <TBD.zone>(); int aIndex = 0; TBD.zone aZone = tbdDocument.Building.GetZone(aIndex); while (aZone != null) { aZoneList.Add(aZone); aIndex++; aZone = tbdDocument.Building.GetZone(aIndex); } return(aZoneList); }
public static SpaceSimulationResult SpaceSimulationResult(this TBD.zone zone, LoadType loadType) { if (zone == null || loadType == LoadType.Undefined) { return(null); } string name = zone.name; string reference = zone.GUID; double area = zone.floorArea; double volume = zone.volume; double designLoad = loadType == LoadType.Cooling ? zone.maxCoolingLoad : zone.maxHeatingLoad; SpaceSimulationResult result = new SpaceSimulationResult(name, Query.Source(), reference); result.SetValue(Analytical.SpaceSimulationResultParameter.Area, area); result.SetValue(Analytical.SpaceSimulationResultParameter.Volume, volume); result.SetValue(Analytical.SpaceSimulationResultParameter.DesignLoad, designLoad); result.SetValue(Analytical.SpaceSimulationResultParameter.LoadType, loadType.Text()); return(result); }
public static List <TBD.InternalCondition> InternalConditions(this TBD.zone zone) { if (zone == null) { return(null); } List <TBD.InternalCondition> result = new List <TBD.InternalCondition>(); int count = 0; TBD.InternalCondition internalCondition = zone.GetIC(count); while (internalCondition != null) { result.Add(internalCondition); count++; internalCondition = zone.GetIC(count); } return(result); }
public static Dictionary <string, TBD.zone> ZoneDictionary(this TBD.Building building) { Dictionary <string, TBD.zone> result = new Dictionary <string, TBD.zone>(); int index = 0; TBD.zone zone = building.GetZone(index); while (zone != null) { string name = zone.name; if (name != null) { result[name] = zone; } index++; zone = building.GetZone(index); } return(result); }
private static TBD.InternalCondition GetInternalCondition(TBD.zone zone, TBD.dayType dayType) { if (zone == null) { return(null); } int aIndex = 0; TBD.InternalCondition aInternalCondition = zone.GetIC(aIndex); while (aInternalCondition != null) { if (HasDayType(aInternalCondition, dayType)) { return(aInternalCondition); } aIndex++; aInternalCondition = zone.GetIC(aIndex); } return(null);; }
public static TBD.InternalCondition InternalCondition(this TBD.zone zone, TBD.dayType dayType) { if (zone == null) { return(null); } int index = 0; TBD.InternalCondition internalCondition = zone.GetIC(index); while (internalCondition != null) { if (HasDayType(internalCondition, dayType)) { return(internalCondition); } index++; internalCondition = zone.GetIC(index); } return(null); }
public static Space ToSAM(this TBD.zone zone, out List <InternalCondition> internalConditions) { internalConditions = null; if (zone == null) { return(null); } Space result = new Space(zone.name); double area = zone.floorArea; result.SetValue(SpaceParameter.Area, area); result.SetValue(SpaceParameter.Volume, zone.volume); List <TBD.InternalCondition> internalConditions_TBD = zone.InternalConditions(); if (internalConditions_TBD != null) { internalConditions = new List <InternalCondition>(); foreach (TBD.InternalCondition internalCondition_TBD in internalConditions_TBD) { InternalCondition internalCondition = internalCondition_TBD.ToSAM(area); if (internalCondition == null) { continue; } internalConditions.Add(internalCondition); } } return(result); }
internal Zone(TBD.zone Zone) { pZone = Zone; }
public static BHE.Space FromTAS(this TBD.zone tbdSpace, TBD.TBDDocument tbdDocument) { BHE.Space space = new BHE.Space(); space.Name = tbdSpace.name + tbdSpace.number.ToString(); BHP.LoadFragment loads = new BHP.LoadFragment(); loads.CoolingLoad = tbdSpace.maxCoolingLoad; loads.HeatingLoad = tbdSpace.maxHeatingLoad; space.Fragments.Add(loads); //Adding data to Extended Poroperties-------------------------------------------------------------------------------------------------------------- //EnvironmentContextProperties BHP.OriginContextFragment environmentContextProperties = new BHP.OriginContextFragment(); environmentContextProperties.ElementID = tbdSpace.GUID.RemoveBrackets(); environmentContextProperties.Description = tbdSpace.description; environmentContextProperties.TypeName = tbdSpace.name; space.Fragments.Add(environmentContextProperties); //SpaceContextProperties BHP.SpaceContextFragment spaceContextProperties = new BHP.SpaceContextFragment(); spaceContextProperties.Colour = BH.Engine.Adapters.TAS.Query.GetRGB(tbdSpace.colour).ToString(); spaceContextProperties.IsExternal = tbdSpace.external != 0; //spaceContextProperties.ConnectedElements = tbdSpace.external != 0; space.Fragments.Add(spaceContextProperties); //SpaceAnalyticalProperties BHP.SpaceAnalyticalFragment spaceAnalyticalProperties = new BHP.SpaceAnalyticalFragment(); spaceAnalyticalProperties.DaylightFactor = tbdSpace.daylightFactor; spaceAnalyticalProperties.FacadeLength = tbdSpace.facadeLength; spaceAnalyticalProperties.FixedConvectionCoefficient = tbdSpace.fixedConvectionCoefficient; spaceAnalyticalProperties.SizeCoolingMethod = ((TBD.SizingType)tbdSpace.sizeCooling).FromTAS(); spaceAnalyticalProperties.SizeHeatingMethod = ((TBD.SizingType)tbdSpace.sizeCooling).FromTAS(); space.Fragments.Add(spaceAnalyticalProperties); //Extended Properties TASSpaceData tasData = new TASSpaceData(); tasData.Colour = System.Convert.ToUInt32(tbdSpace.colour); tasData.DaylightFactor = tbdSpace.daylightFactor; tasData.ExposedPerimeter = tbdSpace.exposedPerimeter; tasData.External = tbdSpace.external; tasData.FacadeLength = tbdSpace.facadeLength; tasData.FixedConvectionCoefficient = tbdSpace.fixedConvectionCoefficient; tasData.FloorArea = tbdSpace.floorArea; tasData.TASID = tbdSpace.GUID.RemoveBrackets(); tasData.Length = tbdSpace.length; tasData.SizeCooling = tbdSpace.sizeCooling; tasData.SizeHeating = tbdSpace.sizeHeating; tasData.Volume = tbdSpace.volume; tasData.WallFloorAreaRatio = tbdSpace.wallFloorAreaRatio; TASDescription tasDescription = new TASDescription(); tasDescription.Description = tbdSpace.description; //Proces to extract Number of people directly into space if needed //double[] YearlyPeopleSensibleSepcificGain = Query.GetNumberOfPeople(tbdDocument, tbdSpace); //double MaxSpecificSensibleGain = YearlyPeopleSensibleSepcificGain.Max(); //double[] YearlyPeopleLatenteSepcificGain = Query.GetNumberOfPeople(tbdDocument, tbdSpace, TBD.Profiles.ticOLG); //double MaxSpecificLatentGain = YearlyPeopleLatenteSepcificGain.Max(); //double NumberOfPeople = PeopleDesity / tbdSpace.floorArea; space.Fragments.Add(tasData); space.Fragments.Add(tasDescription); return(space); }
public static TBD.IZAM IZAM(this TBD.Building building, Space space, string name, bool from, IEnumerable <TBD.zone> zones, IEnumerable <TBD.dayType> dayTypes) { string directionText = "To"; if (from) { directionText = "From"; } string name_Direction = null; if (!space.TryGetValue(string.Format("SAM_IZAM_{0}_Source", directionText), out name_Direction, true)) { return(null); } if (string.IsNullOrWhiteSpace(name_Direction)) { return(null); } TBD.IZAM iZAM = building.AddIZAM(null); foreach (TBD.dayType aDayType in dayTypes) { iZAM.SetDayType(aDayType, true); } TBD.zone zone_Source = null; TBD.zone zone_Assign = null; TBD.zone zone = zones.Zone(name_Direction); if (zone != null) { if (from) { iZAM.name = string.Format("IZAM_{0}_FROM_{1}", name, name_Direction); zone_Source = zone; zone_Assign = zones.Zone(name); } else { iZAM.name = string.Format("IZAM_{0}_FROM_{1}", name_Direction, name); zone_Source = zones.Zone(name); zone_Assign = zone; } } else { iZAM.name = string.Format("IZAM_{0}_{1} OUTSIDE", name, directionText.ToUpper()); zone_Assign = zones.Zone(name); if (from) { iZAM.fromOutside = 1; } else { iZAM.fromOutside = 0; } } if (zone_Source != null) { iZAM.SetSourceZone(zone_Source); } if (zone_Assign != null) { zone_Assign.AssignIZAM(iZAM, true); } TBD.profile profile = iZAM.GetProfile(); profile.type = TBD.ProfileTypes.ticValueProfile; double value; if (space.TryGetValue(string.Format("SAM_IZAM_{0}_Value", directionText), out value, true)) { profile.value = (float)value; } double factor; if (space.TryGetValue(string.Format("SAM_IZAM_{0}_ValueFactor", directionText), out factor, true)) { profile.factor = (float)factor; } double setbackValue; if (space.TryGetValue(string.Format("SAM_IZAM_{0}_ValueSetBack", directionText), out setbackValue, true)) { profile.setbackValue = (float)setbackValue; } string scheduleValues = null; if (space.TryGetValue(string.Format("SAM_IZAM_{0}_Schedule", directionText), out scheduleValues, true)) { string name_Schedule = string.Format("SAM_IZAM_{0}_Schedule_{1}", directionText, "IZAMSCHED"); List <int> values = scheduleValues.Ints(); TBD.schedule schedule = Schedule(building, name_Schedule, values); if (schedule != null) { profile.schedule = schedule; } } return(iZAM); }
/// <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 double[] GetNumberOfPeople(TBD.TBDDocument tbdDocument, TBD.zone tbdZone) { if (tbdDocument == null) { return(null); } TBD.dayType[] aDayTypeArray = GetDayTypeArray(tbdDocument); List <TBD.dayType> aDayTypeList_Unique = GetUnique(aDayTypeArray); double[] aHourlyValues = null; double[] aHourlyValuesLatent = null; double aTotalPersonGain = 0; Dictionary <string, double[]> aDictionary_DayType = new Dictionary <string, double[]>(); Dictionary <string, double[]> aDictionary_DayTypeLatent = new Dictionary <string, double[]>(); foreach (TBD.dayType aDayType in aDayTypeList_Unique) { TBD.InternalCondition aInternalCondition = GetInternalCondition(tbdZone, aDayType); if (aInternalCondition == null) { continue; } TBD.IInternalGain aInternalGain = aInternalCondition.GetInternalGain(); aTotalPersonGain = aInternalGain.personGain; TBD.profile aProfile = aInternalGain.GetProfile((int)TBD.Profiles.ticOSG); TBD.profile aProfileLatent = aInternalGain.GetProfile((int)TBD.Profiles.ticOLG); //check if profile hourly or yearly if yearly take it and skip next step aHourlyValues = GetHourlyValues(aProfile); aHourlyValuesLatent = GetHourlyValues(aProfileLatent); //double[] result = x.Select(r => r * factor).ToArray(); aHourlyValues = MultiplyByFactor(aHourlyValues, aProfile.factor); aHourlyValuesLatent = MultiplyByFactor(aHourlyValuesLatent, aProfile.factor); aDictionary_DayType.Add(aDayType.name, aHourlyValues); aDictionary_DayTypeLatent.Add(aDayType.name, aHourlyValuesLatent); } double[] aYearlyValues = new double[8760]; int aCount = 0; for (int i = 0; i < 365; i++) { TBD.dayType aDayType = aDayTypeArray[i]; if (!aDictionary_DayType.ContainsKey(aDayType.name)) { break; } aHourlyValues = aDictionary_DayType[aDayType.name]; for (int j = 0; j < 24; j++) { aYearlyValues[aCount] = aHourlyValues[j]; aCount++; } } double[] aYearlyValuesLatent = new double[8760]; aCount = 0; for (int i = 0; i < 365; i++) { TBD.dayType aDayType = aDayTypeArray[i]; if (!aDictionary_DayType.ContainsKey(aDayType.name)) { break; } aHourlyValuesLatent = aDictionary_DayTypeLatent[aDayType.name]; for (int j = 0; j < 24; j++) { aYearlyValuesLatent[aCount] = aHourlyValuesLatent[j]; aCount++; } } double[] aNumberOfPeople = new double[7]; double aMaxSpecificSensibleGain = aYearlyValues.Max();//Unit W/m2 sensible gain aNumberOfPeople[0] = aMaxSpecificSensibleGain; double aMaxSpecificLatentGain = aYearlyValuesLatent.Max();//Unit W/m2 latent gain aNumberOfPeople[1] = aMaxSpecificLatentGain; double aPeopleDesity = (aMaxSpecificLatentGain + aMaxSpecificSensibleGain) / aTotalPersonGain; //Unit people/m2 aNumberOfPeople[2] = aPeopleDesity; double aPeople = tbdZone.floorArea * aPeopleDesity; aNumberOfPeople[3] = aPeople; double aPersonSensibleGain = aMaxSpecificSensibleGain / aPeopleDesity; //sensible gain per person aNumberOfPeople[4] = aPersonSensibleGain; double aPersonLatenteGain = aMaxSpecificLatentGain / aPeopleDesity; //sensible gain per person aNumberOfPeople[5] = aPersonLatenteGain; double aMetabolicRateCheck = aPersonSensibleGain + aPersonLatenteGain; aNumberOfPeople[6] = aMetabolicRateCheck; return(aYearlyValues); }
public static TBD.Building ToTBD(this AnalyticalModel analyticalModel, TBD.TBDDocument tBDDocument) { if (analyticalModel == null) { return(null); } TBD.Building result = tBDDocument.Building; if (result == null) { return(null); } AdjacencyCluster adjacencyCluster = analyticalModel.AdjacencyCluster; if (adjacencyCluster == null) { return(null); } List <Space> spaces = adjacencyCluster.GetSpaces(); if (spaces == null) { return(result); } MaterialLibrary materialLibrary = analyticalModel.MaterialLibrary; Plane plane = Plane.WorldXY; List <TBD.DaysShade> daysShades = new List <TBD.DaysShade>(); result.ClearShadingData(); Dictionary <System.Guid, List <TBD.zoneSurface> > dictionary_Panel = new Dictionary <System.Guid, List <TBD.zoneSurface> >(); Dictionary <System.Guid, List <TBD.zoneSurface> > dictionary_Aperture = new Dictionary <System.Guid, List <TBD.zoneSurface> >(); foreach (Space space in spaces) { Shell shell = adjacencyCluster.Shell(space); if (shell == null) { return(null); } TBD.zone zone = result.AddZone(); zone.name = space.Name; zone.volume = System.Convert.ToSingle(shell.Volume()); if (space.TryGetValue(SpaceParameter.Color, out SAMColor sAMColor) && sAMColor != null) { zone.colour = Core.Convert.ToUint(sAMColor.ToColor()); } List <Face3D> face3Ds = Geometry.Spatial.Query.Section(shell, 0.01, false); if (face3Ds != null && face3Ds.Count != 0) { face3Ds.RemoveAll(x => x == null || !x.IsValid()); zone.floorArea = System.Convert.ToSingle(face3Ds.ConvertAll(x => x.GetArea()).Sum()); zone.exposedPerimeter = System.Convert.ToSingle(face3Ds.ConvertAll(x => Geometry.Planar.Query.Perimeter(x.ExternalEdge2D)).Sum()); zone.length = System.Convert.ToSingle(face3Ds.ConvertAll(x => Geometry.Tas.Query.Length(x)).Sum()); } TBD.room room = zone.AddRoom(); List <TBD.buildingElement> buildingElements = result.BuildingElements(); List <TBD.Construction> constructions = result.Constructions(); List <Panel> panels = adjacencyCluster?.GetPanels(space); if (panels != null || panels.Count != 0) { foreach (Panel panel in panels) { string name_Panel = panel.Name; if (string.IsNullOrWhiteSpace(name_Panel)) { continue; } Face3D face3D_Panel = panel.Face3D; if (face3D_Panel == null) { continue; } BoundingBox3D boundingBox3D_Panel = face3D_Panel.GetBoundingBox(); TBD.zoneSurface zoneSurface_Panel = zone.AddSurface(); zoneSurface_Panel.orientation = System.Convert.ToSingle(Geometry.Spatial.Query.Azimuth(panel, Vector3D.WorldY)); zoneSurface_Panel.inclination = System.Convert.ToSingle(Geometry.Spatial.Query.Tilt(panel)); zoneSurface_Panel.altitude = System.Convert.ToSingle(boundingBox3D_Panel.GetCentroid().Z); zoneSurface_Panel.altitudeRange = System.Convert.ToSingle(boundingBox3D_Panel.Max.Z - boundingBox3D_Panel.Min.Z); zoneSurface_Panel.area = System.Convert.ToSingle(face3D_Panel.GetArea()); zoneSurface_Panel.planHydraulicDiameter = System.Convert.ToSingle(Geometry.Tas.Query.HydraulicDiameter(face3D_Panel)); TBD.RoomSurface roomSurface_Panel = room.AddSurface(); roomSurface_Panel.area = zoneSurface_Panel.area; roomSurface_Panel.zoneSurface = zoneSurface_Panel; Geometry.SolarCalculator.SolarFaceSimulationResult solarFaceSimulationResult = analyticalModel.GetResults <Geometry.SolarCalculator.SolarFaceSimulationResult>(panel)?.FirstOrDefault(); if (solarFaceSimulationResult != null) { List <TBD.SurfaceShade> surfaceShades = Modify.UpdateSurfaceShades(result, daysShades, zoneSurface_Panel, analyticalModel, solarFaceSimulationResult); } TBD.Perimeter perimeter_Panel = Geometry.Tas.Convert.ToTBD(panel.GetFace3D(true), roomSurface_Panel); if (perimeter_Panel == null) { continue; } PanelType panelType = panel.PanelType; TBD.buildingElement buildingElement_Panel = buildingElements.Find(x => x.name == name_Panel); if (buildingElement_Panel == null) { TBD.Construction construction_TBD = null; Construction construction = panel.Construction; if (construction != null) { construction_TBD = constructions.Find(x => x.name == construction.Name); if (construction_TBD == null) { construction_TBD = result.AddConstruction(null); construction_TBD.name = construction.Name; if (construction.Transparent(materialLibrary)) { construction_TBD.type = TBD.ConstructionTypes.tcdTransparentConstruction; } List <ConstructionLayer> constructionLayers = construction.ConstructionLayers; if (constructionLayers != null && constructionLayers.Count != 0) { int index = 1; foreach (ConstructionLayer constructionLayer in constructionLayers) { Material material = analyticalModel?.MaterialLibrary?.GetMaterial(constructionLayer.Name) as Core.Material; if (material == null) { continue; } TBD.material material_TBD = construction_TBD.AddMaterial(material); if (material_TBD != null) { material_TBD.width = System.Convert.ToSingle(constructionLayer.Thickness); construction_TBD.materialWidth[index] = System.Convert.ToSingle(constructionLayer.Thickness); index++; } } } constructions.Add(construction_TBD); } if (panelType == PanelType.Undefined && construction != null) { panelType = construction.PanelType(); if (panelType == PanelType.Undefined && construction.TryGetValue(ConstructionParameter.DefaultPanelType, out string panelTypeString)) { panelType = Core.Query.Enum <PanelType>(panelTypeString); } } } buildingElement_Panel = result.AddBuildingElement(); buildingElement_Panel.name = name_Panel; buildingElement_Panel.colour = Core.Convert.ToUint(Analytical.Query.Color(panelType)); buildingElement_Panel.BEType = Query.BEType(panelType.Text()); buildingElement_Panel.AssignConstruction(construction_TBD); buildingElements.Add(buildingElement_Panel); } if (buildingElement_Panel != null) { zoneSurface_Panel.buildingElement = buildingElement_Panel; } zoneSurface_Panel.type = TBD.SurfaceType.tbdExposed; List <Aperture> apertures = panel.Apertures; if (apertures != null && apertures.Count != 0) { bool @internal = adjacencyCluster.Internal(panel); foreach (Aperture aperture in apertures) { string name_Aperture = aperture.Name; if (string.IsNullOrWhiteSpace(name_Aperture)) { continue; } name_Aperture = string.Format("{0} -pane", aperture.Name); Face3D face3D_Aperture = aperture.Face3D; if (face3D_Aperture == null) { continue; } BoundingBox3D boundingBox3D_Aperture = face3D_Aperture.GetBoundingBox(); float area = System.Convert.ToSingle(face3D_Aperture.GetArea()); TBD.zoneSurface zoneSurface_Aperture = zoneSurface_Panel.AddChildSurface(area); if (zoneSurface_Aperture == null) { continue; } zoneSurface_Aperture.orientation = zoneSurface_Panel.orientation; zoneSurface_Aperture.inclination = zoneSurface_Panel.inclination; zoneSurface_Aperture.altitude = System.Convert.ToSingle(boundingBox3D_Aperture.GetCentroid().Z); zoneSurface_Aperture.altitudeRange = System.Convert.ToSingle(boundingBox3D_Aperture.Max.Z - boundingBox3D_Aperture.Min.Z); zoneSurface_Aperture.planHydraulicDiameter = System.Convert.ToSingle(Geometry.Tas.Query.HydraulicDiameter(face3D_Aperture)); //zoneSurface_Aperture.area = System.Convert.ToSingle(face3D_Aperture.GetArea()); zoneSurface_Aperture.type = @internal ? TBD.SurfaceType.tbdLink : zoneSurface_Panel.type; TBD.RoomSurface roomSurface_Aperture = room.AddSurface(); roomSurface_Aperture.area = zoneSurface_Aperture.area; roomSurface_Aperture.zoneSurface = zoneSurface_Aperture; TBD.Perimeter perimeter_Aperture = Geometry.Tas.Convert.ToTBD(face3D_Aperture, roomSurface_Aperture); if (perimeter_Aperture == null) { continue; } TBD.buildingElement buildingElement_Aperture = buildingElements.Find(x => x.name == name_Aperture); if (buildingElement_Aperture == null) { TBD.Construction construction_TBD = null; ApertureConstruction apertureConstruction = aperture.ApertureConstruction; if (apertureConstruction != null) { construction_TBD = constructions.Find(x => x.name == apertureConstruction.Name); if (construction_TBD == null) { construction_TBD = result.AddConstruction(null); construction_TBD.name = name_Aperture; if (apertureConstruction.Transparent(materialLibrary)) { construction_TBD.type = TBD.ConstructionTypes.tcdTransparentConstruction; } List <ConstructionLayer> constructionLayers = apertureConstruction.PaneConstructionLayers; if (constructionLayers != null && constructionLayers.Count != 0) { int index = 1; foreach (ConstructionLayer constructionLayer in constructionLayers) { Core.Material material = materialLibrary?.GetMaterial(constructionLayer.Name) as Material; if (material == null) { continue; } TBD.material material_TBD = construction_TBD.AddMaterial(material); if (material_TBD != null) { material_TBD.width = System.Convert.ToSingle(constructionLayer.Thickness); construction_TBD.materialWidth[index] = System.Convert.ToSingle(constructionLayer.Thickness); index++; } } } constructions.Add(construction_TBD); } } ApertureType apertureType = aperture.ApertureType; buildingElement_Aperture = result.AddBuildingElement(); buildingElement_Aperture.name = name_Aperture; buildingElement_Aperture.colour = Core.Convert.ToUint(Analytical.Query.Color(apertureType)); buildingElement_Aperture.BEType = Query.BEType(apertureType, false); buildingElement_Aperture.AssignConstruction(construction_TBD); buildingElements.Add(buildingElement_Aperture); } if (buildingElement_Aperture != null) { zoneSurface_Aperture.buildingElement = buildingElement_Aperture; } if (!dictionary_Aperture.TryGetValue(aperture.Guid, out List <TBD.zoneSurface> zoneSurfaces_Aperture) || zoneSurfaces_Aperture == null) { zoneSurfaces_Aperture = new List <TBD.zoneSurface>(); dictionary_Aperture[aperture.Guid] = zoneSurfaces_Aperture; } zoneSurfaces_Aperture.Add(zoneSurface_Aperture); } } zoneSurface_Panel.type = Query.SurfaceType(panelType); if (!dictionary_Panel.TryGetValue(panel.Guid, out List <TBD.zoneSurface> zoneSurfaces_Panel) || zoneSurfaces_Panel == null) { zoneSurfaces_Panel = new List <TBD.zoneSurface>(); dictionary_Panel[panel.Guid] = zoneSurfaces_Panel; } zoneSurfaces_Panel.Add(zoneSurface_Panel); } } } foreach (KeyValuePair <System.Guid, List <TBD.zoneSurface> > keyValuePair in dictionary_Panel) { if (keyValuePair.Value == null || keyValuePair.Value.Count <= 1) { continue; } keyValuePair.Value[1].linkSurface = keyValuePair.Value[0]; keyValuePair.Value[0].linkSurface = keyValuePair.Value[1]; if (keyValuePair.Value[0].inclination == 0 || keyValuePair.Value[0].inclination == 180) { float inclination = keyValuePair.Value[1].inclination; inclination -= 180; if (inclination < 0) { inclination += 360; } keyValuePair.Value[1].inclination = inclination; keyValuePair.Value[1].reversed = 1; } else { float orientation = keyValuePair.Value[1].orientation; orientation += 180; if (orientation >= 360) { orientation -= 360; } keyValuePair.Value[1].orientation = orientation; keyValuePair.Value[1].reversed = 1; float inclination = keyValuePair.Value[1].inclination; if (inclination > 180) { inclination -= 180; } keyValuePair.Value[1].inclination = inclination; } } foreach (KeyValuePair <System.Guid, List <TBD.zoneSurface> > keyValuePair in dictionary_Aperture) { if (keyValuePair.Value == null || keyValuePair.Value.Count <= 1) { continue; } keyValuePair.Value[1].linkSurface = keyValuePair.Value[0]; keyValuePair.Value[0].linkSurface = keyValuePair.Value[1]; if (keyValuePair.Value[0].inclination == 0 || keyValuePair.Value[0].inclination == 180) { float inclination = keyValuePair.Value[0].inclination; inclination -= 180; if (inclination < 0) { inclination += 360; } keyValuePair.Value[0].inclination = inclination; keyValuePair.Value[0].reversed = 1; } else { float orientation = keyValuePair.Value[1].orientation; orientation += 180; if (orientation >= 360) { orientation -= 360; } keyValuePair.Value[1].orientation = orientation; keyValuePair.Value[1].reversed = 1; } } return(result); }
/***************************************************/ public List <Panel> ReadBuildingElements(List <string> ids = null) { TBD.Building building = m_tbdDocument.Building; List <Panel> buildingElements = new List <Panel>(); int zoneIndex = 0; TBD.zone zone = null; while ((zone = building.GetZone(zoneIndex)) != null) { int zoneSurfaceIndex = 0; TBD.zoneSurface zoneSrf = null; while ((zoneSrf = zone.GetSurface(zoneSurfaceIndex)) != null) { //check to exlude tine area if (zoneSrf.internalArea > 0 || zoneSrf.area > 0.2) { buildingElements.Add(zoneSrf.buildingElement.FromTAS(zoneSrf, _tasSettings)); } zoneSurfaceIndex++; } zoneIndex++; } //Clean up building elements with openings and constructions List <Panel> nonOpeningElements = buildingElements.Where(x => { TASPanelData fragment = x.FindFragment <TASPanelData>(typeof(TASPanelData)); return(fragment.PanelIsOpening); }).ToList(); List <Panel> frameElements = buildingElements.Where(x => { TASPanelData fragment = x.FindFragment <TASPanelData>(typeof(TASPanelData)); return(fragment.PanelIsOpening && fragment.OpeningIsFrame); }).ToList(); List <Panel> panes = buildingElements.Where(x => { TASPanelData fragment = x.FindFragment <TASPanelData>(typeof(TASPanelData)); return(fragment.PanelIsOpening && !fragment.OpeningIsFrame); }).ToList(); foreach (Panel element in nonOpeningElements) { //Sort out opening construction OriginContextFragment originContext = element.FindFragment <OriginContextFragment>(typeof(OriginContextFragment)); string elementID = (originContext != null ? originContext.ElementID : ""); element.Openings = new List <Opening>(); List <Panel> frames = frameElements.Where(x => { return(x.Openings.Where(y => { TASOpeningData fragment = y.FindFragment <TASOpeningData>(typeof(TASOpeningData)); return fragment.ParentGUID == elementID; }).Count() > 0); }).ToList(); foreach (Panel frame in frames) { Panel pane = panes.Where(x => (x.FindFragment <OriginContextFragment>(typeof(OriginContextFragment))).TypeName == frame.Name.Replace("frame", "pane")).FirstOrDefault(); if (pane != null) { Opening newOpening = new Opening(); newOpening.Edges = frame.ExternalEdges; newOpening.Fragments = new FragmentSet(pane.Fragments); string oldname = (newOpening.FindFragment <OriginContextFragment>(typeof(OriginContextFragment))).TypeName; (newOpening.FindFragment <OriginContextFragment>(typeof(OriginContextFragment))).TypeName = oldname.RemoveStringPart(" -pane"); newOpening.Name = oldname.RemoveStringPart(" -pane"); element.Openings.Add(newOpening); } } } return(nonOpeningElements); }
internal Zone(TBD.zone Zone) { pZone = Zone; pName = pZone.name; pGUID = pZone.GUID; }