|
2 | 2 | # 1. cout / cin / deltar all zero (no resistive plasma combination, no inner layer) |
3 | 3 | # 2. matched ξ_j == the gal coil column sols(:,:,2·msing+j) (and ξ′ likewise) |
4 | 4 | # Usage: julia --project=. benchmarks/verify_gal_ideal.jl [path/to/gpec.h5] |
| 5 | +# Requires [DEBUG] gal_basis_output = true in the deck (compares against the raw-basis dump). |
5 | 6 | using HDF5, Printf, LinearAlgebra |
6 | 7 |
|
7 | 8 | h5path = length(ARGS) >= 1 ? ARGS[1] : "/tmp/gal_ideal_test/gpec.h5" |
8 | 9 | to_c(a) = eltype(a) <: Complex ? ComplexF64.(a) : map(x -> ComplexF64(x.re, x.im), a) |
9 | 10 |
|
10 | | -cout, deltar, mxi, mdxi, sols, sols_d, sing_psi = h5open(h5path) do f |
| 11 | +cout, deltar, mxi, mdxi, sols, sols_d, iss, sing_psi = h5open(h5path) do f |
11 | 12 | (to_c(read(f["ForceFreeStates/Solutions/GalerkinIntegration/Match/cout"])), to_c(read(f["ForceFreeStates/Solutions/GalerkinIntegration/Match/Delta_r"])), |
12 | | - to_c(read(f["ForceFreeStates/Solutions/GalerkinIntegration/Match/xi"])), to_c(read(f["ForceFreeStates/Solutions/GalerkinIntegration/Match/dxidpsi"])), |
13 | | - to_c(read(f["ForceFreeStates/Solutions/GalerkinIntegration/Solution/xi_psi"])), to_c(read(f["ForceFreeStates/Solutions/GalerkinIntegration/Solution/dxi_psidpsi"])), |
14 | | - read(f["SingularSurfaces/GalerkinDeltaPrime/rational_psi"])) |
| 13 | + to_c(read(f["ForceFreeStates/Solutions/GalerkinIntegration/xi_psi"])), to_c(read(f["ForceFreeStates/Solutions/GalerkinIntegration/dxi_psidpsi"])), |
| 14 | + to_c(read(f["ForceFreeStates/Solutions/GalerkinIntegration/Basis/xi_psi"])), to_c(read(f["ForceFreeStates/Solutions/GalerkinIntegration/Basis/dxi_psidpsi"])), |
| 15 | + Bool.(read(f["ForceFreeStates/Solutions/GalerkinIntegration/Basis/is_rational"])), |
| 16 | + read(f["ForceFreeStates/Solutions/GalerkinIntegration/rational_psi"])) |
15 | 17 | end |
16 | 18 | msing = length(sing_psi) |
17 | | -mpert, ngrid, mcoil = size(mxi) |
| 19 | +mpert, mcoil, ngrid = size(mxi) |
| 20 | +keep = .!iss |
18 | 21 |
|
19 | 22 | @printf("[1] ‖cout‖ = %.2e, ‖deltar‖ = %.2e %s\n", norm(cout), norm(deltar), |
20 | 23 | (norm(cout) == 0 && norm(deltar) == 0) ? "✓ no resistive combination (ideal)" : "✗") |
21 | 24 |
|
22 | 25 | # matched ξ_j should equal the coil column sols(:,:,2msing+j) |
23 | 26 | err = maximum(1:mcoil) do j |
24 | 27 | csol = 2msing + j |
25 | | - max(norm(mxi[:, :, j] - sols[:, :, csol]), norm(mdxi[:, :, j] - sols_d[:, :, csol])) |
| 28 | + max(norm(mxi[:, j, :] - sols[:, csol, keep]), norm(mdxi[:, j, :] - sols_d[:, csol, keep])) |
26 | 29 | end |
27 | 30 | @printf("[2] max‖ξ_matched − coil column‖ = %.2e %s\n", err, |
28 | 31 | err < 1e-12 ? "✓ matched ξ == bare ideal coil column" : "✗") |
|
0 commit comments