def test_new(): """py.test for IDF.new()""" idf = IDF() idf.new() # assert idf.idfobjects['building'.upper()] == Idf_MSequence() assert idf.idfobjects["building".upper()].list1 == [] assert idf.idfobjects["building".upper()].list2 == []
def test_newidfobject(): """py.test for newidfobject""" # make a blank idf # make a function for this and then continue. idf = IDF() idf.new() objtype = 'material:airgap'.upper() obj = idf.newidfobject(objtype, Name='Argon') obj = idf.newidfobject(objtype, Name='Krypton') obj = idf.newidfobject(objtype, Name='Xenon') assert idf.model.dt[objtype] == [['MATERIAL:AIRGAP', 'Argon'], ['MATERIAL:AIRGAP', 'Krypton'], ['MATERIAL:AIRGAP', 'Xenon'], ] # remove an object idf.popidfobject(objtype, 1) assert idf.model.dt[objtype] == [['MATERIAL:AIRGAP', 'Argon'], ['MATERIAL:AIRGAP', 'Xenon'], ] lastobject = idf.idfobjects[objtype][-1] idf.removeidfobject(lastobject) assert idf.model.dt[objtype] == [['MATERIAL:AIRGAP', 'Argon'], ] # copyidfobject onlyobject = idf.idfobjects[objtype][0] idf.copyidfobject(onlyobject) assert idf.model.dt[objtype] == [['MATERIAL:AIRGAP', 'Argon'], ['MATERIAL:AIRGAP', 'Argon'], ] # test some functions objtype = 'FENESTRATIONSURFACE:DETAILED' obj = idf.newidfobject(objtype, Name='A Wall') assert obj.coords == [] assert obj.fieldvalues[1] == 'A Wall'
def test_new(): """py.test for IDF.new()""" idf = IDF() idf.new() # assert idf.idfobjects['building'.upper()] == Idf_MSequence() assert idf.idfobjects['building'.upper()].list1 == [] assert idf.idfobjects['building'.upper()].list2 == []
def test_newidfobject(): """py.test for newidfobject""" # make a blank idf # make a function for this and then continue. idf = IDF() idf.new() objtype = "material:airgap".upper() obj = idf.newidfobject(objtype, Name="Argon") obj = idf.newidfobject(objtype, Name="Krypton") obj = idf.newidfobject(objtype, Name="Xenon") assert idf.model.dt[objtype] == [ ["MATERIAL:AIRGAP", "Argon"], ["MATERIAL:AIRGAP", "Krypton"], ["MATERIAL:AIRGAP", "Xenon"], ] # remove an object idf.popidfobject(objtype, 1) assert idf.model.dt[objtype] == [ ["MATERIAL:AIRGAP", "Argon"], ["MATERIAL:AIRGAP", "Xenon"], ] lastobject = idf.idfobjects[objtype][-1] idf.removeidfobject(lastobject) assert idf.model.dt[objtype] == [["MATERIAL:AIRGAP", "Argon"]] # copyidfobject onlyobject = idf.idfobjects[objtype][0] idf.copyidfobject(onlyobject) assert idf.model.dt[objtype] == [ ["MATERIAL:AIRGAP", "Argon"], ["MATERIAL:AIRGAP", "Argon"], ] # remove all objects idf.removeallidfobjects(objtype) assert len(idf.idfobjects[objtype]) == 0 # test some functions objtype = "FENESTRATIONSURFACE:DETAILED" obj = idf.newidfobject(objtype, Name="A Wall") assert obj.coords == [] assert obj.fieldvalues[1] == "A Wall" # test defaultvalues=True and defaultvalues=False sim_deftrue = idf.newidfobject("SimulationControl".upper(), defaultvalues=True) assert sim_deftrue.Do_Zone_Sizing_Calculation == "No" sim_deffalse = idf.newidfobject("SimulationControl".upper(), defaultvalues=False) assert sim_deffalse.Do_Zone_Sizing_Calculation == ""
def test_newidfobject(): """py.test for newidfobject""" # make a blank idf # make a function for this and then continue. idf = IDF() idf.new() objtype = 'material:airgap'.upper() obj = idf.newidfobject(objtype, Name='Argon') obj = idf.newidfobject(objtype, Name='Krypton') obj = idf.newidfobject(objtype, Name='Xenon') assert idf.model.dt[objtype] == [ ['MATERIAL:AIRGAP', 'Argon'], ['MATERIAL:AIRGAP', 'Krypton'], ['MATERIAL:AIRGAP', 'Xenon'], ] # remove an object idf.popidfobject(objtype, 1) assert idf.model.dt[objtype] == [ ['MATERIAL:AIRGAP', 'Argon'], ['MATERIAL:AIRGAP', 'Xenon'], ] lastobject = idf.idfobjects[objtype][-1] idf.removeidfobject(lastobject) assert idf.model.dt[objtype] == [ ['MATERIAL:AIRGAP', 'Argon'], ] # copyidfobject onlyobject = idf.idfobjects[objtype][0] idf.copyidfobject(onlyobject) assert idf.model.dt[objtype] == [ ['MATERIAL:AIRGAP', 'Argon'], ['MATERIAL:AIRGAP', 'Argon'], ] # test some functions objtype = 'FENESTRATIONSURFACE:DETAILED' obj = idf.newidfobject(objtype, Name='A Wall') assert obj.coords == [] assert obj.fieldvalues[1] == 'A Wall' # test defaultvalues=True and defaultvalues=False sim_deftrue = idf.newidfobject('SimulationControl'.upper(), defaultvalues=True) assert sim_deftrue.Do_Zone_Sizing_Calculation == 'No' sim_deffalse = idf.newidfobject('SimulationControl'.upper(), defaultvalues=False) assert sim_deffalse.Do_Zone_Sizing_Calculation == ''
def test_newidfobject_warning(): """Test that the warning for newidfobject created with `aname` is working. Fails if the warning is not issued when `aname` is used, or if the warning is issued when `aname` is not used. """ # make a blank idf # make a function for this and then continue. idf = IDF() idf.new() objtype = "material:airgap".upper() # expect warnings here with pytest.warns(UserWarning): idf.newidfobject(objtype, aname="Krypton") with pytest.warns(UserWarning): idf.newidfobject(objtype, "Krypton") # expect no warnings here - we pass None so as not to trigger the `Failed: DID NOT WARN` message from pytest with pytest.warns(None) as captured_warnings: idf.newidfobject(objtype, Name="Krypton") assert len(captured_warnings) == 0
def test_newidfobject_warning(): """Test that the warning for newidfobject created with `aname` is working. Fails if the warning is not issued when `aname` is used, or if the warning is issued when `aname` is not used. """ # make a blank idf # make a function for this and then continue. idf = IDF() idf.new() objtype = 'material:airgap'.upper() # expect warnings here with pytest.warns(UserWarning): idf.newidfobject(objtype, aname="Krypton") with pytest.warns(UserWarning): idf.newidfobject(objtype, "Krypton") # expect no warnings here - we pass None so as not to trigger the `Failed: DID NOT WARN` message from pytest with pytest.warns(None) as captured_warnings: idf.newidfobject(objtype, Name="Krypton") assert len(captured_warnings) == 0
def test_newidfobject(): """py.test for newidfobject""" # make a blank idf # make a function for this and then continue. idf = IDF() idf.new() objtype = 'material:airgap'.upper() obj = idf.newidfobject(objtype, Name='Argon') obj = idf.newidfobject(objtype, Name='Krypton') obj = idf.newidfobject(objtype, Name='Xenon') assert idf.model.dt[objtype] == [['MATERIAL:AIRGAP', 'Argon'], ['MATERIAL:AIRGAP', 'Krypton'], ['MATERIAL:AIRGAP', 'Xenon'], ] # remove an object idf.popidfobject(objtype, 1) assert idf.model.dt[objtype] == [['MATERIAL:AIRGAP', 'Argon'], ['MATERIAL:AIRGAP', 'Xenon'], ] lastobject = idf.idfobjects[objtype][-1] idf.removeidfobject(lastobject) assert idf.model.dt[objtype] == [['MATERIAL:AIRGAP', 'Argon'], ] # copyidfobject onlyobject = idf.idfobjects[objtype][0] idf.copyidfobject(onlyobject) assert idf.model.dt[objtype] == [['MATERIAL:AIRGAP', 'Argon'], ['MATERIAL:AIRGAP', 'Argon'], ] # test some functions objtype = 'FENESTRATIONSURFACE:DETAILED' obj = idf.newidfobject(objtype, Name='A Wall') assert obj.coords == [] assert obj.fieldvalues[1] == 'A Wall' # test defaultvalues=True and defaultvalues=False sim_deftrue = idf.newidfobject('SimulationControl'.upper(), defaultvalues=True) assert sim_deftrue.Do_Zone_Sizing_Calculation == 'No' sim_deffalse = idf.newidfobject('SimulationControl'.upper(), defaultvalues=False) assert sim_deffalse.Do_Zone_Sizing_Calculation == ''
def test_newidfobject(): """py.test for newidfobject""" # make a blank idf # make a function for this and then continue. idf = IDF() idf.new() objtype = 'material:airgap'.upper() obj = idf.newidfobject(objtype, Name='Argon') obj = idf.newidfobject(objtype, Name='Krypton') obj = idf.newidfobject(objtype, Name='Xenon') assert idf.model.dt[objtype] == [ ['MATERIAL:AIRGAP', 'Argon'], ['MATERIAL:AIRGAP', 'Krypton'], ['MATERIAL:AIRGAP', 'Xenon'], ] # remove an object idf.popidfobject(objtype, 1) assert idf.model.dt[objtype] == [ ['MATERIAL:AIRGAP', 'Argon'], ['MATERIAL:AIRGAP', 'Xenon'], ] lastobject = idf.idfobjects[objtype][-1] idf.removeidfobject(lastobject) assert idf.model.dt[objtype] == [ ['MATERIAL:AIRGAP', 'Argon'], ] # copyidfobject onlyobject = idf.idfobjects[objtype][0] idf.copyidfobject(onlyobject) assert idf.model.dt[objtype] == [ ['MATERIAL:AIRGAP', 'Argon'], ['MATERIAL:AIRGAP', 'Argon'], ] # test some functions objtype = 'FENESTRATIONSURFACE:DETAILED' obj = idf.newidfobject(objtype, Name='A Wall') assert obj.coords == [] assert obj.fieldvalues[1] == 'A Wall'
def test_newidfobject_warning(): """Test that the warning for newidfobject created with `aname` is working. Fails if the warning is not issued when `aname` is used, or if the warning is issued when `aname` is not used. """ # make a blank idf # make a function for this and then continue. idf = IDF() idf.new() objtype = 'material:airgap'.upper() # expect warnings here pytest.warns(UserWarning, idf.newidfobject, objtype, aname="Krypton") pytest.warns(UserWarning, idf.newidfobject, objtype, "Krypton") # expect no warnings here # This works because pytest.warn raises an exception if no warning is # produced. We expect this and catch it with pytest.raises. pytest.raises(Exception, pytest.warns, UserWarning, idf.newidfobject, objtype, Name="Krypton")
def generate_idf3(save_path, idf_data, idf_surfaces, idf_fenestration, wall_type, window_type, save_as): mater = 'Material' # All glazi = 'WindowMaterial:SimpleGlazingSystem' # All const = 'Construction' # All surfa = 'BuildingSurface:Detailed' # For geometry fenes = 'FenestrationSurface:Detailed' # For geometry gen00 = 'Version' # All gen01 = 'SimulationControl' # All gen02 = 'RunPeriod' # All gen03 = 'Building' # All gen04 = 'Timestep' # All gen05 = 'SizingPeriod:WeatherFileDays' # All gen06 = 'RunPeriodControl:DaylightSavingTime' # All gen07 = 'Site:GroundTemperature:BuildingSurface' # All gen08 = 'GlobalGeometryRules' # All zon01 = 'ZoneVentilation:DesignFlowRate' # For geometry zon02 = 'ZoneInfiltration:DesignFlowRate' # For geometry zon03 = 'ZoneList' # For geometry zon04 = 'Zone' # For geometry lds01 = 'People' # For geometry lds02 = 'Lights' # For geometry lds03 = 'ElectricEquipment' # For geometry sch01 = 'Schedule:Compact' sch02 = 'ScheduleTypeLimits' sch03 = 'Schedule:Day:Interval' sch04 = 'Schedule:Week:Daily' sch05 = 'Schedule:Year' sch06 = 'Schedule:Constant' hvc01 = 'HVACTemplate:Thermostat' # All hvc02 = 'HVACTemplate:Zone:VAV' # For geometry hvc03 = 'HVACTemplate:System:PackagedVAV' # All out01 = 'Output:Surfaces:Drawing' out02 = 'OutputControl:Table:Style' out03 = 'Output:Table:SummaryReports' del_01 = 'LifeCycleCost:Parameters' del_02 = 'LifeCycleCost:UsePriceEscalation' del_03 = 'ZoneControl:Thermostat' del_04 = 'ThermostatSetpoint:DualSetpoint' del_05 = 'HVACTemplate:Zone:IdealLoadsAirSystem' del_06 = 'DesignSpecification:OutdoorAir' del_07 = 'Sizing:Parameters' del_08 = 'Material:AirGap' del_09 = 'WindowMaterial:Blind' del_10 = 'WindowMaterial:Glazing' del_11 = 'WindowProperty:FrameAndDivider' del_12 = 'WindowProperty:ShadingControl' del_13 = 'Site:Location' del_14 = 'Output:VariableDictionary' del_15 = 'Output:SQLite' del_16 = 'LifeCycleCost:NonrecurringCost' # Assignments gen00 = idf_data.idfobjects[gen00.upper()][0] gen01 = idf_data.idfobjects[gen01.upper()][0] gen02 = idf_data.idfobjects[gen02.upper()][0] gen03 = idf_data.idfobjects[gen03.upper()][0] gen04 = idf_data.idfobjects[gen04.upper()][0] gen05 = idf_data.idfobjects[gen05.upper()][0] gen06 = idf_data.idfobjects[gen06.upper()][0] gen07 = idf_data.idfobjects[gen07.upper()][0] gen08 = idf_data.idfobjects[gen08.upper()][0] zon01 = idf_surfaces.idfobjects[zon01.upper()][0] zon02 = idf_surfaces.idfobjects[zon02.upper()][0] zon03 = idf_surfaces.idfobjects[zon03.upper()][0] zon04 = idf_surfaces.idfobjects[zon04.upper()] lds01 = idf_surfaces.idfobjects[lds01.upper()][0] lds02 = idf_surfaces.idfobjects[lds02.upper()][0] lds03 = idf_surfaces.idfobjects[lds03.upper()][0] sch01 = idf_data.idfobjects[sch01.upper()] sch02 = idf_data.idfobjects[sch02.upper()] sch03 = idf_data.idfobjects[sch03.upper()] sch04 = idf_data.idfobjects[sch04.upper()] sch05 = idf_data.idfobjects[sch05.upper()] sch06 = idf_data.idfobjects[sch06.upper()] hvc01 = idf_data.idfobjects[hvc01.upper()][0] hvc02 = idf_surfaces.idfobjects[hvc02.upper()] hvc03 = idf_data.idfobjects[hvc03.upper()][0] out01 = idf_data.idfobjects[out01.upper()][0] out02 = idf_data.idfobjects[out02.upper()][0] out03 = idf_data.idfobjects[out03.upper()][0] # MATERIALS mater = idf_data.idfobjects[mater.upper()] glazi = idf_data.idfobjects[glazi.upper()] # CONSTRUCTION const = idf_data.idfobjects[const.upper()] # GEOMETRY surface_objects = idf_surfaces.idfobjects[surfa.upper()] fenestration_objects = idf_fenestration.idfobjects[fenes.upper()] # CREATE NEW IDF FILE # with common info and specific geometry idf2 = IDF() idf2.new() # copy over relevant info from source idfs # GENERAL idf2.copyidfobject(gen00) idf2.copyidfobject(gen01) idf2.copyidfobject(gen02) idf2.copyidfobject(gen03) idf2.copyidfobject(gen04) idf2.copyidfobject(gen05) idf2.copyidfobject(gen06) idf2.copyidfobject(gen07) idf2.copyidfobject(gen08) # ZONE idf2.copyidfobject(zon01) idf2.copyidfobject(zon02) idf2.copyidfobject(zon03) # idf2.copyidfobject(zon04) # LOADS idf2.copyidfobject(lds01) idf2.copyidfobject(lds02) idf2.copyidfobject(lds03) # HVAC idf2.copyidfobject(hvc01) # idf2.copyidfobject(hvc02) idf2.copyidfobject(hvc03) # OUTPUT idf2.copyidfobject(out01) idf2.copyidfobject(out02) idf2.copyidfobject(out03) # SCHEDULES for i in sch01: idf2.copyidfobject(i) for i in sch02: idf2.copyidfobject(i) for i in sch03: idf2.copyidfobject(i) for i in sch04: idf2.copyidfobject(i) for i in sch05: idf2.copyidfobject(i) for i in sch06: idf2.copyidfobject(i) for i in zon04: idf2.copyidfobject(i) for i in hvc02: idf2.copyidfobject(i) # MATERIALS for i in mater: idf2.copyidfobject(i) # GLAZING for i in glazi: idf2.copyidfobject(i) # CONSTRUCTIONS for i in const: idf2.copyidfobject(i) # Basic setup done # Now I need geometry from a specific file. # GEOMETRY for i in surface_objects: idf2.copyidfobject(i) for i in fenestration_objects: idf2.copyidfobject(i) new_surface = idf2.idfobjects[surfa.upper()] new_subsurface = idf2.idfobjects[fenes.upper()] # Now I want to change the construction of each surface and glazing. floor_type = 'Slab A' ceiling_type = 'Slab A' roof_type = 'Roof A' for surface in new_surface: if surface['Surface_Type'] == 'Floor': surface.Construction_Name = floor_type for surface in new_surface: if surface['Surface_Type'] == 'Ceiling': surface.Construction_Name = ceiling_type for surface in new_surface: if surface['Surface_Type'] == 'Roof': surface.Construction_Name = roof_type for surface in new_surface: if surface['Surface_Type'] == 'Wall': surface.Construction_Name = wall_type for subsurface in new_subsurface: if subsurface['Surface_Type'] == 'Window': subsurface.Construction_Name = window_type # Save it to the disk. idf2.saveas('{}/{}.idf'.format(save_path, save_as)) idf_file = '{}/{}.idf'.format(save_path, save_as) return idf_file