Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions docs/src/analysis.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
- `PerturbedEquilibrium`: the plasma response, the resonant fields, island widths and Chirikov parameter against ψ_N or q
- `PerturbedEquilibriumModes`: helpers that convert the modal output to (ψ, θ) and (ψ, θ, φ) grids for real-space plots
- `ErrorFields`: coil sensitivities, tolerance distributions, locking risk and correction limits (see [Error Fields](error_fields.md))
- `EnergyDecomposition`: the plasma energy of free-boundary eigenmodes split into effective-field and standard-form terms on the (ψ, θ) grid

`examples/DIIID-like_ideal_example/analyze_example.jl`, `examples/Solovev_ideal_example/analyze_example.jl` and `examples/DIIID-like_error_field_example/analyze_example.jl` are worked examples of each; the s–α maps of local stability use `salpha_reference`, `compute_ballooning_stability!` and `scan_delta_prime_map`.
Figure conventions for spectrum plots are in `docs/development/plotting.md` of the repository, and `write_imas` on the [Utilities](utilities.md) page exports results to an IMAS data dictionary.
Expand Down Expand Up @@ -60,3 +61,30 @@ Modules = [GeneralizedPerturbedEquilibrium.Analysis.PerturbedEquilibriumModes]
```@autodocs
Modules = [GeneralizedPerturbedEquilibrium.Analysis.ErrorFields]
```

## EnergyDecomposition

A scripted diagnostic, the Julia counterpart of the Fortran `gpout_recon` with `effective_field_flag` and `standard_form_flag`. It needs `integrator = "forward"`, `vac_flag = true`, one toroidal mode number and an ideal solve.

```julia
using GeneralizedPerturbedEquilibrium
const ED = GeneralizedPerturbedEquilibrium.Analysis.EnergyDecomposition
ffs = GeneralizedPerturbedEquilibrium.main(["examples/Solovev_ideal_example"]).ffs
ed = ED.decompose_plasma_energy(ffs; eigenmodes=[1, 2])
ED.plot_energy_decomposition(ed; eigenmode=1, save_path="energy_decomposition.png")
```

The ψ integrals run over every saved ODE step as well as the equilibrium knots, since the knots alone miss the structure of ξ at the rational surfaces. The effective-field total can differ from the standard-form one by a grid-independent amount whose cause is still open (−0.4 % on the DIII-D-like example).

Relative error against `ffs.free_boundary.ep` on the Solovev test fixture (PEST, `mpert = 8`):

| `mpsi` | mode 1 effective / standard | mode 2 effective / standard |
|---|---|---|
| 16 | −4.44e-3 / −4.50e-3 | −3.19e-2 / −3.23e-2 |
| 32 | −2.17e-6 / −8.19e-6 | −3.35e-5 / −6.86e-5 |
| 64 | −1.07e-6 / −1.37e-6 | −9.14e-6 / −1.11e-5 |
| 128 | −2.01e-6 / −1.98e-6 | −1.72e-5 / −1.72e-5 |

```@autodocs
Modules = [GeneralizedPerturbedEquilibrium.Analysis.EnergyDecomposition]
```
2 changes: 2 additions & 0 deletions src/Analysis/Analysis.jl
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ lists the plots for a result, a path, or the named tuple `main` returns.
- `PerturbedEquilibrium`: Plotting functions for perturbed equilibrium and singular coupling results
- `PerturbedEquilibriumModes`: Data helpers to convert modal GPEC output to (ψ, θ) and (ψ, θ, φ) grids
- `ErrorFields`: Plotting functions for the error-field assessment (coil sensitivities, tolerance Monte Carlo, locking risk, phasing maps)
- `EnergyDecomposition`: Decomposition of the plasma energy of free-boundary eigenmodes on the (ψ, θ) grid
"""
module Analysis

Expand All @@ -25,6 +26,7 @@ include("CoilForcing.jl")
include("PerturbedEquilibrium.jl")
include("PerturbedEquilibriumModes.jl")
include("ErrorFields.jl")
include("EnergyDecomposition.jl")

export available_plots

Expand Down
Loading
Loading