Skip to content
Open
4 changes: 2 additions & 2 deletions documentation/source/development/add-vars.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ Here is a code snippet showing how `rmajor` is defined in `iteration_variables.p
```python
ITERATION_VARIABLES = {
...
3: IterationVariable("rmajor", fortran.physics_variables, 0.1, 50.00),
3: IterationVariable("rmajor", "physics", 0.1, 50.00),
```

-----------------
Expand All @@ -97,7 +97,7 @@ objective_function():
match figure_of_merit:
...
case 1:
objective_metric = 0.2 * physics_variables.rmajor
objective_metric = 0.2 * data.physics.rmajor
```

-----------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ $$
\mathtt{ecgam} = 0.25(\mathtt{ecgam1} + \mathtt{ecgam2} +\mathtt{ecgam3} + \mathtt{ecgam4})
$$

7. Calculate the current drive efficiency by dividing `ecgam` by `(dlocal * physics_variables.rmajor)`.
7. Calculate the current drive efficiency by dividing `ecgam` by `(dlocal * data.physics.rmajor)`.

$$
\text{Current drive efficiency [A/W]} = \frac{\mathtt{ecgam}}{\mathtt{dlocal} \times R_0}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ AEA FUS 172: Physics Assessment for the European Reactor Study[^1]
6. Calculate the parallel refractive index, `nplacc`, which is needed for plasma access. It uses the local density `dlocal` and the local magnetic field `blocal` to calculate a fraction `frac`. `nplacc` is then obtained by adding `frac` to the square root of `1.0 + frac * frac`.
7. Calculate the local inverse aspect ratio, `epslh`, by dividing `rpenet` by `rmajor`.
8. Calculate the LH normalised efficiency, `x`, using the formula `24.0 / (nplacc * sqrt(tlocal))`.
9. Calculate several intermediate terms, `term01`, `term02`, `term03`, and `term04`, using different formulas involving `nplacc`, `physics_variables.zeff`, `tlocal`, `epslh`, and `x`.
9. Calculate several intermediate terms, `term01`, `term02`, `term03`, and `term04`, using different formulas involving `nplacc`, `zeff`, `tlocal`, `epslh`, and `x`.
10. Calculate the current drive efficiency, `gamlh`, using the formula `term01 * term02 * (1.0e0 - term03 / term04)`.
11. Return the current drive efficiency normalised by the product of `0.1e0 * dlocal` and `physics_variables.rmajor`.
11. Return the current drive efficiency normalised by the product of `0.1e0 * dlocal` and `rmajor`.

[^1]: T. C. Hender, M. K. Bevir, M. Cox, R. J. Hastie, P. J. Knight, C. N. Lashmore-Davies, B. Lloyd, G. P. Maddison, A. W. Morris, M. R. O'Brien, M.F. Turner abd H. R. Wilson, *"Physics Assessment for the European Reactor Study"*, AEA Fusion Report AEA FUS 172 (1992)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -177,20 +177,20 @@ It updates the instance attributes for the cumulative power densities and reacti

### Set global physics variables | `set_physics_variables()`

This method sets the required physics variables in the `physics_variables` and `physics_module` modules. It updates the global physics variables and module variables with the current instance's fusion power densities and reaction rates.
This method sets the required physics variables on the `physics` data structure with the current instance's fusion power densities and reaction rates.

#### Updates:
- `physics_variables.pden_plasma_alpha_mw`: Updated with `self.alpha_power_density`
- `physics_variables.pden_non_alpha_charged_mw`: Updated with `self.pden_non_alpha_charged_mw`
- `physics_variables.pden_plasma_neutron_mw`: Updated with `self.neutron_power_density`
- `physics_variables.fusden_plasma`: Updated with `self.fusion_rate_density`
- `physics_variables.fusden_plasma_alpha`: Updated with `self.alpha_rate_density`
- `physics_variables.proton_rate_density`: Updated with `self.proton_rate_density`
- `physics_module.sigmav_dt_average`: Updated with `self.sigmav_dt_average`
- `physics_module.dt_power_density_plasma`: Updated with `self.dt_power_density`
- `physics_module.dhe3_power_density`: Updated with `self.dhe3_power_density`
- `physics_module.dd_power_density`: Updated with `self.dd_power_density`
- `physics_functions.f_dd_branching_trit`: Updated with `self.f_dd_branching_trit`
- `pden_plasma_alpha_mw`: Updated with `self.alpha_power_density`
- `pden_non_alpha_charged_mw`: Updated with `self.pden_non_alpha_charged_mw`
- `pden_plasma_neutron_mw`: Updated with `self.neutron_power_density`
- `fusden_plasma`: Updated with `self.fusion_rate_density`
- `fusden_plasma_alpha`: Updated with `self.alpha_rate_density`
- `proton_rate_density`: Updated with `self.proton_rate_density`
- `sigmav_dt_average`: Updated with `self.sigmav_dt_average`
- `dt_power_density_plasma`: Updated with `self.dt_power_density`
- `dhe3_power_density`: Updated with `self.dhe3_power_density`
- `dd_power_density`: Updated with `self.dd_power_density`
- `f_dd_branching_trit`: Updated with `self.f_dd_branching_trit`

-----------------------

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,7 @@ Found as a reasonable fit to the computed no wall limit at $f_{\text{BS}} \appro

---------

#### Tholerus Relation | `calculate_beta_norm_max_thloreus()`
#### Tholerus Relation | `calculate_beta_norm_max_tholerus()`

This can be activated by stating `i_beta_norm_max = 4` in the input file.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ The density profile class is organised around a central runner function that is

2. The steps between the normalised points is then done by [`calculate_profile_dx()`](./plasma_profiles_abstract_class.md#calculate-the-profile-steps-in-x--calculate_profile_dx) which divides the max x-dimension by the number of points.

3. The core electron and ion temperatures are claculated via [`set_physics_variables()`]()
3. The core electron and ion temperatures are calculated via [`set_physics_variables()`]()

### Calculate core values | `set_physics_variables()`

Expand Down
20 changes: 7 additions & 13 deletions examples/single_model_evaluation.ex.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,15 @@
import matplotlib.pyplot as plt
import numpy as np

from process import data_structure
from process.data_structure.physics_variables import PhysicsData
from process.main import SingleRun

# %% [markdown]
# ## Set up
# First, inspect a variable to check its uninitialised value:

# %%
print(
f"p_plasma_separatrix_mw = {data_structure.physics_variables.p_plasma_separatrix_mw}"
)
print(f"p_plasma_separatrix_mw = {PhysicsData.p_plasma_separatrix_mw}")

# %% [markdown]
# In order to initialise all variables in Process with their values at a given point (design parameter vector), run an evaluation input file (one with no optimisation) to initialise values in all models. The "large tokamak" regression test solution is used here.
Expand All @@ -53,9 +51,9 @@ def print_values():
print(
f"W frac = {single_run.data.impurity_radiation.f_nd_impurity_electron_array[13]:.3e}"
)
print(f"p_plasma_rad_mw = {data_structure.physics_variables.p_plasma_rad_mw:.3e}")
print(f"p_plasma_rad_mw = {single_run.data.physics.p_plasma_rad_mw:.3e}")
print(
f"p_plasma_separatrix_mw = {data_structure.physics_variables.p_plasma_separatrix_mw:.3e}"
f"p_plasma_separatrix_mw = {single_run.data.physics.p_plasma_separatrix_mw:.3e}"
)


Expand Down Expand Up @@ -99,13 +97,9 @@ def run_impurities(w_imp_fracs):
).normalised_residual

# Need to copy values
p_plasma_rad_mw[i] = data_structure.physics_variables.p_plasma_rad_mw.item()
p_plasma_separatrix_mw[i] = (
data_structure.physics_variables.p_plasma_separatrix_mw.item()
)
p_l_h_threshold_mw[i] = (
data_structure.physics_variables.p_l_h_threshold_mw.item()
)
p_plasma_rad_mw[i] = single_run.data.physics.p_plasma_rad_mw.item()
p_plasma_separatrix_mw[i] = single_run.data.physics.p_plasma_separatrix_mw.item()
p_l_h_threshold_mw[i] = single_run.data.physics.p_l_h_threshold_mw.item()
# Need to flip sign of constraint so negative means violated
con15[i] = -con15_value

Expand Down
2 changes: 1 addition & 1 deletion process/core/caller.py
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,7 @@ def _call_models_once(self, xc: np.ndarray, data: DataStructure):

# Tight aspect ratio machine model
if (
data_structure.physics_variables.itart == 1
data.physics.itart == 1
and data_structure.tfcoil_variables.i_tf_sup
!= TFConductorModel.SUPERCONDUCTING
):
Expand Down
Loading
Loading