public static List <Construction> ToSAM_Constructions(this ModelEnergyProperties modelEnergyProperties, MaterialLibrary materialLibrary = null) { if (modelEnergyProperties == null) { return(null); } IEnumerable <IConstruction> constructions_Honeybee = modelEnergyProperties.ConstructionList; if (constructions_Honeybee == null) { return(null); } List <Construction> result = new List <Construction>(); foreach (IConstruction construction_Honeybee in constructions_Honeybee) { Construction construction = construction_Honeybee?.ToSAM_Construction(materialLibrary); if (construction != null) { result.Add(construction); } } return(result); }
public static MaterialLibrary ToSAM_MaterialLibrary(this ModelEnergyProperties modelEnergyProperties) { if (modelEnergyProperties == null) { return(null); } IEnumerable <HoneybeeSchema.Energy.IMaterial> materials_Honeybee = modelEnergyProperties.MaterialList; if (materials_Honeybee == null) { return(null); } MaterialLibrary result = new MaterialLibrary(string.Empty); foreach (HoneybeeSchema.Energy.IMaterial material_Honeybee in materials_Honeybee) { IMaterial material = material_Honeybee.ToSAM(); if (material != null) { result.Add(material); } } return(result); }
public static Log Log(this Model model) { if (model == null) { return(null); } Log result = new Log(); Core.Modify.AddRange(result, ((IDdBaseModel)model).Log()); model.OrphanedApertures?.ForEach(x => Core.Modify.AddRange(result, Log(x as Aperture))); model.OrphanedDoors?.ForEach(x => Core.Modify.AddRange(result, Log(x as Door))); model.OrphanedFaces?.ForEach(x => Core.Modify.AddRange(result, Log(x as Face))); model.OrphanedShades?.ForEach(x => Core.Modify.AddRange(result, Log(x as Shade))); model.Rooms?.ForEach(x => Core.Modify.AddRange(result, Log(x as Room))); ModelEnergyProperties modelEnergyProperties = model.Properties.Energy; if (modelEnergyProperties != null) { modelEnergyProperties.Constructions?.ForEach(x => Core.Modify.AddRange(result, Log(x as AnyOf <OpaqueConstructionAbridged, WindowConstructionAbridged, WindowConstructionShadeAbridged, AirBoundaryConstructionAbridged, OpaqueConstruction, WindowConstruction, WindowConstructionShade, WindowConstructionDynamicAbridged, WindowConstructionDynamic, AirBoundaryConstruction, ShadeConstruction>))); modelEnergyProperties.ConstructionSets?.ForEach(x => Core.Modify.AddRange(result, Log(x as HoneybeeSchema.AnyOf <ConstructionSetAbridged, ConstructionSet>))); modelEnergyProperties.Materials?.ForEach(x => Core.Modify.AddRange(result, Log(x as AnyOf <EnergyMaterial, EnergyMaterialNoMass, EnergyWindowMaterialGas, EnergyWindowMaterialGasCustom, EnergyWindowMaterialGasMixture, EnergyWindowMaterialSimpleGlazSys, EnergyWindowMaterialBlind, EnergyWindowMaterialGlazing, EnergyWindowMaterialShade>))); modelEnergyProperties.Hvacs?.ForEach(x => Core.Modify.AddRange(result, Log(x as AnyOf <IdealAirSystemAbridged, VAV, PVAV, PSZ, PTAC, ForcedAirFurnace, FCUwithDOASAbridged, WSHPwithDOASAbridged, VRFwithDOASAbridged, FCU, WSHP, VRF, Baseboard, EvaporativeCooler, Residential, WindowAC, GasUnitHeater>))); modelEnergyProperties.ProgramTypes?.ForEach(x => Core.Modify.AddRange(result, Log(x as HoneybeeSchema.AnyOf <ProgramTypeAbridged, ProgramType>))); modelEnergyProperties.Schedules?.ForEach(x => Core.Modify.AddRange(result, Log(x as AnyOf <ScheduleRulesetAbridged, ScheduleFixedIntervalAbridged, ScheduleRuleset, ScheduleFixedInterval>))); modelEnergyProperties.ScheduleTypeLimits?.ForEach(x => Core.Modify.AddRange(result, Log(x as ScheduleTypeLimit))); } return(result); }
internal HB.ModelEnergyProperties CheckResources() { var eng = new ModelEnergyProperties(); eng.AddSchedule(this.ScheduleRuleset); eng.AddScheduleTypeLimit(this.TypeLimitObj); return(eng.DuplicateModelEnergyProperties()); }
public static ModelEnergyProperties GetResourcesByStandardConstructionSetIdentifier(string standardConstructionSet) { var year = standardConstructionSet.Split(':').First(); if (string.IsNullOrEmpty(year)) { throw new ArgumentException($"Invalid {standardConstructionSet}"); } var found = StandardsConstructionSets.TryGetValue(standardConstructionSet, out ConstructionSetAbridged cSet); if (!found) { throw new ArgumentException($"Cannot find {standardConstructionSet}"); } // get constructions var cNames = cSet.GetAllConstructions(); var constructions = cNames.Select(_ => { IConstruction con = null; if (StandardsOpaqueConstructions.TryGetValue(_, out var opaque)) { con = opaque; } else if (StandardsWindowConstructions.TryGetValue(_, out var window)) { con = window; } //TODO: Shade, AirBoundary, WindowDynamic return(con); }); var materials = constructions .SelectMany(_ => _.GetAbridgedConstructionMaterials()) .Select(_ => { IMaterial mat = null; if (StandardsOpaqueMaterials.TryGetValue(_, out var opaque)) { mat = opaque; } else if (StandardsWindowMaterials.TryGetValue(_, out var window)) { mat = window; } return(mat); }); var res = new ModelEnergyProperties(); res.AddConstructionSet(cSet); res.AddConstructions(constructions); res.AddMaterials(materials); return(res); }
public Dialog_ConstructionSetManager(ref ModelEnergyProperties libSource, bool returnSelectedOnly = false) : this() { libSource.FillNulls(); this._returnSelectedOnly = returnSelectedOnly; this._vm = new ConstructionSetManagerViewModel(libSource, this); Content = Init(out var gd); this._vm.GridControl = gd; }
public Dialog_SHWManager(ref ModelEnergyProperties libSource, bool returnSelectedOnly = false, Func <string> roomIDPicker = default) : this() { libSource.FillNulls(); this._returnSelectedOnly = returnSelectedOnly; this._vm = new SHWManagerViewModel(libSource, this, roomIDPicker: roomIDPicker); Content = Init(out var gd); this._vm.GridControl = gd; }
public void Init() { instance = Helper.EnergyLibrary.DefaultModelEnergyProperties; //var url = @"https://raw.githubusercontent.com/ladybug-tools/honeybee-standards/master/honeybee_standards/energy_default.json"; //using (System.Net.WebClient wc = new System.Net.WebClient()) //{ // var json = wc.DownloadString(url); // instance = ModelEnergyProperties.FromJson(json); //} }
public void DeserializeConstructionSetTest() { var engProp = ModelEnergyProperties.Default; var constructionSets = engProp.ConstructionSets; var count = constructionSets.Count(); var json = engProp.ToJson(); var dupEngProp = ModelEnergyProperties.FromJson(json); var count2 = dupEngProp.ConstructionSets.Count(); Assert.IsTrue(count == count2); }
public bool CalThermalValues(ModelEnergyProperties libSource = default) { this.RValue = this.WindowConstruction.RValue; this.RFactor = this.WindowConstruction.RFactor; // U value this.UValue = this.WindowConstruction.UValue; this.UFactor = this.WindowConstruction.UFactor; //SHGC, solarT, visT this.SHGC = this.WindowConstruction.SHGC; this.SolarTransmittance = this.WindowConstruction.SolarTransmittance; this.VisibleTransmittance = this.WindowConstruction.VisibleTransmittance; return(true); }
public void ConstrucitonThermalPropertiesTest() { var lib = new ModelEnergyProperties(); lib.AddMaterials(Helper.EnergyLibrary.StandardsOpaqueMaterials.Values); lib.AddMaterials(Helper.EnergyLibrary.StandardsWindowMaterials.Values); // test opaque constructions var opqs = Helper.EnergyLibrary.StandardsOpaqueConstructions; var OpaqueTests = new Dictionary <string, (double, double, double)>() { { "Typical Insulated Metal Building Roof-R19", (3.346111, 0.284911, 0.298854) }, { "Typical Built Up Roof", (0.087655, 3.977601, 11.408410) }, };
public SubConstructionSetViewModel(ref ModelEnergyProperties libSource, string cName, Action <HoneybeeSchema.IIDdBase> setAction) : base(setAction) { HoneybeeSchema.Energy.IConstruction c = null; if (!string.IsNullOrEmpty(cName)) { // check in-model lib source before system lib c = libSource.ConstructionList.FirstOrDefault(_ => _.Identifier == cName); c = c ?? SystemEnergyLib.ConstructionList.FirstOrDefault(_ => _.Identifier == cName); } this.SetPropetyObj(c); _libSource = libSource; }
internal HB.ModelEnergyProperties CheckResources(HB.ModelEnergyProperties libSource) { var eng = new ModelEnergyProperties(); eng.AddProgramType(this.ProgramType); var names = (this.ProgramType as ProgramTypeAbridged).GetAllSchedules(); var sches = names .Select(_ => libSource.ScheduleList.FirstOrDefault(m => m.Identifier == _)).Where(_ => _ != null); var schTypes = libSource.ScheduleTypeLimits.Where(_ => _ != null); eng.AddSchedules(sches); eng.AddScheduleTypeLimits(schTypes); return(eng.DuplicateModelEnergyProperties()); }
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 void GlobalConstructionSetTest() { var prop = new ModelEnergyProperties(); var global = prop.GlobalConstructionSet; Assert.IsTrue(global == GlobalConstructionSet.Default); var def = GlobalConstructionSet.Default; Assert.IsTrue(def != null); Assert.IsTrue(def.Materials.Any()); Assert.IsTrue(def.Constructions.Any()); Assert.IsTrue(def.WallSet?.ExteriorConstruction != null); Assert.IsTrue(def.FloorSet?.ExteriorConstruction != null); Assert.IsTrue(def.FloorSet?.ExteriorConstruction != null); Assert.IsTrue(def.RoofCeilingSet?.ExteriorConstruction != null); Assert.IsTrue(def.ApertureSet?.OperableConstruction != null); Assert.IsTrue(def.DoorSet?.ExteriorConstruction != null); Assert.IsTrue(def.ShadeConstruction == "Generic Shade"); Assert.IsTrue(def.AirBoundaryConstruction == "Generic Air Boundary"); }
internal HB.ModelEnergyProperties CheckResources(HB.ModelEnergyProperties systemLibSource) { var eng = new ModelEnergyProperties(); eng.AddConstructionSet(this.ConstructionSet); var cSet = this.ConstructionSet; // get constructions var cNames = cSet.GetAllConstructions(); var cons = cNames.Select(_ => systemLibSource.ConstructionList.FirstOrDefault(c => c.Identifier == _)).Where(_ => _ != null); eng.AddConstructions(cons); // get all materials var mats = cons .SelectMany(_ => _.GetAbridgedConstructionMaterials()) .Select(_ => systemLibSource.MaterialList.FirstOrDefault(m => m.Identifier == _)).Where(_ => _ != null); eng.AddMaterials(mats); return(eng); }
public static void LoadUserEnergyLibraries() { _userConstructions = new List <HBEng.IConstruction>(); _userMaterials = new List <HBEng.IMaterial>(); _userSchedules = new List <HBEng.ISchedule>(); _userConstructionSets = new List <HBEng.IBuildingConstructionset>(); _userProgramtypes = new List <HBEng.IProgramtype>(); _userScheduleTypeLimits = new List <ScheduleTypeLimit>(); var lib = LoadFromUserLibraryFolder(loadEnergy: true); if (lib.Energy != null) { var eng = lib.Energy; _userMaterials = eng.MaterialList.ToList(); _userConstructions = eng.ConstructionList.ToList(); _userConstructionSets = eng.ConstructionSetList.ToList(); _userSchedules = eng.ScheduleList.ToList(); _userProgramtypes = eng.ProgramTypeList.ToList(); _userScheduleTypeLimits = eng.ScheduleTypeLimits; _userEnergylib = eng; } }
public static List <InternalCondition> ToSAM_InternalConditions(this ModelEnergyProperties modelEnergyProperties) { if (modelEnergyProperties == null) { return(null); } IEnumerable <IProgramtype> programTypes = modelEnergyProperties.ProgramTypeList; if (programTypes == null) { return(null); } List <InternalCondition> result = new List <InternalCondition>(); foreach (IProgramtype programType in programTypes) { InternalCondition internalCondition = null; if (programType is ProgramTypeAbridged) { internalCondition = ((ProgramTypeAbridged)programType).ToSAM_InternalCondition(modelEnergyProperties); } else if (programType is ProgramType) { internalCondition = ((ProgramType)programType).ToSAM_InternalCondtion(); } if (internalCondition != null) { result.Add(internalCondition); } } return(result); }
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 void Init() { instance = ModelEnergyProperties.Default; }
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 InternalCondition ToSAM_InternalCondition(this ProgramTypeAbridged programTypeAbridged, ModelEnergyProperties modelEnergyProperties) { if (programTypeAbridged == null) { return(null); } InternalCondition result = new InternalCondition(programTypeAbridged.Identifier); PeopleAbridged peopleAbridged = programTypeAbridged.People; if (peopleAbridged != null) { result.SetValue(Analytical.InternalConditionParameter.OccupancyProfileName, peopleAbridged.OccupancySchedule); result.SetValue(Analytical.InternalConditionParameter.AreaPerPerson, 1 / peopleAbridged.PeoplePerArea); if (modelEnergyProperties != null) { IEnumerable <HoneybeeSchema.Energy.ISchedule> schedules = modelEnergyProperties.ScheduleList; if (schedules != null) { foreach (HoneybeeSchema.Energy.ISchedule schedule in schedules) { if (schedule.Identifier == peopleAbridged.ActivitySchedule) { Profile profile = schedule.ToSAM(ProfileType.Other); if (profile != null) { result.SetValue(InternalConditionParameter.TotalMetabolicRatePerPerson, profile.MaxValue); } } } } } result.SetValue(Analytical.InternalConditionParameter.OccupancyRadiantProportion, peopleAbridged.RadiantFraction); result.SetValue(Analytical.InternalConditionParameter.OccupancyViewCoefficient, 0.227); //TODDO: Implement proper OccupancyViewCoefficient if (peopleAbridged.LatentFraction != null && peopleAbridged.LatentFraction.Obj is double) { result.SetValue(InternalConditionParameter.LatentFraction, (double)peopleAbridged.LatentFraction.Obj); //TODO: Recalculate value per space } } LightingAbridged lightingAbridged = programTypeAbridged.Lighting; if (lightingAbridged != null) { result.SetValue(Analytical.InternalConditionParameter.LightingProfileName, lightingAbridged.Schedule); result.SetValue(Analytical.InternalConditionParameter.LightingGainPerArea, lightingAbridged.WattsPerArea); result.SetValue(Analytical.InternalConditionParameter.LightingRadiantProportion, lightingAbridged.RadiantFraction); result.SetValue(Analytical.InternalConditionParameter.LightingViewCoefficient, lightingAbridged.VisibleFraction); } ElectricEquipmentAbridged electricEquipmentAbridged = programTypeAbridged.ElectricEquipment; if (electricEquipmentAbridged != null) { result.SetValue(Analytical.InternalConditionParameter.EquipmentSensibleProfileName, electricEquipmentAbridged.Schedule); result.SetValue(Analytical.InternalConditionParameter.EquipmentSensibleGainPerArea, electricEquipmentAbridged.WattsPerArea); result.SetValue(Analytical.InternalConditionParameter.EquipmentRadiantProportion, electricEquipmentAbridged.RadiantFraction); result.SetValue(Analytical.InternalConditionParameter.EquipmentViewCoefficient, 0.372); //TODDO: Implement proper EquipmentViewCoefficient } InfiltrationAbridged infiltrationAbridged = programTypeAbridged.Infiltration; if (infiltrationAbridged != null) { result.SetValue(Analytical.InternalConditionParameter.InfiltrationProfileName, infiltrationAbridged.Schedule); result.SetValue(InternalConditionParameter.FlowPerExteriorArea, infiltrationAbridged.FlowPerExteriorArea); //TODO: Recalculate value per space } SetpointAbridged setPoint = programTypeAbridged.Setpoint; if (setPoint != null) { result.SetValue(Analytical.InternalConditionParameter.CoolingProfileName, setPoint.CoolingSchedule); result.SetValue(Analytical.InternalConditionParameter.HeatingProfileName, setPoint.HeatingSchedule); } VentilationAbridged ventilationAbridged = programTypeAbridged.Ventilation; if (ventilationAbridged != null) { result.SetValue(Analytical.InternalConditionParameter.SupplyAirFlow, ventilationAbridged.FlowPerZone); result.SetValue(Analytical.InternalConditionParameter.SupplyAirFlowPerArea, ventilationAbridged.FlowPerArea); result.SetValue(Analytical.InternalConditionParameter.SupplyAirFlowPerPerson, ventilationAbridged.FlowPerPerson); result.SetValue(Analytical.InternalConditionParameter.ExhaustAirFlow, ventilationAbridged.FlowPerZone); result.SetValue(Analytical.InternalConditionParameter.ExhaustAirFlowPerArea, ventilationAbridged.FlowPerArea); result.SetValue(Analytical.InternalConditionParameter.ExhaustAirFlowPerPerson, ventilationAbridged.FlowPerPerson); } return(result); }
public static Model ToLadybugTools(this BuildingModel buildingModel, double silverSpacing = Tolerance.MacroDistance, double tolerance = Tolerance.Distance) { if (buildingModel == null) { return(null); } BuildingModel architecturalModel_Temp = new BuildingModel(buildingModel); architecturalModel_Temp.OffsetAperturesOnEdge(0.1, tolerance); architecturalModel_Temp.ReplaceTransparentPartitions(0.1); architecturalModel_Temp.UpdateMaterialsByMaterialLayerThickness(tolerance); architecturalModel_Temp.UpdateMaterialsByHeatTransferCoefficients(true, true); string uniqueName = Core.LadybugTools.Query.UniqueName(architecturalModel_Temp); 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 = architecturalModel_Temp.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 <IPartition> > dictionary_elevations = Geometry.Spatial.Query.ElevationDictionary(buildingModel.GetPartitions()); 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(architecturalModel_Temp, silverSpacing, tolerance); if (room == null) { continue; } if (levels != null && levels.Count > 0) { double elevation_Min = Analytical.Query.MinElevation(buildingModel, space); 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 <IPartition> partitions_Shade = buildingModel.GetShadePartitions(); if (partitions_Shade != null) { foreach (IPartition partition_Shade in partitions_Shade) { if (partitions_Shade == null) { continue; } Shade shade = partition_Shade.ToLadybugTools_Shade(); if (shade == null) { continue; } if (shades == null) { shades = new List <Shade>(); } shades.Add(shade); } } List <HostPartitionType> hostPartitionTypes = buildingModel.GetHostPartitionTypes(); List <OpeningType> openingTypes = buildingModel.GetOpeningTypes(); 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 (hostPartitionTypes != null) { foreach (HostPartitionType hostPartitionType in hostPartitionTypes) { List <MaterialLayer> materialLayers = hostPartitionType.MaterialLayers; if (materialLayers == null) { continue; } constructions.Add(hostPartitionType.ToLadybugTools()); constructions.Add(hostPartitionType.ToLadybugTools(false)); foreach (MaterialLayer materialLayer in materialLayers) { IMaterial material = buildingModel.GetMaterial(materialLayer); if (material == null) { continue; } if (dictionary_Materials.ContainsKey(material.Name)) { continue; } HoneybeeSchema.Energy.IMaterial material_HoneybeeSchema = material.ToLadybugTools(materialLayer.Thickness, false); if (material_HoneybeeSchema == null) { continue; } dictionary_Materials[material.Name] = material_HoneybeeSchema; } } } if (openingTypes != null) { foreach (OpeningType openingType in openingTypes) { List <MaterialLayer> materialLayers = openingType.PaneMaterialLayers; if (materialLayers == null) { continue; } MaterialType materialType = buildingModel.GetMaterialType(materialLayers); if (openingType is WindowType && materialType != MaterialType.Opaque) { WindowType windowType = (WindowType)openingType; constructions.Add(windowType.ToLadybugTools_WindowConstructionAbridged()); constructions.Add(windowType.ToLadybugTools_WindowConstructionAbridged(false)); } else { constructions.Add(openingType.ToLadybugTools()); constructions.Add(openingType.ToLadybugTools(false)); } foreach (MaterialLayer materialLayer in materialLayers) { IMaterial material = buildingModel.GetMaterial(materialLayer); if (material == null) { continue; } if (dictionary_Materials.ContainsKey(material.Name)) { continue; } HoneybeeSchema.Energy.IMaterial material_HoneybeeSchema = material.ToLadybugTools(materialLayer.Thickness, false); if (material_HoneybeeSchema == null) { continue; } dictionary_Materials[material.Name] = material_HoneybeeSchema; } } } Dictionary <System.Guid, ProgramType> dictionary_ProgramTypes = new Dictionary <System.Guid, ProgramType>(); if (spaces != null) { foreach (Space space in spaces) { InternalCondition internalCondition = space?.InternalCondition; if (internalCondition == null) { continue; } if (dictionary_ProgramTypes.ContainsKey(internalCondition.Guid)) { continue; } ProgramType programType = space.ToLadybugTools(buildingModel); if (programType != null) { dictionary_ProgramTypes[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_ProgramTypes.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, buildingModel.Name, null, rooms, faces_Orphaned, shades); model.AngleTolerance = Units.Convert.ToDegrees(Tolerance.Angle);// 2; model.Tolerance = Tolerance.MacroDistance; return(model); }