Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 14 additions & 9 deletions process/availability.py
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you request a modeller to review just this file and check they are happy with this bit. Maybe @chris-ashe ?

Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import logging
import math

import numpy as np
from scipy.special import comb as combinations

from process import constants
Expand Down Expand Up @@ -110,9 +109,13 @@ def avail(self, output: bool):
# Calculate blanket lifetime using neutron fluence model (ibkt_life=0)
# or DEMO fusion power model (ibkt_life=1)
if cv.ibkt_life == 0:
fwbsv.life_blkt_fpy = min(
(cv.abktflnc / np.asarray(pv.pflux_fw_neutron_mw)).item(),
cv.life_plant,
fwbsv.life_blkt_fpy = (
cv.life_plant
if pv.pflux_fw_neutron_mw == 0.0
else min(
(cv.abktflnc / pv.pflux_fw_neutron_mw),
cv.life_plant,
)
)
else:
fwbsv.life_blkt_fpy = min(
Expand Down Expand Up @@ -1355,11 +1358,13 @@ def cp_lifetime():
# SC magnets CP lifetime
# Rem : only the TF maximum fluence is considered for now
if tfv.i_tf_sup == 1:
cplife = min(
(
ctv.nflutfmax / (np.asarray(fwbsv.neut_flux_cp) * YEAR_SECONDS)
).item(),
cv.life_plant,
cplife = (
cv.life_plant
if fwbsv.neut_flux_cp <= 0.0
else min(
(ctv.nflutfmax / (fwbsv.neut_flux_cp * YEAR_SECONDS)),
cv.life_plant,
)
)

# Aluminium/Copper magnets CP lifetime
Expand Down
2 changes: 2 additions & 0 deletions tests/unit/test_availability.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ def test_avail_1(monkeypatch, availability):
monkeypatch.setattr(cv, "uufw", 0.8)
monkeypatch.setattr(cv, "uumag", 0.9)
monkeypatch.setattr(cv, "uuves", 0.11)
monkeypatch.setattr(tv, "t_plant_pulse_total", 1e4)

availability.avail(output=False)
cfactr_obs = cv.f_t_plant_available
Expand Down Expand Up @@ -221,6 +222,7 @@ def calc_u_planned_fix(request, monkeypatch):
monkeypatch.setattr(cv, "cplife", 0.0)
monkeypatch.setattr(cv, "cpstflnc", param["cpstflnc"])
monkeypatch.setattr(cv, "num_rh_systems", param["num_rh_systems"])
monkeypatch.setattr(fwbsv, "neut_flux_cp", 1e18)

# Return the expected result for the given parameter list
return param["expected"]
Expand Down
2 changes: 2 additions & 0 deletions tests/unit/test_current_drive.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,8 @@ def test_cudriv_primary_neutral_beam(current_drive):
physics_variables.m_beam_amu = 2.0
physics_variables.temp_plasma_electron_density_weighted_kev = 10.0
physics_variables.n_charge_plasma_effective_vol_avg = 2.0
physics_variables.dlamie = 1.0
physics_variables.n_charge_plasma_effective_mass_weighted_vol_avg = 0.4
current_drive.cudriv()

assert current_drive_variables.eta_cd_hcd_primary == pytest.approx(
Expand Down
2 changes: 2 additions & 0 deletions tests/unit/test_plasma_profiles.py
Original file line number Diff line number Diff line change
Expand Up @@ -469,6 +469,8 @@ def test_plasma_profiles(plasmaprofilesparam, monkeypatch):

monkeypatch.setattr(physics_variables, "rminor", plasmaprofilesparam.rminor)

monkeypatch.setattr(physics_variables, "a_plasma_poloidal", 4.0)

plasmaprofile = PlasmaProfile()
plasmaprofile.run()

Expand Down