/// <summary> /// Opens TAS TBD Document /// </summary> /// <param name="Name">Building Name</param> /// <param name="Description">Building Description</param> /// <returns name="TBDDocument">TBD Document</returns> /// <search> /// TAS, TBDDocument, tas, tbddocument, new tbddocument,newtbddocument /// </search> public static TBDDocument New(string Name, string Description) { TBD.TBDDocument aTBDDocument = GetTBDDocument(false); aTBDDocument.Building.name = Name; aTBDDocument.Building.description = Description; return(new TBDDocument(aTBDDocument, false)); }
public static TBD.dayType DayType(this TBD.TBDDocument tBDDocument, string name) { if (string.IsNullOrEmpty(name)) { return(null); } TBD.Calendar calendar = tBDDocument?.Building?.GetCalendar(); if (calendar == null) { return(null); } int index = 1; TBD.dayType dayType = calendar.dayTypes(index); while (dayType != null) { if (dayType.name.Equals(name)) { return(dayType); } index++; dayType = calendar.dayTypes(index); } return(null); }
private static TBD.TBDDocument GetTBDDocument(bool Save) { TBD.TBDDocument aTBDDocument = null; try { object aObject = System.Runtime.InteropServices.Marshal.GetActiveObject("TBD.Document"); if (aObject != null && aObject is TAS3D.T3DDocument) { aTBDDocument = aObject as TBD.TBDDocument; if (Save) { aTBDDocument.save(); } aTBDDocument.close(); } } catch { } if (aTBDDocument == null) { aTBDDocument = new TBD.TBDDocument(); } return(aTBDDocument); }
/// <summary> /// Close TAS TBD Document. READ ME ============== /// Option 1 = File will be close when Dynamo is restarted /// if you use Dynamo with Revit you need to restart both /// Option 2 = when script is done and you confirmed it was saved just /// go to TaskManager and End Process for TBD.exe /// </summary> /// <param name="TBDDocument">TBD Document</param> /// <returns name="integer">integer</returns> /// <search> /// TAS, TBDDocument, tas, tbddocument, close tbddocument, closebddocument /// </search> public static int Close(TBDDocument TBDDocument) { int aResult = TBDDocument.pTBDDocument.close(); TBDDocument.pTBDDocument = null; TBDDocument = null; return(aResult); }
public static bool UpdateShading(this TBD.TBDDocument tBDDocument, AnalyticalModel analyticalModel, double tolerance = Core.Tolerance.Distance) { if (tBDDocument == null || analyticalModel == null) { return(false); } return(UpdateShading(tBDDocument?.Building, analyticalModel, tolerance)); }
public static AnalyticalModel ToSAM(this TBD.TBDDocument tBDDocument) { if (tBDDocument == null) { return(null); } return(ToSAM_AnalyticalModel(tBDDocument.Building)); }
public static WeatherData ToSAM_WeatherData(this TBD.TBDDocument tBDDocument) { if (tBDDocument == null) { return(null); } return(ToSAM_WeatherData(tBDDocument.Building)); }
public static bool UpdateWeatherData(this TBD.TBDDocument tBDDocument, WeatherData weatherData) { if (tBDDocument == null || weatherData == null) { return(false); } return(UpdateWeatherData(tBDDocument.Building, weatherData)); }
public static bool Simulate(TBD.TBDDocument tBDDocument, string path_TSD, int day_First, int day_Last) { if (tBDDocument == null || string.IsNullOrWhiteSpace(path_TSD)) { return(false); } tBDDocument.simulate(day_First, day_Last, 0, 1, 0, 0, path_TSD, 1, 0); return(Core.Query.WaitToUnlock(path_TSD)); }
private static TBD.dayType[] GetDayTypeArray(TBD.TBDDocument tbdDocument) { TBD.dayType[] aDayTypeArray = new TBD.dayType[365]; TBD.Calendar aCalendar = tbdDocument.Building.GetCalendar(); for (int i = 0; i < 365; i++) { aDayTypeArray[i] = aCalendar.days(i + 1).dayType; } return(aDayTypeArray); }
public static List <bool> UpdateSurfaceOutputSpecs(this TBD.TBDDocument tBDDocument, IEnumerable <SurfaceOutputSpec> surfaceOutputSpecs) { if (tBDDocument == null || surfaceOutputSpecs == null) { return(null); } TBD.Building building = tBDDocument.Building; if (building == null) { return(null); } List <bool> result = new List <bool>(); List <TBD.SurfaceOutputSpec> surfaceOutputSpecs_TBD = building?.SurfaceOutputSpecs(); foreach (TBD.SurfaceOutputSpec surfaceOutputSpec_TBD in surfaceOutputSpecs_TBD) { tBDDocument.DeleteObjectByName(surfaceOutputSpec_TBD.name); } surfaceOutputSpecs_TBD.Clear(); foreach (SurfaceOutputSpec surfaceOutputSpec in surfaceOutputSpecs) { if (surfaceOutputSpec == null) { continue; } TBD.SurfaceOutputSpec surfaceOutputSpec_TBD = surfaceOutputSpecs_TBD.Find(x => x.name == surfaceOutputSpec.Name); if (surfaceOutputSpec_TBD == null) { surfaceOutputSpec_TBD = building.AddSurfaceOutputSpec(); if (surfaceOutputSpec.Name != null) { surfaceOutputSpec_TBD.name = surfaceOutputSpec.Name; } } surfaceOutputSpec_TBD.description = surfaceOutputSpec.Description; surfaceOutputSpec_TBD.apertureData = surfaceOutputSpec.ApertureData ? 1 : 0; surfaceOutputSpec_TBD.condensation = surfaceOutputSpec.Condensation ? 1 : 0; surfaceOutputSpec_TBD.convection = surfaceOutputSpec.Convection ? 1 : 0; surfaceOutputSpec_TBD.solarGain = surfaceOutputSpec.SolarGain ? 1 : 0; surfaceOutputSpec_TBD.conduction = surfaceOutputSpec.Conduction ? 1 : 0; surfaceOutputSpec_TBD.longWave = surfaceOutputSpec.LongWave ? 1 : 0; surfaceOutputSpec_TBD.dryBulbTemp = surfaceOutputSpec.Temperature ? 1 : 0; } return(result); }
void IDisposable.Dispose() { if (pTBDDocument != null) { if (pSave) { pTBDDocument.save(); } pTBDDocument.close(); pTBDDocument = null; } }
private TBD.TBDDocument GetTbdDocumentReadOnly() { m_tbdDocument = new TBD.TBDDocument(); if (!String.IsNullOrEmpty(tbdFilePath) && System.IO.File.Exists(tbdFilePath)) { m_tbdDocument.openReadOnly(tbdFilePath); } else if (!String.IsNullOrEmpty(tbdFilePath)) { m_tbdDocument.create(tbdFilePath); //TODO: what if an existing file has the same name? } else { BH.Engine.Base.Compute.RecordError("The TBD file does not exist"); } return(m_tbdDocument); }
// we close and save TBD private void CloseTbdDocument(bool save = true) { if (m_tbdDocument != null) { if (save == true) { m_tbdDocument.save(); } m_tbdDocument.close(); if (m_tbdDocument != null) { // issue with closing files and not closing ClearCOMObject(m_tbdDocument); m_tbdDocument = null; } } }
protected virtual void Dispose(bool disposing) { if (!disposed) { if (disposing) { // TODO: dispose managed state (managed objects). if (tBDDocument != null) { tBDDocument.close(); Core.Modify.ReleaseCOMObject(tBDDocument); tBDDocument = null; } } // TODO: free unmanaged resources (unmanaged objects) and override a finalizer below. // TODO: set large fields to null. disposed = true; } }
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 bool AssignSurfaceOutputSpecs(this TBD.TBDDocument tBDDocument, string name) { if (tBDDocument == null) { return(false); } TBD.Building building = tBDDocument.Building; if (building == null) { return(false); } List <TBD.SurfaceOutputSpec> surfaceOutputSpecs_TBD = building?.SurfaceOutputSpecs(); if (surfaceOutputSpecs_TBD == null || surfaceOutputSpecs_TBD.Count == 0) { return(false); } TBD.SurfaceOutputSpec surfaceOutputSpec = surfaceOutputSpecs_TBD.Find(x => x.name == name); if (surfaceOutputSpec == null) { return(false); } List <TBD.buildingElement> buildingElements = building.BuildingElements(); if (buildingElements == null || buildingElements.Count == 0) { return(false); } foreach (TBD.buildingElement buildingElement in buildingElements) { buildingElement.AssignSurfaceOutputSpec(surfaceOutputSpec); } return(true); }
public static TBD.TBDDocument TBDDocument() { TBD.TBDDocument tBDDocument = null; try { object aObject = Marshal.GetActiveObject("Document"); if (aObject != null) { tBDDocument = aObject as TBD.TBDDocument; Core.Modify.ReleaseCOMObject(aObject); tBDDocument = null; } } catch { } tBDDocument = new TBD.TBDDocument(); return(tBDDocument); }
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 List <string> RemoveSchedules(this TBD.TBDDocument tBDDocument, string sufix, bool caseSensitive = true, bool trim = false) { if (tBDDocument == null || string.IsNullOrWhiteSpace(sufix)) { return(null); } TBD.Building building = tBDDocument.Building; if (building == null) { return(null); } List <string> result = new List <string>(); List <TBD.schedule> schedules = building.Schedules(); if (schedules == null || schedules.Count == 0) { return(result); } string sufix_Temp = sufix; if (trim) { sufix_Temp = sufix_Temp.Trim(); } if (!caseSensitive) { sufix_Temp = sufix_Temp.ToUpper(); } foreach (TBD.schedule schedule in schedules) { string name = schedule?.name; if (string.IsNullOrEmpty(name)) { continue; } if (trim) { name = name.Trim(); } if (!caseSensitive) { name = name.ToUpper(); } if (name.EndsWith(sufix_Temp)) { result.Add(schedule.name); } } foreach (string name in result) { tBDDocument.DeleteObjectByName(name); } return(result); }
/// <summary> /// This is the method that actually does the work. /// </summary> /// <param name="dataAccess">The DA object is used to retrieve from inputs and store in outputs.</param> protected override void SolveInstance(IGH_DataAccess dataAccess) { int index_successful = Params.IndexOfOutputParam("successful"); if (index_successful != -1) { dataAccess.SetData(index_successful, false); } int index; bool run = false; index = Params.IndexOfInputParam("_run"); if (index == -1 || !dataAccess.GetData(index, ref run)) { run = false; } if (!run) { return; } string path_TBD = null; index = Params.IndexOfInputParam("_path_TBD"); if (index == -1 || !dataAccess.GetData(index, ref path_TBD) || string.IsNullOrWhiteSpace(path_TBD)) { AddRuntimeMessage(GH_RuntimeMessageLevel.Error, "Invalid data"); return; } AnalyticalModel analyticalModel = null; index = Params.IndexOfInputParam("_analyticalModel"); if (index == -1 || !dataAccess.GetData(index, ref analyticalModel) || string.IsNullOrWhiteSpace(path_TBD)) { AddRuntimeMessage(GH_RuntimeMessageLevel.Error, "Invalid data"); return; } WeatherData weatherData = null; index = Params.IndexOfInputParam("weatherData_"); if (index != -1) { if (!dataAccess.GetData(index, ref weatherData)) { weatherData = null; } } List <DesignDay> heatingDesignDays = new List <DesignDay>(); index = Params.IndexOfInputParam("heatingDesignDays_"); if (index == -1 || !dataAccess.GetDataList(index, heatingDesignDays) || heatingDesignDays == null || heatingDesignDays.Count == 0) { heatingDesignDays = null; } List <DesignDay> coolingDesignDays = new List <DesignDay>(); index = Params.IndexOfInputParam("coolingDesignDays_"); if (index == -1 || !dataAccess.GetDataList(index, coolingDesignDays) || coolingDesignDays == null || coolingDesignDays.Count == 0) { coolingDesignDays = null; } List <SurfaceOutputSpec> surfaceOutputSpecs = null; List <GH_ObjectWrapper> objectWrappers = new List <GH_ObjectWrapper>(); index = Params.IndexOfInputParam("surfaceOutputSpec_"); if (index != -1 && dataAccess.GetDataList(index, objectWrappers) && objectWrappers != null && objectWrappers.Count != 0) { surfaceOutputSpecs = new List <SurfaceOutputSpec>(); foreach (GH_ObjectWrapper objectWrapper in objectWrappers) { object value = objectWrapper.Value; if (value is IGH_Goo) { value = (value as dynamic)?.Value; } if (value is bool && ((bool)value)) { SurfaceOutputSpec surfaceOutputSpec = new SurfaceOutputSpec("Tas.Simulate"); surfaceOutputSpec.SolarGain = true; surfaceOutputSpec.Conduction = true; surfaceOutputSpec.ApertureData = false; surfaceOutputSpec.Condensation = false; surfaceOutputSpec.Convection = false; surfaceOutputSpec.LongWave = false; surfaceOutputSpec.Temperature = false; surfaceOutputSpecs.Add(surfaceOutputSpec); } else if (Core.Query.IsNumeric(value) && Core.Query.TryConvert(value, out double @double) && @double == 2.0) { surfaceOutputSpecs = new List <SurfaceOutputSpec>() { new SurfaceOutputSpec("Tas.Simulate") }; surfaceOutputSpecs[0].SolarGain = true; surfaceOutputSpecs[0].Conduction = true; surfaceOutputSpecs[0].ApertureData = true; surfaceOutputSpecs[0].Condensation = true; surfaceOutputSpecs[0].Convection = true; surfaceOutputSpecs[0].LongWave = true; surfaceOutputSpecs[0].Temperature = true; } else if (value is SurfaceOutputSpec) { surfaceOutputSpecs.Add((SurfaceOutputSpec)value); } } } bool unmetHours = false; index = Params.IndexOfInputParam("_runUnmetHours_"); if (index != -1) { if (!dataAccess.GetData(index, ref unmetHours)) { unmetHours = true; } } if (System.IO.File.Exists(path_TBD)) { System.IO.File.Delete(path_TBD); } using (SAMTBDDocument sAMTBDDocument = new SAMTBDDocument(path_TBD)) { TBD.TBDDocument tBDDocument = sAMTBDDocument.TBDDocument; if (weatherData != null) { Weather.Tas.Modify.UpdateWeatherData(tBDDocument, weatherData); } TBD.Calendar calendar = tBDDocument.Building.GetCalendar(); List <TBD.dayType> dayTypes = Grashopper.Tas.Query.DayTypes(calendar); if (dayTypes.Find(x => x.name == "HDD") == null) { TBD.dayType dayType = calendar.AddDayType(); dayType.name = "HDD"; } if (dayTypes.Find(x => x.name == "CDD") == null) { TBD.dayType dayType = calendar.AddDayType(); dayType.name = "CDD"; } Analytical.Tas.Convert.ToTBD(analyticalModel, tBDDocument); Analytical.Tas.Modify.UpdateZones(tBDDocument.Building, analyticalModel, true); if (coolingDesignDays != null || heatingDesignDays != null) { Analytical.Tas.Modify.AddDesignDays(tBDDocument, coolingDesignDays, heatingDesignDays, 30); } sAMTBDDocument.Save(); } analyticalModel = Analytical.Tas.Modify.RunWorkflow(analyticalModel, path_TBD, null, weatherData, heatingDesignDays, coolingDesignDays, surfaceOutputSpecs, unmetHours); index = Params.IndexOfOutputParam("_path_TSD"); if (index != -1) { string directory = System.IO.Path.GetDirectoryName(path_TBD); string fileName = System.IO.Path.GetFileNameWithoutExtension(path_TBD); string path_TSD = System.IO.Path.Combine(directory, string.Format("{0}.{1}", fileName, "tsd")); dataAccess.SetData(index, path_TSD); } index = Params.IndexOfOutputParam("analyticalModel"); if (index != -1) { dataAccess.SetData(index, analyticalModel); } if (index_successful != -1) { dataAccess.SetData(index_successful, true); } }
public static List <TBD.InternalCondition> InternalConditions(this TBD.TBDDocument tBDDocument) { return(InternalConditions(tBDDocument?.Building)); }
internal TBDDocument(string FilePath, bool Save) { pSave = Save; pTBDDocument = GetTBDDocument(pSave); pTBDDocument.open(FilePath); }
/// <summary> /// This is the method that actually does the work. /// </summary> /// <param name="dataAccess">The DA object is used to retrieve from inputs and store in outputs.</param> protected override void SolveInstance(IGH_DataAccess dataAccess) { dataAccess.SetData(0, false); bool run = false; if (!dataAccess.GetData(5, ref run)) { AddRuntimeMessage(GH_RuntimeMessageLevel.Error, "Invalid data"); return; } if (!run) { return; } string path_TBD = null; if (!dataAccess.GetData(0, ref path_TBD) || string.IsNullOrWhiteSpace(path_TBD)) { AddRuntimeMessage(GH_RuntimeMessageLevel.Error, "Invalid data"); return; } string path_TSD = null; if (!dataAccess.GetData(1, ref path_TSD) || string.IsNullOrWhiteSpace(path_TSD)) { AddRuntimeMessage(GH_RuntimeMessageLevel.Error, "Invalid data"); return; } int day_First = -1; if (!dataAccess.GetData(3, ref day_First)) { AddRuntimeMessage(GH_RuntimeMessageLevel.Error, "Invalid data"); return; } int day_Last = -1; if (!dataAccess.GetData(4, ref day_Last)) { AddRuntimeMessage(GH_RuntimeMessageLevel.Error, "Invalid data"); return; } List <SurfaceOutputSpec> surfaceOutputSpecs = null; List <GH_ObjectWrapper> objectWrappers = new List <GH_ObjectWrapper>(); if (dataAccess.GetDataList(2, objectWrappers) && objectWrappers != null && objectWrappers.Count != 0) { surfaceOutputSpecs = new List <SurfaceOutputSpec>(); foreach (GH_ObjectWrapper objectWrapper in objectWrappers) { object value = objectWrapper.Value; if (value is IGH_Goo) { value = (value as dynamic)?.Value; } if (value is bool && ((bool)value)) { SurfaceOutputSpec surfaceOutputSpec = new SurfaceOutputSpec("Tas.Simulate"); surfaceOutputSpec.SolarGain = true; surfaceOutputSpec.Conduction = true; surfaceOutputSpec.ApertureData = false; surfaceOutputSpec.Condensation = false; surfaceOutputSpec.Convection = false; surfaceOutputSpec.LongWave = false; surfaceOutputSpec.Temperature = false; surfaceOutputSpecs.Add(surfaceOutputSpec); } else if (Core.Query.IsNumeric(value) && Core.Query.TryConvert(value, out double @double) && @double == 2.0) { surfaceOutputSpecs = new List <SurfaceOutputSpec>() { new SurfaceOutputSpec("Tas.Simulate") }; surfaceOutputSpecs[0].SolarGain = true; surfaceOutputSpecs[0].Conduction = true; surfaceOutputSpecs[0].ApertureData = true; surfaceOutputSpecs[0].Condensation = true; surfaceOutputSpecs[0].Convection = true; surfaceOutputSpecs[0].LongWave = true; surfaceOutputSpecs[0].Temperature = true; } else if (value is SurfaceOutputSpec) { surfaceOutputSpecs.Add((SurfaceOutputSpec)value); } } } if (surfaceOutputSpecs != null && surfaceOutputSpecs.Count > 0) { using (SAMTBDDocument sAMTBDDocument = new SAMTBDDocument(path_TBD)) { TBD.TBDDocument tBDDocument = sAMTBDDocument.TBDDocument; Core.Tas.Modify.UpdateSurfaceOutputSpecs(tBDDocument, surfaceOutputSpecs); Core.Tas.Modify.AssignSurfaceOutputSpecs(tBDDocument, surfaceOutputSpecs[0].Name); sAMTBDDocument.Save(); } } bool result = Analytical.Tas.Modify.Simulate(path_TBD, path_TSD, day_First, day_Last); dataAccess.SetData(0, result); }
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 List <Guid> AssignBuildingElementType(this TBD.TBDDocument tBDDocument, TBD.BuildingElementType buildingElementType, IEnumerable <string> names, bool caseSensitive = true, bool trim = false) { return(AssignBuildingElementType(tBDDocument?.Building, buildingElementType, names, caseSensitive, trim)); }
internal TBDDocument(TBD.TBDDocument TBDDocument, bool Save) { pSave = Save; pTBDDocument = TBDDocument; }
/// <summary> /// This is the method that actually does the work. /// </summary> /// <param name="dataAccess">The DA object is used to retrieve from inputs and store in outputs.</param> protected override void SolveInstance(IGH_DataAccess dataAccess) { int index_successful = Params.IndexOfOutputParam("successful"); if (index_successful != -1) { dataAccess.SetData(index_successful, false); } int index; bool run = false; index = Params.IndexOfInputParam("_run"); if (index == -1 || !dataAccess.GetData(index, ref run)) { run = false; } if (!run) { return; } string path = null; index = Params.IndexOfInputParam("_path_TBD"); if (index == -1 || !dataAccess.GetData(index, ref path) || string.IsNullOrWhiteSpace(path)) { AddRuntimeMessage(GH_RuntimeMessageLevel.Error, "Invalid data"); return; } AnalyticalModel analyticalModel = null; index = Params.IndexOfInputParam("_analyticalModel"); if (index == -1 || !dataAccess.GetData(index, ref analyticalModel) || string.IsNullOrWhiteSpace(path)) { AddRuntimeMessage(GH_RuntimeMessageLevel.Error, "Invalid data"); return; } WeatherData weatherData = null; index = Params.IndexOfInputParam("weatherData_"); if (index != -1) { if (!dataAccess.GetData(index, ref weatherData)) { weatherData = null; } } List <DesignDay> heatingDesignDays = new List <DesignDay>(); index = Params.IndexOfInputParam("heatingDesignDays_"); if (index == -1 || !dataAccess.GetDataList(index, heatingDesignDays) || heatingDesignDays == null || heatingDesignDays.Count == 0) { heatingDesignDays = null; } List <DesignDay> coolingDesignDays = new List <DesignDay>(); index = Params.IndexOfInputParam("coolingDesignDays_"); if (index == -1 || !dataAccess.GetDataList(index, coolingDesignDays) || coolingDesignDays == null || coolingDesignDays.Count == 0) { coolingDesignDays = null; } if (System.IO.File.Exists(path)) { System.IO.File.Delete(path); } using (SAMTBDDocument sAMTBDDocument = new SAMTBDDocument(path)) { TBD.TBDDocument tBDDocument = sAMTBDDocument.TBDDocument; if (weatherData != null) { Weather.Tas.Modify.UpdateWeatherData(tBDDocument, weatherData); } TBD.Calendar calendar = tBDDocument.Building.GetCalendar(); List <TBD.dayType> dayTypes = Grashopper.Tas.Query.DayTypes(calendar); if (dayTypes.Find(x => x.name == "HDD") == null) { TBD.dayType dayType = calendar.AddDayType(); dayType.name = "HDD"; } if (dayTypes.Find(x => x.name == "CDD") == null) { TBD.dayType dayType = calendar.AddDayType(); dayType.name = "CDD"; } Analytical.Tas.Convert.ToTBD(analyticalModel, tBDDocument); Analytical.Tas.Modify.UpdateZones(tBDDocument.Building, analyticalModel, true); if (coolingDesignDays != null || heatingDesignDays != null) { Analytical.Tas.Modify.AddDesignDays(tBDDocument, coolingDesignDays, heatingDesignDays, 30); } sAMTBDDocument.Save(); } index = Params.IndexOfOutputParam("analyticalModel"); if (index != -1) { dataAccess.SetData(index, analyticalModel); } if (index_successful != -1) { dataAccess.SetData(index_successful, true); } }
public static List <Guid> AssignAdiabaticConstruction(this TBD.TBDDocument tBDDocument, string constructionName_Adiabatic, IEnumerable <string> constructionNames_Sufixes, bool caseSensitive = true, bool trim = false) { return(AssignAdiabaticConstruction(tBDDocument?.Building, constructionName_Adiabatic, constructionNames_Sufixes, caseSensitive, trim)); }
protected override void Create() { Document = new TBD.TBDDocument(); }