Skip to content

Commit

Permalink
Rename normalised_total_beta to norm_beta_total and add norm_beta_tor…
Browse files Browse the repository at this point in the history
…oidal and norm_beta_poloidal to update related calculations and references for consistency
  • Loading branch information
chris-ashe committed Nov 11, 2024
1 parent 84009f3 commit 7b8f4cf
Show file tree
Hide file tree
Showing 5 changed files with 65 additions and 49 deletions.
2 changes: 1 addition & 1 deletion process/io/mfile_comparison.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@
"q95",
"beta",
"normalised_thermal_beta",
"normalised_total_beta",
"norm_beta_total",
"thermal_beta",
"thermal_poloidal_beta",
"te",
Expand Down
82 changes: 45 additions & 37 deletions process/physics.py
Original file line number Diff line number Diff line change
Expand Up @@ -1601,6 +1601,14 @@ def physics(self):
* physics_variables.bt
/ physics_variables.plasma_current,
)
physics_variables.norm_beta_toroidal = (
physics_variables.norm_beta_total
* (physics_variables.btot / physics_variables.bt) ** 2
)
physics_variables.norm_beta_poloidal = (
physics_variables.norm_beta_total
* (physics_variables.btot / physics_variables.bp) ** 2
)

# Set PF coil ramp times
if pulse_variables.lpulse != 1:
Expand Down Expand Up @@ -3011,7 +3019,7 @@ def calculate_plasma_current(
)

# Normalised beta from Troyon beta limit
physics_variables.normalised_total_beta = (
physics_variables.norm_beta_total = (
1.0e8 * physics_variables.beta * rminor * bt / plasma_current
)

Expand Down Expand Up @@ -3470,7 +3478,30 @@ def outplas(self):
)

po.osubhd(self.outfile, "Beta Information :")

if physics_variables.i_beta_component == 0:
po.ovarrf(
self.outfile,
"Limit on total beta",
"(beta_limit_upper)",
physics_variables.beta_limit_upper,
"OP ",
)
elif physics_variables.i_beta_component == 1:
po.ovarrf(
self.outfile,
"Limit on thermal beta",
"(beta_limit_upper)",
physics_variables.beta_limit_upper,
"OP ",
)
else:
po.ovarrf(
self.outfile,
"Limit on thermal + NB beta",
"(beta_limit_upper)",
physics_variables.beta_limit_upper,
"OP ",
)
gammaft = (
physics_variables.beta_fast_alpha + physics_variables.beta_beam
) / physics_variables.beta_thermal
Expand Down Expand Up @@ -3547,7 +3578,7 @@ def outplas(self):
"(epbetmax)",
physics_variables.epbetmax,
)

po.osubhd(self.outfile, "Normalised Beta Information :")
if stellarator_variables.istell == 0:
if physics_variables.iprofile == 1:
po.ovarrf(
Expand All @@ -3564,57 +3595,34 @@ def outplas(self):
"(dnbeta)",
physics_variables.dnbeta,
)

po.ovarrf(
self.outfile,
"Normalised thermal beta",
"(norm_beta_thermal) ",
physics_variables.norm_beta_thermal,
"Normalised total beta",
"(norm_beta_total)",
physics_variables.norm_beta_total,
"OP ",
)

po.ovarrf(
self.outfile,
"Normalised total beta",
"(normalised_total_beta)",
physics_variables.normalised_total_beta,
"Normalised thermal beta",
"(norm_beta_thermal) ",
physics_variables.norm_beta_thermal,
"OP ",
)

normalised_toroidal_beta = (
physics_variables.normalised_total_beta
* (physics_variables.btot / physics_variables.bt) ** 2
)
po.ovarrf(
self.outfile,
"Normalised toroidal beta",
"(normalised_toroidal_beta)",
normalised_toroidal_beta,
"(norm_beta_toroidal) ",
physics_variables.norm_beta_toroidal,
"OP ",
)

if physics_variables.i_beta_component == 0:
po.ovarrf(
self.outfile,
"Limit on total beta",
"(beta_limit_upper)",
physics_variables.beta_limit_upper,
"OP ",
)
elif physics_variables.i_beta_component == 1:
po.ovarrf(
self.outfile,
"Limit on thermal beta",
"(beta_limit_upper)",
physics_variables.beta_limit_upper,
"OP ",
)
else:
po.ovarrf(
self.outfile,
"Limit on thermal + NB beta",
"(beta_limit_upper)",
physics_variables.beta_limit_upper,
"Normalised poloidal beta",
"(norm_beta_poloidal) ",
physics_variables.norm_beta_poloidal,
"OP ",
)

Expand Down
12 changes: 10 additions & 2 deletions source/fortran/physics_variables.f90
Original file line number Diff line number Diff line change
Expand Up @@ -80,12 +80,18 @@ module physics_variables
real(dp) :: beta_thermal_toroidal
!! poloidal thermal beta

real(dp) :: normalised_total_beta
real(dp) :: norm_beta_total
!! normaised total beta

real(dp) :: norm_beta_thermal
!! normaised thermal beta

real(dp) :: norm_beta_toroidal
!! normaised toroidal beta

real(dp) :: norm_beta_poloidal
!! normaised poloidal beta

real(dp) :: betbm0
!! leading coefficient for NB beta fraction

Expand Down Expand Up @@ -937,8 +943,10 @@ subroutine init_physics_variables
beta_thermal = 0.0D0
beta_thermal_poloidal = 0.0D0
beta_thermal_poloidal = 0.0D0
normalised_total_beta = 0.0D0
norm_beta_total = 0.0D0
norm_beta_thermal = 0.0D0
norm_beta_poloidal = 0.0D0
norm_beta_toroidal = 0.0D0
betbm0 = 1.5D0
bp = 0.0D0
bt = 5.68D0
Expand Down
6 changes: 3 additions & 3 deletions tests/integration/ref_dicts.json
Original file line number Diff line number Diff line change
Expand Up @@ -3407,7 +3407,7 @@
"nnetau": 0.0,
"no_roots": 30.0,
"nohc": 0.0,
"normalised_total_beta": 0.0,
"norm_beta_total": 0.0,
"nout": 11.0,
"noutvars": 84.0,
"np": 2.0,
Expand Down Expand Up @@ -10163,7 +10163,7 @@
"nnetau": "",
"no_roots": "",
"nohc": "number of PF coils (excluding the central solenoid) + 1",
"normalised_total_beta": "normaised total beta",
"norm_beta_total": "normaised total beta",
"nout": "Output file unit identifier",
"noutvars": "",
"np": "Array length",
Expand Down Expand Up @@ -19058,7 +19058,7 @@
"beta_limit_lower",
"beta_beam",
"beta_poloidal",
"normalised_total_beta",
"norm_beta_total",
"betbm0",
"bp",
"bt",
Expand Down
12 changes: 6 additions & 6 deletions tests/unit/test_physics.py
Original file line number Diff line number Diff line change
Expand Up @@ -569,7 +569,7 @@ def test_bootstrap_fraction_sakai(bootstrapfractionsakaiparam, monkeypatch, phys


class PlasmaCurrentParam(NamedTuple):
normalised_total_beta: Any = None
norm_beta_total: Any = None

beta: Any = None

Expand Down Expand Up @@ -626,7 +626,7 @@ class PlasmaCurrentParam(NamedTuple):
"plasmacurrentparam",
(
PlasmaCurrentParam(
normalised_total_beta=0,
norm_beta_total=0,
beta=0.030000000000000006,
i_plasma_current=4,
iprofile=1,
Expand Down Expand Up @@ -654,7 +654,7 @@ class PlasmaCurrentParam(NamedTuple):
expected_plasma_current=18398455.678867526,
),
PlasmaCurrentParam(
normalised_total_beta=2.4784688886891844,
norm_beta_total=2.4784688886891844,
beta=0.030000000000000006,
i_plasma_current=4,
iprofile=1,
Expand Down Expand Up @@ -698,8 +698,8 @@ def test_calculate_plasma_current(plasmacurrentparam, monkeypatch, physics):

monkeypatch.setattr(
physics_variables,
"normalised_total_beta",
plasmacurrentparam.normalised_total_beta,
"norm_beta_total",
plasmacurrentparam.norm_beta_total,
)

monkeypatch.setattr(physics_variables, "beta", plasmacurrentparam.beta)
Expand All @@ -725,7 +725,7 @@ def test_calculate_plasma_current(plasmacurrentparam, monkeypatch, physics):
triang95=plasmacurrentparam.triang95,
)

assert physics_variables.normalised_total_beta == pytest.approx(
assert physics_variables.norm_beta_total == pytest.approx(
plasmacurrentparam.expected_normalised_total_beta
)

Expand Down

0 comments on commit 7b8f4cf

Please sign in to comment.