Skip to content

Commit ec914ed

Browse files
hamelphiTorax team
authored andcommitted
Implement Waltz rotation rule.
PiperOrigin-RevId: 866495099
1 parent 0ec1611 commit ec914ed

9 files changed

Lines changed: 406 additions & 24 deletions

docs/configuration.rst

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1365,6 +1365,24 @@ It is recommended to not set ``qlknn_model_name``, or
13651365

13661366
* ``full_radius``: The rotation correction is applied everywhere.
13671367

1368+
``shear_suppression_model`` (str [default = 'waltz_rule'])
1369+
Selects the shear suppression model used for rotation effects on transport.
1370+
Options are:
1371+
1372+
* ``waltz_rule``: Simple model from Waltz et al., PoP 1998
1373+
(https://doi.org/10.1063/1.872847): :math:`f_{rot} = -\alpha`.
1374+
1375+
* ``vandeplassche2020``: Fitted rotation rule from Van de Plassche et al.,
1376+
PoP 2020 (https://doi.org/10.1063/1.5134126).
1377+
1378+
``shear_suppression_alpha`` (float [default = 1.0])
1379+
Alpha parameter for the Waltz rule shear suppression model. Only used when
1380+
``shear_suppression_model`` is ``'waltz_rule'``.
1381+
1382+
``output_mode_contributions`` (bool [default = False])
1383+
If ``True``, output individual ITG/TEM/ETG contributions to transport
1384+
coefficients in addition to the total values.
1385+
13681386
tglfnn-ukaea
13691387
^^^^^^^^^^^^
13701388

docs/physics_models.rst

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -395,11 +395,26 @@ be enabled through the transport model configuration.
395395
.. math::
396396
f_{rot} = 1 + f_{rule} \frac{\gamma_{E \times B}}{\gamma_{max}}
397397
398-
Here, :math:`f_{rule}` is a factor derived from experimental observations,
399-
depending on the safety factor, magnetic shear, and inverse aspect ratio.
400-
This rule effectively suppresses turbulent transport when :math:`E \times B`
401-
shear is strong. The application of this rule is controlled by the
402-
`rotation_mode` configuration parameter. Options for `rotation_mode` are:
398+
The factor :math:`f_{rule}` determines the strength of shear suppression
399+
and can be computed using one of two models, controlled by the
400+
``shear_suppression_model`` configuration parameter:
401+
402+
* ``waltz_rule``: Simple model from Waltz et al., PoP 1998:
403+
:math:`f_{rule} = -\alpha`, where :math:`\alpha` is set by the
404+
``shear_suppression_alpha`` parameter (default 1.0). This model provides
405+
pure suppression of turbulent transport.
406+
407+
* ``vandeplassche2020``: Fitted rotation rule from Van de Plassche et al.,
408+
PoP 2020. This model calculates :math:`f_{rule}` based on the safety
409+
factor, magnetic shear, and inverse aspect ratio. Note that this model
410+
can produce both suppression and enhancement of transport depending on
411+
local plasma parameters. This is because it was fitted for purely
412+
toroidal rotation, which has both stabilizing (ExB shear) and
413+
destabilizing (parallel velocity shear) effects, with a geometry
414+
dependence setting the relative impact.
415+
416+
The application of the rotation rule is controlled by the
417+
``rotation_mode`` configuration parameter. Options for ``rotation_mode`` are:
403418

404419
* ``off``: No rotation correction is applied.
405420

@@ -413,9 +428,9 @@ be enabled through the transport model configuration.
413428
Two parameters are available to fine-tune the impact of rotation, both of them
414429
default to 1.0:
415430

416-
* `rotation_multiplier`: Located in the transport model configs, this
431+
* ``rotation_multiplier``: Located in the transport model configs, this
417432
parameter scales the :math:`E \times B` shear term.
418-
* `poloidal_velocity_multiplier`: Found under the `neoclassical`
433+
* ``poloidal_velocity_multiplier``: Found under the ``neoclassical``
419434
configuration, this parameter directly scales the poloidal velocity term.
420435

421436
Edge models

torax/_src/transport_model/pydantic_model.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,13 @@ class QLKNNTransportModel(pydantic_model_base.TransportBase):
108108
D.
109109
rotation_multiplier: Multiplier for rotation.
110110
rotation_mode: Mode for rotation, either HALF_RADIUS, FULL_RADIUS or OFF.
111+
shear_suppression_model: Shear suppression model for rotation effects.
112+
Either WALTZ_RULE [Waltz et al., PoP
113+
1998](https://doi.org/10.1063/1.872847) or VANDEPLASSCHE2020 [Van de
114+
Plassche et al. PoP 2020](https://doi.org/10.1063/1.5134126).
115+
shear_suppression_alpha: Alpha parameter for Waltz rule. Larger values
116+
increase the suppression effect. Only used when shear_suppression_model =
117+
WALTZ_RULE.
111118
"""
112119

113120
model_name: Annotated[Literal['qlknn'], torax_pydantic.JAX_STATIC] = 'qlknn'
@@ -130,6 +137,10 @@ class QLKNNTransportModel(pydantic_model_base.TransportBase):
130137
rotation_mode: Annotated[
131138
qualikiz_based_transport_model.RotationMode, torax_pydantic.JAX_STATIC
132139
] = qualikiz_based_transport_model.RotationMode.OFF
140+
shear_suppression_model: Annotated[
141+
qlknn_transport_model.ShearSuppressionModel, torax_pydantic.JAX_STATIC
142+
] = qlknn_transport_model.ShearSuppressionModel.WALTZ_RULE
143+
shear_suppression_alpha: pydantic.NonNegativeFloat = 1.0
133144
output_mode_contributions: Annotated[bool, torax_pydantic.JAX_STATIC] = False
134145

135146
@pydantic.model_validator(mode='before')
@@ -184,6 +195,8 @@ def build_runtime_params(
184195
An_min=self.An_min,
185196
rotation_multiplier=self.rotation_multiplier,
186197
rotation_mode=self.rotation_mode,
198+
shear_suppression_model=self.shear_suppression_model,
199+
shear_suppression_alpha=self.shear_suppression_alpha,
187200
output_mode_contributions=self.output_mode_contributions,
188201
**base_kwargs,
189202
)

torax/_src/transport_model/qlknn_transport_model.py

Lines changed: 54 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414

1515
"""A transport model that uses a QLKNN model."""
1616
import dataclasses
17+
import enum
1718
import functools
1819
import logging
1920
import os
@@ -37,16 +38,37 @@
3738

3839

3940
# pylint: disable=invalid-name
41+
class ShearSuppressionModel(enum.StrEnum):
42+
"""Shear suppression model for rotation effects on transport.
43+
44+
WALTZ_RULE: Simple model from Waltz et al., PoP 1998
45+
(https://doi.org/10.1063/1.872847): f_rot_rule = -alpha.
46+
VANDEPLASSCHE2020: Fitted rotation rule from Van de Plassche et al., PoP 2020
47+
(https://doi.org/10.1063/1.5134126). It was fitted for purely toroidal
48+
transport, so has both stabilizing (ExB shear) and destabilizing (parallel
49+
velocity shear) effects, with a geometry dependence setting the relative
50+
impact.
51+
"""
52+
53+
WALTZ_RULE = 'waltz_rule'
54+
VANDEPLASSCHE2020 = 'vandeplassche2020'
55+
56+
4057
@jax.tree_util.register_dataclass
4158
@dataclasses.dataclass(frozen=True)
4259
class RuntimeParams(qualikiz_based_transport_model.RuntimeParams):
60+
"""Runtime parameters for QLKNN transport model."""
4361
include_ITG: bool
4462
include_TEM: bool
4563
include_ETG: bool
4664
ITG_flux_ratio_correction: float
4765
ETG_correction_factor: float
4866
clip_inputs: bool
4967
clip_margin: float
68+
shear_suppression_model: ShearSuppressionModel = dataclasses.field(
69+
metadata={'static': True}
70+
)
71+
shear_suppression_alpha: float
5072
output_mode_contributions: bool = dataclasses.field(metadata={'static': True})
5173

5274

@@ -174,27 +196,27 @@ def clip_inputs(
174196
return feature_scan
175197

176198

177-
def _calculate_rotation_rule_factor(
178-
qualikiz_inputs: qualikiz_based_transport_model.QualikizInputs,
179-
) -> jax.Array:
180-
"""Calculate the rotation scaling factor."""
181-
# TODO(b/456456279): The rotation rule has been calibrated for QLKNN10D.
182-
# We should validate if this formula makes sense for QLKNN_7_11.
183-
return (
184-
_C1 * qualikiz_inputs.q
185-
+ _C2 * qualikiz_inputs.smag
186-
+ _C3 / (_EPSILON_NN * qualikiz_inputs.x)
187-
- _C4
188-
)
189-
190-
191199
def _maybe_apply_rotation_rule(
192200
model_output: base_qlknn_model.ModelOutput,
193201
qualikiz_inputs: qualikiz_based_transport_model.QualikizInputs,
194202
rotation_mode: qualikiz_based_transport_model.RotationMode,
203+
shear_suppression_model: ShearSuppressionModel,
204+
shear_suppression_alpha: float,
195205
geo: geometry.Geometry,
196206
) -> base_qlknn_model.ModelOutput:
197-
"""Apply the rotation scaling factor to the model output (Victor rule)."""
207+
"""Apply the rotation scaling factor to the model output.
208+
209+
Args:
210+
model_output: The raw model output from QLKNN.
211+
qualikiz_inputs: Prepared inputs for the quasilinear model.
212+
rotation_mode: Controls where the rotation rule is applied.
213+
shear_suppression_model: Which shear suppression model to use.
214+
shear_suppression_alpha: Alpha parameter for Waltz rule.
215+
geo: Geometry of the torus.
216+
217+
Returns:
218+
Model output with rotation scaling applied to ITG and TEM modes.
219+
"""
198220
if rotation_mode == qualikiz_based_transport_model.RotationMode.OFF:
199221
# Rotation is disabled. Do not apply the rotation rule.
200222
return model_output
@@ -212,7 +234,21 @@ def _maybe_apply_rotation_rule(
212234
)
213235
gamma_E_GB = gamma_E_GB * scaling
214236

215-
f_rot_rule = _calculate_rotation_rule_factor(qualikiz_inputs)
237+
if shear_suppression_model == ShearSuppressionModel.WALTZ_RULE:
238+
c1, c2, c3, c4 = 0.0, 0.0, 0.0, shear_suppression_alpha
239+
elif shear_suppression_model == ShearSuppressionModel.VANDEPLASSCHE2020:
240+
c1, c2, c3, c4 = _C1, _C2, _C3, _C4
241+
else:
242+
raise ValueError(
243+
f'Unknown shear suppression model: {shear_suppression_model}'
244+
)
245+
246+
f_rot_rule = (
247+
c1 * qualikiz_inputs.q
248+
+ c2 * qualikiz_inputs.smag
249+
+ c3 / (_EPSILON_NN * qualikiz_inputs.x)
250+
- c4
251+
)
216252

217253
lower_bound = 1e-4
218254
gamma_max = jnp.maximum(model_output['gamma_max'].squeeze(), lower_bound)
@@ -347,6 +383,8 @@ def _combined(
347383
model_output,
348384
qualikiz_inputs,
349385
runtime_config_inputs.transport.rotation_mode,
386+
runtime_config_inputs.transport.shear_suppression_model,
387+
runtime_config_inputs.transport.shear_suppression_alpha,
350388
geo,
351389
)
352390

0 commit comments

Comments
 (0)