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); }