Skip to content
Draft
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
6 changes: 0 additions & 6 deletions benchmarks/benchmark_against_fortran_run.jl
Original file line number Diff line number Diff line change
Expand Up @@ -406,9 +406,6 @@ function write_gpec_toml_coil(
println(io, "mtheta = $(p.mtheta_equil)")
println(io, "etol = 1e-7")
println(io)
println(io, "[Wall]")
println(io, "shape = \"nowall\"")
println(io)
println(io, "[ForceFreeStates]")
println(io, "local_stability_flag = true")
println(io, "vac_flag = true")
Expand Down Expand Up @@ -469,9 +466,6 @@ function write_gpec_toml_file(
println(io, "mtheta = $(p.mtheta_equil)")
println(io, "etol = 1e-7")
println(io)
println(io, "[Wall]")
println(io, "shape = \"nowall\"")
println(io)
println(io, "[ForceFreeStates]")
println(io, "local_stability_flag = true")
println(io, "vac_flag = true")
Expand Down
3 changes: 1 addition & 2 deletions benchmarks/benchmark_delta_prime_methods.jl
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,7 @@ function setup_and_run_solovev()
(Symbol(k) => v for (k, v) in inputs["ForceFreeStates"])...)
eq_config = GeneralizedPerturbedEquilibrium.Equilibrium.EquilibriumConfig(inputs["Equilibrium"], ex)
equil = GeneralizedPerturbedEquilibrium.Equilibrium.setup_equilibrium(eq_config)
intr.wall_settings = GeneralizedPerturbedEquilibrium.Vacuum.WallShapeSettings(;
(Symbol(k) => v for (k, v) in inputs["Wall"])...)
intr.wall_settings = GeneralizedPerturbedEquilibrium.Vacuum.parse_wall(get(inputs, "Wall", nothing))
FFS.sing_lim!(intr, ctrl, equil)
intr.nlow = ctrl.nn_low;
intr.nhigh = ctrl.nn_high;
Expand Down
7 changes: 3 additions & 4 deletions benchmarks/benchmark_diiid_ideal_ntv_torque.jl
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,9 @@ const KF = GPE.KineticForces
const Eq = GPE.Equilibrium
const PE = GPE.PerturbedEquilibrium

"Fortran GPEC DIII-D ideal example run directory, from the environment (no on-disk default)."
"""
Fortran GPEC DIII-D ideal example run directory, from the environment (no on-disk default).
"""
default_fortran_dir() = get(() -> error("Set GPEC_FORTRAN_DIIID, or pass the Fortran run directory as the first argument"),
ENV, "GPEC_FORTRAN_DIIID")

Expand Down Expand Up @@ -125,9 +127,6 @@ mtheta = 256
newq0 = 0
etol = 1e-7

[Wall]
shape = "nowall"

[ForceFreeStates]
local_stability_flag = true
vac_flag = true
Expand Down
7 changes: 3 additions & 4 deletions benchmarks/benchmark_diiid_kinetic_stability.jl
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,9 @@ using GeneralizedPerturbedEquilibrium
const GPE = GeneralizedPerturbedEquilibrium
const AnalysisFFS = GPE.Analysis.ForceFreeStates

"Fortran GPEC DIII-D kinetic example run directory, from the environment (no on-disk default)."
"""
Fortran GPEC DIII-D kinetic example run directory, from the environment (no on-disk default).
"""
default_fortran_dir() = get(() -> error("Set GPEC_FORTRAN_DIIID_DCON, or pass the Fortran run directory as the first argument"),
ENV, "GPEC_FORTRAN_DIIID_DCON")

Expand Down Expand Up @@ -132,9 +134,6 @@ mtheta = 256
newq0 = 0
etol = 1e-7

[Wall]
shape = "nowall"

[ForceFreeStates]
local_stability_flag = true
vac_flag = true
Expand Down
3 changes: 1 addition & 2 deletions benchmarks/benchmark_riccati_der.jl
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,7 @@ function setup_solovev()
(Symbol(k) => v for (k, v) in inputs["ForceFreeStates"])...)
eq_config = GeneralizedPerturbedEquilibrium.Equilibrium.EquilibriumConfig(inputs["Equilibrium"], ex)
equil = GeneralizedPerturbedEquilibrium.Equilibrium.setup_equilibrium(eq_config)
intr.wall_settings = GeneralizedPerturbedEquilibrium.Vacuum.WallShapeSettings(;
(Symbol(k) => v for (k, v) in inputs["Wall"])...)
intr.wall_settings = GeneralizedPerturbedEquilibrium.Vacuum.parse_wall(get(inputs, "Wall", nothing))
FFS.sing_lim!(intr, ctrl, equil)
intr.nlow = ctrl.nn_low;
intr.nhigh = ctrl.nn_high;
Expand Down
3 changes: 1 addition & 2 deletions benchmarks/benchmark_threads.jl
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@ function run_ffs(ex; integrator)
(Symbol(k) => v for (k, v) in inputs["ForceFreeStates"])...)
eq_config = GeneralizedPerturbedEquilibrium.Equilibrium.EquilibriumConfig(inputs["Equilibrium"], ex)
equil = GeneralizedPerturbedEquilibrium.Equilibrium.setup_equilibrium(eq_config)
intr.wall_settings = GeneralizedPerturbedEquilibrium.Vacuum.WallShapeSettings(;
(Symbol(k) => v for (k, v) in inputs["Wall"])...)
intr.wall_settings = GeneralizedPerturbedEquilibrium.Vacuum.parse_wall(get(inputs, "Wall", nothing))
GeneralizedPerturbedEquilibrium.ForceFreeStates.sing_lim!(intr, ctrl, equil)
intr.nlow = ctrl.nn_low;
intr.nhigh = ctrl.nn_high;
Expand Down
4 changes: 2 additions & 2 deletions docs/development/architecture.md
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ Splines are provided by the external `FastInterpolations` package rather than by
All GPEC modules are configured via a single TOML file with the following sections:

- `[Equilibrium]` - Equilibrium solver settings
- `[Wall]` - Wall geometry and vacuum region
- `[Wall]` - Wall geometry (omitted for no wall)
- `[ForceFreeStates]` - Stability analysis parameters
- `[PerturbedEquilibrium]` - Perturbed equilibrium settings
- `[ForcingTerms]` - External field specification
Expand Down Expand Up @@ -199,7 +199,7 @@ The complete GPEC analysis pipeline:

### Vacuum
- `VacuumInput` - Input parameters for vacuum calculations
- `WallShapeSettings` - Wall geometry configuration
- `WallSettings` - Wall shape configuration (`ConformalWall`, `DeeWall`, ...); no wall is `nothing`

### Stability
- `SingType` - Singular surface data including:
Expand Down
5 changes: 3 additions & 2 deletions docs/development/toml-conventions.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ modify them. **Do not invent a new convention** — match what the existing exam
n-range, ideal vs kinetic). No ASCII-art separators or decorative dividers.
2. **Inline annotation on every variable line.** Every `key = value` gets a trailing
`# description`. Source the wording from the matching config struct's docstring
(`EquilibriumConfig`, `WallShapeSettings`, `ForceFreeStatesControl`, `ForcingTermsControl`,
(`EquilibriumConfig`, the `WallSettings` types, `ForceFreeStatesControl`, `ForcingTermsControl`,
`PerturbedEquilibriumControl`, `SolovevConfig`, `TJAnalyticConfig`, `KineticForcesControl`)
and keep it to one terse line. **Use the same description for the same variable across all
files** — `examples/DIIID-like_ideal_example/gpec.toml` is the canonical reference for the
Expand All @@ -20,7 +20,8 @@ modify them. **Do not invent a new convention** — match what the existing exam
the header plus an informative block comment per quantity group instead.
3. **Section comments only when informative.** No comment is required above a section. Keep a
block comment only when it carries real information (e.g. the Solovev `[Wall]` note on why a
conformal wall is needed). Never add decorative section dividers.
conformal wall is needed). Never add decorative section dividers. No wall is spelled by omitting `[Wall]`
entirely; a `[Wall]` section always names a `shape` and only that shape's parameters.
4. **No Fortran references — annotations must be self-contained and Julia-centric.** The Julia
code is the production workhorse; a new user must not need to know the legacy Fortran GPEC
code to read an example. Headers explain the *scenario and its unique aspect*; inline comments
Expand Down
2 changes: 1 addition & 1 deletion docs/src/set_up.md
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,7 @@ println("Beta-N: ", equil.params.betan)
GPEC uses TOML configuration files (`gpec.toml`) with the following main sections:

- **`[Equilibrium]`**: Equilibrium solver settings (input file, grid resolution, coordinate system, etc.)
- **`[Wall]`**: Wall geometry for vacuum calculations (shape, size, position)
- **`[Wall]`**: Wall geometry for vacuum calculations (shape, size, position); omit for no wall
- **`[ForceFreeStates]`**: Stability analysis settings (mode numbers, tolerances, flags)
- **`[PerturbedEquilibrium]`**: Plasma response settings (forcing data, output options)

Expand Down
3 changes: 1 addition & 2 deletions docs/src/stability.md
Original file line number Diff line number Diff line change
Expand Up @@ -313,8 +313,7 @@ equil = GeneralizedPerturbedEquilibrium.Equilibrium.setup_equilibrium(
GeneralizedPerturbedEquilibrium.Equilibrium.EquilibriumConfig(inputs["Equilibrium"], ex))

intr = FFS.ForceFreeStatesInternal(; dir_path=ex)
intr.wall_settings = GeneralizedPerturbedEquilibrium.Vacuum.WallShapeSettings(;
(Symbol(k) => v for (k, v) in inputs["Wall"])...)
intr.wall_settings = GeneralizedPerturbedEquilibrium.Vacuum.parse_wall(get(inputs, "Wall", nothing))
intr.nlow = ctrl.nn_low; intr.nhigh = ctrl.nn_high; intr.npert = 1
FFS.sing_lim!(intr, ctrl, equil)
FFS.sing_find!(intr, equil)
Expand Down
19 changes: 9 additions & 10 deletions docs/src/vacuum.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@ Contains plasma boundary data and calculation parameters including:
- Grid resolution (mtheta) for vacuum calculations
- Optional kernel sign and symmetry flags

### WallShapeSettings
Specifies wall geometry configuration with options for:
- No wall, conformal, elliptical, dee-shaped, or custom walls
- Geometric parameters (a, aw, bw, cw, dw, tw)
- Equal arc length spacing option
### WallSettings
Abstract type of the wall shapes, one concrete type each with only its own parameters:
- `ConformalWall`, `EllipticalWall`, `DeeWall`, `ModDeeWall`, `FileWall`
- Equal arc length spacing option (`equal_arc_wall`)
- No wall is `nothing` rather than a shape: the `[Wall]` section is omitted from the deck, and `compute_vacuum_response(inputs, nothing)` leaves the vacuum region unbounded

## API Reference

Expand Down Expand Up @@ -61,10 +61,9 @@ inputs = GeneralizedPerturbedEquilibrium.Vacuum.VacuumInput(
kernelsign = 1.0 # Kernel sign (+1 or -1)
)

# Define wall settings
wall_settings = GeneralizedPerturbedEquilibrium.Vacuum.WallShapeSettings(
shape = "conformal", # Wall shape type
a = 0.3, # Wall distance parameter
# Define wall settings (use `nothing` for no wall)
wall_settings = GeneralizedPerturbedEquilibrium.Vacuum.ConformalWall(
a = 0.3, # Wall distance in units of the minor radius
equal_arc_wall = true # Use equal arc length spacing
)

Expand All @@ -77,5 +76,5 @@ vac = GeneralizedPerturbedEquilibrium.Vacuum.compute_vacuum_response(inputs, wal
- The Julia implementation uses Bulirsch's algorithm for elliptic integrals, providing improved accuracy over polynomial approximations
- For large mode numbers (nρ̂ ≥ 0.1), 32-point Gaussian quadrature is used for Legendre function evaluation
- For n=0 modes with closed walls, automatic regularization is applied
- Wall shapes support: nowall, conformal, elliptical, dee, mod_dee, or custom from file
- Wall shapes: conformal, elliptical, dee, mod_dee, or custom from file; no wall is `nothing`
- The vacuum response matrix wv is scaled by the singular factor (m - nq)(m' - nq) per [Chance Phys. Plasmas 1997]
4 changes: 2 additions & 2 deletions docs/src/workflow.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,11 @@ The single `gpec.toml` file supplies user-selected options to every module. The

**Purpose**: Compute the magnetostatic vacuum response matrices that couple the plasma boundary to external fields. These matrices are used by ForceFreeStates and PerturbedEquilibrium to apply boundary conditions and decompose fields in poloidal mode space.

**Configuration**: `[Wall]` section of `gpec.toml`
**Configuration**: `[Wall]` section of `gpec.toml`; omit it for no wall

**Inputs**:
- `PlasmaEquilibrium` from Stage 1 (plasma boundary coordinates, toroidal mode number n)
- Wall geometry: shape (conformal, elliptical, dee-shaped, or custom) and dimensions
- Wall geometry (optional): shape (conformal, elliptical, dee-shaped, or custom) and dimensions; with no `[Wall]` section the vacuum region is unbounded

**Outputs**:
- `wv` — Vacuum response matrix (scaled by the singular factor (m - nq)(m' - nq), see Chance 1997)
Expand Down
10 changes: 0 additions & 10 deletions examples/DIIID-like_SLAYER_example/gpec.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,6 @@ newq0 = 0 # Target on-axis safety factor q(0) (0 = use inpu
etol = 1e-10 # Error tolerance for equilibrium solver
force_termination = false # Terminate after equilibrium setup (skip stability calculations)

[Wall]
shape = "nowall" # Wall shape (nowall, conformal, elliptical, dee, mod_dee, filepath)
a = 0.2415 # Distance from plasma (conformal) or shape parameter
aw = 0.05 # Half-thickness parameter for Dee-shaped walls
bw = 1.5 # Elongation parameter for wall shapes
cw = 0 # Offset of wall center from major radius
dw = 0.5 # Triangularity parameter for wall shapes
tw = 0.05 # Sharpness of wall corners (try 0.05 as initial value)
equal_arc_wall = true # Equal arc length distribution of nodes on wall

[ForceFreeStates]
force_termination = true # Run FFS + SLAYER, skip PerturbedEquilibrium
local_stability_flag = true # Perform local stability analysis (Mercier and ballooning) across the ψ profile
Expand Down
10 changes: 0 additions & 10 deletions examples/DIIID-like_error_field_example/gpec.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,6 @@ newq0 = 0 # Target on-axis safety factor q(0) (0 = use inpu
etol = 1e-10 # Error tolerance for equilibrium solver
force_termination = false # Terminate after equilibrium setup (skip stability calculations)

[Wall]
shape = "nowall" # Wall shape (nowall, conformal, elliptical, dee, mod_dee, filepath)
a = 0.2415 # Distance from plasma (conformal) or shape parameter
aw = 0.05 # Half-thickness parameter for Dee-shaped walls
bw = 1.5 # Elongation parameter for wall shapes
cw = 0 # Offset of wall center from major radius
dw = 0.5 # Triangularity parameter for wall shapes
tw = 0.05 # Sharpness of wall corners (try 0.05 as initial value)
equal_arc_wall = true # Equal arc length distribution of nodes on wall

[ForceFreeStates]
local_stability_flag = true # Perform local stability analysis (Mercier and ballooning) across the ψ profile
vac_flag = true # Compute plasma, vacuum, and total energies for free-boundary modes
Expand Down
10 changes: 0 additions & 10 deletions examples/DIIID-like_gal_resistive_example/gpec.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,6 @@ newq0 = 0 # Target on-axis safety factor q(0) (0 = use inpu
etol = 1e-10 # Error tolerance for equilibrium solver
force_termination = false # Terminate after equilibrium setup (skip stability calculations)

[Wall]
shape = "nowall" # Wall shape (nowall, conformal, elliptical, dee, mod_dee, filepath)
a = 0.2415 # Distance from plasma (conformal) or shape parameter
aw = 0.05 # Half-thickness parameter for Dee-shaped walls
bw = 1.5 # Elongation parameter for wall shapes
cw = 0 # Offset of wall center from major radius
dw = 0.5 # Triangularity parameter for wall shapes
tw = 0.05 # Sharpness of wall corners (try 0.05 as initial value)
equal_arc_wall = true # Equal arc length distribution of nodes on wall

[ForceFreeStates]
local_stability_flag = true # Perform local stability analysis (Mercier and ballooning) across the ψ profile
vac_flag = true # Compute plasma, vacuum, and total energies for free-boundary modes
Expand Down
10 changes: 0 additions & 10 deletions examples/DIIID-like_gal_resistive_pe_example/gpec.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,6 @@ newq0 = 0 # Target on-axis safety factor q(0) (0 = use inpu
etol = 1e-10 # Error tolerance for equilibrium solver
force_termination = false # Terminate after equilibrium setup (skip stability calculations)

[Wall]
shape = "nowall" # Wall shape (nowall, conformal, elliptical, dee, mod_dee, filepath)
a = 0.2415 # Distance from plasma (conformal) or shape parameter
aw = 0.05 # Half-thickness parameter for Dee-shaped walls
bw = 1.5 # Elongation parameter for wall shapes
cw = 0 # Offset of wall center from major radius
dw = 0.5 # Triangularity parameter for wall shapes
tw = 0.05 # Sharpness of wall corners (try 0.05 as initial value)
equal_arc_wall = true # Equal arc length distribution of nodes on wall

[ForceFreeStates]
local_stability_flag = true # Perform local stability analysis (Mercier and ballooning) across the ψ profile
vac_flag = true # Compute plasma, vacuum, and total energies for free-boundary modes
Expand Down
10 changes: 0 additions & 10 deletions examples/DIIID-like_ideal_example/gpec.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,6 @@ newq0 = 0 # Target on-axis safety factor q(0) (0 = use inpu
etol = 1e-10 # Error tolerance for equilibrium solver
force_termination = false # Terminate after equilibrium setup (skip stability calculations)

[Wall]
shape = "nowall" # Wall shape (nowall, conformal, elliptical, dee, mod_dee, filepath)
a = 0.2415 # Distance from plasma (conformal) or shape parameter
aw = 0.05 # Half-thickness parameter for Dee-shaped walls
bw = 1.5 # Elongation parameter for wall shapes
cw = 0 # Offset of wall center from major radius
dw = 0.5 # Triangularity parameter for wall shapes
tw = 0.05 # Sharpness of wall corners (try 0.05 as initial value)
equal_arc_wall = true # Equal arc length distribution of nodes on wall

[ForceFreeStates]
local_stability_flag = true # Perform local stability analysis (Mercier and ballooning) across the ψ profile
vac_flag = true # Compute plasma, vacuum, and total energies for free-boundary modes
Expand Down
3 changes: 0 additions & 3 deletions examples/DIIID-like_ideal_example_IMAS/gpec.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,6 @@ mpsi = 128 # Number of radial grid intervals (0 = two-pass a
mtheta = 256 # Number of poloidal grid points
imas_cocos = 11 # Expected COCOS convention of the input IMAS dd (11 = IMAS standard)

[Wall]
shape = "nowall" # Wall shape (nowall, conformal, elliptical, dee, mod_dee, filepath)

[ForceFreeStates]
nn_low = 1 # Smallest toroidal mode number to include
nn_high = 1 # Largest toroidal mode number to include
Expand Down
7 changes: 3 additions & 4 deletions examples/DIIID-like_ideal_example_IMAS/run_imas_example.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ IMAS Integration Benchmark — DIII-D-like H-mode equilibrium

Demonstrates that GPEC produces the same stability eigenvalue when reading the
equilibrium from an IMAS data dictionary (IMASdd.dd) as when reading directly
from the g-file. Both runs use identical ForceFreeStates and Wall settings so
from the g-file. Both runs use identical ForceFreeStates settings and no wall so
the only difference is how the equilibrium is loaded.

EFIT.jl is NOT a GPEC dependency. Install it in your own environment before running:
Expand All @@ -22,7 +22,7 @@ using EFIT
const GEQDSK = joinpath(@__DIR__, "../DIIID-like_ideal_example/TkMkr_D3Dlike_Hmode.geqdsk")
@assert isfile(GEQDSK) "G-file not found at $GEQDSK"

# Shared settings: both runs use identical ForceFreeStates and Wall config.
# Shared settings: both runs use identical ForceFreeStates config and no wall.
# Only the [Equilibrium] section differs between IMAS and g-file paths.
const SHARED_CONFIG = Dict(
"ForceFreeStates" => Dict(
Expand All @@ -34,8 +34,7 @@ const SHARED_CONFIG = Dict(
"verbose" => false,
"delta_mhigh" => 16,
"qlow" => 1.02
),
"Wall" => Dict("shape" => "nowall")
)
)

const EQ_COMMON = Dict(
Expand Down
10 changes: 0 additions & 10 deletions examples/DIIID-like_ideal_multi_n_example/gpec.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,6 @@ newq0 = 0 # Target on-axis safety factor q(0) (0 = use inpu
etol = 1e-10 # Error tolerance for equilibrium solver
force_termination = false # Terminate after equilibrium setup (skip stability calculations)

[Wall]
shape = "nowall" # Wall shape (nowall, conformal, elliptical, dee, mod_dee, filepath)
a = 0.2415 # Distance from plasma (conformal) or shape parameter
aw = 0.05 # Half-thickness parameter for Dee-shaped walls
bw = 1.5 # Elongation parameter for wall shapes
cw = 0 # Offset of wall center from major radius
dw = 0.5 # Triangularity parameter for wall shapes
tw = 0.05 # Sharpness of wall corners (try 0.05 as initial value)
equal_arc_wall = true # Equal arc length distribution of nodes on wall

[ForceFreeStates]
local_stability_flag = true # Perform local stability analysis (Mercier and ballooning) across the ψ profile
vac_flag = true # Compute plasma, vacuum, and total energies for free-boundary modes
Expand Down
Loading
Loading