def run_for_single_building(building, bpr, weather_data, date, locator,
                            use_dynamic_infiltration_calculation, resolution_output, loads_output,
                            massflows_output, temperatures_output, format_output, config, write_detailed_output, debug):
    calc_thermal_loads(building, bpr, weather_data, date, locator,
                       use_dynamic_infiltration_calculation, resolution_output, loads_output,
                       massflows_output, temperatures_output, format_output, config, write_detailed_output, debug)
    df = pd.read_csv(locator.get_demand_results_file(building, format_output))
    return building, float(df['Qhs_sys_kWh'].sum()), df['Qcs_sys_kWh'].sum(), float(df['Qww_sys_kWh'].sum())
def thermal_loads_all_buildings(building_properties, date, gv, locator, num_buildings, usage_schedules,
                                weather_data):
    for i, building in enumerate(building_properties.list_building_names()):
        bpr = building_properties[building]
        thermal_loads.calc_thermal_loads(
            building, bpr, weather_data, usage_schedules, date, gv, locator)
        gv.log('Building No. %(bno)i completed out of %(num_buildings)i: %(building)s', bno=i + 1,
               num_buildings=num_buildings, building=building)
def thermal_loads_all_buildings(building_properties, date, gv, locator, list_building_names, usage_schedules,
                                weather_data, use_dynamic_infiltration_calculation):
    num_buildings = len(list_building_names)
    for i, building in enumerate(list_building_names):
        bpr = building_properties[building]
        thermal_loads.calc_thermal_loads(building, bpr, weather_data, usage_schedules, date, gv, locator,
                                         use_dynamic_infiltration_calculation)
        gv.log('Building No. %(bno)i completed out of %(num_buildings)i: %(building)s', bno=i + 1,
               num_buildings=num_buildings, building=building)
Exemple #4
0
def run_for_single_building(building, bpr, weather_data, date_range, locator,
                            use_dynamic_infiltration_calculation, resolution_outputs, loads_output,
                            massflows_output, temperatures_output, config, debug):
    config.multiprocessing = False
    schedule_maker_main(locator, config, building=building)
    calc_thermal_loads(building, bpr, weather_data, date_range, locator,
                       use_dynamic_infiltration_calculation, resolution_outputs, loads_output, massflows_output,
                       temperatures_output, config, debug)
    df = pd.read_csv(locator.get_demand_results_file(building))
    return building, float(df['Qhs_sys_kWh'].sum()), df['Qcs_sys_kWh'].sum(), float(df['Qww_sys_kWh'].sum())
def thermal_loads_all_buildings(building_properties, date, gv, locator,
                                num_buildings, usage_schedules, weather_data):
    for i, building in enumerate(building_properties.list_building_names()):
        bpr = building_properties[building]
        thermal_loads.calc_thermal_loads(building, bpr, weather_data,
                                         usage_schedules, date, gv, locator)
        gv.log(
            'Building No. %(bno)i completed out of %(num_buildings)i: %(building)s',
            bno=i + 1,
            num_buildings=num_buildings,
            building=building)
Exemple #6
0
def run_for_single_building(building, bpr, weather_data, usage_schedules, date,
                            gv, locator, use_stochastic_occupancy,
                            use_dynamic_infiltration_calculation,
                            resolution_output, loads_output, massflows_output,
                            temperatures_output, format_output, region):
    calc_thermal_loads(building, bpr, weather_data, usage_schedules, date, gv,
                       locator, use_stochastic_occupancy,
                       use_dynamic_infiltration_calculation, resolution_output,
                       loads_output, massflows_output, temperatures_output,
                       format_output, region)
    df = pd.read_csv(locator.get_demand_results_file(building, format_output))
    return building, float(
        df['Qhs_sys_kWh'].sum()), df['Qcs_sys_kWh'].sum(), float(
            df['Qww_sys_kWh'].sum())
Exemple #7
0
def calc_demand_singleprocessing(
        building_properties, date_range, locator, list_building_names,
        weather_data, use_dynamic_infiltration_calculation, resolution_outputs,
        loads_output, massflows_output, temperatures_output, format_output,
        config, write_detailed_output, debug):
    num_buildings = len(list_building_names)
    for i, building in enumerate(list_building_names):
        bpr = building_properties[building]
        thermal_loads.calc_thermal_loads(
            building, bpr, weather_data, date_range, locator,
            use_dynamic_infiltration_calculation, resolution_outputs,
            loads_output, massflows_output, temperatures_output, format_output,
            config, write_detailed_output, debug)
        print('Building No. %i completed out of %i: %s' %
              (i + 1, num_buildings, building))
def calc_demand_singleprocessing(
        building_properties, date, locator, list_building_names,
        usage_schedules, weather_data, use_dynamic_infiltration_calculation,
        use_stochastic_occupancy, resolution_outputs, loads_output,
        massflows_output, temperatures_output, format_output, region):
    num_buildings = len(list_building_names)
    for i, building in enumerate(list_building_names):
        bpr = building_properties[building]
        thermal_loads.calc_thermal_loads(
            building, bpr, weather_data, usage_schedules, date, locator,
            use_stochastic_occupancy, use_dynamic_infiltration_calculation,
            resolution_outputs, loads_output, massflows_output,
            temperatures_output, format_output, region)
        print('Building No. %i completed out of %i: %s' %
              (i + 1, num_buildings, building))
Exemple #9
0
    def test_calc_thermal_loads_new_ventilation(self):
        # FIXME: the usage_schedules bit needs to be fixed!!
        bpr = self.building_properties['B01']
        result = calc_thermal_loads('B01', bpr, self.weather_data,
                                    self.usage_schedules, self.date, self.gv, self.locator)
        self.assertIsNone(result)
        self.assertTrue(os.path.exists(self.locator.get_demand_results_file('B01')), 'Building csv not produced')
        self.assertTrue(os.path.exists(self.locator.get_temporary_file('B01T.csv')),
                        'Building temp file not produced')

        # test the building csv file
        df = pd.read_csv(self.locator.get_demand_results_file('B01'))
        #
        # expected_columns = self.gv.demand_building_csv_columns
        # print expected_columns
        # set(expected_columns)
        # self.assertEqual(set(expected_columns), set(df.columns),
        #                  'Column list of building csv does not match: ' + str(
        #                      set(expected_columns).symmetric_difference(set(df.columns))))
        # self.assertEqual(df.shape[0], 8760, 'Expected one row per hour in the year')

        value_columns = [u'Ealf_kWh', u'Eauxf_kWh', u'Edataf_kWh', u'Ef_kWh', u'QCf_kWh', u'QHf_kWh',
                         u'Qcdataf_kWh', u'Qcref_kWh', u'Qcs_kWh', u'Qcsf_kWh', u'Qhs_kWh', u'Qhsf_kWh', u'Qww_kWh',
                         u'Qwwf_kWh', u'Tcsf_re_C', u'Thsf_re_C', u'Twwf_re_C', u'Tcsf_sup_C', u'Thsf_sup_C',
                         u'Twwf_sup_C']
        values = [155102.61600000001, 2786.3400000000001, 0.0, 157888.95600000001, 81124.394, 150471.052, 0.0, 0.0,
                  73314.964999999997, 81124.394, 99848.559000000008, 110534.87899999999, 37198.886999999995, 39936.178,
                  16826, 43329, 99496.0, 11866, 49218, 525600]
        for i, column in enumerate(value_columns):
            try:
                self.assertAlmostEqual(values[i], df[column].sum(), msg='Sum of column %s differs' % column, places=3)
            except:
                raise
Exemple #10
0
    def test_calc_thermal_loads(self):
        bpr = self.building_properties['B1011']
        self.config.general.multiprocessing = False
        self.config.schedule_maker.schedule_model = "deterministic"
        schedule_maker_main(self.locator, self.config, building='B1011')

        result = calc_thermal_loads(
            'B1011', bpr, self.weather_data, self.date_range, self.locator,
            self.use_dynamic_infiltration_calculation, self.resolution_output,
            self.loads_output, self.massflows_output, self.temperatures_output,
            self.config, self.debug)
        self.assertIsNone(result)
        self.assertTrue(
            os.path.exists(self.locator.get_demand_results_file('B1011')),
            'Building csv not produced')
        self.assertTrue(
            os.path.exists(self.locator.get_temporary_file('B1011T.csv')),
            'Building temp file not produced')

        # test the building csv file (output of the `calc_thermal_loads` call above)
        df = pd.read_csv(self.locator.get_demand_results_file('B1011'))

        value_columns = json.loads(
            self.test_config.get('test_calc_thermal_loads', 'value_columns'))
        values = json.loads(
            self.test_config.get('test_calc_thermal_loads', 'values'))

        for i, column in enumerate(value_columns):
            self.assertAlmostEqual(values[i],
                                   df[column].sum(),
                                   msg='Sum of column %s differs, %f != %f' %
                                   (column, values[i], df[column].sum()),
                                   places=3)
Exemple #11
0
    def test_calc_thermal_loads(self):
        bpr = self.building_properties['B01']
        result = calc_thermal_loads(
            'B01', bpr, self.weather_data, self.usage_schedules, self.date,
            self.gv, self.locator, self.use_stochastic_occupancy,
            self.use_dynamic_infiltration_calculation, self.resolution_output,
            self.loads_output, self.massflows_output, self.temperatures_output,
            self.format_output, self.region)
        self.assertIsNone(result)
        self.assertTrue(
            os.path.exists(
                self.locator.get_demand_results_file('B01',
                                                     self.format_output)),
            'Building csv not produced')
        self.assertTrue(
            os.path.exists(self.locator.get_temporary_file('B01T.csv')),
            'Building temp file not produced')

        # test the building csv file (output of the `calc_thermal_loads` call above)
        df = pd.read_csv(
            self.locator.get_demand_results_file('B01', self.format_output))

        value_columns = json.loads(
            self.test_config.get('test_calc_thermal_loads', 'value_columns'))
        values = json.loads(
            self.test_config.get('test_calc_thermal_loads', 'values'))

        for i, column in enumerate(value_columns):
            self.assertAlmostEqual(values[i],
                                   df[column].sum(),
                                   msg='Sum of column %s differs, %f != %f' %
                                   (column, values[i], df[column].sum()),
                                   places=3)
Exemple #12
0
def main():
    locator = InputLocator(REFERENCE_CASE)
    gv = GlobalVariables()
    weather_path = locator.get_default_weather()
    weather_data = epwreader.epw_reader(weather_path)[[
        'drybulb_C', 'relhum_percent', 'windspd_ms', 'skytemp_C'
    ]]

    building_properties = BuildingProperties(locator, gv)
    date = pd.date_range(gv.date_start, periods=8760, freq='H')
    list_uses = building_properties.list_uses()
    schedules = schedule_maker(date, locator, list_uses)
    usage_schedules = {'list_uses': list_uses, 'schedules': schedules}

    print("data for test_calc_thermal_loads_new_ventilation:")
    print building_properties.list_building_names()

    bpr = building_properties['B01']
    result = calc_thermal_loads('B01', bpr, weather_data, usage_schedules,
                                date, gv, locator)

    # test the building csv file
    df = pd.read_csv(locator.get_demand_results_file('B01'))

    expected_columns = list(df.columns)
    print("expected_columns = %s" % repr(expected_columns))

    value_columns = [
        u'Ealf_kWh', u'Eauxf_kWh', u'Edataf_kWh', u'Ef_kWh', u'QCf_kWh',
        u'QHf_kWh', u'Qcdataf_kWh', u'Qcref_kWh', u'Qcs_kWh', u'Qcsf_kWh',
        u'Qhs_kWh', u'Qhsf_kWh', u'Qww_kWh', u'Qwwf_kWh', u'Tcsf_re_C',
        u'Thsf_re_C', u'Twwf_re_C', u'Tcsf_sup_C', u'Thsf_sup_C', u'Twwf_sup_C'
    ]

    print("values = %s " % repr([df[column].sum()
                                 for column in value_columns]))

    print("data for test_calc_thermal_loads_other_buildings:")
    # randomly selected except for B302006716, which has `Af == 0`
    buildings = {
        'B01': (81124.39400, 150471.05200),
        'B03': (81255.09200, 150520.01000),
        'B02': (82176.15300, 150604.85100),
        'B05': (84058.72400, 150841.56200),
        'B04': (82356.22600, 150598.43400),
        'B07': (81052.19000, 150490.94800),
        'B06': (83108.45600, 150657.24900),
        'B09': (84491.58100, 150853.54000),
        'B08': (88572.59000, 151020.09300),
    }

    for building in buildings.keys():
        bpr = building_properties[building]
        b, qcf_kwh, qhf_kwh = run_for_single_building(building, bpr,
                                                      weather_data,
                                                      usage_schedules, date,
                                                      gv, locator)
        print("'%(b)s': (%(qcf_kwh).5f, %(qhf_kwh).5f)," % locals())
Exemple #13
0
    def test_calc_thermal_loads(self):
        # FIXME: the usage_schedules bit needs to be fixed!!
        bpr = self.building_properties['B01']
        result = calc_thermal_loads('B01', bpr, self.weather_data,
                                    self.usage_schedules, self.date, self.gv,
                                    self.locator)
        self.assertIsNone(result)
        self.assertTrue(
            os.path.exists(self.locator.get_demand_results_file('B01')),
            'Building csv not produced')
        self.assertTrue(
            os.path.exists(self.locator.get_temporary_file('B01T.csv')),
            'Building temp file not produced')

        # test the building csv file
        df = pd.read_csv(self.locator.get_demand_results_file('B01'))
        #
        # expected_columns = self.gv.demand_building_csv_columns
        # print expected_columns
        # set(expected_columns)
        # self.assertEqual(set(expected_columns), set(df.columns),
        #                  'Column list of building csv does not match: ' + str(
        #                      set(expected_columns).symmetric_difference(set(df.columns))))
        # self.assertEqual(df.shape[0], 8760, 'Expected one row per hour in the year')

        value_columns = [
            u'Ealf_kWh', u'Eauxf_kWh', u'Edataf_kWh', u'Ef_kWh', u'QCf_kWh',
            u'QHf_kWh', u'Qcdataf_kWh', u'Qcref_kWh', u'Qcs_kWh', u'Qcsf_kWh',
            u'Qhs_kWh', u'Qhsf_kWh', u'Qww_kWh', u'Qwwf_kWh', u'Tcsf_re_C',
            u'Thsf_re_C', u'Twwf_re_C', u'Tcsf_sup_C', u'Thsf_sup_C',
            u'Twwf_sup_C'
        ]
        values = [
            155102.615999994, 3817.304, 0.0, 158919.92, 8373.964, 235413.775,
            0, 0, 7888.446, 8373.964, 183389.465, 195411.984, 37198.8870000003,
            40001.765, 2567.0, 67361.359, 99496.0, 1812.0, 77058.2680000001,
            525600
        ]

        for i, column in enumerate(value_columns):
            try:
                self.assertAlmostEqual(
                    values[i],
                    df[column].sum(),
                    msg='Sum of column %s differs, %f != %f' %
                    (column, values[i], df[column].sum()),
                    places=3)
            except:
                print 'values:', [
                    df[column].sum() for column in value_columns
                ]  # make it easier to update changes
                raise
def main():
    locator = InputLocator(REFERENCE_CASE)
    gv = GlobalVariables()
    weather_path = locator.get_default_weather()
    weather_data = epwreader.epw_reader(weather_path)[['drybulb_C', 'relhum_percent', 'windspd_ms', 'skytemp_C']]

    building_properties = BuildingProperties(locator, gv)
    date = pd.date_range(gv.date_start, periods=8760, freq='H')
    list_uses = building_properties.list_uses()
    schedules = schedule_maker(date, locator, list_uses)
    usage_schedules = {'list_uses': list_uses,
                            'schedules': schedules}

    print("data for test_calc_thermal_loads_new_ventilation:")
    print building_properties.list_building_names()

    bpr = building_properties['B01']
    result = calc_thermal_loads('B01', bpr, weather_data, usage_schedules, date, gv, locator)

    # test the building csv file
    df = pd.read_csv(locator.get_demand_results_file('B01'))

    expected_columns = list(df.columns)
    print("expected_columns = %s" % repr(expected_columns))

    value_columns = [u'Ealf_kWh', u'Eauxf_kWh', u'Edataf_kWh', u'Ef_kWh', u'QCf_kWh', u'QHf_kWh',
                     u'Qcdataf_kWh', u'Qcref_kWh', u'Qcs_kWh', u'Qcsf_kWh', u'Qhs_kWh', u'Qhsf_kWh', u'Qww_kWh',
                     u'Qwwf_kWh', u'Tcsf_re_C', u'Thsf_re_C', u'Twwf_re_C', u'Tcsf_sup_C', u'Thsf_sup_C',
                     u'Twwf_sup_C']

    print("values = %s " % repr([df[column].sum() for column in value_columns]))

    print("data for test_calc_thermal_loads_other_buildings:")
    # randomly selected except for B302006716, which has `Af == 0`
    buildings = {'B01': (81124.39400, 150471.05200),
                 'B03': (81255.09200, 150520.01000),
                 'B02': (82176.15300, 150604.85100),
                 'B05': (84058.72400, 150841.56200),
                 'B04': (82356.22600, 150598.43400),
                 'B07': (81052.19000, 150490.94800),
                 'B06': (83108.45600, 150657.24900),
                 'B09': (84491.58100, 150853.54000),
                 'B08': (88572.59000, 151020.09300), }

    for building in buildings.keys():
        bpr = building_properties[building]
        b, qcf_kwh, qhf_kwh = run_for_single_building(building, bpr, weather_data, usage_schedules,
                                                      date, gv, locator)
        print("'%(b)s': (%(qcf_kwh).5f, %(qhf_kwh).5f)," % locals())
def main(output_file):
    import cea.examples
    archive = zipfile.ZipFile(
        os.path.join(os.path.dirname(cea.examples.__file__),
                     'reference-case-open.zip'))
    archive.extractall(tempfile.gettempdir())
    reference_case = os.path.join(tempfile.gettempdir(), 'reference-case-open',
                                  'baseline')

    locator = InputLocator(reference_case)
    config = cea.config.Configuration(cea.config.DEFAULT_CONFIG)

    weather_path = locator.get_weather('Zug')
    weather_data = epwreader.epw_reader(weather_path)[[
        'year', 'drybulb_C', 'wetbulb_C', 'relhum_percent', 'windspd_ms',
        'skytemp_C'
    ]]

    # run properties script
    import cea.datamanagement.data_helper
    cea.datamanagement.data_helper.data_helper(locator, config, True, True,
                                               True, True, True, True)

    region = config.region
    year = weather_data['year'][0]
    use_daysim_radiation = config.demand.use_daysim_radiation
    resolution_outputs = config.demand.resolution_output
    loads_output = config.demand.loads_output
    massflows_output = config.demand.massflows_output
    temperatures_output = config.demand.temperatures_output
    format_output = config.demand.format_output
    use_dynamic_infiltration_calculation = config.demand.use_dynamic_infiltration_calculation
    use_stochastic_occupancy = config.demand.use_stochastic_occupancy
    building_properties, schedules_dict, date = properties_and_schedule(
        locator, region, year, use_daysim_radiation)

    print("data for test_calc_thermal_loads:")
    print(building_properties.list_building_names())

    bpr = building_properties['B01']
    result = calc_thermal_loads('B01', bpr, weather_data, schedules_dict, date,
                                locator, use_stochastic_occupancy,
                                use_dynamic_infiltration_calculation,
                                resolution_outputs, loads_output,
                                massflows_output, temperatures_output,
                                format_output, region)

    # test the building csv file
    df = pd.read_csv(locator.get_demand_results_file('B01'))

    expected_columns = list(df.columns)
    print("expected_columns = %s" % repr(expected_columns))

    test_config = ConfigParser.SafeConfigParser()
    test_config.read(output_file)

    value_columns = [
        u"E_sys_kWh", u"Qcdata_sys_kWh", u"Qcre_sys_kWh", u"Qcs_sys_kWh",
        u"Qhs_sys_kWh", u"Qww_sys_kWh", u"Tcs_sys_re_C", u"Ths_sys_re_C",
        u"Tww_sys_re_C", u"Tcs_sys_sup_C", u"Ths_sys_sup_C", u"Tww_sys_sup_C"
    ]

    values = [float(df[column].sum()) for column in value_columns]
    print("values = %s " % repr(values))

    if not test_config.has_section("test_calc_thermal_loads"):
        test_config.add_section("test_calc_thermal_loads")
    test_config.set("test_calc_thermal_loads", "value_columns",
                    json.dumps(value_columns))
    print values
    test_config.set("test_calc_thermal_loads", "values", json.dumps(values))

    print("data for test_calc_thermal_loads_other_buildings:")
    buildings = ['B01', 'B03', 'B02', 'B05', 'B04', 'B07', 'B06', 'B09', 'B08']

    results = {}
    for building in buildings:
        bpr = building_properties[building]
        b, qhs_sys_kwh, qcs_sys_kwh, qww_sys_kwh = run_for_single_building(
            building, bpr, weather_data, schedules_dict, date, locator,
            use_stochastic_occupancy, use_dynamic_infiltration_calculation,
            resolution_outputs, loads_output, massflows_output,
            temperatures_output, format_output, region)
        print(
            "'%(b)s': (%(qhs_sys_kwh).5f, %(qcs_sys_kwh).5f, %(qww_sys_kwh).5f),"
            % locals())
        results[building] = (qhs_sys_kwh, qcs_sys_kwh, qww_sys_kwh)

    if not test_config.has_section("test_calc_thermal_loads_other_buildings"):
        test_config.add_section("test_calc_thermal_loads_other_buildings")
    test_config.set("test_calc_thermal_loads_other_buildings", "results",
                    json.dumps(results))
    with open(output_file, 'w') as f:
        test_config.write(f)
    print("Wrote output to %(output_file)s" % locals())
Exemple #16
0
def main(output_file):
    import cea.examples
    archive = zipfile.ZipFile(
        os.path.join(os.path.dirname(cea.examples.__file__),
                     'reference-case-open.zip'))
    archive.extractall(tempfile.gettempdir())
    reference_case = os.path.join(tempfile.gettempdir(), 'reference-case-open',
                                  'baseline')

    locator = InputLocator(reference_case)
    config = cea.config.Configuration(cea.config.DEFAULT_CONFIG)

    weather_path = locator.get_weather('Zug_inducity_2009')
    weather_data = epwreader.epw_reader(weather_path)[[
        'year', 'drybulb_C', 'wetbulb_C', 'relhum_percent', 'windspd_ms',
        'skytemp_C'
    ]]

    # run properties script
    import cea.datamanagement.archetypes_mapper
    cea.datamanagement.archetypes_mapper.archetypes_mapper(
        locator, True, True, True, True, True, True, [])

    year = weather_data['year'][0]
    date_range = get_date_range_hours_from_year(year)
    resolution_outputs = config.demand.resolution_output
    loads_output = config.demand.loads_output
    massflows_output = config.demand.massflows_output
    temperatures_output = config.demand.temperatures_output
    use_dynamic_infiltration_calculation = config.demand.use_dynamic_infiltration_calculation
    debug = config.debug
    building_properties = BuildingProperties(locator)

    print("data for test_calc_thermal_loads:")
    print(building_properties.list_building_names())

    schedule_maker_main(locator, config, building='B1011')

    bpr = building_properties['B1011']
    result = calc_thermal_loads('B1011', bpr, weather_data, date_range,
                                locator, use_dynamic_infiltration_calculation,
                                resolution_outputs, loads_output,
                                massflows_output, temperatures_output, config,
                                debug)

    # test the building csv file
    df = pd.read_csv(locator.get_demand_results_file('B1011'))

    expected_columns = list(df.columns)
    print("expected_columns = %s" % repr(expected_columns))

    test_config = configparser.ConfigParser()
    test_config.read(output_file)

    value_columns = [
        u"E_sys_kWh", u"Qcdata_sys_kWh", u"Qcre_sys_kWh", u"Qcs_sys_kWh",
        u"Qhs_sys_kWh", u"Qww_sys_kWh", u"Tcs_sys_re_C", u"Ths_sys_re_C",
        u"Tww_sys_re_C", u"Tcs_sys_sup_C", u"Ths_sys_sup_C", u"Tww_sys_sup_C"
    ]

    values = [float(df[column].sum()) for column in value_columns]
    print("values = %s " % repr(values))

    if not test_config.has_section("test_calc_thermal_loads"):
        test_config.add_section("test_calc_thermal_loads")
    test_config.set("test_calc_thermal_loads", "value_columns",
                    json.dumps(value_columns))
    print(values)
    test_config.set("test_calc_thermal_loads", "values", json.dumps(values))

    print("data for test_calc_thermal_loads_other_buildings:")
    buildings = [
        'B1013', 'B1012', 'B1010', 'B1000', 'B1009', 'B1011', 'B1006', 'B1003',
        'B1004', 'B1001', 'B1002', 'B1005', 'B1008', 'B1007', 'B1014'
    ]

    results = {}

    for building in buildings:
        bpr = building_properties[building]
        b, qhs_sys_kwh, qcs_sys_kwh, qww_sys_kwh = run_for_single_building(
            building, bpr, weather_data, date_range, locator,
            use_dynamic_infiltration_calculation, resolution_outputs,
            loads_output, massflows_output, temperatures_output, config, debug)
        print(
            "'%(b)s': (%(qhs_sys_kwh).5f, %(qcs_sys_kwh).5f, %(qww_sys_kwh).5f),"
            % locals())
        results[building] = (qhs_sys_kwh, qcs_sys_kwh, qww_sys_kwh)

    if not test_config.has_section("test_calc_thermal_loads_other_buildings"):
        test_config.add_section("test_calc_thermal_loads_other_buildings")
    test_config.set("test_calc_thermal_loads_other_buildings", "results",
                    json.dumps(results))
    with open(output_file, 'w') as f:
        test_config.write(f)
    print("Wrote output to %(output_file)s" % locals())
def run_for_single_building(building, bpr, weather_data, usage_schedules, date, gv, locator):
    calc_thermal_loads(building, bpr, weather_data, usage_schedules, date, gv, locator)
    df = pd.read_csv(locator.get_demand_results_file(building))
    return building, df['QCf_kWh'].sum(), df['QHf_kWh'].sum()
Exemple #18
0
def main():
    import zipfile
    import cea.examples
    import tempfile
    archive = zipfile.ZipFile(
        os.path.join(os.path.dirname(cea.examples.__file__),
                     'reference-case-open.zip'))
    archive.extractall(tempfile.gettempdir())
    reference_case = os.path.join(tempfile.gettempdir(), 'reference-case-open',
                                  'baseline')
    locator = InputLocator(reference_case)
    gv = GlobalVariables()
    weather_path = locator.get_default_weather()
    weather_data = epwreader.epw_reader(weather_path)[[
        'drybulb_C', 'relhum_percent', 'windspd_ms', 'skytemp_C'
    ]]

    # run properties script
    import cea.demand.preprocessing.properties
    cea.demand.preprocessing.properties.properties(locator, True, True, True,
                                                   True)

    building_properties = BuildingProperties(locator, gv)
    date = pd.date_range(gv.date_start, periods=8760, freq='H')
    list_uses = building_properties.list_uses()
    archetype_schedules, archetype_values = schedule_maker(
        date, locator, list_uses)
    usage_schedules = {
        'list_uses': list_uses,
        'archetype_schedules': archetype_schedules,
        'occupancy_densities': archetype_values['people'],
        'archetype_values': archetype_values
    }

    print("data for test_calc_thermal_loads:")
    print building_properties.list_building_names()

    bpr = building_properties['B01']
    result = calc_thermal_loads('B01', bpr, weather_data, usage_schedules,
                                date, gv, locator)

    # test the building csv file
    df = pd.read_csv(locator.get_demand_results_file('B01'))

    expected_columns = list(df.columns)
    print("expected_columns = %s" % repr(expected_columns))

    value_columns = [
        u'Ealf_kWh', u'Eauxf_kWh', u'Edataf_kWh', u'Ef_kWh', u'QCf_kWh',
        u'QHf_kWh', u'Qcdataf_kWh', u'Qcref_kWh', u'Qcs_kWh', u'Qcsf_kWh',
        u'Qhs_kWh', u'Qhsf_kWh', u'Qww_kWh', u'Qwwf_kWh', u'Tcsf_re_C',
        u'Thsf_re_C', u'Twwf_re_C', u'Tcsf_sup_C', u'Thsf_sup_C', u'Twwf_sup_C'
    ]

    print("values = %s " % repr([df[column].sum()
                                 for column in value_columns]))

    print("data for test_calc_thermal_loads_other_buildings:")
    # randomly selected except for B302006716, which has `Af == 0`
    buildings = ['B01', 'B03', 'B02', 'B05', 'B04', 'B07', 'B06', 'B09', 'B08']

    for building in buildings:
        bpr = building_properties[building]
        b, qcf_kwh, qhf_kwh = run_for_single_building(building, bpr,
                                                      weather_data,
                                                      usage_schedules, date,
                                                      gv, locator)
        print("'%(b)s': (%(qcf_kwh).5f, %(qhf_kwh).5f)," % locals())
Exemple #19
0
def run_for_single_building(building, bpr, weather_data, usage_schedules, date,
                            gv, locator):
    calc_thermal_loads(building, bpr, weather_data, usage_schedules, date, gv,
                       locator)
    df = pd.read_csv(locator.get_demand_results_file(building))
    return building, float(df['QCf_kWh'].sum()), float(df['QHf_kWh'].sum())
Exemple #20
0
def main(output_file):
    import cea.examples
    archive = zipfile.ZipFile(
        os.path.join(os.path.dirname(cea.examples.__file__),
                     'reference-case-open.zip'))
    archive.extractall(tempfile.gettempdir())
    reference_case = os.path.join(tempfile.gettempdir(), 'reference-case-open',
                                  'baseline')
    locator = InputLocator(reference_case)
    gv = GlobalVariables()
    weather_path = locator.get_default_weather()
    weather_data = epwreader.epw_reader(weather_path)[[
        'drybulb_C', 'relhum_percent', 'windspd_ms', 'skytemp_C'
    ]]

    # run properties script
    import cea.demand.preprocessing.properties
    cea.demand.preprocessing.properties.properties(locator, True, True, True,
                                                   True)

    building_properties = BuildingProperties(locator, gv)
    date = pd.date_range(gv.date_start, periods=8760, freq='H')
    list_uses = building_properties.list_uses()
    archetype_schedules, archetype_values = schedule_maker(
        date, locator, list_uses)
    usage_schedules = {
        'list_uses': list_uses,
        'archetype_schedules': archetype_schedules,
        'occupancy_densities': archetype_values['people'],
        'archetype_values': archetype_values
    }

    print("data for test_calc_thermal_loads:")
    print(building_properties.list_building_names())

    bpr = building_properties['B01']
    result = calc_thermal_loads('B01', bpr, weather_data, usage_schedules,
                                date, gv, locator)

    # test the building csv file
    df = pd.read_csv(locator.get_demand_results_file('B01'))

    expected_columns = list(df.columns)
    print("expected_columns = %s" % repr(expected_columns))

    config = ConfigParser.SafeConfigParser()
    config.read(output_file)

    value_columns = [
        u'Ealf_kWh', u'Eauxf_kWh', u'Edataf_kWh', u'Ef_kWh', u'QCf_kWh',
        u'QHf_kWh', u'Qcdataf_kWh', u'Qcref_kWh', u'Qcs_kWh', u'Qcsf_kWh',
        u'Qhs_kWh', u'Qhsf_kWh', u'Qww_kWh', u'Qwwf_kWh', u'Tcsf_re_C',
        u'Thsf_re_C', u'Twwf_re_C', u'Tcsf_sup_C', u'Thsf_sup_C', u'Twwf_sup_C'
    ]

    values = [float(df[column].sum()) for column in value_columns]
    print("values = %s " % repr(values))

    if not config.has_section("test_calc_thermal_loads"):
        config.add_section("test_calc_thermal_loads")
    config.set("test_calc_thermal_loads", "value_columns",
               json.dumps(value_columns))
    print values
    config.set("test_calc_thermal_loads", "values", json.dumps(values))

    print("data for test_calc_thermal_loads_other_buildings:")
    buildings = ['B01', 'B03', 'B02', 'B05', 'B04', 'B07', 'B06', 'B09', 'B08']

    results = {}
    for building in buildings:
        bpr = building_properties[building]
        b, qcf_kwh, qhf_kwh = run_for_single_building(building, bpr,
                                                      weather_data,
                                                      usage_schedules, date,
                                                      gv, locator)
        print("'%(b)s': (%(qcf_kwh).5f, %(qhf_kwh).5f)," % locals())
        results[building] = (qcf_kwh, qhf_kwh)

    if not config.has_section("test_calc_thermal_loads_other_buildings"):
        config.add_section("test_calc_thermal_loads_other_buildings")
    config.set("test_calc_thermal_loads_other_buildings", "results",
               json.dumps(results))
    with open(output_file, 'w') as f:
        config.write(f)
    print("Wrote output to %(output_file)s" % locals())