Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
54 commits
Select commit Hold shift + click to select a range
2b84235
Add IMAS integration skeleton with TODO markers (Chapter 1)
logan-nc Mar 1, 2026
a860e3d
Add comprehensive IMAS exercise guide
Mar 1, 2026
72203e8
Complete IMAS exercise guide with all 8 files
Mar 1, 2026
f64b40c
Update DCON.jl
calin1989 Mar 2, 2026
b185002
Update WriteImas.jl
calin1989 Mar 3, 2026
9332fe1
Update runtests_imas.jl
calin1989 Mar 3, 2026
191818d
Update Main.jl
calin1989 Mar 4, 2026
43b7a16
Update Equilibrium.jl
calin1989 Mar 4, 2026
a72b8d4
Update ReadEquilibrium.jl
calin1989 Mar 4, 2026
78083ba
Update Project.toml
calin1989 Mar 4, 2026
b243ea7
Update Project.toml
calin1989 Mar 4, 2026
0598a48
Update DCON.jl
calin1989 Mar 4, 2026
5210a1f
Update DCON.jl
calin1989 Mar 4, 2026
0dbb7d3
Fix syntax errors in IMAS integration code
Mar 4, 2026
e86ccb0
Add missing zo test in IMAS equilibrium comparison
Mar 4, 2026
e56baf2
Add IMAS integration demonstration and fix compilation
Mar 4, 2026
b0dd317
Update imas_standalone_test.jl
calin1989 Mar 4, 2026
f2e1d19
Update imas_standalone_test.jl
calin1989 Mar 4, 2026
2268e17
Delete examples/IMAS_DEMONSTRATION_README.md
calin1989 Mar 4, 2026
23afef7
Fix JPEC compilation - remove AbstractExtrap type dependencies
Mar 4, 2026
5521f37
Fix JPEC compilation - add missing dependencies
Mar 4, 2026
c3a16d9
Add DCON module to JPEC and fix compilation issues
Mar 4, 2026
b9fa67e
Fix JPEC Equilibrium module imports and API issues
Mar 4, 2026
a55fedb
Fix all remaining JPEC compilation issues - IMAS tests now pass!
Mar 4, 2026
e7ae849
Add comprehensive full JPEC IMAS workflow demonstration
Mar 4, 2026
c110663
Update jpec_imas_full_workflow.jl
calin1989 Mar 4, 2026
72183a4
Delete IMAS_EXERCISE_GUIDE.md
calin1989 Mar 4, 2026
0234c01
Remove IMAS_EXERCISE_GUIDE.md
Mar 4, 2026
7a4172a
Merge branch 'Calin/IMAS-integration' of https://github.com/OpenFUSIO…
Mar 4, 2026
d6f6118
Update WriteImas.jl
calin1989 Mar 4, 2026
8a0fe6d
Update jpec_imas_full_workflow.jl
calin1989 Mar 4, 2026
485335f
Update runtests_imas.jl
calin1989 Mar 4, 2026
f93a9a4
Update jpec_imas_full_workflow.jl
calin1989 Mar 4, 2026
61c4f5a
Update jpec_imas_full_workflow.jl
calin1989 Mar 4, 2026
5bf6674
Add comprehensive IMAS equivalence test
Mar 8, 2026
6494d3a
Merge branch 'Calin/IMAS-integration' of https://github.com/OpenFUSIO…
Mar 8, 2026
9e39222
Enable JPEC.main() to accept optional IMAS dd parameter
Mar 9, 2026
569461b
Fix FastInterpolations API compatibility issues
Mar 9, 2026
2f068d7
Fix IMAS integration to produce identical eigenvalues as EFIT path
Mar 10, 2026
069a75c
Add DIII-D advisor validation test - COCOS 2 IMAS integration
Mar 11, 2026
0a8b81e
Update test_final_diiid.jl
calin1989 Mar 11, 2026
2c3631d
Delete examples/ADVISOR_PRESENTATION_GUIDE.md
calin1989 Mar 11, 2026
a45a344
Update IMAS integration for compatibility with latest JPEC
Mar 11, 2026
ee6d8e3
Delete .ipynb_checkpoints/Untitled-checkpoint.ipynb
calin1989 Mar 11, 2026
599e3f0
Delete .ipynb_checkpoints/Untitled1-checkpoint.ipynb
calin1989 Mar 11, 2026
2616a5a
Delete examples/imas_integration_demo.jl
calin1989 Mar 11, 2026
6685809
Delete examples/imas_standalone_test.jl
calin1989 Mar 11, 2026
e640ca1
Delete examples/DIIID-like_ideal_example/.ipynb_checkpoints/run_and_a…
calin1989 Mar 11, 2026
f149b4f
Delete src/Equilibrium/AnalyticEquilibrium.jl.bak4
calin1989 Mar 11, 2026
3d46583
Delete src/Equilibrium/DirectEquilibrium.jl.bak4
calin1989 Mar 11, 2026
7f6b57a
Delete src/Equilibrium/Equilibrium.jl.bak2
calin1989 Mar 11, 2026
641e561
Delete src/Equilibrium/Equilibrium.jl.bak3
calin1989 Mar 11, 2026
da36ef7
Clean up IMAS integration PR: remove old files, revert unrelated chan…
Mar 17, 2026
fba2f2a
Revert non-IMAS files to match latest origin/develop
Mar 17, 2026
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
13 changes: 8 additions & 5 deletions .github/copilot-instructions.md
Original file line number Diff line number Diff line change
@@ -1,19 +1,21 @@
# Copilot instructions for JPEC
# Copilot instructions for GPEC

## Project overview
- JPEC is a Julia port of GPEC-style MHD equilibrium and stability analysis. Core modules live in [src](src): Utilities, Equilibrium, Vacuum, ForceFreeStates, ForcingTerms, PerturbedEquilibrium (see [CLAUDE.md](CLAUDE.md)).
- GPEC is a Julia port of GPEC-style MHD equilibrium and stability analysis. Core modules live in [src](src): Utilities, Equilibrium, Vacuum, ForceFreeStates, ForcingTerms, PerturbedEquilibrium (see [CLAUDE.md](CLAUDE.md)).
- Data flow: equilibrium setup → vacuum response → stability analysis (documented in [CLAUDE.md](CLAUDE.md)).

## Architecture and entry points
- Main entry point: `GeneralizedPerturbedEquilibrium.main()` in [src/GeneralizedPerturbedEquilibrium.jl](src/GeneralizedPerturbedEquilibrium.jl).
- Equilibrium: `setup_equilibrium(path|config)`; types in [src/Equilibrium](src/Equilibrium).
- Vacuum: `compute_vacuum_response()`; code in [src/Vacuum](src/Vacuum).
- DCON stability: entry points in [src/DCON/Main.jl](src/DCON/Main.jl).
- ForceFreeStates (ideal MHD stability): types and functions in [src/ForceFreeStates](src/ForceFreeStates).
- PerturbedEquilibrium (plasma response): entry point in [src/PerturbedEquilibrium](src/PerturbedEquilibrium).

## Data flow and key structures
- Equilibrium: TOML config → read equilibrium → solve → diagnostics (gse*.h5) when relevant.
- Vacuum: initialize plasma/wall surfaces → compute response matrix → return wv, grri, xzpts.
- Stability: equilibrium + vacuum response → integrate ODEs → compute energies.
- Core types: `PlasmaEquilibrium` and `EquilibriumConfig` in [src/Equilibrium/EquilibriumTypes.jl](src/Equilibrium/EquilibriumTypes.jl); `DconControl` in [src/DCON/DconStructs.jl](src/DCON/DconStructs.jl).
- Core types: `PlasmaEquilibrium` and `EquilibriumConfig` in [src/Equilibrium/EquilibriumTypes.jl](src/Equilibrium/EquilibriumTypes.jl); `ForceFreeStatesControl` and `ForceFreeStatesInternal` in [src/ForceFreeStates/ForceFreeStatesStructs.jl](src/ForceFreeStates/ForceFreeStatesStructs.jl).

## Tests and docs
- Run all tests:
Expand All @@ -37,7 +39,8 @@
- Many routines use 0-based indexing for historical consistency with the original GPEC Fortran code before converting to 1-based Julia indexing (see [CLAUDE.md](CLAUDE.md)).

## Configuration examples
- TOML configs: `equil.toml` uses `[EQUIL_CONTROL]` and `[EQUIL_OUTPUT]`; `dcon.toml` uses `[DCON_CONTROL]` and `[WALL]`.
- Unified configuration: `gpec.toml` uses `[Equilibrium]`, `[Wall]`, `[ForceFreeStates]`, `[PerturbedEquilibrium]`, and `[ForcingTerms]` sections.
- Legacy configs (`equil.toml`, `dcon.toml`, `vac.in`) are deprecated.
- Example configs in [examples/DIIID-like_ideal_example](examples/DIIID-like_ideal_example) and [examples/Solovev_ideal_example](examples/Solovev_ideal_example).

## Development tips
Expand Down
16 changes: 13 additions & 3 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,18 @@ on:
- develop

jobs:
runtests:
runs-on: ubuntu-latest
test:
name: runtests ${{ matrix.version }} - ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
version:
- 'lts' # long-term support (currently 1.10)
- '1.11'
- '1.x' # latest (currently 1.12)
os:
- ubuntu-latest

steps:
- name: Checkout repository
Expand All @@ -21,7 +31,7 @@ jobs:
- name: Set up Julia
uses: julia-actions/setup-julia@v2
with:
version: '1.11'
version: ${{ matrix.version }}

- name: Cache Julia packages
uses: julia-actions/cache@v2
Expand Down
46 changes: 23 additions & 23 deletions CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,19 @@ This file provides guidance to Claude Code (claude.ai/code) when working with co

## Overview

JPEC (Julia Perturbed Equilibrium Code) is a comprehensive Julia implementation of GPEC-style (Generalized Perturbed Equilibrium Code) MHD analysis for fusion plasmas. The code performs equilibrium reconstruction, ideal MHD stability analysis, and perturbed equilibrium calculations including plasma response and singular surface coupling diagnostics.
GPEC (Generalized Perturbed Equilibrium Code, Julia implementation) is a comprehensive Julia reimplementation of the GPEC suite for MHD analysis of fusion plasmas. The code performs equilibrium reconstruction, ideal MHD stability analysis, and perturbed equilibrium calculations including plasma response and singular surface coupling diagnostics.

**Relationship to Fortran GPEC**: JPEC is an evolution of the Fortran GPEC code suite, available at https://github.com/PrincetonUniversity/GPEC. When users reference "GPEC", "the Fortran code", or "the original GPEC", they are referring to this Fortran codebase. JPEC reimplements and extends GPEC's functionality in Julia with improved performance and maintainability.
**Relationship to Fortran GPEC**: This Julia GPEC is an evolution of the Fortran GPEC code suite, available at https://github.com/PrincetonUniversity/GPEC. When users reference "the Fortran code", "the original GPEC", or "Fortran GPEC", they are referring to that Fortran codebase. This Julia implementation reimplements and extends GPEC's functionality with improved performance and maintainability.

**Local GPEC Repository**: For code conversion or comparison with the original Fortran implementation, check for a local GPEC repository at `~/Code/gpec`. If not found at this location, ask the user for the correct path.

JPEC is implemented in Julia. References to “Fortran GPEC” or “legacy VACUUM” refer to the original upstream codebase, not a runtime dependency of JPEC.
This codebase is implemented in Julia. References to “Fortran GPEC” or “legacy VACUUM” refer to the original upstream Fortran codebase, not a runtime dependency of this Julia implementation.

**Current Development Focus**: The `perturbed_equilibrium` branch is implementing full GPEC-style perturbed equilibrium functionality, including singular coupling analysis, island formation diagnostics, and mode-space field reconstruction.

## Key References

**IMPORTANT**: The papers in `docs/resources/` provide the theoretical foundation for JPEC's algorithms and should be referenced to understand what the code is doing. **Citing equations from these papers in code comments and annotations is strongly encouraged** to maintain traceability between theory and implementation.
**IMPORTANT**: The papers in `docs/resources/` provide the theoretical foundation for GPEC's algorithms and should be referenced to understand what the code is doing. **Citing equations from these papers in code comments and annotations is strongly encouraged** to maintain traceability between theory and implementation.

### Vacuum Module

Expand Down Expand Up @@ -76,9 +76,9 @@ The PerturbedEquilibrium module implements GPEC-style perturbed equilibrium calc
- Published: Physics of Plasmas **24**, 032505 (2017)
- Describes: Self-consistent coupling with neoclassical effects

### Resistive DCON Module (Future Work)
### Resistive MHD Stability Analysis (Future Work)

JPEC will eventually implement resistive MHD stability analysis based on:
GPEC will eventually implement resistive MHD stability analysis based on:

- **Glasser (2016)**: "Computation of resistive instabilities by matched asymptotic expansions"
- Location: `docs/resources/2016-Glasser-Computation_of_resistive_instabilities_by_matched_asymptotic_expansions-compressed.pdf`
Expand All @@ -97,7 +97,7 @@ JPEC will eventually implement resistive MHD stability analysis based on:

### PENTRC Module (Future Work)

JPEC will eventually port the PENTRC (Perturbed Equilibrium Neoclassical Toroidal viscosity in Realistic geometry Code) functionality from the Fortran GPEC suite. This is described in:
GPEC will eventually port the PENTRC (Perturbed Equilibrium Neoclassical Toroidal viscosity in Realistic geometry Code) functionality from the Fortran GPEC suite. This is described in:

- **Logan & Park (2013)**: "Neoclassical toroidal viscosity in perturbed equilibria with general tokamak geometry"
- Location: `docs/resources/2013-Logan-Neoclassical_toroidal_viscosity_in_perturbed_equilibria_with_general_tokamak_geometry.pdf`
Expand Down Expand Up @@ -141,7 +141,7 @@ julia --project=. test/runtests.jl test/runtests_solovev.jl
# Build documentation locally
julia --project=. build_docs_local.jl

# Documentation hosted at: https://openfusiontoolkit.github.io/JPEC/dev/
# Documentation hosted at: https://openfusiontoolkit.github.io/GPEC/dev/
```

### Development with Revise
Expand All @@ -150,7 +150,7 @@ For faster recompilation during development, use Revise.jl (installed in global

```julia
using Revise
using JPEC
using GeneralizedPerturbedEquilibrium
```

### Benchmarking
Expand Down Expand Up @@ -205,7 +205,7 @@ julia benchmarks/benchmark_git_branches.jl \

### Computational Workflow

JPEC follows a three-stage analysis pipeline:
GPEC follows a three-stage analysis pipeline:

1. **Equilibrium** → Solve Grad-Shafranov equation, compute flux surfaces, safety factor q-profile
2. **Stability Analysis** → Solve ideal MHD eigenvalue problem (DCON-style), identify singular surfaces
Expand All @@ -215,7 +215,7 @@ This workflow is reflected in the modular structure and data flow.

### Module Structure

JPEC consists of **seven main modules** organized in `src/`:
GPEC consists of **seven main modules** organized in `src/`:

#### Foundation Modules

Expand Down Expand Up @@ -299,9 +299,9 @@ JPEC consists of **seven main modules** organized in `src/`:

### Configuration

**Unified Configuration File**: `jpec.toml`
**Unified Configuration File**: `gpec.toml`

All JPEC modules are configured via a single TOML file with the following sections:
All GPEC modules are configured via a single TOML file with the following sections:

- `[Equilibrium]` - Equilibrium solver settings
- `[Wall]` - Wall geometry and vacuum region
Expand All @@ -311,20 +311,20 @@ All JPEC modules are configured via a single TOML file with the following sectio

Key parameters:
- `force_termination` - Set to `true` to exit after equilibrium/stability (skip perturbed equilibrium)
- `output_file` - Output filename (default: `jpec.h5`)
- `output_file` - Output filename (default: `gpec.h5`)

Example configuration files are provided in:
- `examples/Solovev_ideal_example/jpec.toml`
- `examples/DIIID-like_ideal_example/jpec.toml`
- `examples/Solovev_ideal_example/gpec.toml`
- `examples/DIIID-like_ideal_example/gpec.toml`

**Note**: Legacy configuration files (`equil.toml`, `vac.in`) are deprecated.

### Data Flow

The complete JPEC analysis pipeline:
The complete GPEC analysis pipeline:

1. **Equilibrium Setup**:
- `setup_equilibrium(config)` reads configuration from `jpec.toml`
- `setup_equilibrium(config)` reads configuration from `gpec.toml`
- Parses equilibrium data (EFIT, CHEASE, or analytical)
- Runs Grad-Shafranov solver (direct or inverse)
- Computes global parameters: q-profile, pressure, current density, β
Expand Down Expand Up @@ -357,7 +357,7 @@ The complete JPEC analysis pipeline:
- Outputs: `PerturbedEquilibriumState` with response fields and diagnostics

5. **Output**:
- All results saved to single HDF5 file (default: `jpec.h5`)
- All results saved to single HDF5 file (default: `gpec.h5`)
- HDF5 groups: `input/`, `info/`, `equil/`, `splines/`, `locstab/`, `integration/`, `singular/`, `vacuum/`, and perturbed equilibrium data

### Key Data Structures
Expand Down Expand Up @@ -390,7 +390,7 @@ The complete JPEC analysis pipeline:
### Module Dependencies

```
JPEC
GeneralizedPerturbedEquilibrium
├── Splines (foundation)
├── Utilities (shared tools)
│ └── FourierTransforms
Expand Down Expand Up @@ -440,12 +440,12 @@ This format is used for compiling release notes, so tags should be human-readabl
- **No step numbering in code comments** - Avoid annotations like "Step 1: do this" followed by "Step 2: do that". These get out of sync as code changes. Just describe the action without numbering.

### Output Files
- **Default output**: `jpec.h5` (previously `euler.h5` in older versions)
- **Legacy diagnostic files**: When modifying equilibrium code, remember that older versions output `gsec.h5`, `gse.h5`, `gsei.h5` - these are now consolidated into `jpec.h5`
- **Default output**: `gpec.h5` (previously `euler.h5` in older versions)
- **Legacy diagnostic files**: When modifying equilibrium code, remember that older versions output `gsec.h5`, `gse.h5`, `gsei.h5` - these are now consolidated into `gpec.h5`

### Current Development Priorities
- **Perturbed equilibrium module**: Active development of GPEC-style singular coupling analysis
- **Configuration**: All settings now in unified `jpec.toml` file
- **Configuration**: All settings now in unified `gpec.toml` file

### Performance
- Pure Julia implementations are available for all major components and offer comparable or better performance than Fortran
Expand Down
36 changes: 33 additions & 3 deletions Project.toml
Original file line number Diff line number Diff line change
@@ -1,24 +1,36 @@
name = "JPEC"
uuid = "462872dd-e066-4d2e-b993-6468b5239634"
license = "MIT"
authors = ["Matthew Pharr <matthewcpharr@gmail.com>", "Rithik Banerjee <rb3736@columbia.edu>", "Jaebeom Cho <aspire1019@snu.ac.kr>", "Jacob Halpern <jmh2363@columbia.edu>"]
version = "0.1.0"
authors = ["Matthew Pharr <matthewcpharr@gmail.com>", "Rithik Banerjee <rb3736@columbia.edu>", "Jaebeom Cho <aspire1019@snu.ac.kr>", "Jacob Halpern <jmh2363@columbia.edu>"]

[deps]
AbstractTrees = "1520ce14-60c1-5f80-bbc7-55ef81b5835c"
AdaptiveArrayPools = "4f381ef7-9af0-4cbe-99d4-cf36d7b0f233"
BenchmarkTools = "6e4b80f9-dd63-53aa-95a3-0cdb28fa8baf"
DataFrames = "a93c6f00-e57d-5684-b7b6-d8193f3e46c0"
DelimitedFiles = "8bb1440f-4735-579b-a4ab-409b98df4dab"
DiffEqCallbacks = "459566f4-90b8-5000-8ac3-15dfb0a30def"
Distributions = "31c24e10-a181-5473-b8eb-7969acd0382f"
Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4"
DynamicalSystems = "61744808-ddfa-5f27-97ff-6e42cc95d634"
EFIT = "cda752c5-6b03-55a3-9e33-132a441b0c17"
FFTW = "7a1cc6ca-52ef-59f5-83cd-3a7055c09341"
FastGaussQuadrature = "442a2c76-b920-505d-bb47-c5924d526838"
FastInterpolations = "9ea80cae-fc13-4c00-8066-6eaedb12f34b"
FileIO = "5789e2e9-d7fb-5bc7-8068-2c6fae9b9549"
HDF5 = "f67ccb44-e63f-5c2f-98bd-6dc0ccc4ba2f"
IJulia = "7073ff75-c697-5162-941a-fcdaad2a7d2a"
IMASdd = "c5a45a97-b3f9-491c-b9a7-aa88c3bc0067"
JLD2 = "033835bb-8acc-5ee8-8aae-3f567f8a3819"
LaTeXStrings = "b964fa9f-0449-5b57-a5c2-d3ea65f4040f"
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
Measurements = "eff96d63-e80a-5855-80a2-b1b0885c5ab7"
OrdinaryDiffEq = "1dea7af3-3e70-54e6-95c3-0bf5283fa5ed"
Pkg = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f"
Plots = "91a5bcdd-55d7-5caf-9e0b-520d859cae80"
Printf = "de0858da-6303-5e67-8744-51eddeeeb8d7"
PyPlot = "d330b81b-6aea-500a-939a-2ce795aea3ee"
Roots = "f2b01f46-fcfa-551c-844a-d8ac1e96c665"
SpecialFunctions = "276daf66-3868-5448-9aa4-cd146d93841b"
StaticArrays = "90137ffa-7385-5640-81b9-e52037218182"
Expand All @@ -27,23 +39,41 @@ TOML = "fa267f1f-6049-4f14-aa54-33bafae1ed76"
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"

[compat]
AdaptiveArrayPools = "0.2.0"
AbstractTrees = "0.4.5"
AdaptiveArrayPools = "0.1.2"
BenchmarkTools = "1.6.3"
DataFrames = "1.8.1"
DelimitedFiles = "1.9.1"
DiffEqCallbacks = "4.9.0"
Distributions = "0.25.123"
Documenter = "1.14.1"
DynamicalSystems = "3.6.7"
EFIT = "1.2.5"
FFTW = "1.9.0"
FastGaussQuadrature = "1.1.0"
FastInterpolations = ">=0.2.13"
FileIO = "1.18.0"
HDF5 = "0.17.2"
IJulia = "1.34.2"
IMASdd = ">=8"
JLD2 = "0.6.3"
LaTeXStrings = "1.4.0"
LinearAlgebra = "1.11.0"
Measurements = "2.14.1"
OrdinaryDiffEq = "6.102.0"
Pkg = "1.11.0"
Plots = "1.40.15"
Printf = "1.11.0"
PyPlot = "2.11.6"
Roots = "2.2.13"
SpecialFunctions = "2.5.1"
StaticArrays = "1.9.15"
Statistics = "1.11.0"
Statistics = "1.11.1"
TOML = "1.0.3"
Test = "1.11.0"

[extras]
EFIT = "cda752c5-6b03-55a3-9e33-132a441b0c17"

[targets]
test = ["EFIT"]
Loading