Everything per module, renewable modules with their own portfolio, the nuclear modules of T-K on shared units, S41 counted to the first unit. The factor of S51 enters the revenue and the disconnection arm of S47. S53 and S54 are put together over a programme for all solutions. Present values are exactly rounded sums, so the same computation gives the same last digit every time. The chapters after the cash flow refuse T and a loss of demand for now. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
483 lines
22 KiB
Python
483 lines
22 KiB
Python
"""Solution T through the power system and the cash flow, the loss of demand, S53 and S54.
|
|
|
|
Made-up round numbers only; nothing here says anything about the hypothesis. The path used
|
|
most is T-K with two facilities' worth of modules from the made-up set with new grid in
|
|
2033 and 0.5 TWh of new renewable power a year (hand-computed in ``test_trinnvis.py``):
|
|
three renewable modules (2030, 2031, 2033), then ten nuclear modules in 2035 and seven in
|
|
2036. A module uses 8760 * 0.75 * 1.2 * 100 = 788 400 MWh a year, and one unit of
|
|
1 000 MW gives 8760 * 0.8 * 1000 = 7 008 000 MWh.
|
|
"""
|
|
|
|
from __future__ import annotations
|
|
|
|
import math
|
|
from typing import TYPE_CHECKING
|
|
|
|
import numpy as np
|
|
import pytest
|
|
|
|
from tokenfabrikker import dommer, eierskap, miljo, nivaaisert, skala
|
|
from tokenfabrikker import kontantstrom as ks
|
|
from tokenfabrikker import ligninger as lg
|
|
from tokenfabrikker import utbygging as ub
|
|
from tokenfabrikker.kontantstrom import Knapphet
|
|
from tokenfabrikker.utbygging import Losning
|
|
|
|
if TYPE_CHECKING:
|
|
from collections.abc import Callable
|
|
|
|
from conftest import LagInndata
|
|
from tokenfabrikker.inndata import Inndata
|
|
|
|
E_MODUL = 8760.0 * 0.75 * 1.2 * 100.0
|
|
"""Yearly energy to one made-up module: 788 400 MWh."""
|
|
|
|
E_ENHET = 8760.0 * 0.8 * 1000.0
|
|
"""Yearly production of one made-up unit on the grid: 7 008 000 MWh."""
|
|
|
|
GAMLE = (Losning.A, Losning.B, Losning.B_MERKET, Losning.C, Losning.R)
|
|
"""The solutions of chapters 0 to 16."""
|
|
|
|
|
|
def _regn(
|
|
inn: Inndata,
|
|
losning: Losning,
|
|
*,
|
|
N_anlegg: int = 1,
|
|
bortfall: Callable[[int], float] | None = None,
|
|
**brytere: bool,
|
|
) -> ks.Programresultat:
|
|
dim = ks.dimensjoner(inn, losning)
|
|
plan = ks.lag_plan(inn, losning, dim, N_anlegg=N_anlegg, **brytere)
|
|
return ks.regn_program(inn, losning, plan, Knapphet.NORMALISERING, dim=dim, bortfall=bortfall)
|
|
|
|
|
|
def _tk(oppdiktet: LagInndata, *, L_N: float = 20.0) -> tuple[Inndata, ks.Programresultat]:
|
|
inn = oppdiktet(tau_nett=6.0, g_fornybar=0.5e6, L_N=L_N)
|
|
return inn, _regn(inn, Losning.T_K, N_anlegg=2)
|
|
|
|
|
|
def _lik(a: ks.Programresultat, b: ks.Programresultat) -> None:
|
|
"""Every yearly table and every present value of the two results is the same number."""
|
|
for navn in ("KS_D", "KS_N", "F_a", "Delta_W", "utslipp", "K_prog", "V"):
|
|
assert np.array_equal(getattr(a, navn), getattr(b, navn)), navn
|
|
for navn in ("NV_datasenter", "NV_kraft", "NV_ovrige", "RV", "SE", "NNV"):
|
|
assert getattr(a, navn) == getattr(b, navn), navn
|
|
assert a.RV_anlegg == b.RV_anlegg
|
|
assert a.varsigma == b.varsigma
|
|
|
|
|
|
def test_samme_regning_to_ganger_gir_samme_tall_til_siste_siffer(oppdiktet: LagInndata) -> None:
|
|
"""The present values are exactly rounded sums, not dot products (which are not repeatable)."""
|
|
inn = oppdiktet(tau_nett=6.0)
|
|
for losning in (Losning.A, Losning.T_F):
|
|
forste = _regn(inn, losning, N_anlegg=2)
|
|
for _ in range(5):
|
|
_lik(_regn(inn, losning, N_anlegg=2), forste)
|
|
|
|
|
|
# ------------------------------------------------------- everything per module
|
|
|
|
|
|
def test_alt_i_datasenteret_er_per_modul(oppdiktet: LagInndata) -> None:
|
|
"""Module 1 of T-F starts in 2030: 100 MW, built over two years, connected the year before."""
|
|
inn = oppdiktet(tau_nett=6.0)
|
|
res = _regn(inn, Losning.T_F)
|
|
assert res.P_enhet == 100.0
|
|
assert len(res.anlegg) == 10
|
|
modul = res.anlegg[0]
|
|
assert modul.inntekt[2030 - 2027] == pytest.approx(res.y(2030) * 100.0)
|
|
assert modul.drift[2030 - 2027] == pytest.approx(2.5e6 * 100.0)
|
|
# building: 100 mill. kr per MW plus ten per cent, half in 2028 and half in 2029
|
|
assert modul.I_bygg[2028 - 2027] == pytest.approx(5.5e9)
|
|
assert modul.I_bygg[2029 - 2027] == pytest.approx(5.5e9)
|
|
# first vintage with the building, the next one paid in 2034
|
|
assert modul.I_H[2028 - 2027] == pytest.approx(10e9)
|
|
assert modul.I_H[2034 - 2027] == pytest.approx(20e9)
|
|
# grid: 5 mill. kr per MW for the half of 120 MW that is not taken from others
|
|
assert modul.I_nett[2029 - 2027] == pytest.approx(5e6 * 0.5 * 120.0)
|
|
assert modul.kraftkjop[2030 - 2027] == pytest.approx(
|
|
1.05 * res.kraftaar[2030 - 2027].pris * E_MODUL
|
|
)
|
|
# the emissions from building in Norway follow the module's size
|
|
assert res.utslipp[2030 - 2027] == pytest.approx(1000.0 * 0.5 * 2000.0 * 100.0)
|
|
|
|
|
|
def test_fornybarmodulene_har_portefoljen_s39_legger_til(oppdiktet: LagInndata) -> None:
|
|
"""Hydropower fills the first two modules and part of the third; then wind.
|
|
|
|
2 TWh of hydropower gives 1.6 TWh in a dry year: modules 1 and 2 use 1 576 800 MWh of
|
|
it, module 3 the 23 200 MWh that are left (29 000 MWh in a normal year) and wind.
|
|
"""
|
|
inn = oppdiktet(tau_nett=6.0)
|
|
res = _regn(inn, Losning.T_F)
|
|
dim = ks.dimensjoner(inn, Losning.T_F)
|
|
assert res.verk == tuple(ks.kraftverk_for_anlegg(inn, Losning.C, dim, j) for j in range(1, 11))
|
|
(vann,) = res.verk[0]
|
|
assert vann.teknologi == "vann"
|
|
assert vann.energi == pytest.approx(E_MODUL / 0.8)
|
|
tredje = {verk.teknologi: verk.energi for verk in res.verk[2]}
|
|
assert tredje["vann"] == pytest.approx(2e6 - 2 * E_MODUL / 0.8)
|
|
assert tredje["vind"] == pytest.approx(E_MODUL - 23_200.0)
|
|
# ten modules have the portfolio of one facility of 1 000 MW in C
|
|
c = ks.kraftverk_for_anlegg(inn, Losning.C, ks.dimensjoner(inn, Losning.C), 1)
|
|
for verk in c:
|
|
i_moduler = math.fsum(
|
|
v.energi for modul in res.verk for v in modul if v.teknologi == verk.teknologi
|
|
)
|
|
assert i_moduler == pytest.approx(verk.energi)
|
|
|
|
|
|
def test_tf_i_moduler_paa_ett_anlegg_uten_forste_trinn_er_c(oppdiktet: LagInndata) -> None:
|
|
"""A module the size of a facility, started when new grid can come, is a facility in C."""
|
|
inn = oppdiktet(tau_nett=6.0, P_m=1000.0)
|
|
for N_anlegg in (1, 3):
|
|
c = _regn(inn, Losning.C, N_anlegg=N_anlegg)
|
|
tf = _regn(inn, Losning.T_F, N_anlegg=N_anlegg, uten_forste_trinn=True)
|
|
assert tf.plan.anlegg == c.plan.anlegg
|
|
_lik(tf, c)
|
|
|
|
|
|
def test_kraftsystemet_teller_modulene(oppdiktet: LagInndata) -> None:
|
|
"""2031: two modules, both on hydropower that gives all they use in a dry year."""
|
|
inn = oppdiktet(tau_nett=6.0)
|
|
res = _regn(inn, Losning.T_F)
|
|
rad = res.kraftaar[2031 - 2027]
|
|
# half of the use takes the place of others; production in a normal year is use / 0.8
|
|
assert rad.Delta_Q == pytest.approx(0.5 * 2 * E_MODUL - 2 * E_MODUL / 0.8)
|
|
assert rad.Delta_Q_tort == pytest.approx(0.5 * 2 * E_MODUL - 2 * E_MODUL)
|
|
effekt = 2 * E_MODUL / 0.8 / 3000.0
|
|
assert rad.Delta_R == pytest.approx(0.9 * effekt - 0.5 * 1.2 * 200.0)
|
|
assert res.V[2031 - 2027] == pytest.approx(0.5 * 2 * E_MODUL * 70.0)
|
|
|
|
|
|
def test_m4_leses_av_kraftsystemet_ogsaa_for_t(oppdiktet: LagInndata) -> None:
|
|
inn = oppdiktet(tau_nett=6.0)
|
|
forsyning = dommer.m4_forsyning(inn, _regn(inn, Losning.T_F))
|
|
assert not forsyning.svakere_ogsaa_med_tiltak
|
|
|
|
|
|
def test_en_plan_i_moduler_horer_til_t(oppdiktet: LagInndata) -> None:
|
|
inn = oppdiktet(tau_nett=6.0)
|
|
plan_c = ks.lag_plan(inn, Losning.C, ks.dimensjoner(inn, Losning.C), N_anlegg=1)
|
|
plan_t = ks.lag_plan(inn, Losning.T_F, ks.dimensjoner(inn, Losning.T_F), N_anlegg=1)
|
|
with pytest.raises(TypeError, match="built in modules"):
|
|
ks.regn_program(inn, Losning.T_F, plan_c, Knapphet.NORMALISERING)
|
|
with pytest.raises(TypeError, match="built in modules"):
|
|
ks.regn_program(inn, Losning.C, plan_t, Knapphet.NORMALISERING)
|
|
|
|
|
|
# ----------------------------------------------------- nuclear power in T-K
|
|
|
|
|
|
def test_tk_uten_kjernekraft_er_tf_i_alle_tall(oppdiktet: LagInndata) -> None:
|
|
"""One facility's worth of modules: S49 is not met, so T-K is T-F in every year."""
|
|
inn = oppdiktet(tau_nett=6.0, g_fornybar=0.5e6)
|
|
tk, tf = _regn(inn, Losning.T_K), _regn(inn, Losning.T_F)
|
|
assert isinstance(tk.plan, ub.Trinnvisplan)
|
|
assert not tk.plan.kjernekraft_bygges
|
|
assert tk.felles == ()
|
|
assert not tk.K_prog.any()
|
|
_lik(tk, tf)
|
|
|
|
|
|
def test_enhetene_i_tk_folger_kjernekraftmodulene(oppdiktet: LagInndata) -> None:
|
|
"""Ten nuclear modules in 2035 need 7.884 TWh, more than one unit gives: two units.
|
|
|
|
Seventeen need 13.4 TWh, still two. The units go out after 2054, while the seven
|
|
modules from 2036 are operated one more year and need one unit: a third from 2055.
|
|
The three renewable modules do not count.
|
|
"""
|
|
inn, res = _tk(oppdiktet)
|
|
grupper = [(f.gruppe.start, f.gruppe.siste_driftsaar, f.gruppe.numre) for f in res.felles]
|
|
assert grupper == [(2035, 2054, (1, 2)), (2055, 2074, (3,))]
|
|
assert res.felles[0].gruppe.verk.energi == pytest.approx(2 * E_ENHET)
|
|
assert [len(verk) for verk in res.verk] == [1, 1, 2] + [0] * 17
|
|
assert [res.paa_felles_kjernekraft(k) for k in (0, 2, 3, 19)] == [False, False, True, True]
|
|
tf = _regn(inn, Losning.T_F, N_anlegg=2)
|
|
assert ks.enheter_i_B(inn, tf.dim, tf.plan, losning=Losning.T_F) == ()
|
|
|
|
|
|
def test_kjernekraften_i_tk_selger_som_i_b(oppdiktet: LagInndata) -> None:
|
|
_, res = _tk(oppdiktet)
|
|
j = 2040 - 2027
|
|
assert res.felles[0].salg[j] == pytest.approx(res.kraftaar[j].pris * 2 * E_ENHET)
|
|
# two units of 1 000 MW, the largest of them out in the scarcest hour
|
|
rad = res.kraftaar[j]
|
|
assert rad.Delta_R - rad.Delta_R_utfall == pytest.approx(0.98 * 1000.0)
|
|
assert set(res.varsigma) == {"kjernekraft", "vann", "vind"}
|
|
|
|
|
|
def test_nettet_til_en_kjernekraftmodul_baerer_ogsaa_reaktoreffekten(
|
|
oppdiktet: LagInndata,
|
|
) -> None:
|
|
"""A nuclear module pays for its draw and for 0.75 * 1.2 * 100 / 0.8 = 112.5 MW of reactor."""
|
|
_, res = _tk(oppdiktet)
|
|
assert res.anlegg[3].I_nett[2034 - 2027] == pytest.approx(5e6 * (0.5 * 120.0 + 112.5))
|
|
assert res.anlegg[2].I_nett[2032 - 2027] == pytest.approx(5e6 * 0.5 * 120.0)
|
|
|
|
|
|
def test_s41_i_tk_regnes_til_forste_kjernekraftenhet(oppdiktet: LagInndata) -> None:
|
|
"""200 man-years at 1 mill. kr, spread over 2028 to 2035, the first unit's first year."""
|
|
_, res = _tk(oppdiktet)
|
|
assert res.plan.t_1 == 2030
|
|
assert res.K_prog[1 : 2035 - 2027 + 1] == pytest.approx(0.2 * 1000.0 * 1e6 / 8.0)
|
|
assert not res.K_prog[2036 - 2027 :].any()
|
|
assert res.K_prog[0] == 0.0
|
|
|
|
|
|
def test_knappheten_i_t_regnes_fra_forste_modul(oppdiktet: LagInndata) -> None:
|
|
"""S43: the markup lasts ten years from the first module, not from the first unit."""
|
|
inn = oppdiktet(tau_nett=6.0, g_fornybar=0.5e6)
|
|
dim = ks.dimensjoner(inn, Losning.T_K)
|
|
plan = ks.lag_plan(inn, Losning.T_K, dim, N_anlegg=2)
|
|
res = ks.regn_program(inn, Losning.T_K, plan, Knapphet.VARER, dim=dim)
|
|
assert res.y(2039) == pytest.approx(150e6)
|
|
assert res.y(2040) < 150e6
|
|
|
|
|
|
def test_restverdien_deler_kjernekraften_paa_kjernekraftmodulene(oppdiktet: LagInndata) -> None:
|
|
"""With 30 operating years the modules run past 2060, and S40 gives each a residual value.
|
|
|
|
In the last five years all seventeen nuclear modules are operated, so each carries a
|
|
seventeenth of the units' cash flow; a renewable module carries none of it.
|
|
"""
|
|
_, res = _tk(oppdiktet, L_N=30.0)
|
|
assert [a.L_rest for a in (res.anlegg[0], res.anlegg[3], res.anlegg[19])] == [0, 4, 5]
|
|
kjerne = sum(f.netto(res.varsigma["kjernekraft"]) for f in res.felles)
|
|
# module 1 goes out after 2059, so the capacity cost is shared by 20 and then by 19
|
|
med_last = np.array([max(1, res.plan.antall_med_last(t)) for t in res.aar])
|
|
assert list(med_last[-5:]) == [20, 20, 20, 20, 19]
|
|
|
|
def restverdi(k: int, andel_kjerne: float) -> float:
|
|
a = res.anlegg[k]
|
|
netto = a.datasenter() + a.kraft(res.varsigma, res.F_a / med_last) + andel_kjerne * kjerne
|
|
return lg.s40_restverdi(
|
|
NK_snitt=float(np.mean(netto[-5:])),
|
|
L_rest=a.L_rest,
|
|
rho_D=0.08,
|
|
rho_avvikling=0.06,
|
|
avvikling=0.0,
|
|
T_s=2060,
|
|
T_0=2027,
|
|
)
|
|
|
|
assert res.RV_anlegg[3] == pytest.approx(restverdi(3, 1.0 / 17.0))
|
|
assert res.RV_anlegg[19] == pytest.approx(restverdi(19, 1.0 / 17.0))
|
|
assert res.RV_anlegg[2] == pytest.approx(restverdi(2, 0.0))
|
|
assert res.RV_anlegg[3] != pytest.approx(restverdi(3, 1.0 / 20.0))
|
|
# the units from 2035 go out in 2064: their decommissioning falls after the final year
|
|
assert res.felles[0].avvikling_etter == pytest.approx(5e6 * 2000.0)
|
|
assert res.RV_felles < 0
|
|
assert res.RV == pytest.approx(math.fsum(res.RV_anlegg) + res.RV_felles)
|
|
|
|
|
|
def test_nnv_er_summen_av_delene_i_t(oppdiktet: LagInndata) -> None:
|
|
_, res = _tk(oppdiktet)
|
|
D_D = np.array([1.08 ** -(t - 2027) for t in res.aar])
|
|
D_N = np.array([1.06 ** -(t - 2027) for t in res.aar])
|
|
egne = sum(a.kraft(res.varsigma, np.zeros(len(res.aar))) for a in res.anlegg)
|
|
felles = sum(f.netto(res.varsigma["kjernekraft"]) for f in res.felles)
|
|
assert res.KS_N == pytest.approx(egne + felles - res.F_a)
|
|
assert res.NV_datasenter == pytest.approx(float(D_D @ res.KS_D))
|
|
assert res.NV_kraft == pytest.approx(float(D_N @ res.KS_N))
|
|
assert res.NNV == pytest.approx(
|
|
res.NV_datasenter + res.NV_kraft + res.NV_ovrige - 0.2 * res.SE + res.RV
|
|
)
|
|
|
|
|
|
# ------------------------------------------------ the loss of demand (S51)
|
|
|
|
|
|
@pytest.mark.parametrize("losning", [*GAMLE, Losning.T_F])
|
|
def test_uten_bortfall_er_alle_tall_uendret(oppdiktet: LagInndata, losning: Losning) -> None:
|
|
inn = oppdiktet(tau_nett=6.0)
|
|
uten = _regn(inn, losning, N_anlegg=2)
|
|
assert uten.mu_d.hovedforlop
|
|
assert uten.mu_d(2030) == 1.0
|
|
_lik(_regn(inn, losning, N_anlegg=2, bortfall=ks.fast_bortfall(0.0)), uten)
|
|
|
|
|
|
def test_bortfallet_folger_aargangen_og_endrer_bare_inntekten(oppdiktet: LagInndata) -> None:
|
|
"""The made-up scenario: d is 0.1 for the vintage of 2030 and 0.2 from 2035."""
|
|
inn = oppdiktet()
|
|
uten = _regn(inn, Losning.C)
|
|
med = _regn(inn, Losning.C, bortfall=ks.bortfall_i_scenario(inn, "lavt"))
|
|
assert med.plan == uten.plan
|
|
assert not med.mu_d.hovedforlop
|
|
a, b = med.anlegg[0], uten.anlegg[0]
|
|
assert a.inntekt[2030 - 2027 : 2035 - 2027] == pytest.approx(
|
|
0.9 * b.inntekt[2030 - 2027 : 2035 - 2027]
|
|
)
|
|
assert a.inntekt[2035 - 2027 :] == pytest.approx(0.8 * b.inntekt[2035 - 2027 :])
|
|
for navn in ("drift", "kraftkjop", "I_bygg", "I_H", "I_nett"):
|
|
assert np.array_equal(getattr(a, navn), getattr(b, navn)), navn
|
|
assert med.NNV < uten.NNV
|
|
with pytest.raises(KeyError, match="unknown scenario"):
|
|
ks.bortfall_i_scenario(inn, "finnes ikke")
|
|
|
|
|
|
def test_eps_d_skalerer_bortfallet(oppdiktet: LagInndata) -> None:
|
|
inn = oppdiktet(eps_d=2.0)
|
|
uten = _regn(inn, Losning.R)
|
|
med = _regn(inn, Losning.R, bortfall=ks.fast_bortfall(0.2))
|
|
assert med.mu_d(2030) == pytest.approx(0.6)
|
|
assert med.anlegg[0].inntekt == pytest.approx(0.6 * uten.anlegg[0].inntekt)
|
|
|
|
|
|
@pytest.mark.parametrize("losning", [Losning.A, Losning.B, Losning.R, Losning.T_K])
|
|
def test_likt_bortfall_er_det_samme_som_lavere_solgt_andel(
|
|
oppdiktet: LagInndata, losning: Losning
|
|
) -> None:
|
|
"""17.3: the factor stands everywhere mu stands with the price, so d = 0.2 is mu = 0.8."""
|
|
inn = oppdiktet(tau_nett=6.0, g_fornybar=0.5e6)
|
|
med = _regn(inn, losning, N_anlegg=2, bortfall=ks.fast_bortfall(0.2))
|
|
lavere = _regn(oppdiktet(tau_nett=6.0, g_fornybar=0.5e6, mu_rel=0.8), losning, N_anlegg=2)
|
|
assert med.NNV == pytest.approx(lavere.NNV)
|
|
assert med.KS_D == pytest.approx(lavere.KS_D)
|
|
assert med.F_a == pytest.approx(lavere.F_a)
|
|
|
|
|
|
def test_bortfallet_staar_i_utkoblingsarmen(oppdiktet: LagInndata) -> None:
|
|
"""R builds no power, so capacity is missing; disconnecting is the cheaper arm here.
|
|
|
|
The arm is the revenue lost in the scarce hours, so it falls with the revenue.
|
|
"""
|
|
inn = oppdiktet()
|
|
uten = _regn(inn, Losning.R)
|
|
med = _regn(inn, Losning.R, bortfall=ks.fast_bortfall(0.2))
|
|
j = 2032 - 2027
|
|
mangler = 0.5 * 1.2 * 1000.0
|
|
assert uten.F_a[j] == pytest.approx(100.0 * uten.y(2030) / (8760.0 * 1.2) * mangler)
|
|
assert uten.F_a[j] < 1.4e6 * mangler
|
|
assert med.F_a[j] == pytest.approx(0.8 * uten.F_a[j])
|
|
|
|
|
|
def test_kapitlene_etter_kontantstrommen_avviser_det_de_ikke_kan_ennaa(
|
|
oppdiktet: LagInndata,
|
|
) -> None:
|
|
inn = oppdiktet(tau_nett=6.0)
|
|
t = _regn(inn, Losning.T_F)
|
|
med = _regn(inn, Losning.C, bortfall=ks.fast_bortfall(0.2))
|
|
for res, melding in ((t, "solution T is not taken"), (med, "loss of demand")):
|
|
with pytest.raises(NotImplementedError, match=melding):
|
|
nivaaisert.kraftkostnad(inn, res)
|
|
with pytest.raises(NotImplementedError, match=melding):
|
|
eierskap.bedriftsstrom(inn, res)
|
|
with pytest.raises(NotImplementedError, match=melding):
|
|
skala.skala(inn, res)
|
|
|
|
|
|
# ------------------------------------------------- S32, S53 and S54 over a programme
|
|
|
|
|
|
def test_utslippene_i_t_folger_modulens_egen_kraft(oppdiktet: LagInndata) -> None:
|
|
"""Module 1 has hydropower only; a nuclear module has the figure for nuclear power."""
|
|
inn, res = _tk(oppdiktet)
|
|
assert miljo.kraftutslipp_per_mwh(inn, res, 0) == pytest.approx(0.004)
|
|
assert miljo.kraftutslipp_per_mwh(inn, res, 3) == pytest.approx(0.012)
|
|
U = miljo.utslipp_livslop(inn, res)
|
|
# 2030: one module on hydropower, with its building and its first vintage
|
|
assert U[2030 - 2027] == pytest.approx(0.004 * E_MODUL + (1000.0 + 2000.0) * 100.0)
|
|
tf = _regn(inn, Losning.T_F, N_anlegg=2)
|
|
assert miljo.kraftutslipp_per_mwh(inn, tf, 3) < 0.012
|
|
assert not miljo.brukt_brensel(inn, tf).any()
|
|
|
|
|
|
def test_kjernekraftproduksjonen_teller_bare_kjernekraft(oppdiktet: LagInndata) -> None:
|
|
"""T-K: nothing before 2035, two units to 2054 and one from 2055; renewables never count."""
|
|
inn, res = _tk(oppdiktet)
|
|
E_N = miljo.kjernekraftproduksjon(res)
|
|
assert not E_N[: 2035 - 2027].any()
|
|
assert E_N[2035 - 2027 : 2055 - 2027] == pytest.approx(2 * E_ENHET)
|
|
assert E_N[2055 - 2027 :] == pytest.approx(E_ENHET)
|
|
assert miljo.brukt_brensel(inn, res) == pytest.approx(3e-6 * E_N)
|
|
# A: the plant only produces what the data centre uses
|
|
a = _regn(inn, Losning.A)
|
|
assert miljo.kjernekraftproduksjon(a)[a.plan.t_1 - 2027] == pytest.approx(10 * E_MODUL)
|
|
assert not miljo.kjernekraftproduksjon(_regn(inn, Losning.C)).any()
|
|
|
|
|
|
def test_s53_unngaatte_utslipp_over_et_program(oppdiktet: LagInndata) -> None:
|
|
"""u_alt falls from 0.4 in 2025 to 0.2 in 2035: 0.3 tonnes per MWh in 2030.
|
|
|
|
One facility of 1 000 MW that sells everything: 8760 * 0.75 * 1.2 * 1000 MWh with the
|
|
competitor's PUE.
|
|
"""
|
|
inn = oppdiktet()
|
|
res = _regn(inn, Losning.C)
|
|
unngaatt = miljo.unngaatt_utslipp(inn, res)
|
|
assert not unngaatt[: 2030 - 2027].any()
|
|
assert unngaatt[2030 - 2027] == pytest.approx(0.3 * 7_884_000.0)
|
|
assert unngaatt[2045 - 2027] == pytest.approx(0.1 * 7_884_000.0)
|
|
assert unngaatt[2049 - 2027] == pytest.approx(0.1 * 7_884_000.0)
|
|
assert unngaatt[2050 - 2027] == 0.0 # the facility went out after 20 years
|
|
assert miljo.unngaatt_utslipp(inn, res, anslag="fast")[2040 - 2027] == pytest.approx(
|
|
0.5 * 7_884_000.0
|
|
)
|
|
assert not miljo.unngaatt_utslipp(inn, res, anslag="null").any()
|
|
med = miljo.utslipp_med_fradrag(inn, res)
|
|
assert med == pytest.approx(miljo.utslipp_livslop(inn, res) - unngaatt)
|
|
|
|
|
|
def test_s53_teller_bare_det_som_er_solgt_og_levert(oppdiktet: LagInndata) -> None:
|
|
inn = oppdiktet(PUE_v=1.5)
|
|
c = _regn(inn, Losning.C)
|
|
assert miljo.unngaatt_utslipp(inn, c)[2030 - 2027] == pytest.approx(
|
|
0.3 * 8760.0 * 0.75 * 1.5 * 1000.0
|
|
)
|
|
# the loss of demand follows the vintage: 0.1 for the one of 2030, 0.2 from 2035
|
|
med = _regn(inn, Losning.C, bortfall=ks.bortfall_i_scenario(inn, "lavt"))
|
|
forhold = miljo.unngaatt_utslipp(inn, med) / np.maximum(1.0, miljo.unngaatt_utslipp(inn, c))
|
|
assert forhold[2034 - 2027] == pytest.approx(0.9)
|
|
assert forhold[2035 - 2027] == pytest.approx(0.8)
|
|
# A delivers the share Gamma of the year
|
|
a = _regn(inn, Losning.A)
|
|
assert a.dim.Gamma < 1.0
|
|
assert miljo.unngaatt_utslipp(inn, a)[2045 - 2027] == pytest.approx(
|
|
a.dim.Gamma * 0.1 * 8760.0 * 0.75 * 1.5 * 1000.0
|
|
)
|
|
# a share that is not sold replaces nothing
|
|
halv = oppdiktet(PUE_v=1.5, mu_rel=0.5)
|
|
assert miljo.unngaatt_utslipp(halv, _regn(halv, Losning.C))[2030 - 2027] == pytest.approx(
|
|
0.5 * 0.3 * 8760.0 * 0.75 * 1.5 * 1000.0
|
|
)
|
|
|
|
|
|
def test_s53_i_t_summerer_over_modulene(oppdiktet: LagInndata) -> None:
|
|
"""2036: all twenty modules have a vintage in operation, 2 000 MW; u_alt is 0.19."""
|
|
inn, res = _tk(oppdiktet)
|
|
assert miljo.unngaatt_utslipp(inn, res)[2036 - 2027] == pytest.approx(0.19 * 2 * 7_884_000.0)
|
|
assert miljo.unngaatt_utslipp(inn, res)[2031 - 2027] == pytest.approx(0.28 * 2 * 788_400.0)
|
|
|
|
|
|
def test_s54_kjolevann_over_et_program(oppdiktet: LagInndata) -> None:
|
|
"""T-K in 2036: 2 000 MW IT use 13.14 TWh, and two units produce 14.016 TWh."""
|
|
inn, res = _tk(oppdiktet)
|
|
j = 2036 - 2027
|
|
E_IT = 20 * 8760.0 * 0.75 * 100.0
|
|
assert miljo.it_energi(inn, res)[j] == pytest.approx(E_IT)
|
|
vann = miljo.kjolevann(inn, res)
|
|
assert vann.uttak[j] == pytest.approx(0.1 * E_IT + 150.0 * 2 * E_ENHET)
|
|
assert not vann.forbruk_kjernekraft.any()
|
|
assert vann.forbruk_hoyst[j] == pytest.approx(0.1 * E_IT)
|
|
# 2031: two renewable modules, no nuclear power yet
|
|
assert vann.uttak[2031 - 2027] == pytest.approx(0.1 * 2 * 8760.0 * 0.75 * 100.0)
|
|
# the figures shown next to the main ones take their own factors
|
|
taarn = miljo.vannmengde(inn, res, w_D=0.0, w_N=inn.kjoletaarn["forbruk"][1])
|
|
assert taarn[j] == pytest.approx(2.5 * 2 * E_ENHET)
|
|
|
|
|
|
@pytest.mark.parametrize("losning", GAMLE)
|
|
def test_s54_i_losningene_fra_for(oppdiktet: LagInndata, losning: Losning) -> None:
|
|
inn = oppdiktet(w_N_forbruk=1.0)
|
|
res = _regn(inn, losning)
|
|
j = res.plan.t_1 - 2027
|
|
E_IT = 8760.0 * 0.75 * 1000.0
|
|
E_N = miljo.kjernekraftproduksjon(res)[j]
|
|
vann = miljo.kjolevann(inn, res)
|
|
assert vann.uttak[j] == pytest.approx(0.1 * E_IT + 150.0 * E_N)
|
|
assert vann.forbruk_kjernekraft[j] == pytest.approx(E_N)
|
|
assert vann.forbruk_hoyst[j] == pytest.approx(0.1 * E_IT + E_N)
|
|
assert (E_N > 0) == losning.kjernekraft
|
|
assert not vann.uttak[:j].any()
|