public static bool TBDSizing(string tbdFile, bool run = false) { if (!run) { return(false); } if (string.IsNullOrEmpty(tbdFile)) { BH.Engine.Base.Compute.RecordError("Please provide a valid TBD file path"); return(false); } TBDDocument tbdDocument = new TBDDocument(); tbdDocument.open(tbdFile); if (tbdDocument != null) { tbdDocument.sizing(0); } tbdDocument.save(); tbdDocument.close(); int intrefcountTBD = 0; do { intrefcountTBD = Marshal.FinalReleaseComObject(tbdDocument); } while (intrefcountTBD > 0); tbdDocument = null; return(true); }
public static bool TBDSizing(string tbdFile, int startDay = 0, int endDay = 365, bool autoViewResults = false, bool run = false) { if (!run) { return(false); } if (!run) { return(false); } if (string.IsNullOrEmpty(tbdFile)) { BH.Engine.Base.Compute.RecordError("Please provide a valid TBD file path"); return(false); } TBDDocument tbdDocument = new TBDDocument(); tbdDocument.open(tbdFile); string tsdFile = tbdFile.Replace(".tbd", ".tsd"); if (tbdDocument != null) { tbdDocument.simulate(startDay, endDay, autoViewResults ? 1 : 0, 1, 0, 0, tsdFile, 0, 0); tbdDocument.save(); tbdDocument.close(); } int intrefcountTBD = 0; do { intrefcountTBD = Marshal.FinalReleaseComObject(tbdDocument); } while (intrefcountTBD > 0); tbdDocument = null; return(true); }
private static bool Sizing_ExcludePositiveInternalGains(this TBDDocument tBDDocument) { if (tBDDocument == null) { return(false); } List <zone> zones = tBDDocument?.Building?.Zones(); if (zones == null) { return(false); } SizingType sizingType = SizingType.tbdDesignSizingOnly; List <Tuple <zone, TBD.InternalCondition, double> > tuples = new List <Tuple <zone, TBD.InternalCondition, double> >(); foreach (zone zone in zones) { zone.sizeHeating = (int)sizingType; zone.sizeCooling = (int)sizingType; List <TBD.InternalCondition> internalConditions = zone.InternalConditions(); if (internalConditions == null || internalConditions.Count == 0) { tuples.Add(new Tuple <zone, TBD.InternalCondition, double>(zone, null, -50)); continue; } TBD.InternalCondition internalCondition = internalConditions.Find(x => x.name.EndsWith(" - HDD")); if (internalCondition == null) { tuples.Add(new Tuple <zone, TBD.InternalCondition, double>(zone, null, -50)); continue; } tuples.Add(new Tuple <zone, TBD.InternalCondition, double>(zone, internalCondition, internalCondition.GetLowerLimit())); } List <double> temperatures_Unique = tuples.ConvertAll(x => x.Item3).Distinct().ToList(); temperatures_Unique.Sort(); if (temperatures_Unique.Count == 0) { return(false); } Dictionary <zone, double> dictionary = new Dictionary <zone, double>(); foreach (double tempearture in temperatures_Unique) { if (tempearture <= -50) { continue; } //Here we filter room that have higher temperature than current set point List <Tuple <zone, TBD.InternalCondition, double> > tuples_Temperature = tuples.FindAll(x => x.Item3 >= tempearture); foreach (Tuple <zone, TBD.InternalCondition, double> tuple in tuples_Temperature) { Thermostat thermostat = tuple.Item2?.GetThermostat(); if (thermostat == null) { continue; } profile profile = thermostat.GetProfile((int)Profiles.ticLL); if (profile == null) { continue; } profile.value = global::System.Convert.ToSingle(tempearture); } tBDDocument.save(); tBDDocument.sizing(0); tuples_Temperature = tuples_Temperature.FindAll(x => x.Item3 == tempearture); foreach (Tuple <zone, TBD.InternalCondition, double> tuple in tuples_Temperature) { if (!dictionary.ContainsKey(tuple.Item1)) { dictionary[tuple.Item1] = tuple.Item1.maxHeatingLoad; } } } sizingType = SizingType.tbdNoSizing; foreach (KeyValuePair <zone, double> keyValuePair in dictionary) { zone zone = keyValuePair.Key; zone.sizeCooling = (int)sizingType; zone.sizeHeating = (int)sizingType; zone.maxHeatingLoad = global::System.Convert.ToSingle(keyValuePair.Value); } return(true); }