Exemple #1
0
    def __init__(self, *args, **kwargs):

        super().__init__(_facade_requires_=[
            "bus", "diameter", "temp_h", "temp_c", "temp_env", "u_value"
        ],
                         *args,
                         **kwargs)

        self.height = kwargs.get("height")

        self.water_properties = {
            'heat_capacity': kwargs.get("heat_capacity"),
            'density': kwargs.get("density")
        }

        self.capacity = kwargs.get("capacity")

        self.storage_capacity_cost = kwargs.get("storage_capacity_cost")

        self.capacity_cost = kwargs.get("capacity_cost")

        self.storage_capacity_potential = kwargs.get(
            "storage_capacity_potential", float("+inf"))

        self.capacity_potential = kwargs.get("capacity_potential",
                                             float("+inf"))

        self.minimum_storage_capacity = kwargs.get("minimum_storage_capacity",
                                                   0)

        self.expandable = bool(kwargs.get("expandable", False))

        if self.expandable and self.capacity is None:
            self.capacity = 0

        self.efficiency = kwargs.get("efficiency", 1)

        self.marginal_cost = kwargs.get("marginal_cost", 0)

        self.input_parameters = kwargs.get("input_parameters", {})

        self.output_parameters = kwargs.get("output_parameters", {})

        losses = calculate_losses(
            self.u_value, self.diameter, self.temp_h, self.temp_c,
            self.temp_env, **{
                key: value
                for key, value in self.water_properties.items()
                if value is not None
            })

        self.loss_rate = losses[0]

        self.fixed_losses_relative = losses[1]

        self.fixed_losses_absolute = losses[2]

        self.build_solph_components()
def test_calculate_losses():
    params = {
        'u_value': 1,  # W/(m2*K)
        'diameter': 10,  # m
        'temp_h': 100,  # deg C
        'temp_c': 50,  # deg C
        'temp_env': 10,  # deg C
    }

    loss_rate, fixed_losses_relative, fixed_losses_absolute = calculate_losses(
        **params)
    assert loss_rate == 0.0003531819182021882\
        and fixed_losses_relative == 0.00028254553456175054\
        and fixed_losses_absolute == 0.010210176124166827
Exemple #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,
    )
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,
        'Max. heat flow charging [MW]': maximum_heat_flow_charging,
        'Max. heat flow discharging [MW]': maximum_heat_flow_discharging,
        'Loss rate [-]': loss_rate,