Beispiel #1
0
    def test_stratified_thermal_storage_invest_option_2_facade(self):
        """
        Constraint test of a StratifiedThermalStorage with investment.
        Ratio between capacity and storage_capacity is left open.
        """
        bus_heat = solph.Bus(label='bus_heat')

        facades.StratifiedThermalStorage(label='thermal_storage',
                                         bus=bus_heat,
                                         diameter=10,
                                         temp_h=95,
                                         temp_c=60,
                                         temp_env=10,
                                         u_value=0.5,
                                         expandable=True,
                                         capacity_cost=50,
                                         storage_capacity_cost=400,
                                         minimum_storage_capacity=1,
                                         min_storage_level=0.975,
                                         max_storage_level=0.025,
                                         efficiency=1,
                                         marginal_cost=0.0001)

        self.compare_to_reference_lp(
            'stratified_thermal_storage_invest_option_2.lp')
Beispiel #2
0
    def test_stratified_thermal_storage_facade(self):
        """Constraint test of a StratifiedThermalStorage without investment.
        """
        bus_heat = solph.Bus(label='bus_heat')

        facades.StratifiedThermalStorage(label='thermal_storage',
                                         bus=bus_heat,
                                         diameter=10,
                                         height=30,
                                         temp_h=95,
                                         temp_c=60,
                                         temp_env=10,
                                         u_value=0.5,
                                         min_storage_level=0.975,
                                         max_storage_level=0.025,
                                         capacity=2,
                                         efficiency=1,
                                         marginal_cost=0.0001)

        self.compare_to_reference_lp('stratified_thermal_storage.lp')
excess = Sink(label='excess', inputs={bus_heat: Flow()})

heat_demand = Sink(
    label='heat_demand',
    inputs={bus_heat: Flow(nominal_value=1, fix=demand_timeseries)})

thermal_storage = facades.StratifiedThermalStorage(
    label='thermal_storage',
    bus=bus_heat,
    diameter=input_data[
        'diameter'],  # TODO: setting to zero should give an error
    temp_h=input_data['temp_h'],
    temp_c=input_data['temp_c'],
    temp_env=input_data['temp_env'],
    u_value=u_value,
    expandable=True,
    capacity_cost=50,
    storage_capacity_cost=400,
    minimum_storage_capacity=1,  # TODO: setting to zero should give an error!
    min_storage_level=input_data['min_storage_level'],
    max_storage_level=input_data['max_storage_level'],
    efficiency=1,
    marginal_cost=0.0001)

energysystem.add(bus_heat, heat_source, shortage, excess, heat_demand,
                 thermal_storage)

# Create and solve the optimization model
optimization_model = Model(energysystem)
optimization_model.solve(solver=solver,
shortage = Source(label='shortage',
                  outputs={bus_heat: Flow(variable_costs=1e6)})

excess = Sink(label='excess', inputs={bus_heat: Flow()})

heat_demand = Sink(
    label='heat_demand',
    inputs={bus_heat: Flow(nominal_value=1, fix=demand_timeseries)})

thermal_storage = facades.StratifiedThermalStorage(
    label='thermal_storage',
    bus=bus_heat,
    diameter=input_data['diameter'],
    height=input_data['height'],
    temp_h=input_data['temp_h'],
    temp_c=input_data['temp_c'],
    temp_env=input_data['temp_env'],
    u_value=u_value,
    min_storage_level=input_data['min_storage_level'],
    max_storage_level=input_data['max_storage_level'],
    capacity=input_data['maximum_heat_flow_charging'],
    efficiency=1,
    marginal_cost=0.0001)

energysystem.add(bus_heat, heat_source, shortage, excess, heat_demand,
                 thermal_storage)

# Create and solve the optimization model
optimization_model = Model(energysystem)
Beispiel #5
0
def run_storage_model(initial_storage_level, temp_h, temp_c):
    data_path = os.path.join(
        os.path.dirname(os.path.abspath(__file__)),
        './data/validation_data.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'])

    # Set up an energy system model
    periods = 10
    datetimeindex = pd.date_range('1/1/2019', periods=periods, freq='H')
    demand_timeseries = np.zeros(periods)
    heat_feedin_timeseries = np.zeros(periods)

    energysystem = EnergySystem(timeindex=datetimeindex)

    bus_heat = Bus(label='bus_heat')

    heat_source = Source(
        label='heat_source',
        outputs={bus_heat: Flow(
            nominal_value=1,
            fix=heat_feedin_timeseries)})

    shortage = Source(
        label='shortage',
        outputs={bus_heat: Flow(variable_costs=1e6)})

    excess = Sink(
        label='excess',
        inputs={bus_heat: Flow()})

    heat_demand = Sink(
        label='heat_demand',
        inputs={bus_heat: Flow(
            nominal_value=1,
            fix=demand_timeseries)})

    thermal_storage = facades.StratifiedThermalStorage(
        label='thermal_storage',
        bus=bus_heat,
        diameter=input_data['diameter'],
        height=input_data['height'],
        temp_h=temp_h,
        temp_c=temp_c,
        temp_env=input_data['temp_env'],
        u_value=u_value,  # W/(m2*K)
        min_storage_level=input_data['min_storage_level'],
        max_storage_level=input_data['max_storage_level'],
        initial_storage_level=initial_storage_level,
        capacity=input_data['maximum_heat_flow_charging'],
        efficiency=1,
        marginal_cost=0.0001
    )

    energysystem.add(
        bus_heat,
        heat_source,
        shortage,
        excess,
        heat_demand,
        thermal_storage)

    # create and solve the optimization model
    optimization_model = Model(energysystem)
    optimization_model.write('storage_model_facades.lp',
                             io_options={'symbolic_solver_labels': True})
    optimization_model.solve(solver='cbc', solve_kwargs={'tee': False})

    energysystem.results['main'] = solph.processing.results(optimization_model)
    string_results = solph.views.convert_keys_to_strings(energysystem.results['main'])

    # Get time series of level (state of charge) of the thermal energy storage
    TES_soc = (string_results['thermal_storage', 'None']['sequences'])

    # Save results to csv file
    TES_soc.to_csv("./data/storage_soc_calculated.csv")

    return