Skip to content
Merged
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
1 change: 1 addition & 0 deletions process/current_drive.py
Original file line number Diff line number Diff line change
Expand Up @@ -1001,6 +1001,7 @@ def electron_bernstein_freethy(
/ (2.0e0 * np.pi)
* np.sqrt(
dene20
* 1.0e20
* constants.ELECTRON_CHARGE**2
/ (constants.ELECTRON_MASS * constants.EPSILON0)
)
Expand Down
8 changes: 4 additions & 4 deletions process/data_structure/current_drive_variables.py
Original file line number Diff line number Diff line change
Expand Up @@ -483,8 +483,8 @@ def init_current_drive_variables():
n_ecrh_harmonic = 2.0
i_ecrh_wave_mode = 0
e_beam_kev = 1.0e3
eta_hcd_primary_injector_wall_plug = 0.0
eta_hcd_secondary_injector_wall_plug = 0.0
eta_hcd_primary_injector_wall_plug = 0.3
eta_hcd_secondary_injector_wall_plug = 0.3
eta_ecrh_injector_wall_plug = 0.3
eta_lowhyb_injector_wall_plug = 0.3
eta_beam_injector_wall_plug = 0.3
Expand Down Expand Up @@ -529,8 +529,8 @@ def init_current_drive_variables():
c_hcd_secondary_driven = 0.0
f_c_plasma_hcd_primary = 0.0
f_c_plasma_hcd_secondary = 0.0
eta_icrh_injector_wall_plug = 0.0
eta_ebw_injector_wall_plug = 0.0
eta_icrh_injector_wall_plug = 0.3
eta_ebw_injector_wall_plug = 0.3
p_hcd_primary_injected_mw = 0.0
p_hcd_icrh_injected_total_mw = 0.0
p_hcd_ebw_injected_total_mw = 0.0
Expand Down
6 changes: 6 additions & 0 deletions process/input.py
Original file line number Diff line number Diff line change
Expand Up @@ -632,6 +632,12 @@ def __post_init__(self):
"eta_ecrh_injector_wall_plug": InputVariable(
data_structure.current_drive_variables, float, range=(0.0, 1.0)
),
"eta_icrh_injector_wall_plug": InputVariable(
data_structure.current_drive_variables, float, range=(0.0, 1.0)
),
"eta_ebw_injector_wall_plug": InputVariable(
data_structure.current_drive_variables, float, range=(0.0, 1.0)
),
"eta_coolant_pump_electric": InputVariable(
data_structure.fwbs_variables, float, range=(0.1, 1.0)
),
Expand Down
190 changes: 190 additions & 0 deletions tests/unit/test_current_drive.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import pytest

from process import constants
from process.current_drive import (
CurrentDrive,
ElectronBernstein,
Expand Down Expand Up @@ -132,3 +133,192 @@ def test_sigbeam(current_drive):
assert current_drive.neutral_beam.sigbeam(
1e3, 13.07, 8.0e-1, 0.1, 1e-4, 1e-4, 1e-4
) == pytest.approx(2.013589662302492e-11)


def test_cudriv_primary_neutral_beam(current_drive):
current_drive_variables.i_hcd_primary = 5 # Neutral Beam
current_drive_variables.i_hcd_secondary = 0
current_drive_variables.i_hcd_calculations = 1
current_drive_variables.p_hcd_primary_extra_heat_mw = 0.0
current_drive_variables.eta_cd_hcd_secondary = 0.0
physics_variables.nd_plasma_electrons_vol_avg = 1e20
physics_variables.temp_plasma_electron_vol_avg_kev = 10
physics_variables.rmajor = 6.2
physics_variables.plasma_current = 15e6
physics_variables.f_c_plasma_auxiliary = 0.2
current_drive_variables.eta_beam_injector_wall_plug = 0.3
physics_variables.m_beam_amu = 2.0
physics_variables.temp_plasma_electron_density_weighted_kev = 10.0
physics_variables.zeff = 2.0
current_drive.cudriv()

assert current_drive_variables.eta_cd_hcd_primary == pytest.approx(
0.050571139708731186, rel=1e-6
)
assert current_drive_variables.eta_cd_norm_hcd_primary == pytest.approx(
0.31354106619413336, rel=1e-6
)
assert current_drive_variables.f_c_plasma_hcd_secondary == pytest.approx(
0.0, rel=1e-6
)
assert current_drive_variables.p_hcd_primary_injected_mw == pytest.approx(
59.32237274617019, rel=1e-6
)
assert current_drive_variables.c_hcd_primary_driven == pytest.approx(
3000000.0, rel=1e-6
)
assert current_drive_variables.f_c_plasma_hcd_primary == pytest.approx(
0.2, rel=1e-6
)
assert heat_transport_variables.p_hcd_primary_electric_mw == pytest.approx(
59.32237274617019, rel=1e-6
)
assert heat_transport_variables.p_hcd_secondary_electric_mw == pytest.approx(
0.0, rel=1e-6
)
assert current_drive_variables.p_hcd_injected_total_mw == pytest.approx(
59.32237274617019, rel=1e-6
)


def test_cudriv_primary_electron_cyclotron(current_drive):
current_drive_variables.i_hcd_primary = 3 # Electron Cyclotron
current_drive_variables.i_hcd_secondary = 0
current_drive_variables.i_hcd_calculations = 1
current_drive_variables.p_hcd_primary_extra_heat_mw = 0.0
current_drive_variables.eta_cd_hcd_secondary = 0.0
physics_variables.nd_plasma_electrons_vol_avg = 1e20
physics_variables.temp_plasma_electron_vol_avg_kev = 10
physics_variables.rmajor = 6.2
physics_variables.plasma_current = 15e6
physics_variables.f_c_plasma_auxiliary = 0.2
current_drive_variables.eta_ecrh_injector_wall_plug = 0.5
physics_variables.dlamee = 1.0
physics_variables.temp_plasma_electron_density_weighted_kev = 10.0
current_drive.cudriv()

assert current_drive_variables.eta_cd_hcd_primary == pytest.approx(
0.33870967741935487, rel=1e-6
)
assert current_drive_variables.eta_cd_norm_hcd_primary == pytest.approx(
2.1, rel=1e-6
)
assert current_drive_variables.f_c_plasma_hcd_secondary == pytest.approx(
0.0, rel=1e-6
)
assert current_drive_variables.p_hcd_primary_injected_mw == pytest.approx(
8.857142857142856, rel=1e-6
)
assert current_drive_variables.c_hcd_primary_driven == pytest.approx(
3000000.0, rel=1e-6
)
assert current_drive_variables.f_c_plasma_hcd_primary == pytest.approx(
0.2, rel=1e-6
)
assert heat_transport_variables.p_hcd_primary_electric_mw == pytest.approx(
17.71428571428571, rel=1e-6
)
assert heat_transport_variables.p_hcd_secondary_electric_mw == pytest.approx(
0.0, rel=1e-6
)
assert current_drive_variables.p_hcd_injected_total_mw == pytest.approx(
8.857142857142856, rel=1e-6
)
assert current_drive_variables.p_hcd_injected_electrons_mw == pytest.approx(
8.857142857142856, rel=1e-6
)


def test_cudriv_primary_ion_cyclotron(current_drive):
current_drive_variables.i_hcd_primary = 2 # Ion Cyclotron
current_drive_variables.i_hcd_secondary = 0
current_drive_variables.i_hcd_calculations = 1
current_drive_variables.p_hcd_primary_extra_heat_mw = 0.0
current_drive_variables.eta_cd_hcd_secondary = 0.0
physics_variables.nd_plasma_electrons_vol_avg = 1e20
physics_variables.temp_plasma_electron_vol_avg_kev = 10
physics_variables.rmajor = 6.2
physics_variables.plasma_current = 15e6
physics_variables.f_c_plasma_auxiliary = 0.2
current_drive_variables.eta_icrh_injector_wall_plug = 0.35
physics_variables.zeff = 2.0
physics_variables.temp_plasma_electron_density_weighted_kev = 10.0
current_drive.cudriv()

assert current_drive_variables.eta_cd_hcd_primary == pytest.approx(
0.025403225806451612, rel=1e-6
)
assert current_drive_variables.eta_cd_norm_hcd_primary == pytest.approx(
0.1575, rel=1e-6
)
assert current_drive_variables.f_c_plasma_hcd_secondary == pytest.approx(
0.0, rel=1e-6
)
assert current_drive_variables.p_hcd_primary_injected_mw == pytest.approx(
118.0952380952381, rel=1e-6
)
assert current_drive_variables.c_hcd_primary_driven == pytest.approx(
3000000.0, rel=1e-6
)
assert current_drive_variables.f_c_plasma_hcd_primary == pytest.approx(
0.2, rel=1e-6
)
assert heat_transport_variables.p_hcd_primary_electric_mw == pytest.approx(
337.4149659863946, rel=1e-6
)
assert heat_transport_variables.p_hcd_secondary_electric_mw == pytest.approx(
0.0, rel=1e-6
)
assert current_drive_variables.p_hcd_injected_total_mw == pytest.approx(
118.0952380952381, rel=1e-6
)


def test_cudriv_primary_electron_bernstein(current_drive):
current_drive_variables.i_hcd_primary = 12 # Electron Bernstein
current_drive_variables.i_hcd_secondary = 0
current_drive_variables.i_hcd_calculations = 1
current_drive_variables.p_hcd_primary_extra_heat_mw = 0.0
current_drive_variables.eta_cd_hcd_secondary = 0.0
physics_variables.nd_plasma_electrons_vol_avg = 2e20
physics_variables.temp_plasma_electron_vol_avg_kev = 10
physics_variables.rmajor = 6.2
physics_variables.plasma_current = 15e6
physics_variables.f_c_plasma_auxiliary = 0.2
current_drive_variables.eta_ebw_injector_wall_plug = 0.45
physics_variables.b_plasma_toroidal_on_axis = 2.0
physics_variables.temp_plasma_electron_density_weighted_kev = 10.0
current_drive_variables.n_ecrh_harmonic = 2
current_drive_variables.xi_ebw = 0.7
constants.ELECTRON_CHARGE = constants.ELECTRON_CHARGE
constants.ELECTRON_MASS = constants.ELECTRON_MASS
constants.EPSILON0 = constants.EPSILON0
current_drive.cudriv()

assert current_drive_variables.eta_cd_hcd_primary == pytest.approx(
0.011640447389800388, rel=1e-6
)
assert current_drive_variables.eta_cd_norm_hcd_primary == pytest.approx(
0.1443415476335248, rel=1e-6
)
assert current_drive_variables.f_c_plasma_hcd_secondary == pytest.approx(
0.0, rel=1e-6
)
assert current_drive_variables.p_hcd_primary_injected_mw == pytest.approx(
257.72205307406523, rel=1e-6
)
assert current_drive_variables.c_hcd_primary_driven == pytest.approx(
3000000.0, rel=1e-6
)
assert current_drive_variables.f_c_plasma_hcd_primary == pytest.approx(
0.2, rel=1e-6
)
assert heat_transport_variables.p_hcd_primary_electric_mw == pytest.approx(
572.7156734979227, rel=1e-6
)
assert heat_transport_variables.p_hcd_secondary_electric_mw == pytest.approx(
0.0, rel=1e-6
)
assert current_drive_variables.p_hcd_injected_total_mw == pytest.approx(
257.72205307406523, rel=1e-6
)
Loading