|
547 | 547 | @test all(value.(m[:cap_capex])[n, t_inv] ≈ capex[t_inv] for t_inv ∈ 𝒯ᴵⁿᵛ) |
548 | 548 | end |
549 | 549 | end |
| 550 | + |
| 551 | +@testset "RollingLife - Longer lifetime, StartInvData" begin |
| 552 | + # Creation and solving of the model |
| 553 | + inv_data = StartInvData( |
| 554 | + FixedProfile(1000), |
| 555 | + FixedProfile(40), |
| 556 | + StrategicProfile([15, 10, 5, 0]), |
| 557 | + ContinuousInvestment(FixedProfile(0), FixedProfile(15)), |
| 558 | + RollingLife(FixedProfile(20)) |
| 559 | + ) |
| 560 | + demand = StrategicProfile([5,10,15,15]) |
| 561 | + m, para = simple_model(;inv_data, demand) |
| 562 | + |
| 563 | + # Extraction of required data |
| 564 | + n = para[:node] |
| 565 | + 𝒯 = para[:T] |
| 566 | + 𝒯ᴵⁿᵛ = strat_periods(𝒯) |
| 567 | + inv_data = para[:inv_data] |
| 568 | + disc_rate = 1/(1+para[:disc_rate])^10 |
| 569 | + invest = StrategicProfile([0, 0, 10, 5]) |
| 570 | + |
| 571 | + # Retirements are at the end of the strategic period following the investment period |
| 572 | + # This is only the last strategic period |
| 573 | + removal = StrategicProfile([0, 0, 0, 10]) |
| 574 | + |
| 575 | + # Explicit calculation of CAPEX |
| 576 | + # 1. Investments do not require reinvestments. |
| 577 | + # 2. The investment in strategic period 4 has a final value, equal to discounted 10/20 % |
| 578 | + # of the intial value |
| 579 | + capex = StrategicProfile([0, 0, 10, 5*(1-0.5*disc_rate)]) * 1e3 |
| 580 | + |
| 581 | + # Explicit calculation of the current capacity |
| 582 | + cap_initial = StrategicProfile([15, 10, 5, 0]) |
| 583 | + cap_current = cap_initial + invest + removal |
| 584 | + |
| 585 | + # Tests of the lifetime calculation |
| 586 | + # - set_capacity_cost(m, element, inv_data, prefix, 𝒯ᴵⁿᵛ, disc_rate, ::RollingLife) |
| 587 | + @testset "Lifetime calculations" begin |
| 588 | + # Test that `:cap_current` follows the initial capacity |
| 589 | + @test all(value.(m[:cap_current][n, t_inv]) == cap_current[t_inv] for t_inv ∈ 𝒯ᴵⁿᵛ) |
| 590 | + |
| 591 | + # Test that `:cap_rem` follows the lifetime |
| 592 | + @test all(value.(m[:cap_rem][n, t_inv]) == removal[t_inv] for t_inv ∈ 𝒯ᴵⁿᵛ) |
| 593 | + |
| 594 | + # Test that `:cap_add` follows the lifetime |
| 595 | + @test all(value.(m[:cap_add][n, t_inv]) == invest[t_inv] for t_inv ∈ 𝒯ᴵⁿᵛ) |
| 596 | + |
| 597 | + # Test that the CAPEX is correctly calculated |
| 598 | + # - set_capex_discounter(years, lifetime, disc_rate) |
| 599 | + @test all( |
| 600 | + value.(m[:cap_capex])[n, t_inv] ≈ |
| 601 | + value.(m[:cap_add])[n, t_inv] * EMI.capex(inv_data, t_inv) * |
| 602 | + StrategicProfile([1, 1, 1, 1*(1-0.5*disc_rate)])[t_inv] |
| 603 | + for t_inv ∈ 𝒯ᴵⁿᵛ) |
| 604 | + @test all(value.(m[:cap_capex])[n, t_inv] ≈ capex[t_inv] for t_inv ∈ 𝒯ᴵⁿᵛ) |
| 605 | + end |
| 606 | +end |
0 commit comments