Esempio n. 1
0
 def initialize_thermal_prediction(self, config_file):
     """ copyright by Martin Knorr """
     conf_pred = config_file['prediction']['heat']
     conf_powr = config_file['prediction']['power']
     # conf_pred
     n_day = conf_pred['n_day']
     n_values = conf_pred['n_values_per_day']
     precision_in_h = conf_pred['precision_in_h']
     use_predef_loads = conf_pred['use_predef_loads']
     predef_loads_file_path = conf_pred['path_loads']
     # heating curve
     conf_hk = config_file['components']['heating_curve']
     hk_ta = conf_hk['design_ambient_temperature_oC']
     hk_ti = conf_hk['design_indoor_temperature_oC']
     hk_tv = conf_hk['design_supply_temperature_oC']
     hk_tr = conf_hk['design_return_temperature_oC']
     hk_n = conf_hk['radiator_coefficient_n']
     hk_m = conf_hk['radiator_coefficient_m']
     hk_qn = conf_hk['design_heat_load_in_kW']
     # chp unit
     patm = utils.get_pressure_in_MPa()
     calcopt = utils.get_calc_option()
     eps_el_chp = config_file['components']['chp_unit']['electrical_efficiency']
     eps_th_chp = config_file['components']['chp_unit']['thermal_efficiency']
     qel_n_chp = config_file['components']['chp_unit']['max_electric_power_in_kW']
     chp_tinp = config_file['components']['chp_unit']['design_input_temperature_oC']
     chp_tmax = config_file['components']['chp_unit']['design_output_temperature_oC']
     qth_n_chp = eps_th_chp * qel_n_chp / eps_el_chp  # in kW
     mstr_chp = qth_n_chp / (utils.cp_fluid_water(0.5 * (chp_tmax + chp_tinp), patm, calcopt) * (chp_tmax - chp_tinp))  # in kg/s = kW / (kJ/kg/K * K)
     # gas boiler
     qth_n_gb = config_file['components']['gas_boiler']['max_thermal_power_in_kW']
     gb_tinp = config_file['components']['gas_boiler']['design_input_temperature_oC']
     gb_tmax = config_file['components']['gas_boiler']['design_output_temperature_oC']
     mstr_gb = qth_n_gb / (utils.cp_fluid_water(0.5 * (gb_tinp + gb_tmax), patm, calcopt) * (gb_tmax - gb_tinp))  # in kg/s = kW / (kJ/kg/K * K)  # in kg/s = kW / (kJ/kg/K * K)
     # storage tank
     effective_height = config_file['components']['storage_tank']['effective_heigth_in_m']
     inner_radius = config_file['components']['storage_tank']['inner_radius_tank_in_m']
     effective_pipe_volume = config_file['components']['storage_tank']['effective_coil_volume_in_m3']   # in m3 - water volume of the pipes of inner heat exchanger
     effective_volume = config_file['components']['storage_tank']['effective_volume_in_m3']
     if (effective_volume <= 0.0):
         effective_volume = math.pi * inner_radius * inner_radius * effective_height - effective_pipe_volume # in m3
     nr_calc = 20
     slice_volume = effective_volume / nr_calc  # in m3
     qmax_rod_el = config_file['components']['storage_tank']['power_heating_rod_in_kW']
     open_weather_map_active = config_file['calculation']['platform_mode']['open_weather_map_active']
     # conf_powr
     #print('\n initialize_thermal_prediction')
     #print('use_predef_loads = {}; {}'.format(use_predef_loads,type(use_predef_loads)))
     #print('predef_loads_file_path = {}; {}'.format(predef_loads_file_path,type(predef_loads_file_path)))
     return predict_thermal.predict_Q(n_day, n_values, precision_in_h, predef_loads_file_path, use_predef_loads, 
                self.output_horizon_in_h, self.output_resolution_in_s, conf_powr, hk_tv, hk_tr, hk_ti, hk_ta, 
                hk_qn, hk_n, hk_m, chp_tmax, gb_tmax, slice_volume, mstr_chp, mstr_gb, qmax_rod_el, eps_th_chp, 
                eps_el_chp, open_weather_map_active)
 def __init__(self, design_ambient_temp, design_indoor_temp,
              design_supply_temp, design_return_temp, n_coefficient,
              m_coefficient, design_heat_load):
     self.p_atm = utils.get_pressure_in_MPa()  # in MPa
     self.design_ambient_temp = design_ambient_temp
     self.design_indoor_temp = design_indoor_temp
     self.design_supply_temp = design_supply_temp
     self.supply_temp = design_supply_temp
     self.design_return_temp = design_return_temp
     self.return_temp = design_return_temp
     self.n_coefficient = n_coefficient
     self.m_coefficient = m_coefficient
     self.design_heat_load = design_heat_load  # in kW
     self.volume_flow = 0.0
     self.calc_volume_flow()
     self.status = 0
Esempio n. 3
0
def get_heat_consumption_from_crate(cursor, start_time, horizont_in_h, pred, time_step_in_s):
    """ 
    # gets data from crate db
    # calculates from it the heat flows needed by Martin's function 
    # and passes them as result 
    """
    # 
    q_th_dhw = 0.0
    q_th_hk = 0.0
    t_a_avg = 0.0
    n_avg = 0
    p_in_MPa = utils.get_pressure_in_MPa()
    calc_opt = utils.get_calc_option()
    # 
    cursor.execute("SELECT time_index,t30_ambientairtemperature,t21_domestichotwater,t22_domesticcoldwater,v01_colddrinkingwater,t25_supply_heatingcircuit,t24_return_heatingcircuit,v02_heatingcircuit FROM mtopeniot.etrvk")
    result = cursor.fetchone()
    while result != None:
        timestamp = datetime.utcfromtimestamp(float(result[0]*0.001))
        actual_time = start_time
        if((timestamp >= start_time) and (timestamp < (start_time + timedelta(hours=horizont_in_h)))):
            # ambient ar temperature
            t30_ambientairtemperature = result[1]
            # heat consumption for domestic hot water - get the data
            t21_domestichotwater = result[2]
            t22_domesticcoldwater = result[3]
            v01_colddrinkingwater = result[4]
            cp_dhw = utils.cp_fluid_water(0.5 * (t22_domesticcoldwater + t21_domestichotwater), p_in_MPa, calc_opt)
            rho_dhw = utils.rho_fluid_water(t22_domesticcoldwater, p_in_MPa, 1)
            # kg/m3 * m3/s * J/kg/K * K * s = J
            q_dhw = rho_dhw * v01_colddrinkingwater * cp_dhw * (t21_domestichotwater - t22_domesticcoldwater) * time_step_in_s
            # heat consumption for heating system - get the data
            t25_supply_heatingcircuit = result[5]
            t24_return_heatingcircuit = result[6]
            v02_heatingcircuit = result[7]
            cp_hk = utils.cp_fluid_water(0.5 * (t24_return_heatingcircuit + t25_supply_heatingcircuit), p_in_MPa, calc_opt)
            rho_hk = utils.rho_fluid_water(t24_return_heatingcircuit, p_in_MPa, 1)
            # kg/m3 * m3/s * J/kg/K * K * s = J
            q_hk = rho_hk * v02_heatingcircuit * cp_hk * (t25_supply_heatingcircuit - t24_return_heatingcircuit) * time_step_in_s
            # aggregate the data in the needed resolution
            t_act = actual_time.hour                           # t_act - actual time in hours
            q_act = (q_dhw + q_hk)/time_step_in_s              # q_act - actual heat load of the system in W 
            t_e_act = t30_ambientairtemperature                # t_e_act - ambient air temperature in grad Celcius
            # add aggregated data to the data structure for predict_thermal.py
            pred.run_to_save_data(t_act,q_act,t_e_act)
Esempio n. 4
0
 def __init__(self, thermal_eff, max_th_power, status, min_rest_time, input_temp, output_temp, ambient_temp, actual_time):
  # gasheater.GasBoiler(0.85   , 7.0         , 0     , 60.0         , 10.0      , 85.0       ,    20.0)
     self.thermal_eff = thermal_eff
     self.max_th_power = max_th_power
     self.status = status
     self.min_rest_time = min_rest_time
     self.next_safe_turn_on = actual_time
     self.design_input_temperature = input_temp  # 40.0  # in grad C
     self.design_output_temperature = output_temp  # 85.0  # in grad C
     self.p_atm = utils.get_pressure_in_MPa()
     self.design_mass_flow = self.calc_mass_flow()
     self.ambient_temp = ambient_temp
     if(status == 0):
         self.input_temperature = ambient_temp
         self.output_temperature = ambient_temp       # hot end - temperature of water flowing out of chp
         self.mass_flow = 0.0
     elif(status == 1):
         self.input_temperature = input_temp
         self.output_temperature = output_temp
         self.mass_flow = self.design_mass_flow
Esempio n. 5
0
 def __init__(self, electrical_eff, thermal_eff, max_el_power, status, min_rest_time, input_temp, output_temp, ambient_temp, actual_time):
     self.status = status
     self.design_input_temperature = input_temp
     self.design_output_temperature = output_temp
     self.p_atm = utils.get_pressure_in_MPa()
     self.ambient_temp = ambient_temp
     self.electrical_eff = electrical_eff
     self.thermal_eff = thermal_eff
     self.max_el_power = max_el_power  # in kW
     self.status = status  # on/off
     self.min_rest_time = min_rest_time  # in seconds
     self.next_safe_turn_on = actual_time
     self.design_mass_flow = self.set_design_mass_flow()
     if(status == 0):
         self.input_temperature = ambient_temp         # cold end - temperature of water flowing into chp
         self.output_temperature = ambient_temp       # hot end - temperature of water flowing out of chp
         self.mass_flow = 0.0
     elif(status == 1):
         self.input_temperature = input_temp         # cold end - temperature of water flowing into chp
         self.output_temperature = output_temp       # hot end - temperature of water flowing out of chp
         self.mass_flow = self.design_mass_flow
     self.max_temp = output_temp