|
| 1 | +# Copyright 2024 DeepMind Technologies Limited |
| 2 | +# |
| 3 | +# Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | +# you may not use this file except in compliance with the License. |
| 5 | +# You may obtain a copy of the License at |
| 6 | +# |
| 7 | +# http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | +# |
| 9 | +# Unless required by applicable law or agreed to in writing, software |
| 10 | +# distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | +# See the License for the specific language governing permissions and |
| 13 | +# limitations under the License. |
| 14 | + |
| 15 | +"""Fast ion physics classes.""" |
| 16 | + |
| 17 | +import dataclasses |
| 18 | + |
| 19 | +import jax |
| 20 | +from jax import numpy as jnp |
| 21 | +from torax._src import constants |
| 22 | +from torax._src import math_utils |
| 23 | +from torax._src.fvm import cell_variable |
| 24 | + |
| 25 | + |
| 26 | +# pylint: disable=invalid-name |
| 27 | +@jax.tree_util.register_dataclass |
| 28 | +@dataclasses.dataclass(frozen=True) |
| 29 | +class FastIon: |
| 30 | + """State of a fast ion species. |
| 31 | +
|
| 32 | + Attributes: |
| 33 | + species: Species name (e.g. 'He3'). |
| 34 | + source: Source name (e.g. 'ICRH'). |
| 35 | + n: Density [m^-3]. |
| 36 | + T: Temperature [keV]. |
| 37 | + """ |
| 38 | + |
| 39 | + species: str = dataclasses.field(metadata={'static': True}) |
| 40 | + source: str = dataclasses.field(metadata={'static': True}) |
| 41 | + n: cell_variable.CellVariable |
| 42 | + T: cell_variable.CellVariable |
| 43 | + |
| 44 | + |
| 45 | +def bimaxwellian_split( |
| 46 | + power_deposition: jax.Array, |
| 47 | + T_e: jax.Array, |
| 48 | + n_e: jax.Array, |
| 49 | + T_i: jax.Array, |
| 50 | + minority_concentration: jax.Array | float, |
| 51 | + P_total_W: float, |
| 52 | + charge_number: int, |
| 53 | + mass_number: float, |
| 54 | +) -> tuple[jax.Array, jax.Array]: |
| 55 | + """Returns (n_tail, T_tail) using the Power Balance Closure. |
| 56 | +
|
| 57 | + Splits a minority species density into a bulk thermal component and a |
| 58 | + high-energy tail component based on Stix theory power balance. |
| 59 | +
|
| 60 | + Args: |
| 61 | + power_deposition: Power deposition profile [MW/m^3 / MW_in]. Normalized per |
| 62 | + MW of input power. |
| 63 | + T_e: Electron temperature profile [keV]. |
| 64 | + n_e: Electron density profile [m^-3]. |
| 65 | + T_i: Ion temperature profile [keV]. |
| 66 | + minority_concentration: Minority species fractional concentration |
| 67 | + (n_minority/n_e). |
| 68 | + P_total_W: Total absolute power absorbed [W]. |
| 69 | + charge_number: Charge number of the minority species (e.g. 2 for He3). |
| 70 | + mass_number: Mass number of the minority species (e.g. 3.016 for He3). |
| 71 | +
|
| 72 | + Returns: |
| 73 | + Tuple containing: |
| 74 | + n_tail: Density of the fast tail component [m^-3]. |
| 75 | + T_tail: Temperature of the fast tail component [keV]. |
| 76 | + """ |
| 77 | + keV_to_J = constants.CONSTANTS.keV_to_J |
| 78 | + |
| 79 | + n_total = n_e * minority_concentration |
| 80 | + |
| 81 | + # Calculate T_tail (The high-energy slope from Stix) |
| 82 | + # power_deposition is normalized (per MW input). |
| 83 | + # Calculate absolute power density in MW/m^3. |
| 84 | + # P_total_W is in Watts, convert to MW: P_total_W / 1e6 |
| 85 | + # Result p_dens_mw is in MW/m^3. |
| 86 | + p_dens_mw = power_deposition * (P_total_W / 1.0e6) |
| 87 | + |
| 88 | + n_e20 = n_e / 1.0e20 |
| 89 | + |
| 90 | + # Stix parameter xi [Stix, Nucl. Fusion 15, 737 (1975)]. |
| 91 | + # xi = (0.24 * sqrt(T_e) * A_f * p_dens) / (n_e20^2 * Z_f^2 * c_fast) |
| 92 | + xi = (0.24 * jnp.sqrt(T_e) * mass_number * p_dens_mw) / ( |
| 93 | + n_e20**2 * charge_number**2 * minority_concentration |
| 94 | + ) |
| 95 | + |
| 96 | + T_tail = T_e * (1.0 + xi) |
| 97 | + T_bulk = T_i |
| 98 | + |
| 99 | + # Spitzer slowing-down time on electrons: |
| 100 | + # tau_s = 6.27e8 * A_f * T_e[eV]^1.5 / (Z_f^2 * n_e[cm^-3] * ln_lambda) |
| 101 | + # Converting to T_e[keV] and n_e20 [1e20 m^-3] with ln_lambda ~ 15: |
| 102 | + # 6.27e8 * 1000^1.5 / 1e14 / 15 ~ 0.013. |
| 103 | + tau_s = (0.013 * mass_number * T_e**1.5) / (charge_number**2 * n_e20) |
| 104 | + |
| 105 | + # Solve for n_tail using Power Balance: |
| 106 | + # P_abs (W/m^3) = 1.5 * n_tail * (T_tail - T_bulk) * e / tau_s |
| 107 | + p_abs_w = p_dens_mw * 1.0e6 # MW/m^3 -> W/m^3 |
| 108 | + |
| 109 | + dT_joules = (T_tail - T_bulk) * keV_to_J |
| 110 | + |
| 111 | + n_tail = math_utils.safe_divide(p_abs_w * tau_s, 1.5 * dT_joules) |
| 112 | + |
| 113 | + # Constraints and Particle Conservation |
| 114 | + # Tail density cannot exceed 99% of total He3 |
| 115 | + n_tail = jnp.clip(n_tail, 0.0, n_total * 0.99) |
| 116 | + |
| 117 | + return n_tail, T_tail |
0 commit comments