Skip to content
Closed
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
8 changes: 4 additions & 4 deletions CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,8 @@ JPEC consists of four main modules, each organized in `src/`:
- `Vacuum_math.jl` - Mathematical utilities
- `fortran/` - Legacy Fortran code compiled to shared library

4. **DCON** (`src/DCON/`) - Stability analysis
- `DconStructs.jl` - Core data structures
4. **ForceFreeStates** (`src/ForceFreeStates/`) - Stability analysis
- `ForceFreeStatesStructs.jl` - Core data structures
- `Main.jl` - Main entry points
- `Ode.jl` - ODE solver for stability equations
- `Sing.jl` - Singular point handling
Expand Down Expand Up @@ -126,13 +126,13 @@ CODE - TAG - Detailed message
```

Where:
- CODE: Module name (EQUIL, DCON, VAC, VACUUM, etc.)
- CODE: Module name (EQUIL, ForceFreeStates, VAC, VACUUM, etc.)
- TAG: Type descriptor (WIP, MINOR, IMPROVEMENT, BUG FIX, NEW FEATURE, etc.)

Examples:
- `VAC - WIP - Converting vaccal wall code to Julia`
- `EQUIL - BUG FIX - Fixed separatrix finding for high kappa`
- `DCON - NEW FEATURE - Added Mercier criterion calculation`
- `ForceFreeStates - NEW FEATURE - Added Mercier criterion calculation`

This format is used for compiling release notes, so tags should be human-readable and descriptive.

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ To assist with the process of compiling release notes, please confirm to the com
```
CODE - TAG - Detailed message
```
where CODE is EQUIL, DCON, VAC, etc. and TAGs are short descriptors of the type of commit. Example tags might be WIP (work in progress), MINOR, IMPROVEMENT, BUG FIX, NEW FEATURE, etc. Look through old commits for examples of what tags are commonly used.
where CODE is EQUIL, ForceFreeStates, VAC, etc. and TAGs are short descriptors of the type of commit. Example tags might be WIP (work in progress), MINOR, IMPROVEMENT, BUG FIX, NEW FEATURE, etc. Look through old commits for examples of what tags are commonly used.

Again, this is currently used for the by-hand compilation of release notes. The tags thus need to be human readable but are not strictly inforced to be within some limited set. The objective is to allow a lead developer to skim through commits and pick out only the key new features / bug fixes / improvements to note in the release while not having to read all the work-in-progress or minor changes.

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[DCON_CONTROL]
[ForceFreeStates_CONTROL]
bal_flag = false # Ideal MHD ballooning criterion for short wavelengths
mat_flag = true # Construct coefficient matrices for diagnostic purposes
ode_flag = true # Integrate ODE's for determining stability of internal long-wavelength mode (must be true for GPEC)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,7 @@
"# Run DCON in Julia\n",
"Pkg.activate(\"../..\")\n",
"using JPEC\n",
"JPEC.DCON.Main(\"./\") # \"./\" tells us to obtain inputs and direct outputs to our current folder"
"JPEC.ForceFreeStates.Main(\"./\") # \"./\" tells us to obtain inputs and direct outputs to our current folder"
]
},
{
Expand Down
12 changes: 6 additions & 6 deletions benchmarks/DIIID_ideal_example/vacuum_accuracy_benchmark.jl
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ if benchmark_n
println("Testing n = $n_test")

# Compute Fortran solution
JPEC.Vacuum.set_dcon_params(mtheta_eq, vac_inputs.mlow, vac_inputs.mhigh,
JPEC.Vacuum.set_surface_params(mtheta_eq, vac_inputs.mlow, vac_inputs.mhigh,
n_test, vac_inputs.qa, vac_inputs.r,
vac_inputs.z, vac_inputs.delta)

Expand All @@ -53,7 +53,7 @@ if benchmark_n
complex_flag, kernelsign, wall_flag,
farwall_flag, grri, xzpts)

JPEC.Vacuum.unset_dcon_params()
JPEC.Vacuum.unset_surface_params()

# Compute Julia solution
vac_inputs_test = deepcopy(vac_inputs)
Expand Down Expand Up @@ -123,15 +123,15 @@ if benchmark_m

# Fortran reference
mpert_ref = mhigh_reference - vac_inputs.mlow
JPEC.Vacuum.set_dcon_params(mtheta_eq, vac_inputs.mlow, mhigh_reference,
JPEC.Vacuum.set_surface_params(mtheta_eq, vac_inputs.mlow, mhigh_reference,
1, vac_inputs.qa, vac_inputs.r,
vac_inputs.z, vac_inputs.delta)
wv_block_ref_fortran_m = zeros(ComplexF64, mpert_ref, mpert_ref)
grri_ref = zeros(Float64, 2 * (mthvac + 5), 2 * mpert_ref)
JPEC.Vacuum.mscvac(wv_block_ref_fortran_m, mpert_ref, mtheta_eq, mthvac,
complex_flag, kernelsign, wall_flag,
farwall_flag, grri_ref, xzpts, ahg_file, "$(@__DIR__)/../../examples/DIIID-like_ideal_example")
JPEC.Vacuum.unset_dcon_params()
JPEC.Vacuum.unset_surface_params()

println("Reference solutions computed.\n")

Expand All @@ -142,7 +142,7 @@ if benchmark_m
mpert_test = mhigh_test - vac_inputs.mlow

# Compute Fortran solution
JPEC.Vacuum.set_dcon_params(mtheta_eq, vac_inputs.mlow, mhigh_test,
JPEC.Vacuum.set_surface_params(mtheta_eq, vac_inputs.mlow, mhigh_test,
1, vac_inputs.qa, vac_inputs.r,
vac_inputs.z, vac_inputs.delta)

Expand All @@ -152,7 +152,7 @@ if benchmark_m
complex_flag, kernelsign, wall_flag,
farwall_flag, grri_test, xzpts, ahg_file, "$(@__DIR__)/../../examples/DIIID-like_ideal_example")

JPEC.Vacuum.unset_dcon_params()
JPEC.Vacuum.unset_surface_params()

# Compute Julia solution
vac_inputs_test_m = deepcopy(vac_inputs)
Expand Down
8 changes: 4 additions & 4 deletions benchmarks/DIIID_ideal_example/vacuum_speed_benchmark.jl
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ if benchmark_n
println("Benchmarking n = $n_test")

# Benchmark Fortran version
JPEC.Vacuum.set_dcon_params(mtheta_eq, vac_inputs.mlow, vac_inputs.mhigh,
JPEC.Vacuum.set_surface_params(mtheta_eq, vac_inputs.mlow, vac_inputs.mhigh,
n_test, vac_inputs.qa, vac_inputs.r,
vac_inputs.z, vac_inputs.delta)

Expand All @@ -49,7 +49,7 @@ if benchmark_n
push!(fortran_allocs, median(b_fortran).allocs)
push!(fortran_memory, median(b_fortran).memory / 1e6)

JPEC.Vacuum.unset_dcon_params()
JPEC.Vacuum.unset_surface_params()

# Benchmark Julia version
vac_inputs_test = deepcopy(vac_inputs)
Expand Down Expand Up @@ -106,7 +106,7 @@ if benchmark_m
mpert_test = mhigh_test - vac_inputs.mlow

# Benchmark Fortran version
JPEC.Vacuum.set_dcon_params(mtheta_eq, vac_inputs.mlow, mhigh_test,
JPEC.Vacuum.set_surface_params(mtheta_eq, vac_inputs.mlow, mhigh_test,
1, vac_inputs.qa, vac_inputs.r,
vac_inputs.z, vac_inputs.delta)

Expand All @@ -119,7 +119,7 @@ if benchmark_m
push!(fortran_mhigh_allocs, median(b_fortran).allocs)
push!(fortran_mhigh_memory, median(b_fortran).memory / 1e6)

JPEC.Vacuum.unset_dcon_params()
JPEC.Vacuum.unset_surface_params()

# Benchmark Julia version
vac_inputs_test = deepcopy(vac_inputs)
Expand Down
8 changes: 4 additions & 4 deletions benchmarks/Solovev_ideal_example/vacuum_accuracy_benchmark.jl
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ if benchmark_n
println("Testing n = $n_test")

# Compute Fortran solution
JPEC.Vacuum.set_dcon_params(mtheta_eq, vac_inputs.mlow, vac_inputs.mhigh,
JPEC.Vacuum.set_surface_params(mtheta_eq, vac_inputs.mlow, vac_inputs.mhigh,
n_test, vac_inputs.qa, vac_inputs.r,
vac_inputs.z, vac_inputs.delta)

Expand All @@ -57,7 +57,7 @@ if benchmark_n
complex_flag, kernelsign, wall_flag,
farwall_flag, grri, xzpts)

JPEC.Vacuum.unset_dcon_params()
JPEC.Vacuum.unset_surface_params()

# Compute Julia solution
vac_inputs_test = deepcopy(vac_inputs)
Expand Down Expand Up @@ -122,7 +122,7 @@ if benchmark_a
println("Testing a = $a_test")

# Compute Fortran solution
JPEC.Vacuum.set_dcon_params(mtheta_eq, vac_inputs.mlow, vac_inputs.mhigh,
JPEC.Vacuum.set_surface_params(mtheta_eq, vac_inputs.mlow, vac_inputs.mhigh,
vac_inputs.n, vac_inputs.qa, vac_inputs.r,
vac_inputs.z, vac_inputs.delta)

Expand All @@ -136,7 +136,7 @@ if benchmark_a
complex_flag, kernelsign, wall_flag,
farwall_flag, grri, xzpts)

JPEC.Vacuum.unset_dcon_params()
JPEC.Vacuum.unset_surface_params()

# Compute Julia solution
new_wall = JPEC.Vacuum.WallShapeSettings(
Expand Down
4 changes: 2 additions & 2 deletions docs/src/equilibrium.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ Key responsibilities of the module:
(global parameters, q-profile finding, separatrix finding, GSE checks).

The module exposes a small public API that covers setup, configuration,
and common analyses used by other JPEC components (e.g. `DCON`, vacuum
and common analyses used by other JPEC components (e.g. `ForceFreeStates`, vacuum
interfaces).

## API Reference
Expand Down Expand Up @@ -65,7 +65,7 @@ Basic example: read a TOML config and build an equilibrium
using JPEC

# Build from a TOML file (searches relative paths if needed)
pe = JPEC.Equilibrium.setup_equilibrium("docs/examples/dcon.toml")
pe = JPEC.Equilibrium.setup_equilibrium("docs/examples/ForceFreeStates.toml")

println("Magnetic axis: ", pe.params.r0, ", ", pe.params.z0)
println("q(0) = ", pe.params.q0)
Expand Down
14 changes: 7 additions & 7 deletions docs/src/examples/vacuum.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@ This page demonstrates the usage of the Vacuum module for magnetostatic calculat

## Basic Vacuum Field Calculation

### Setting up DCON Parameters
### Setting up Surface Parameters

The vacuum module requires initialization with DCON (Displacement CONtinuum) parameters:
The vacuum module requires initialization with surface parameters:

```julia
using JPEC

# Define DCON parameters
# Define surface parameters
mthin = Int32(4) # Number of theta points
lmin = Int32(1) # Minimum poloidal mode number
lmax = Int32(4) # Maximum poloidal mode number
Expand All @@ -24,8 +24,8 @@ xin = rand(Float64, n_modes) # Radial coordinates
zin = rand(Float64, n_modes) # Vertical coordinates
deltain = rand(Float64, n_modes) # Displacement data

# Initialize DCON interface
JPEC.VacuumMod.set_dcon_params(mthin, lmin, lmax, nnin, qa1in, xin, zin, deltain)
# Initialize surface parameters interface
JPEC.VacuumMod.set_surface_params(mthin, lmin, lmax, nnin, qa1in, xin, zin, deltain)
```

### Vacuum Matrix Calculation
Expand Down Expand Up @@ -137,7 +137,7 @@ println("Most unstable eigenvalue: ", eigenvals[max_growth_idx])
# xin, zin, deltain = process_boundary_data(boundary_data)

# 4. Perform vacuum calculation
# JPEC.VacuumMod.set_dcon_params(mthin, lmin, lmax, nnin, qa1in, xin, zin, deltain)
# JPEC.VacuumMod.set_surface_params(mthin, lmin, lmax, nnin, qa1in, xin, zin, deltain)
# ... vacuum calculation ...

# 5. Analyze stability
Expand All @@ -148,7 +148,7 @@ println("Most unstable eigenvalue: ", eigenvals[max_growth_idx])

### Common Issues

1. **Initialization Error**: Ensure `set_dcon_params` is called before `mscvac`
1. **Initialization Error**: Ensure `set_surface_params` is called before `mscvac`
2. **Memory Issues**: Large `mtheta`/`mthvac` values require significant memory
3. **Convergence**: Check that geometry arrays are properly normalized
4. **Complex Arithmetic**: Ensure `complex_flag=true` for stability analysis
Expand Down
2 changes: 1 addition & 1 deletion docs/src/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ To assist with release note compilation, please follow the commit message format
```
CODE - TAG - Detailed message
```
where CODE is EQUIL, DCON, VAC, etc. and TAGs are descriptors like WIP, MINOR, IMPROVEMENT, BUG FIX, NEW FEATURE, etc.
where CODE is Equil, ForceFreeStates, Vacuum, etc. and TAGs are descriptors like WIP, MINOR, IMPROVEMENT, BUG FIX, NEW FEATURE, etc.

Additionally, please see [this](https://docs.google.com/document/d/1XAOTz1IV8ErZAAk-iSuEuddNOLB5XcoVZsAbPKRUUuA) google doc for more details on using the GitHub.

Expand Down
14 changes: 7 additions & 7 deletions docs/src/vacuum.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Refactored/interfaced from/with VACUUM by M.S. Chance.

The module includes:

- Interface to Fortran vacuum field calculations (`mscvac`, `set_dcon_params`)
- Interface to Fortran vacuum field calculations (`mscvac`, `set_surface_params`)
- Pure Julia implementation of vacuum response calculations (`compute_vacuum_response`, `compute_vacuum_field`)
- Support for various wall geometries and configurations

Expand Down Expand Up @@ -35,9 +35,9 @@ Modules = [JPEC.Vacuum]

## Functions

### set_dcon_params
### set_surface_params
```@docs
JPEC.Vacuum.set_dcon_params
JPEC.Vacuum.set_surface_params
```

### mscvac
Expand All @@ -62,15 +62,15 @@ JPEC.Vacuum.compute_vacuum_field
```julia
using JPEC

# Set DCON parameters
# Set surface parameters
mtheta, lmin, lmax, nnin = Int32(4), Int32(1), Int32(4), Int32(2)
qa1in = 1.23
xin = rand(Float64, lmax - lmin + 1)
zin = rand(Float64, lmax - lmin + 1)
deltain = rand(Float64, lmax - lmin + 1)

# Initialize DCON interface
JPEC.Vacuum.set_dcon_params(mtheta, lmin, lmax, nnin, qa1in, xin, zin, deltain)
# Initialize surface parameters interface
JPEC.Vacuum.set_surface_params(mtheta, lmin, lmax, nnin, qa1in, xin, zin, deltain)

# Set up vacuum calculation parameters
mpert = 5
Expand Down Expand Up @@ -127,7 +127,7 @@ wv, grri, xzpts = JPEC.Vacuum.compute_vacuum_response(inputs, wall_settings)

## Notes

- Requires proper initialization of DCON parameters before using the Fortran interface
- Requires proper initialization of surface parameters before using the Fortran interface
- The pure Julia implementation (`compute_vacuum_response`) provides equivalent functionality
- For n=0 modes with closed walls, automatic regularization is applied

Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[DCON_CONTROL]
[ForceFreeStates_CONTROL]
bal_flag = false # Ideal MHD ballooning criterion for short wavelengths
mat_flag = true # Construct coefficient matrices for diagnostic purposes
ode_flag = true # Integrate ODE's for determining stability of internal long-wavelength mode (must be true for GPEC)
Expand Down
2 changes: 1 addition & 1 deletion examples/DIIID-like_ideal_example/run_and_analyze.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
"# Run DCON in Julia\n",
"Pkg.activate(\"../..\")\n",
"using JPEC\n",
"JPEC.DCON.Main(\"./\") # \"./\" tells us to obtain inputs and direct outputs to our current folder"
"JPEC.ForceFreeStates.Main(\"./\") # \"./\" tells us to obtain inputs and direct outputs to our current folder"
]
},
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[DCON_CONTROL]
[ForceFreeStates_CONTROL]
bal_flag = false # Ideal MHD ballooning criterion for short wavelengths
mat_flag = true # Construct coefficient matrices for diagnostic purposes
ode_flag = true # Integrate ODE's for determining stability of internal long-wavelength mode (must be true for GPEC)
Expand Down
2 changes: 1 addition & 1 deletion examples/Solovev_ideal_example/run_and_analyze.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
"# Run DCON in Julia\n",
"Pkg.activate(\"../..\")\n",
"using JPEC\n",
"JPEC.DCON.Main(\"./\") # \"./\" tells us to obtain inputs and direct outputs to our current folder"
"JPEC.ForceFreeStates.Main(\"./\") # \"./\" tells us to obtain inputs and direct outputs to our current folder"
]
},
{
Expand Down
4 changes: 2 additions & 2 deletions examples/Solovev_ideal_example/vacuum_wall_debug.jl
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,15 @@ if !use_wall_arg
end


JPEC.Vacuum.set_dcon_params(mtheta_eq, mlow, mhigh,
JPEC.Vacuum.set_surface_params(mtheta_eq, mlow, mhigh,
n, vac_inputs.qa, vac_inputs.r,
vac_inputs.z, vac_inputs.delta)

wv_fortran = JPEC.Vacuum.mscvac(wv_block, mpert, mtheta_eq, mthvac,
complex_flag, kernelsign, wall_flag,
farwall_flag, grri, xzpts, ahg_file, "$(@__DIR__)")

JPEC.Vacuum.unset_dcon_params()
JPEC.Vacuum.unset_surface_params()

# Now deepcopy the julia vac_inputs and set the new ms
vac_inputs = deepcopy(vac_inputs)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[DCON_CONTROL]
[ForceFreeStates_CONTROL]
bal_flag = false # Ideal MHD ballooning criterion for short wavelengths
mat_flag = true # Construct coefficient matrices for diagnostic purposes
ode_flag = true # Integrate ODE's for determining stability of internal long-wavelength mode (must be true for GPEC)
Expand Down
6 changes: 3 additions & 3 deletions examples/Solovev_ideal_example_multi_n/run_and_analyze.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,9 @@
"# Run DCON in Julia\n",
"Pkg.activate(\"../..\")\n",
"using JPEC\n",
"JPEC.DCON.Main(\"./\") # \"./\" tells us to obtain inputs and direct outputs to our current folder\n",
"JPEC.DCON.Main(\"single_n_1\")\n",
"JPEC.DCON.Main(\"single_n_2\")"
"JPEC.ForceFreeStates.Main(\"./\") # \"./\" tells us to obtain inputs and direct outputs to our current folder\n",
"JPEC.ForceFreeStates.Main(\"single_n_1\")\n",
"JPEC.ForceFreeStates.Main(\"single_n_2\")"
]
},
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[DCON_CONTROL]
[ForceFreeStates_CONTROL]
bal_flag = false # Ideal MHD ballooning criterion for short wavelengths
mat_flag = true # Construct coefficient matrices for diagnostic purposes
ode_flag = true # Integrate ODE's for determining stability of internal long-wavelength mode (must be true for GPEC)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[DCON_CONTROL]
[ForceFreeStates_CONTROL]
bal_flag = false # Ideal MHD ballooning criterion for short wavelengths
mat_flag = true # Construct coefficient matrices for diagnostic purposes
ode_flag = true # Integrate ODE's for determining stability of internal long-wavelength mode (must be true for GPEC)
Expand Down
6 changes: 3 additions & 3 deletions notebooks/vacuum_fortran_example.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@
"zin = rand(Float64, lmax - lmin + 1)\n",
"deltain = rand(Float64, lmax - lmin + 1)\n",
"\n",
"println(\"Testing set_dcon_params…\")\n",
"JPEC.VacuumMod.set_dcon_params(mthin, lmin, lmax, nnin, qa1in, xin, zin, deltain)\n",
"println(\"set_dcon_params OK!\")"
"println(\"Testing set_surface_params…\")\n",
"JPEC.VacuumMod.set_surface_params(mthin, lmin, lmax, nnin, qa1in, xin, zin, deltain)\n",
"println(\"set_surface_params OK!\")"
]
},
{
Expand Down
Loading
Loading