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
11 changes: 2 additions & 9 deletions .github/copilot-instructions.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
# Copilot instructions for JPEC

## Project overview
- JPEC is a Julia/Fortran hybrid port of GPEC for MHD equilibrium and stability analysis. Core modules live in [src](src): Splines, Equilibrium, Vacuum, DCON (see [CLAUDE.md](CLAUDE.md)).
- 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)).
- Data flow: equilibrium setup → vacuum response → stability analysis (documented in [CLAUDE.md](CLAUDE.md)).
- Vacuum is mid-conversion from Fortran to Julia; Fortran libraries are built and called via `ccall` (see [deps/build.jl](deps/build.jl)).

## Architecture and entry points
- Equilibrium: `setup_equilibrium(path|config)`; types in [src/Equilibrium](src/Equilibrium).
- Vacuum: `compute_vacuum_response()` (Julia) and `mscvac()` (Fortran); code in [src/Vacuum](src/Vacuum) and [src/Vacuum/fortran](src/Vacuum/fortran).
- Vacuum: `compute_vacuum_response()`; code in [src/Vacuum](src/Vacuum).
- DCON stability: entry points in [src/DCON/Main.jl](src/DCON/Main.jl).
- Splines: Julia + Fortran implementations in [src/Splines](src/Splines).

## Data flow and key structures
- Equilibrium: TOML config → read equilibrium → solve → diagnostics (gse*.h5) when relevant.
Expand Down Expand Up @@ -42,11 +40,6 @@
- Avoid step numbering in comments; instructions should be unnumbered (see [CLAUDE.md](CLAUDE.md)).
- Many routines use 0-based indexing to mirror Fortran conventions before converting to 1-based Julia (see [CLAUDE.md](CLAUDE.md)).

## Fortran integration notes
- Builds configured in [deps/build.jl](deps/build.jl) and [deps/build_helpers.jl](deps/build_helpers.jl); macOS uses Accelerate and Linux uses OpenBLAS.
- `ccall` uses mangled names; see [src/Vacuum/Vacuum.jl](src/Vacuum/Vacuum.jl) and [src/Splines/CubicSpline.jl](src/Splines/CubicSpline.jl) for patterns.
- Add new Fortran builds via `build_*_fortran()` in [deps/build_helpers.jl](deps/build_helpers.jl).

## Configuration examples
- TOML configs: `equil.toml` uses `[EQUIL_CONTROL]` and `[EQUIL_OUTPUT]`; `dcon.toml` uses `[DCON_CONTROL]` and `[WALL]`.
- Example configs in [examples/DIIID-like_ideal_example](examples/DIIID-like_ideal_example) and [examples/Solovev_ideal_example](examples/Solovev_ideal_example).
Expand Down
23 changes: 9 additions & 14 deletions .github/workflows/copilot-setup-steps.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,47 +3,42 @@ name: "Copilot Setup Steps"
# Automatically run the setup steps when they are changed to allow for easy validation,
# and allow manual testing through the repository's "Actions" tab
on:
workflow_dispatch:
workflow_dispatch:
push:
paths:
paths:
- .github/workflows/copilot-setup-steps.yml
pull_request:
paths:
- . github/workflows/copilot-setup-steps.yml

jobs:
# The job MUST be called `copilot-setup-steps` or it will not be picked up by Copilot
copilot-setup-steps:
copilot-setup-steps:
runs-on: ubuntu-latest

# Set the permissions to the lowest permissions possible needed for your steps
permissions:
contents: read

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Set up Julia
uses: julia-actions/setup-julia@v2
with:
version: '1.11'

- name: Cache Julia packages
uses: julia-actions/cache@v2
with:
cache-name: julia-cache
cache-packages: true
cache-artifacts: true
cache-registries: true

- name: Install Fortran compiler (for Fortran dependencies)
run: |
sudo apt-get update
sudo apt-get install -y gfortran libopenblas-dev


- name: Build Julia project
run: julia --project="." -e "using Pkg; Pkg.build()"

- name: Instantiate Julia environment
run: julia --project="." -e "using Pkg; Pkg.instantiate()"
2 changes: 0 additions & 2 deletions .github/workflows/make_docs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,6 @@ jobs:
key: ${{ runner.os }}-julia-${{ hashFiles('**/Project.toml','**/Manifest.toml') }}
restore-keys: |
${{ runner.os }}-julia-${{ hashFiles('**/Project.toml','**/Manifest.toml') }}
- name: Install system dependencies
run: sudo apt-get update && sudo apt-get install -y libopenblas-dev

- name: Prepare docs environment (develop local package, then instantiate)
run: julia --project=docs -e 'using Pkg; Pkg.activate("docs"); Pkg.develop(PackageSpec(path=".")); Pkg.instantiate(update_registry=false)'
Expand Down
3 changes: 0 additions & 3 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,6 @@ jobs:
- name: Cache Julia packages
uses: julia-actions/cache@v2

- name: Install system dependencies
run: sudo apt-get update && sudo apt-get install -y libopenblas-dev

- name: Build Julia packages
uses: julia-actions/julia-buildpkg@v1

Expand Down
37 changes: 5 additions & 32 deletions CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ JPEC (Julia Perturbed Equilibrium Code) is a comprehensive Julia implementation

**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 a hybrid Julia/Fortran implementation with active Julia development alongside legacy Fortran code called via ccall. The Fortran-to-Julia conversion is largely complete, with pure Julia implementations available for all major components.
JPEC is implemented in Julia. References to “Fortran GPEC” or “legacy VACUUM” refer to the original upstream codebase, not a runtime dependency of JPEC.

**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.

Expand Down Expand Up @@ -120,19 +120,14 @@ JPEC will eventually port the PENTRC (Perturbed Equilibrium Neoclassical Toroida
### Building and Testing

```bash
# Run all tests (includes building Fortran)
julia --project=. -e 'using Pkg; Pkg.activate("."); Pkg.build(); Pkg.instantiate(); include("test/runtests.jl")'

# Build Fortran libraries only
julia --project=. -e 'using Pkg; Pkg.activate("."); Pkg.build()'
# Run all tests
julia --project=. -e 'using Pkg; Pkg.activate("."); Pkg.instantiate(); include("test/runtests.jl")'

# Run specific test file
julia --project=. test/runtests.jl test/runtests_spline.jl
julia --project=. test/runtests.jl test/runtests_solovev.jl

# Available test files:
# - test/runtests_build.jl # Fortran build verification
# - test/runtests_spline.jl # Spline interpolation
# - test/runtests_vacuum_fortran.jl # Fortran vacuum module

# - test/runtests_vacuum_julia.jl # Julia vacuum module
# - test/runtests_solovev.jl # Analytical equilibrium
# - test/runtests_ode.jl # ODE integration
Expand Down Expand Up @@ -258,12 +253,10 @@ JPEC consists of **seven main modules** organized in `src/`:
- Calculates both **interior** (grri) and **exterior** (grre) Green's functions
- Main functions:
- `compute_vacuum_response()` - Pure Julia implementation
- `mscvac()` - Legacy Fortran interface via ccall
- Key files:
- `VacuumStructs.jl` - Data structures
- `VacuumInternals.jl` - Core algorithms
- `VacuumFromEquilibrium.jl` - Integration with equilibrium data
- Fortran code in `src/Vacuum/fortran/`
- Status: **Pure Julia implementation complete and available**

5. **ForceFreeStates** (`src/ForceFreeStates/`) - Ideal MHD stability analysis (DCON-style)
Expand Down Expand Up @@ -409,26 +402,6 @@ JPEC
└── PerturbedEquilibrium (uses ForceFreeStates, Vacuum, ForcingTerms, Utilities)
```

### Fortran Integration

The build system compiles Fortran code into shared libraries for performance-critical routines:

- Build configuration in `deps/build.jl` and `deps/build_helpers.jl`
- OS-specific compiler flags:
- macOS: Uses Accelerate framework
- Linux: Uses OpenBLAS
- Current Fortran modules: Splines, Vacuum
- Compiled libraries:
- `libspline.dylib` / `libspline.so`
- `libvac.dylib` / `libvac.so`
- Platform support: **macOS and Linux only** (Windows unsupported, use WSL)
- Add new Fortran builds by creating `build_*_fortran()` functions in `deps/build_helpers.jl`

**Fortran-to-Julia Conversion Status**:
- ✅ Vacuum module: Pure Julia implementation complete
- ✅ Splines: Both implementations available for validation
- 🔄 Both implementations maintained for testing and verification

## Git Workflow

This project uses GitFlow:
Expand Down
Loading
Loading