drbx 2.0.0.dev0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- drbx/__init__.py +20 -0
- drbx/__main__.py +5 -0
- drbx/cli.py +586 -0
- drbx/config/__init__.py +20 -0
- drbx/config/boutinp.py +556 -0
- drbx/config/model.py +34 -0
- drbx/config/normalization.py +66 -0
- drbx/data/atomic_rates/__init__.py +1 -0
- drbx/data/atomic_rates/iz_AMJUEL_H.x_2.1.5.json +213 -0
- drbx/data/atomic_rates/iz_AMJUEL_H.x_2.3.9a.json +213 -0
- drbx/data/atomic_rates/rec_AMJUEL_H.x_2.1.8.json +213 -0
- drbx/data/atomic_rates/rec_AMJUEL_H.x_2.3.13a.json +213 -0
- drbx/geometry/__init__.py +207 -0
- drbx/geometry/embedding.py +56 -0
- drbx/geometry/essos_import.py +1385 -0
- drbx/geometry/fci_geometry.py +4622 -0
- drbx/geometry/fci_maps.py +85 -0
- drbx/geometry/island_divertor.py +291 -0
- drbx/geometry/metric_tensor.py +99 -0
- drbx/geometry/open_slab.py +150 -0
- drbx/geometry/rotating_ellipse.py +253 -0
- drbx/geometry/shifted_torus.py +225 -0
- drbx/geometry/stellarator.py +287 -0
- drbx/geometry/vmec_extender_import.py +499 -0
- drbx/geometry/vmec_jax_import.py +306 -0
- drbx/linear/__init__.py +37 -0
- drbx/linear/dispersion.py +138 -0
- drbx/linear/eigen.py +91 -0
- drbx/native/__init__.py +224 -0
- drbx/native/array_backend.py +64 -0
- drbx/native/deck_runner.py +779 -0
- drbx/native/electromagnetic.py +250 -0
- drbx/native/expression.py +173 -0
- drbx/native/fci.py +295 -0
- drbx/native/fci_2_field_rhs.py +182 -0
- drbx/native/fci_4_field_rhs.py +1267 -0
- drbx/native/fci_boundaries.py +2494 -0
- drbx/native/fci_differentiable_case.py +304 -0
- drbx/native/fci_drb_EB_rhs.py +1243 -0
- drbx/native/fci_drb_rhs.py +190 -0
- drbx/native/fci_halo.py +1575 -0
- drbx/native/fci_helpers.py +350 -0
- drbx/native/fci_model.py +294 -0
- drbx/native/fci_neutral.py +139 -0
- drbx/native/fci_operators.py +4081 -0
- drbx/native/fci_sharding.py +597 -0
- drbx/native/fci_sheath_recycling.py +206 -0
- drbx/native/fci_time_integrator.py +96 -0
- drbx/native/fci_vorticity.py +198 -0
- drbx/native/fluid_1d.py +330 -0
- drbx/native/hasegawa_wakatani.py +196 -0
- drbx/native/limiters.py +57 -0
- drbx/native/mesh.py +238 -0
- drbx/native/metrics.py +234 -0
- drbx/native/neutrals/__init__.py +58 -0
- drbx/native/neutrals/atomic_rates.py +134 -0
- drbx/native/neutrals/detachment_sol_model.py +221 -0
- drbx/native/neutrals/reactions.py +164 -0
- drbx/native/neutrals/recycling_sol_model.py +197 -0
- drbx/native/sol_flux_tube.py +133 -0
- drbx/native/stellarator_turbulence.py +343 -0
- drbx/native/transport.py +134 -0
- drbx/native/units.py +32 -0
- drbx/native/vorticity.py +252 -0
- drbx/runtime/__init__.py +53 -0
- drbx/runtime/artifacts.py +161 -0
- drbx/runtime/memory.py +144 -0
- drbx/runtime/output.py +374 -0
- drbx/runtime/paths.py +9 -0
- drbx/runtime/performance.py +161 -0
- drbx/runtime/run_config.py +184 -0
- drbx/runtime/scheduler.py +99 -0
- drbx/runtime/state.py +40 -0
- drbx/validation/__init__.py +424 -0
- drbx/validation/autodiff_diffusion.py +329 -0
- drbx/validation/autodiff_diffusion_uncertainty.py +235 -0
- drbx/validation/diverted_tokamak_movie.py +558 -0
- drbx/validation/essos_fieldline_import_campaign.py +181 -0
- drbx/validation/essos_imported_artifact_audit.py +535 -0
- drbx/validation/essos_imported_drb_movie_campaign.py +2826 -0
- drbx/validation/essos_imported_fci_campaign.py +5241 -0
- drbx/validation/essos_imported_pytree_campaign.py +406 -0
- drbx/validation/essos_vmec_closed_field_campaign.py +314 -0
- drbx/validation/essos_vmec_closed_field_transient_campaign.py +629 -0
- drbx/validation/essos_vmec_fieldline_surface_campaign.py +620 -0
- drbx/validation/fluid_1d_mms_convergence.py +250 -0
- drbx/validation/geometry_lineouts.py +136 -0
- drbx/validation/geometry_slices.py +178 -0
- drbx/validation/publication_plotting.py +91 -0
- drbx/validation/stellarator_drb_pytree_campaign.py +621 -0
- drbx/validation/stellarator_fci_geometry_campaign.py +200 -0
- drbx/validation/stellarator_fci_operator_campaign.py +304 -0
- drbx/validation/stellarator_fci_suite_campaign.py +264 -0
- drbx/validation/stellarator_metric_mms_campaign.py +289 -0
- drbx/validation/stellarator_neutral_physics_campaign.py +255 -0
- drbx/validation/stellarator_sheath_recycling_campaign.py +331 -0
- drbx/validation/stellarator_sol_showcase.py +628 -0
- drbx/validation/stellarator_vorticity_campaign.py +304 -0
- drbx/validation/vmec_extender_edge_field_campaign.py +260 -0
- drbx/validation/vmec_extender_sol_smoke_campaign.py +365 -0
- drbx-2.0.0.dev0.dist-info/METADATA +380 -0
- drbx-2.0.0.dev0.dist-info/RECORD +106 -0
- drbx-2.0.0.dev0.dist-info/WHEEL +5 -0
- drbx-2.0.0.dev0.dist-info/entry_points.txt +2 -0
- drbx-2.0.0.dev0.dist-info/licenses/LICENSE +21 -0
- drbx-2.0.0.dev0.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
from dataclasses import dataclass
|
|
4
|
+
|
|
5
|
+
import jax.numpy as jnp
|
|
6
|
+
|
|
7
|
+
from ..geometry import FciMaps, MetricTensor3D
|
|
8
|
+
from .fci import conservative_parallel_diffusion_fci, conservative_perp_diffusion_xz
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
@dataclass(frozen=True)
|
|
12
|
+
class FciNeutralReactionDiffusionResult:
|
|
13
|
+
neutral_density_source: jnp.ndarray
|
|
14
|
+
ion_density_source: jnp.ndarray
|
|
15
|
+
electron_density_source: jnp.ndarray
|
|
16
|
+
neutral_pressure_source: jnp.ndarray
|
|
17
|
+
ion_pressure_source: jnp.ndarray
|
|
18
|
+
electron_pressure_source: jnp.ndarray
|
|
19
|
+
neutral_momentum_source: jnp.ndarray
|
|
20
|
+
ion_momentum_source: jnp.ndarray
|
|
21
|
+
neutral_diffusion_source: jnp.ndarray
|
|
22
|
+
neutral_pressure_diffusion_source: jnp.ndarray
|
|
23
|
+
ionisation_rate: jnp.ndarray
|
|
24
|
+
recombination_rate: jnp.ndarray
|
|
25
|
+
charge_exchange_rate: jnp.ndarray
|
|
26
|
+
total_particle_residual: jnp.ndarray
|
|
27
|
+
total_momentum_residual: jnp.ndarray
|
|
28
|
+
total_charge_exchange_particle_residual: jnp.ndarray
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
def compute_fci_neutral_reaction_diffusion(
|
|
32
|
+
*,
|
|
33
|
+
neutral_density: jnp.ndarray,
|
|
34
|
+
neutral_pressure: jnp.ndarray,
|
|
35
|
+
neutral_momentum: jnp.ndarray,
|
|
36
|
+
ion_density: jnp.ndarray,
|
|
37
|
+
ion_pressure: jnp.ndarray,
|
|
38
|
+
ion_momentum: jnp.ndarray,
|
|
39
|
+
electron_density: jnp.ndarray,
|
|
40
|
+
electron_pressure: jnp.ndarray,
|
|
41
|
+
maps: FciMaps,
|
|
42
|
+
metric: MetricTensor3D,
|
|
43
|
+
neutral_parallel_diffusivity: float = 0.03,
|
|
44
|
+
neutral_perp_diffusivity: float = 4.0e-4,
|
|
45
|
+
ionisation_coefficient: float = 0.08,
|
|
46
|
+
recombination_coefficient: float = 0.015,
|
|
47
|
+
charge_exchange_coefficient: float = 0.04,
|
|
48
|
+
ionisation_energy: float = 0.035,
|
|
49
|
+
recombination_energy: float = 0.012,
|
|
50
|
+
neutral_mass: float = 1.0,
|
|
51
|
+
ion_mass: float = 1.0,
|
|
52
|
+
density_floor: float = 1.0e-12,
|
|
53
|
+
) -> FciNeutralReactionDiffusionResult:
|
|
54
|
+
"""Compute compact FCI neutral diffusion, ionisation, recombination, and CX gates."""
|
|
55
|
+
|
|
56
|
+
nn = jnp.maximum(jnp.asarray(neutral_density, dtype=jnp.float64), float(density_floor))
|
|
57
|
+
pn = jnp.maximum(jnp.asarray(neutral_pressure, dtype=jnp.float64), 0.0)
|
|
58
|
+
mn = jnp.asarray(neutral_momentum, dtype=jnp.float64)
|
|
59
|
+
ni = jnp.maximum(jnp.asarray(ion_density, dtype=jnp.float64), float(density_floor))
|
|
60
|
+
pi = jnp.maximum(jnp.asarray(ion_pressure, dtype=jnp.float64), 0.0)
|
|
61
|
+
mi = jnp.asarray(ion_momentum, dtype=jnp.float64)
|
|
62
|
+
ne = jnp.maximum(jnp.asarray(electron_density, dtype=jnp.float64), float(density_floor))
|
|
63
|
+
pe = jnp.maximum(jnp.asarray(electron_pressure, dtype=jnp.float64), 0.0)
|
|
64
|
+
tn = pn / nn
|
|
65
|
+
ti = pi / ni
|
|
66
|
+
te = pe / ne
|
|
67
|
+
un = mn / jnp.maximum(float(neutral_mass) * nn, float(density_floor))
|
|
68
|
+
ui = mi / jnp.maximum(float(ion_mass) * ni, float(density_floor))
|
|
69
|
+
|
|
70
|
+
neutral_diffusion_coefficient = neutral_parallel_diffusivity * jnp.sqrt(jnp.maximum(tn, 1.0e-12))
|
|
71
|
+
neutral_perp_coefficient = neutral_perp_diffusivity * jnp.sqrt(jnp.maximum(tn, 1.0e-12))
|
|
72
|
+
neutral_diffusion_source = conservative_parallel_diffusion_fci(
|
|
73
|
+
nn,
|
|
74
|
+
neutral_diffusion_coefficient,
|
|
75
|
+
maps,
|
|
76
|
+
jacobian=metric.J,
|
|
77
|
+
) + conservative_perp_diffusion_xz(nn, neutral_perp_coefficient, metric)
|
|
78
|
+
neutral_pressure_diffusion_source = conservative_parallel_diffusion_fci(
|
|
79
|
+
pn,
|
|
80
|
+
neutral_diffusion_coefficient,
|
|
81
|
+
maps,
|
|
82
|
+
jacobian=metric.J,
|
|
83
|
+
) + conservative_perp_diffusion_xz(pn, neutral_perp_coefficient, metric)
|
|
84
|
+
|
|
85
|
+
ionisation_rate = ionisation_coefficient * nn * ne * jnp.sqrt(jnp.maximum(te, 1.0e-12))
|
|
86
|
+
recombination_rate = recombination_coefficient * ni * ne / jnp.sqrt(jnp.maximum(te, 1.0e-12))
|
|
87
|
+
charge_exchange_rate = charge_exchange_coefficient * nn * ni * jnp.sqrt(jnp.maximum(tn + ti, 1.0e-12))
|
|
88
|
+
|
|
89
|
+
neutral_density_source = neutral_diffusion_source - ionisation_rate + recombination_rate
|
|
90
|
+
ion_density_source = ionisation_rate - recombination_rate
|
|
91
|
+
electron_density_source = ionisation_rate - recombination_rate
|
|
92
|
+
|
|
93
|
+
ionisation_neutral_energy = 1.5 * ionisation_rate * tn
|
|
94
|
+
recombination_ion_energy = 1.5 * recombination_rate * ti
|
|
95
|
+
cx_neutral_energy = 1.5 * charge_exchange_rate * tn
|
|
96
|
+
cx_ion_energy = 1.5 * charge_exchange_rate * ti
|
|
97
|
+
relative_velocity = ui - un
|
|
98
|
+
cx_kinetic = 0.5 * charge_exchange_rate * jnp.square(relative_velocity)
|
|
99
|
+
|
|
100
|
+
neutral_pressure_source = (
|
|
101
|
+
neutral_pressure_diffusion_source
|
|
102
|
+
- ionisation_neutral_energy
|
|
103
|
+
+ recombination_ion_energy
|
|
104
|
+
- cx_neutral_energy
|
|
105
|
+
+ cx_ion_energy
|
|
106
|
+
+ cx_kinetic
|
|
107
|
+
)
|
|
108
|
+
ion_pressure_source = ionisation_neutral_energy - recombination_ion_energy + cx_neutral_energy - cx_ion_energy + cx_kinetic
|
|
109
|
+
electron_pressure_source = -ionisation_energy * ionisation_rate - recombination_energy * recombination_rate
|
|
110
|
+
|
|
111
|
+
ionisation_momentum = ionisation_rate * float(neutral_mass) * un
|
|
112
|
+
recombination_momentum = recombination_rate * float(ion_mass) * ui
|
|
113
|
+
cx_neutral_momentum = charge_exchange_rate * float(neutral_mass) * un
|
|
114
|
+
cx_ion_momentum = charge_exchange_rate * float(ion_mass) * ui
|
|
115
|
+
neutral_momentum_source = -ionisation_momentum + recombination_momentum - cx_neutral_momentum + cx_ion_momentum
|
|
116
|
+
ion_momentum_source = ionisation_momentum - recombination_momentum + cx_neutral_momentum - cx_ion_momentum
|
|
117
|
+
|
|
118
|
+
total_particle_residual = jnp.sum((neutral_density_source - neutral_diffusion_source) + ion_density_source)
|
|
119
|
+
total_momentum_residual = jnp.sum(neutral_momentum_source + ion_momentum_source)
|
|
120
|
+
total_charge_exchange_particle_residual = jnp.sum(charge_exchange_rate - charge_exchange_rate)
|
|
121
|
+
|
|
122
|
+
return FciNeutralReactionDiffusionResult(
|
|
123
|
+
neutral_density_source=neutral_density_source,
|
|
124
|
+
ion_density_source=ion_density_source,
|
|
125
|
+
electron_density_source=electron_density_source,
|
|
126
|
+
neutral_pressure_source=neutral_pressure_source,
|
|
127
|
+
ion_pressure_source=ion_pressure_source,
|
|
128
|
+
electron_pressure_source=electron_pressure_source,
|
|
129
|
+
neutral_momentum_source=neutral_momentum_source,
|
|
130
|
+
ion_momentum_source=ion_momentum_source,
|
|
131
|
+
neutral_diffusion_source=neutral_diffusion_source,
|
|
132
|
+
neutral_pressure_diffusion_source=neutral_pressure_diffusion_source,
|
|
133
|
+
ionisation_rate=ionisation_rate,
|
|
134
|
+
recombination_rate=recombination_rate,
|
|
135
|
+
charge_exchange_rate=charge_exchange_rate,
|
|
136
|
+
total_particle_residual=total_particle_residual,
|
|
137
|
+
total_momentum_residual=total_momentum_residual,
|
|
138
|
+
total_charge_exchange_particle_residual=total_charge_exchange_particle_residual,
|
|
139
|
+
)
|