Skip to content

Commit 16c7481

Browse files
committed
Adjust test
1 parent 331ed06 commit 16c7481

1 file changed

Lines changed: 12 additions & 18 deletions

File tree

tests/test_models.py

Lines changed: 12 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ def create_annualized_effects(
9393
@pytest.fixture
9494
def flow_system() -> fx.FlowSystem:
9595
"""Create basic elements for component testing with coordinate parametrization."""
96-
years = pd.Index([2020, 2021, 2022, 2023, 2024, 2030], name='year')
96+
years = pd.Index([2020, 2021, 2022, 2023, 2024, 2026, 2028, 2030], name='year')
9797
timesteps = pd.date_range('2020-01-01', periods=24, freq='h', name='time')
9898
flow_system = fx.FlowSystem(timesteps=timesteps, years=years)
9999

@@ -106,6 +106,7 @@ def flow_system() -> fx.FlowSystem:
106106
electricity_sink = Sinks.electricity_feed_in(p_el)
107107

108108
flow_system.add_elements(*Buses.defaults())
109+
flow_system.buses['Fernwärme'].excess_penalty_per_flow_hour = 0
109110
flow_system.add_elements(costs, heat_load, gas_source, electricity_sink)
110111

111112
return flow_system
@@ -187,42 +188,35 @@ class TestYearAwareInvestmentModelDirect:
187188

188189
def test_flow_invest_new(self, flow_system):
189190
da = xr.DataArray(
190-
[25, 30, 35, 40, 45, 50],
191+
[10] * 8,
191192
coords=(flow_system.years_of_investment,),
192193
).expand_dims(year=flow_system.years)
193-
da = da.where(da.year >= da.year_of_investment).fillna(0)
194+
da = da.where(da.year == da.year_of_investment).fillna(0)
194195

195196
flow = fx.Flow(
196197
'Wärme',
197198
bus='Fernwärme',
198199
size=fx.InvestTimingParameters(
199-
force_investment=xr.DataArray(
200-
[False if year != 2021 else True for year in flow_system.years], coords=(flow_system.years,)
201-
),
202200
# year_of_decommissioning=2030,
203-
duration_in_years=2,
204-
minimum_size=900,
205-
maximum_size=1000,
201+
minimum_lifetime=2,
202+
maximum_lifetime=3,
203+
minimum_size=9,
204+
maximum_size=10,
206205
specific_effects=xr.DataArray(
207-
[25, 30, 35, 40, 45, 50],
206+
[25, 30, 35, 40, 45, 50, 55, 60],
208207
coords=(flow_system.years,),
209208
)
210-
* 0,
209+
* -0,
211210
# fix_effects=-2e3,
212-
specific_effects_by_investment_year=da,
211+
specific_effects_by_investment_year=-1 * da,
213212
),
214213
relative_maximum=np.linspace(0.5, 1, flow_system.timesteps.size),
215214
)
216215

217216
flow_system.add_elements(fx.Source('Source', source=flow))
218217
calculation = fx.FullCalculation('GenericName', flow_system)
219218
calculation.do_modeling()
220-
# calculation.model.add_constraints(calculation.model['Source(Wärme)|decrease'].isel(year=2) == 1)
221-
calculation.solve(fx.solvers.GurobiSolver(0, 60))
222-
223-
calculation = fx.FullCalculation('GenericName', flow_system.sel(year=[2022, 2030]))
224-
calculation.do_modeling()
225-
# calculation.model.add_constraints(calculation.model['Source(Wärme)|decrease'].isel(year=2) == 1)
219+
# calculation.model.add_constraints(calculation.model['Source(Wärme)|is_invested'].sel(year=2022) == 1)
226220
calculation.solve(fx.solvers.GurobiSolver(0, 60))
227221

228222
ds = calculation.results['Source'].solution

0 commit comments

Comments
 (0)