Esempio n. 1
0
def test_calculate_capacities():
    params = {
        'volume': 1000,  # m3
        'temp_h': 100,  # deg C
        'temp_c': 50,  # deg C
    }

    nominal_storage_capacity = calculate_capacities(**params)
    assert nominal_storage_capacity == 56.62804059111111
Esempio n. 2
0
    def build_solph_components(self):
        """
        """
        self.inflow_conversion_factor = sequence(self.efficiency)

        self.outflow_conversion_factor = sequence(self.efficiency)

        self.loss_rate = sequence(self.loss_rate)

        self.fixed_losses_relative = sequence(self.fixed_losses_relative)

        self.fixed_losses_absolute = sequence(self.fixed_losses_absolute)

        # make it investment but don't set costs (set below for flow (power))
        self.investment = self._investment()

        if self.investment:
            self.invest_relation_input_output = 1

            for attr in ["invest_relation_input_output"]:
                if getattr(self, attr) is None:
                    raise AttributeError(
                        ("You need to set attr "
                         "`{}` "
                         "for component {}").format(attr, self.label))

            # set capacity costs at one of the flows
            fi = Flow(investment=Investment(
                ep_costs=self.capacity_cost,
                maximum=self.capacity_potential,
                existing=self.capacity,
            ),
                      **self.input_parameters)
            # set investment, but no costs (as relation input / output = 1)
            fo = Flow(investment=Investment(),
                      variable_costs=self.marginal_cost,
                      **self.output_parameters)
            # required for correct grouping in oemof.solph.components
            self._invest_group = True
        else:
            self.volume = calculate_storage_dimensions(self.height,
                                                       self.diameter)[0]

            self.nominal_storage_capacity = calculate_capacities(
                self.volume, self.temp_h, self.temp_c, **{
                    key: value
                    for key, value in self.water_properties.items()
                    if value is not None
                })

            fi = Flow(nominal_value=self._nominal_value(),
                      **self.input_parameters)
            fo = Flow(nominal_value=self._nominal_value(),
                      variable_costs=self.marginal_cost,
                      **self.output_parameters)

        self.inputs.update({self.bus: fi})

        self.outputs.update({self.bus: fo})

        self._set_flows()
Esempio n. 3
0
def calc_strat_tes_param(
    weather,
    temperature_col="temp_air",
    user_inputs_pvcompare_directory=None,
    user_inputs_mvs_directory=None,
):
    """
    This function does the precalculations of the stratified thermal storage.

    It calculates the following parameters:

    1. nominal_storage_capacity
    2. loss_rate
    3. fixed_losses_relative
    4. fixed_losses_absolute

    from the storage's input data provided in `stratified_thermal_storage.csv`
    and using functions implemented in oemof.thermal (github.com/oemof/oemof-thermal).

    Parameters
    ----------
    weather : :pandas:`pandas.DataFrame<frame>`
        Contains weather data time series. Required: ambient temperature in
        column `temperature_col`.
    temperature_col : str
        Name of column in `weather` containing ambient temperature.
        Default: "temp_air".
    user_inputs_pvcompare_directory: str or None
        Directory of the user inputs. If None,
        `constants.DEFAULT_USER_INPUTS_PVCOMPARE_DIRECTORY` is used as user_inputs_pvcompare_directory.
        Default: None.
    user_inputs_mvs_directory: str or None
        Path to input directory containing files that describe the energy
        system and that are an input to MVS. Default:
        DEFAULT_MVS_OUTPUT_DIRECTORY (see :func:`~pvcompare.constants`.

    Returns
    -------
    nominal_storage_capacity : numeric
        Maximum amount of stored thermal energy [MWh]

    loss_rate : numeric (sequence or scalar)
        The relative loss of the storage capacity between two consecutive
        timesteps [-]

    fixed_losses_relative : numeric (sequence or scalar)
        Losses independent of state of charge between two consecutive
        timesteps relative to nominal storage capacity [-]

    fixed_losses_absolute : numeric (sequence or scalar)
        Losses independent of state of charge and independent of
        nominal storage capacity between two consecutive timesteps [MWh]

    """
    # *********************************************************************************************
    # Set paths - Read and prepare data
    # *********************************************************************************************
    if user_inputs_pvcompare_directory is None:
        input_directory = constants.DEFAULT_USER_INPUTS_PVCOMPARE_DIRECTORY

    if user_inputs_mvs_directory == None:
        user_inputs_mvs_directory = constants.DEFAULT_USER_INPUTS_MVS_DIRECTORY

    input_data_filename = os.path.join(user_inputs_pvcompare_directory,
                                       "stratified_thermal_storage.csv")
    input_data = pd.read_csv(input_data_filename, header=0,
                             index_col=0)["var_value"]

    # Prepare ambient temperature for precalculations
    ambient_temperature = weather[temperature_col]

    # *********************************************************************************************
    # Precalculations
    # *********************************************************************************************

    u_value = strat_tes.calculate_storage_u_value(
        input_data["s_iso"],
        input_data["lamb_iso"],
        input_data["alpha_inside"],
        input_data["alpha_outside"],
    )

    volume, surface = strat_tes.calculate_storage_dimensions(
        input_data["height"], input_data["diameter"])

    nominal_storage_capacity = (strat_tes.calculate_capacities(
        volume, input_data["temp_h"], input_data["temp_c"]) * 1000)

    try:
        int(float(nominal_storage_capacity))
    except ValueError:
        if math.isnan(nominal_storage_capacity) is True:
            nominal_storage_capacity = 0

    (
        loss_rate,
        fixed_losses_relative,
        fixed_losses_absolute,
    ) = strat_tes.calculate_losses(
        u_value,
        input_data["diameter"],
        input_data["temp_h"],  # TODO: In future heat pump temp here
        input_data["temp_c"],  # TODO: In future relation to temp_h here
        ambient_temperature,
    )

    return (
        nominal_storage_capacity,
        loss_rate,
        fixed_losses_relative,
        fixed_losses_absolute,
    )
data_path = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'data',
                         'stratified_thermal_storage.csv')

# Read input data
input_data = pd.read_csv(data_path, index_col=0, header=0)['var_value']

# Precalculation
u_value = calculate_storage_u_value(input_data['s_iso'],
                                    input_data['lamb_iso'],
                                    input_data['alpha_inside'],
                                    input_data['alpha_outside'])

volume, surface = calculate_storage_dimensions(input_data['height'],
                                               input_data['diameter'])

nominal_storage_capacity = calculate_capacities(volume, input_data['temp_h'],
                                                input_data['temp_c'])

loss_rate, fixed_losses_relative, fixed_losses_absolute = calculate_losses(
    u_value, input_data['diameter'], input_data['temp_h'],
    input_data['temp_c'], input_data['temp_env'])

maximum_heat_flow_charging = 2
maximum_heat_flow_discharging = 2


def print_parameters():
    parameter = {
        'U-value [W/(m2*K)]': u_value,
        'Volume [m3]': volume,
        'Surface [m2]': surface,
        'Nominal storage capacity [MWh]': nominal_storage_capacity,
Esempio n. 5
0
data_path = os.path.join(os.path.dirname(os.path.abspath(__file__)),
                         'stratified_thermal_storage.csv')

input_data = pd.read_csv(data_path, index_col=0, header=0)['var_value']

u_value = calculate_storage_u_value(input_data['s_iso'],
                                    input_data['lamb_iso'],
                                    input_data['alpha_inside'],
                                    input_data['alpha_outside'])

volume, surface = calculate_storage_dimensions(input_data['height'],
                                               input_data['diameter'])

nominal_storage_capacity, max_storage_level, min_storage_level = calculate_capacities(
    volume, input_data['temp_h'], input_data['temp_c'],
    input_data['nonusable_storage_volume'], input_data['heat_capacity'],
    input_data['density'])

loss_rate, fixed_losses_relative, fixed_losses_absolute = calculate_losses(
    u_value, input_data['diameter'], input_data['temp_h'],
    input_data['temp_c'], input_data['temp_env'])

maximum_heat_flow_charging = 2
maximum_heat_flow_discharging = 2


def print_results():
    parameter = {
        'U-value [W/(m2*K)]': u_value,
        'Volume [m3]': volume,
        'Surface [m2]': surface,