Пример #1
0
def get_direct_sun_radiation(self, simulation, wetter_file, actual_time,
                             start_datetime, start_sim_inh, end_sim_inh):
    # returns ambient air temperature as read from the wetter_file in the TRY04 format
    # simulation     - flag for real time or file based
    # wetter_file    - file with weather parameters in TRY04 format
    # actual_time    - the current time or current simulation time in the datetime format
    # start_datetime - start of the calculations in datetime format
    # start_sim_inh  - only in simulation mode - the starting point of the simulation in hours - will be found in the wetter_file
    # end_sim_inh    - only in simulation mode - the end point of the simulation in hours - arbitrarily stated
    if simulation:
        # file based simulation - values are read from the file
        #            hour_of_year = 1
        condition = True
        simtime = ((actual_time - start_datetime).total_seconds() /
                   3600.0) + start_sim_inh  # simulationstime in h
        #print('actual_time ={}; start_datetime = {}; simtime = {}; start_sim_inh = {}'.format(actual_time, start_datetime, simtime, start_sim_inh))
        ii = 0
        while condition:
            line1 = utils.get_significant_parts(
                wetter_file[ii].rstrip().split(" "))
            hour = utils.get_time_in_hour(line1)
            condition = (hour < simtime)
            ii = ii + 1
            if (ii > 8760):
                ii = 0
        if (ii == 0):
            ii = 8760
        else:
            ii = ii - 1
        jj = ii - 1
        if jj < 0:
            jj = 8760 - 1
        line2 = utils.get_significant_parts(
            wetter_file[jj].rstrip().split(" "))
        x1 = hour
        x2 = utils.get_time_in_hour(line2)
        y1 = float(
            utils.get_ith_column(12, line1)
        )  # direkte Sonnenstrahlung bezogen auf die horizontale Ebene in W/m2
        y2 = float(utils.get_ith_column(12, line2))
        # time since the beginning of the start of the simulation in hours
        return utils.linear_interpolation(simtime, x1, x2, y1, y2)
    else:
        # real time calculation - values are received via MQTT? - dead for now
        return 10.0

    #end get_ambient_temperature


########################################################################
Пример #2
0
 def get_heater_rod_status(self, simulation, el_load_file, actual_time, start_datetime, start_sim_inh, end_sim_inh):
     """ returns the status between 0 = OFF and 1 = ON of the electrical rod heater """
     if simulation:
         # file based simulation - values are read from the file
         # file based simulation - values are read from the file
         #            hour_of_year = 1
         simtime = int(math.floor(((actual_time - start_datetime).seconds / (60.0 * 15.0)) + start_sim_inh * 60.0 / 15.0))  # simulationstime in quarters = 15 minutes slots
         if (simtime >= 35040):     # actual time exceeds the first year (there are 35 040 slots of 15 minutes in a year)
             simtime = simtime - math.floor(simtime / 35040) * 35040
         line1 = utils.get_significant_parts(el_load_file[simtime].rstrip().split(" "))
         y1 = float(utils.get_ith_column(2, line1))
         return y1    # as load from 0 to 1
     else:
         # real time calculation - values are received via MQTT? - dead for now
         return 0
Пример #3
0
 def predefine_thermal_loads_from_file(self):
     #print(type(self.predef_loads),type(self.predef_loads[0]))
     for li in self.predef_loads[1:]:
         line1 = utils.get_significant_parts(li.rstrip().split(" "))
         time = float(utils.get_ith_column(1, line1))
         load = float(utils.get_ith_column(2, line1))
         t_a = float(utils.get_ith_column(3, line1))
         self.run_to_save_data(time, load, t_a)
         if (self.get_q_write()):
             #print('should break')
             break
     if (not self.get_q_write()):
         print('throw exception')
         print('severe ERROR')
         print(
             'Data in file {} is too short to cover the initialization of class predict_Q'
             .format(self.predef_loads_file_path))
         print(
             'Prove whether the times in file and in simulation are consistent.'
         )