Exemple #1
0
def test_read_data_file():
    test_path = os.path.join(os.path.dirname(__file__), 'test_timeseries')
    file_name = "test_csv.csv"
    # by index
    data = func.read_data_file(test_path, file_name, ",", 0)
    # by name
    data = func.read_data_file(test_path, file_name, ",", "Simple test csv")
    assert len(data) == 168
    for idx in range(len(data)):
        assert data[data.columns[0]][idx] == 1
    def __init__(self, params):
        """Constructor method
        """
        # Call the init function of the mother class.
        Component.__init__(self)
        # ------------------- PARAMETERS -------------------
        self.name = 'H2_refuel_default_name'
        self.bus_el = None
        self.nominal_value = 1
        self.csv_filename = None
        self.csv_separator = ','
        self.column_title = 0
        self.path = os.path.dirname(__file__)
        self.cool_spec_energy = 730
        self.standby_energy = 8100
        self.life_time = 20
        self.number_of_units = 1

        # ------------------- UPDATE PARAMETER DEFAULT VALUES -------------------
        self.set_parameters(params)

        # ------------------- READ CSV FILES -------------------
        self.data = func.read_data_file(self.path, self.csv_filename,
                                        self.csv_separator, self.column_title)

        self.electrical_energy = \
            (self.data * self.cool_spec_energy + self.standby_energy) / 3.6
    def __init__(self, params):
        """Constructor method
        """
        # ToDo: change from hour to flexible timestep!
        # Call the init function of the mother class.
        ExternalComponent.__init__(self)

        # ------------------- PARAMETERS -------------------
        self.name = 'Test_additional/external_costs_default_name'

        self.life_time = 20
        self.vehicle_tank_size = 40
        self.number_of_hoses = 2
        self.refuelling_time = 15
        self.nominal_value = 1
        self.csv_filename = None
        self.csv_separator = ','
        self.column_title = 0
        self.path = os.path.dirname(__file__)

        # ------------------- UPDATE PARAMETER DEFAULT VALUES -------------------
        self.set_parameters(params)

        # ------------------- READ CSV FILES -------------------
        # The demand csv file is read
        self.data = func.read_data_file(self.path, self.csv_filename,
                                        self.csv_separator, self.column_title)

        # ------------------- CALCULATED PARAMETERS -------------------
        self.max_hourly_h2_demand = self.data.values.max()
        self.number_of_refuels_per_hour = 60 / self.refuelling_time
        self.max_number_of_vehicles = self.max_hourly_h2_demand / self.vehicle_tank_size
        self.number_of_units =\
            ceil(self.max_number_of_vehicles / (self.number_of_hoses *
                                                self.number_of_refuels_per_hour))
Exemple #4
0
    def __init__(self, params):

        # Call the init function of the mother class.
        Component.__init__(self)
        """ PARAMETERS """
        self.name = 'General_energy_source'

        self.nominal_value = 1
        self.csv_filename = None
        self.csv_separator = ';'
        self.column_title = 0
        self.path = os.path.dirname(__file__)
        self.bus_out = None
        """ UPDATE PARAMETER DEFAULT VALUES """
        self.set_parameters(params)
        """ READ CSV FILES """
        self.data = func.read_data_file(self.path, self.csv_filename,
                                        self.csv_separator, self.column_title)
        """ STATES """
Exemple #5
0
    def __init__(self, params):
        """Constructor method
        """
        # Call the init function of the mother class.
        Component.__init__(self)

        # ------------------- PARAMETERS -------------------
        self.name = 'General_energy_source'
        self.nominal_value = 1
        self.csv_filename = None
        self.csv_separator = ','
        self.column_title = 0
        self.path = os.path.dirname(__file__)
        self.bus_out = None

        # ------------------- UPDATE PARAMETER DEFAULT VALUES -------------------
        self.set_parameters(params)

        # ------------------- READ CSV FILES -------------------
        self.data = func.read_data_file(self.path, self.csv_filename,
                                        self.csv_separator, self.column_title)
    def __init__(self, params):
        """Constructor method
        """
        # Call the init function of the mother class.
        Component.__init__(self)

        # ------------------- PARAMETERS -------------------
        self.name = 'Heat_pump_default_name'

        self.bus_el = None
        self.bus_th = None

        # Max. heating output [W]
        self.power_max = 1000e3
        # Life time [a]
        self.life_time = 20

        self.csv_filename = None
        self.csv_separator = ','
        self.column_title = 0
        self.path = os.path.dirname(__file__)

        # ------------------- PARAMETERS BASED ON OEMOF THERMAL EXAMPLE -------------------
        # Temperature below which icing occurs [K]
        self.temp_threshold_icing = 275.15
        # Convert to degrees C for oemof_thermal function
        self.temp_threshold_icing_C = self.temp_threshold_icing - 273.15
        # The output temperature from the heat pump [K]
        self.temp_high = 313.15
        # Convert to degrees C for oemof_thermal function
        self.temp_high_C = self.temp_high - 273.15
        # Convert to a list for oemof_thermal function
        self.temp_high_C_list = [self.temp_high_C]
        # The ambient temperature [K]
        self.temp_low = 283.15
        # Convert to degrees C for oemof_thermal function
        self.temp_low_C = self.temp_low - 273.15
        # Quality grade of heat pump [-]
        self.quality_grade = 0.4
        # Can be set to heat pump or chiller
        self.mode = 'heat_pump'
        # COP reduction caused by icing [-]
        self.factor_icing = 0.8
        # Ask Jann about this/look more into detail
        # self.consider_icing = False

        # ------------------- UPDATE PARAMETER DEFAULT VALUES -------------------
        self.set_parameters(params)

        if self.csv_filename is not None:
            # A csv file containing data for the ambient temperature is required [deg C]
            self.temp_low = func.read_data_file(self.path, self.csv_filename,
                                                self.csv_separator,
                                                self.column_title)
            self.temp_low_series = self.temp_low[self.column_title]
            self.temp_low_series_C = pd.Series(self.temp_low_series - 273.15)
        else:
            self.temp_low_list = [self.temp_low_C
                                  ] * self.sim_params.n_intervals
            self.temp_low_series_C = pd.Series(self.temp_low_list)

        # A function taken from oemof thermal that calculates the coefficient
        # of performance (pre-calculated)
        self.cops = cmpr_hp_chiller.calc_cops(
            self.mode,
            self.temp_high_C_list,
            self.temp_low_series_C,
            self.quality_grade,
            self.temp_threshold_icing_C,
            # self.consider_icing,
            self.factor_icing)
    def __init__(self, params):
        """Constructor method
        """
        # Call the init function of the mother class.
        Component.__init__(self)

        # ------------------- PARAMETERS -------------------
        self.name = 'Stratified_thermal_storage_default_name'
        self.bus_in = None
        self.bus_out = None
        self.storage_capacity = 6000e3
        self.storage_level_min = 0.025
        self.storage_level_max = 0.975
        self.max_heat_flow_charge = self.storage_level_max * self.storage_capacity
        self.max_heat_flow_discharge = (
            1 - self.storage_level_min) * self.storage_capacity
        self.initial_storage_factor = 0.5
        self.life_time = 20
        self.nominal_value = 1
        self.csv_filename = None
        self.csv_separator = ','
        self.column_title = 0
        self.path = os.path.dirname(__file__)

        # ------------------- PARAMETERS TAKEN FROM OEMOF THERMAL EXAMPLE FILE -------------------
        self.density = 971.78
        self.heat_capacity = 4180
        self.temp_h = 368.15
        self.temp_c = 333.15
        self.temp_env = 25
        self.height_diameter_ratio = 3
        self.s_iso = 0.05
        self.lamb_iso = 0.03
        self.alpha_inside = 1
        self.alpha_outside = 1

        # ------------------- PARAMETERS (VARIABLE ARTIFICIAL COSTS - VAC) -------------------
        # Normal var. art. costs for charging (in) and discharging (out) the storage [EUR/Wh.
        self.vac_in = 0
        self.vac_out = 0
        # If a storage level is set as wanted, the vac_low costs apply if the
        # storage is below that level [Wh].
        self.storage_level_wanted = None
        # Var. art. costs that apply if the storage level is below the wanted
        # storage level [EUR/Wh].
        self.vac_low_in = 0
        self.vac_low_out = 0

        # ------------------- UPDATE PARAMETER DEFAULT VALUES -------------------
        self.set_parameters(params)
        self.storage_level_init = self.initial_storage_factor * self.storage_capacity

        # Check to see if the environmental temperature has been given as a
        # timeseries or a singular value
        if self.csv_filename is not None:
            # The environment temperature timeseries [K}
            self.temp_env = func.read_data_file(self.path, self.csv_filename,
                                                self.csv_separator,
                                                self.column_title)
            self.temp_env = self.temp_env[self.column_title].values.tolist()
            self.temp_env = [temp + 273.15 for temp in self.temp_env]

        # ------------------- STATES -------------------
        # Storage level [kg of h2]
        self.storage_level = min(
            self.storage_level_init + self.storage_level_min,
            self.storage_capacity)

        # ------------------- VARIABLE ARTIFICIAL COSTS -------------------
        # Store the current artificial costs for input and output [EUR/kg].
        self.current_vac = [0, 0]

        # -------- FURTHER STORAGE VALUES DEPENDING ON SPECIFIED PARAMETERS --------
        # Calculate the storage volume [m³].
        self.volume \
            = self.get_volume(
                self.storage_capacity, self.heat_capacity, self.density, self.temp_h, self.temp_c)
        # Calculate the diameter of the storage [m]
        self.diameter = self.get_diameter(self.volume,
                                          self.height_diameter_ratio)
        # The thermal transmittance is calculated [W/(m2*K)]
        self.u_value = self.calculate_storage_u_value(self.alpha_inside,
                                                      self.s_iso,
                                                      self.lamb_iso,
                                                      self.alpha_outside)
        # The losses in the storage are precalculated based on constant
        # parameters and the environmental temperature timeseries
        [self.loss_rate, self.fixed_losses_relative, self.fixed_losses_absolute] \
            = self.calculate_losses(
            self.u_value,
            self.diameter,
            self.density,
            self.heat_capacity,
            self.temp_c,
            self.temp_h,
            self.temp_env)