diff --git a/DOC/coordinates-and-fields.md b/DOC/coordinates-and-fields.md index eb0a269d..f5a88a19 100644 --- a/DOC/coordinates-and-fields.md +++ b/DOC/coordinates-and-fields.md @@ -395,6 +395,11 @@ evaluation is needed. | SPECTRE | `src/field/field_can_spectre.f90` | $\rho_g$ | Meiss per volume (section 6) | | test | `src/field/field_can_test.f90` | $r$ | analytic circular tokamak | +libneo checks a VMEC file before it builds Boozer coordinates (radial force +balance and resolution) and stops when the file fails. `allow_poor_equilibrium += .true.` with a non-empty `poor_equilibrium_reason` turns the stop into a +logged override, passed as `sfl_quality_config_t` to `get_boozer_coordinates`. + Canonical-flux construction and conversion share the selected, read-only field object across OpenMP threads. The construction/conversion phase flag is also shared and changes only outside the parallel regions; coordinate scratch diff --git a/docs/input-reference.json b/docs/input-reference.json index a787e0f8..d3d37e1d 100644 --- a/docs/input-reference.json +++ b/docs/input-reference.json @@ -4,7 +4,7 @@ "namelists": { "config": { "source": "src/params.f90", - "source_line": 304, + "source_line": 305, "variables": [ { "name": "notrace_passing", @@ -17,7 +17,7 @@ "default_value": "0", "documentation": "Further configuration parameters", "source": "src/params.f90", - "source_line": 188, + "source_line": 189, "validation": { "min": 0, "max": 1 @@ -34,7 +34,7 @@ "default_value": "1000", "documentation": "", "source": "src/params.f90", - "source_line": 30, + "source_line": 31, "validation": { "min": 1 } @@ -50,7 +50,7 @@ "default_value": "100", "documentation": "", "source": "src/params.f90", - "source_line": 194, + "source_line": 195, "validation": { "min": 1 } @@ -66,7 +66,7 @@ "default_value": "10000", "documentation": "", "source": "src/params.f90", - "source_line": 194, + "source_line": 195, "validation": { "min": 2 } @@ -82,7 +82,7 @@ "default_value": "1024", "documentation": "", "source": "src/params.f90", - "source_line": 30, + "source_line": 31, "validation": { "min": 1 } @@ -98,7 +98,7 @@ "default_value": "1d-1", "documentation": "", "source": "src/params.f90", - "source_line": 193, + "source_line": 194, "validation": { "positive": true } @@ -114,7 +114,7 @@ "default_value": "1", "documentation": "", "source": "src/params.f90", - "source_line": 234, + "source_line": 235, "validation": { "min": 0, "max": 2 @@ -135,7 +135,7 @@ "default_value": "0.5d0", "documentation": "", "source": "src/params.f90", - "source_line": 35 + "source_line": 36 }, { "name": "phibeg", @@ -148,7 +148,7 @@ "default_value": "0d0", "documentation": "", "source": "src/params.f90", - "source_line": 32 + "source_line": 33 }, { "name": "thetabeg", @@ -161,7 +161,7 @@ "default_value": "0.0d0", "documentation": "", "source": "src/params.f90", - "source_line": 36 + "source_line": 37 }, { "name": "contr_pp", @@ -174,7 +174,7 @@ "default_value": "-1d0", "documentation": "", "source": "src/params.f90", - "source_line": 76 + "source_line": 77 }, { "name": "face_al", @@ -187,7 +187,7 @@ "default_value": "1d0", "documentation": "", "source": "src/params.f90", - "source_line": 189, + "source_line": 190, "validation": { "positive": true } @@ -203,7 +203,7 @@ "default_value": "-1.0_dp", "documentation": "particle energy in eV; <= 0 selects 3.5 MeV/facE_al", "source": "src/params.f90", - "source_line": 191 + "source_line": 192 }, { "name": "npoiper2", @@ -216,7 +216,7 @@ "default_value": "256", "documentation": "", "source": "src/params.f90", - "source_line": 194, + "source_line": 195, "validation": { "min": 1 } @@ -232,7 +232,7 @@ "default_value": "2", "documentation": "", "source": "src/params.f90", - "source_line": 194 + "source_line": 195 }, { "name": "n_d", @@ -245,7 +245,7 @@ "default_value": "4", "documentation": "", "source": "src/params.f90", - "source_line": 195, + "source_line": 196, "validation": { "positive": true } @@ -326,7 +326,7 @@ "default_value": ".False.", "documentation": "", "source": "src/params.f90", - "source_line": 78 + "source_line": 79 }, { "name": "startmode", @@ -339,7 +339,7 @@ "default_value": "1", "documentation": "", "source": "src/params.f90", - "source_line": 79, + "source_line": 80, "validation": { "min": 1, "max": 7 @@ -360,7 +360,7 @@ "default_value": "(/128, 32, 32/)", "documentation": "", "source": "src/params.f90", - "source_line": 80 + "source_line": 81 }, { "name": "grid_density", @@ -373,7 +373,7 @@ "default_value": "0d0", "documentation": "", "source": "src/params.f90", - "source_line": 97, + "source_line": 98, "validation": { "min": 0, "max": 1 @@ -390,7 +390,7 @@ "default_value": "'nbi_beamlets.dat'", "documentation": "Neutral beam births (startmode 8): beamlet file, path step and length [m].", "source": "src/params.f90", - "source_line": 82 + "source_line": 83 }, { "name": "nbi_path_step", @@ -403,7 +403,7 @@ "default_value": "0.005d0", "documentation": "", "source": "src/params.f90", - "source_line": 83 + "source_line": 84 }, { "name": "nbi_path_length", @@ -416,7 +416,7 @@ "default_value": "8.0d0", "documentation": "", "source": "src/params.f90", - "source_line": 83 + "source_line": 84 }, { "name": "nbi_torque_bins", @@ -429,7 +429,7 @@ "default_value": "50", "documentation": "Radial bins of the beam torque tally in VMEC s; 0 switches the tally off, as needed on chartmap reference coordinates.", "source": "src/params.f90", - "source_line": 86 + "source_line": 87 }, { "name": "ntv_tally", @@ -442,7 +442,7 @@ "default_value": ".false.", "documentation": "Thermal delta-f NTV tally (thermal_ntv.f90), writes thermal_ntv.dat.", "source": "src/params.f90", - "source_line": 88 + "source_line": 89 }, { "name": "ntv_drive", @@ -459,7 +459,7 @@ "default_value": "0.0d0", "documentation": "A_1, A_2 of the weight equation dw = -(A_1 + A_2 E/T) dP/(dP/ds).", "source": "src/params.f90", - "source_line": 90 + "source_line": 91 }, { "name": "ntv_temperature_ev", @@ -472,7 +472,7 @@ "default_value": "0.0d0", "documentation": "Background temperature T of the tally [eV].", "source": "src/params.f90", - "source_line": 92 + "source_line": 93 }, { "name": "ntv_bin", @@ -489,7 +489,7 @@ "default_value": "(/0.0d0, 1.0d0/)", "documentation": "Range of the birth s of the markers whose torque is tallied.", "source": "src/params.f90", - "source_line": 94 + "source_line": 95 }, { "name": "ntv_window_start", @@ -502,7 +502,7 @@ "default_value": "0.0d0", "documentation": "Start of the tally window [s].", "source": "src/params.f90", - "source_line": 96 + "source_line": 97 }, { "name": "special_ants_file", @@ -515,7 +515,7 @@ "default_value": ".False.", "documentation": "", "source": "src/params.f90", - "source_line": 98 + "source_line": 99 }, { "name": "integmode", @@ -528,7 +528,7 @@ "default_value": "1", "documentation": "", "source": "src/params.f90", - "source_line": 106, + "source_line": 107, "validation": { "choices": [ -1, @@ -555,7 +555,7 @@ "default_value": "0", "documentation": "", "source": "src/params.f90", - "source_line": 132, + "source_line": 133, "validation": { "choices": [ 0, @@ -574,7 +574,7 @@ "default_value": "0", "documentation": "Chart for the full-orbit field+geometry: full orbit currently supports only orbit_coord = 1 (Boozer/chartmap), which shares the production GC field.", "source": "src/params.f90", - "source_line": 136, + "source_line": 137, "validation": { "choices": [ 0, @@ -593,7 +593,7 @@ "default_value": "1d-13", "documentation": "", "source": "src/params.f90", - "source_line": 140, + "source_line": 141, "validation": { "positive": true } @@ -609,7 +609,7 @@ "default_value": "'off'", "documentation": "GPU execution is configured in the same namelist as the CPU run. Native CUDA with tuned DOPRI is the default production path. The legacy OpenACC path remains available only when selected explicitly.", "source": "src/params.f90", - "source_line": 111, + "source_line": 112, "validation": { "choices": [ "off", @@ -629,7 +629,7 @@ "default_value": "'cuda-native'", "documentation": "", "source": "src/params.f90", - "source_line": 112, + "source_line": 113, "validation": { "choices": [ "openacc", @@ -649,7 +649,7 @@ "default_value": "'dopri'", "documentation": "", "source": "src/params.f90", - "source_line": 113, + "source_line": 114, "validation": { "choices": [ "auto", @@ -671,7 +671,7 @@ "default_value": "'reference'", "documentation": "", "source": "src/params.f90", - "source_line": 114, + "source_line": 115, "validation": { "choices": [ "reference", @@ -690,7 +690,7 @@ "default_value": ".true.", "documentation": "", "source": "src/params.f90", - "source_line": 115 + "source_line": 116 }, { "name": "gpu_compact_init", @@ -703,7 +703,7 @@ "default_value": ".false.", "documentation": "", "source": "src/params.f90", - "source_line": 116 + "source_line": 117 }, { "name": "gpu_work_order", @@ -716,7 +716,7 @@ "default_value": ".true.", "documentation": "", "source": "src/params.f90", - "source_line": 117 + "source_line": 118 }, { "name": "gpu_num_devices", @@ -729,7 +729,7 @@ "default_value": "1", "documentation": "GPUs per process; 0 = every visible GPU", "source": "src/params.f90", - "source_line": 118, + "source_line": 119, "validation": { "min": 0 } @@ -745,7 +745,7 @@ "default_value": "1.0d-3", "documentation": "", "source": "src/params.f90", - "source_line": 119, + "source_line": 120, "validation": { "positive": true } @@ -761,7 +761,7 @@ "default_value": "0.1d0", "documentation": "", "source": "src/params.f90", - "source_line": 120, + "source_line": 121, "validation": { "positive": true } @@ -777,7 +777,7 @@ "default_value": "0.02d0", "documentation": "", "source": "src/params.f90", - "source_line": 121, + "source_line": 122, "validation": { "nonnegative": true } @@ -793,7 +793,7 @@ "default_value": "1.0d-10", "documentation": "", "source": "src/params.f90", - "source_line": 122, + "source_line": 123, "validation": { "nonnegative": true } @@ -809,7 +809,7 @@ "default_value": "0.04d0", "documentation": "", "source": "src/params.f90", - "source_line": 123, + "source_line": 124, "validation": { "min": 0, "max": 0.25 @@ -826,7 +826,7 @@ "default_value": "''", "documentation": "", "source": "src/params.f90", - "source_line": 124 + "source_line": 125 }, { "name": "symplectic_newton_warning_mode", @@ -852,7 +852,7 @@ "default_value": "1000", "documentation": "RK recoveries one marker may need before it counts as unresolved.", "source": "src/params.f90", - "source_line": 243 + "source_line": 244 }, { "name": "boundary_event_fraction_tolerance", @@ -891,7 +891,7 @@ "default_value": "62", "documentation": "", "source": "src/params.f90", - "source_line": 146, + "source_line": 147, "validation": { "min": 6, "max": 512 @@ -908,7 +908,7 @@ "default_value": "63", "documentation": "", "source": "src/params.f90", - "source_line": 147, + "source_line": 148, "validation": { "min": 6, "max": 512 @@ -925,7 +925,7 @@ "default_value": "64", "documentation": "", "source": "src/params.f90", - "source_line": 148, + "source_line": 149, "validation": { "min": 6, "max": 512 @@ -942,7 +942,7 @@ "default_value": "1d-11", "documentation": "", "source": "src/params.f90", - "source_line": 149, + "source_line": 150, "validation": { "positive": true } @@ -958,7 +958,7 @@ "default_value": "-1d0", "documentation": "", "source": "src/params.f90", - "source_line": 170 + "source_line": 171 }, { "name": "nturns", @@ -971,7 +971,7 @@ "default_value": "8", "documentation": "", "source": "src/params.f90", - "source_line": 172 + "source_line": 173 }, { "name": "debug", @@ -984,7 +984,7 @@ "default_value": ".False.", "documentation": "", "source": "src/params.f90", - "source_line": 226 + "source_line": 227 }, { "name": "class_plot", @@ -997,7 +997,7 @@ "default_value": ".False.", "documentation": "<=AAA", "source": "src/params.f90", - "source_line": 173 + "source_line": 174 }, { "name": "cut_in_per", @@ -1010,7 +1010,7 @@ "default_value": "0d0", "documentation": "<=AAA", "source": "src/params.f90", - "source_line": 174, + "source_line": 175, "validation": { "min": 0, "max": 1 @@ -1027,7 +1027,7 @@ "default_value": ".False.", "documentation": "", "source": "src/params.f90", - "source_line": 176 + "source_line": 177 }, { "name": "vmec_b_scale", @@ -1042,6 +1042,32 @@ "source": "libneo/src/vmec_support/canonical_coordinates_mod.f90", "source_line": 19 }, + { + "name": "allow_poor_equilibrium", + "type": "logical", + "kind": "", + "length": "", + "shape": [], + "extent": [], + "default": ".false.", + "default_value": ".false.", + "documentation": "Accept a VMEC equilibrium that fails libneo's Boozer quality check (for example radial force balance). The reason is required and is logged by libneo with the overridden status.", + "source": "src/field_can.f90", + "source_line": 41 + }, + { + "name": "poor_equilibrium_reason", + "type": "character", + "kind": "", + "length": "256", + "shape": [], + "extent": [], + "default": "''", + "default_value": "''", + "documentation": "", + "source": "src/field_can.f90", + "source_line": 42 + }, { "name": "vmec_rz_scale", "type": "real", @@ -1066,7 +1092,7 @@ "default_value": ".False.", "documentation": "Colliding with D-T reactor plasma. TODO: Make configurable", "source": "src/params.f90", - "source_line": 180 + "source_line": 181 }, { "name": "collision_model", @@ -1079,7 +1105,7 @@ "default_value": "'full'", "documentation": "'full' (Coulomb operator), 'lorentz_nustar' (monoenergetic pitch scattering), or the full operator restricted to one part for diagnostics: 'full_no_pitch' (slowing down and energy diffusion), 'pitch_only' (pitch scattering at fixed energy) or 'drag_only' (slowing down without energy diffusion or pitch scattering)", "source": "src/params.f90", - "source_line": 204, + "source_line": 205, "validation": { "choices": [ "full", @@ -1098,7 +1124,7 @@ "default_value": "'adaptive'", "documentation": "Collision step of the full operator: 'adaptive' (substepped, default) or 'euler', one Euler-Maruyama step per microstep in (p, lambda), term for term ASCOT5's mccc_gc_euler step, for marker-wise comparison.", "source": "src/params.f90", - "source_line": 208 + "source_line": 209 }, { "name": "collision_noise", @@ -1111,7 +1137,7 @@ "default_value": "'random'", "documentation": "Noise of the 'euler' scheme: 'random' (the marker's stream), 'counter' (shared with ASCOT5: a function of collision_noise_seed, marker index and microstep) or 'zero' (drift only)", "source": "src/params.f90", - "source_line": 212 + "source_line": 213 }, { "name": "collision_noise_seed", @@ -1124,7 +1150,7 @@ "default_value": "0", "documentation": "", "source": "src/params.f90", - "source_line": 213 + "source_line": 214 }, { "name": "thermal_stop_factor", @@ -1137,7 +1163,7 @@ "default_value": "0.0d0", "documentation": "Stop a collisional marker once E < thermal_stop_factor*T_i(s); 0 disables.", "source": "src/params.f90", - "source_line": 215 + "source_line": 216 }, { "name": "nu_star_standard", @@ -1150,7 +1176,7 @@ "default_value": "-1.0_dp", "documentation": "Lorentz mode: nu* = R0*nu/(abs(iota)*v0), must be >= 0", "source": "src/params.f90", - "source_line": 217 + "source_line": 218 }, { "name": "lorentz_major_radius_cm", @@ -1163,7 +1189,7 @@ "default_value": "-1.0_dp", "documentation": "Lorentz mode: local major radius R0 in cm, must be > 0", "source": "src/params.f90", - "source_line": 219 + "source_line": 220 }, { "name": "lorentz_iota", @@ -1176,7 +1202,7 @@ "default_value": "0.0_dp", "documentation": "Lorentz mode: local rotational transform, must be nonzero", "source": "src/params.f90", - "source_line": 221 + "source_line": 222 }, { "name": "radial_electric_potential_slope", @@ -1189,7 +1215,7 @@ "default_value": "0.0_dp", "documentation": "slope of Phi(s) = slope*s, added to the Boozer Hamiltonian H (normalized units)", "source": "src/params.f90", - "source_line": 224 + "source_line": 225 }, { "name": "deterministic", @@ -1202,7 +1228,7 @@ "default_value": ".False.", "documentation": "", "source": "src/params.f90", - "source_line": 185 + "source_line": 186 }, { "name": "old_axis_healing", @@ -1315,7 +1341,7 @@ "default_value": "2.0d0", "documentation": "", "source": "src/params.f90", - "source_line": 181 + "source_line": 182 }, { "name": "am2", @@ -1328,7 +1354,7 @@ "default_value": "3.0d0", "documentation": "", "source": "src/params.f90", - "source_line": 181 + "source_line": 182 }, { "name": "z1", @@ -1341,7 +1367,7 @@ "default_value": "1.0d0", "documentation": "", "source": "src/params.f90", - "source_line": 181 + "source_line": 182 }, { "name": "z2", @@ -1354,7 +1380,7 @@ "default_value": "1.0d0", "documentation": "", "source": "src/params.f90", - "source_line": 181 + "source_line": 182 }, { "name": "densi1", @@ -1367,7 +1393,7 @@ "default_value": "0.5d14", "documentation": "", "source": "src/params.f90", - "source_line": 181 + "source_line": 182 }, { "name": "densi2", @@ -1380,7 +1406,7 @@ "default_value": "0.5d14", "documentation": "", "source": "src/params.f90", - "source_line": 181 + "source_line": 182 }, { "name": "tempi1", @@ -1393,7 +1419,7 @@ "default_value": "1.0d4", "documentation": "", "source": "src/params.f90", - "source_line": 181 + "source_line": 182 }, { "name": "tempi2", @@ -1406,7 +1432,7 @@ "default_value": "1.0d4", "documentation": "", "source": "src/params.f90", - "source_line": 181 + "source_line": 182 }, { "name": "tempe", @@ -1419,7 +1445,7 @@ "default_value": "1.0d4", "documentation": "", "source": "src/params.f90", - "source_line": 181 + "source_line": 182 }, { "name": "batch_size", @@ -1432,7 +1458,7 @@ "default_value": "2000000000", "documentation": "Initialize large so batch mode is not default", "source": "src/params.f90", - "source_line": 231, + "source_line": 232, "validation": { "min": 1 } @@ -1448,7 +1474,7 @@ "default_value": "42", "documentation": "", "source": "src/params.f90", - "source_line": 233 + "source_line": 234 }, { "name": "particle_index_offset", @@ -1461,7 +1487,7 @@ "default_value": "0", "documentation": "", "source": "src/params.f90", - "source_line": 232 + "source_line": 233 }, { "name": "reuse_batch", @@ -1474,7 +1500,7 @@ "default_value": ".False.", "documentation": "", "source": "src/params.f90", - "source_line": 235 + "source_line": 236 }, { "name": "field_input", @@ -1487,7 +1513,7 @@ "default_value": "''", "documentation": "", "source": "src/params.f90", - "source_line": 245 + "source_line": 246 }, { "name": "coord_input", @@ -1500,7 +1526,7 @@ "default_value": "''", "documentation": "", "source": "src/params.f90", - "source_line": 246 + "source_line": 247 }, { "name": "profile_label_file", @@ -1513,7 +1539,7 @@ "default_value": "''", "documentation": "Optional netCDF profile label s(R, phi, Z) for the collision profiles with integ_coords = REFCOORDS, MEISS or ALBERT (format: src/profile_label.f90).", "source": "src/params.f90", - "source_line": 249 + "source_line": 250 }, { "name": "marker_weight_file", @@ -1526,7 +1552,7 @@ "default_value": "''", "documentation": "Optional file with one relative source weight per start.dat row (startmode 2 or 6), written to results.nc marker_weight.", "source": "src/params.f90", - "source_line": 253 + "source_line": 254 }, { "name": "wall_input", @@ -1539,7 +1565,7 @@ "default_value": "''", "documentation": "", "source": "src/params.f90", - "source_line": 250 + "source_line": 251 }, { "name": "wall_units", @@ -1552,7 +1578,7 @@ "default_value": "'m'", "documentation": "", "source": "src/params.f90", - "source_line": 255, + "source_line": 256, "validation": { "choices": [ "m", @@ -1571,7 +1597,7 @@ "default_value": "-1.0_dp", "documentation": "-1: LCFS radius, 0: all chords, >0: chart-radius cutoff", "source": "src/params.f90", - "source_line": 256 + "source_line": 257 }, { "name": "chart_boundary_kind", @@ -1584,7 +1610,7 @@ "default_value": "'auto'", "documentation": "", "source": "src/params.f90", - "source_line": 259, + "source_line": 260, "validation": { "choices": [ "auto", @@ -1605,7 +1631,7 @@ "default_value": "-1000", "documentation": "Sentinel: -1000 means user did not set it", "source": "src/params.f90", - "source_line": 261 + "source_line": 262 }, { "name": "crossing_level", @@ -1618,7 +1644,7 @@ "default_value": "3", "documentation": "SPECTRE interface treatment: only full orbit (3) is supported.", "source": "src/params.f90", - "source_line": 263, + "source_line": 264, "validation": { "choices": [ 3 @@ -1636,7 +1662,7 @@ "default_value": "1.5_dp", "documentation": "Full orbit near SPECTRE interfaces: entry distance in radial gyroradii and the relative tolerance of RK45 on the sharp per-volume field. 1.5 keeps the switch's p_zeta invariant as at 3 (entry 1 breaks it) at about half the FO time (concept/spectre_loss_study/results/fo-residence).", "source": "src/params.f90", - "source_line": 268, + "source_line": 269, "validation": { "positive": true } @@ -1652,7 +1678,7 @@ "default_value": "1.0e-9_dp", "documentation": "", "source": "src/params.f90", - "source_line": 269, + "source_line": 270, "validation": { "positive": true } @@ -1672,7 +1698,7 @@ "default_value": "(/32, 64, 32/)", "documentation": "Per-volume FO spline points: rho, theta, zeta per field period.", "source": "src/params.f90", - "source_line": 271 + "source_line": 272 }, { "name": "spectre_outer_loss", @@ -1685,7 +1711,7 @@ "default_value": "'guiding_centre'", "documentation": "Loss at the outer SPECTRE boundary: 'guiding_centre' when the guiding centre crosses it, as for VMEC and GVEC fields; 'particle' when the full orbit touches it, a finite-Larmor-radius loss.", "source": "src/params.f90", - "source_line": 275 + "source_line": 276 }, { "name": "spectre_fo_jump_tol", @@ -1698,7 +1724,7 @@ "default_value": "1.0e-3_dp", "documentation": "Interfaces whose largest jump of |B|/B or of the field direction is below this are crossed by the guiding centre directly, with an error of that size per crossing, instead of in full orbit.", "source": "src/params.f90", - "source_line": 279 + "source_line": 280 }, { "name": "spectre_sbeg_is_toroidal_flux", @@ -1711,7 +1737,7 @@ "default_value": ".false.", "documentation": "", "source": "src/params.f90", - "source_line": 280 + "source_line": 281 }, { "name": "spectre_ncon_r", @@ -1724,7 +1750,7 @@ "default_value": "48", "documentation": "SPECTRE per-volume Meiss construction grid (n_r, n_th, n_phi). Each volume allocates rank-3 arrays plus batch splines of this size, so the total peak memory scales as Mvol*n_r*n_th*n_phi. spectre_ncon_phi = -1 means automatic: 32 for fields with toroidal harmonics and a minimal phi grid for axisymmetric fields (all n = 0), the dominant memory saver for tokamak cases. A positive value forces that phi count verbatim, bypassing the axisymmetric clamp.", "source": "src/params.f90", - "source_line": 289, + "source_line": 290, "validation": { "min": 1 } @@ -1740,7 +1766,7 @@ "default_value": "48", "documentation": "", "source": "src/params.f90", - "source_line": 290, + "source_line": 291, "validation": { "min": 1 } @@ -1756,7 +1782,7 @@ "default_value": "-1", "documentation": "", "source": "src/params.f90", - "source_line": 291 + "source_line": 292 }, { "name": "spectre_ncon_order", @@ -1769,7 +1795,7 @@ "default_value": "5", "documentation": "", "source": "src/params.f90", - "source_line": 292, + "source_line": 293, "validation": { "min": 1 } @@ -1785,7 +1811,7 @@ "default_value": "1000000", "documentation": "", "source": "src/params.f90", - "source_line": 293, + "source_line": 294, "validation": { "min": 1 } @@ -1801,7 +1827,7 @@ "default_value": "1.0e-2_dp", "documentation": "", "source": "src/params.f90", - "source_line": 294, + "source_line": 295, "validation": { "positive": true } @@ -1817,7 +1843,7 @@ "default_value": ".False.", "documentation": "", "source": "src/params.f90", - "source_line": 227 + "source_line": 228 }, { "name": "output_error", @@ -1856,7 +1882,7 @@ "default_value": "'linear'", "documentation": "", "source": "src/params.f90", - "source_line": 102, + "source_line": 103, "validation": { "choices": [ "linear", @@ -1875,7 +1901,7 @@ "default_value": "10.0d0", "documentation": "Legacy progress/checkpoint interval, retained for input compatibility. Tracing performs no timed I/O; results and event totals are emitted after the OpenMP team joins.", "source": "src/params.f90", - "source_line": 145 + "source_line": 146 }, { "name": "restart", @@ -1888,7 +1914,7 @@ "default_value": ".False.", "documentation": "", "source": "src/params.f90", - "source_line": 228 + "source_line": 229 }, { "name": "local", @@ -1901,7 +1927,7 @@ "default_value": ".true.", "documentation": "Removed &config keys. They are still read so that old input files run; a value other than the historical default prints a warning.", "source": "src/params.f90", - "source_line": 298 + "source_line": 299 }, { "name": "loopskip", @@ -1914,7 +1940,7 @@ "default_value": "0", "documentation": "", "source": "src/params.f90", - "source_line": 299 + "source_line": 300 }, { "name": "bmod_ref", @@ -1927,7 +1953,7 @@ "default_value": "5.0d4", "documentation": "", "source": "src/params.f90", - "source_line": 300 + "source_line": 301 }, { "name": "macrostep_log_ratio", @@ -1940,7 +1966,7 @@ "default_value": "1.0d3", "documentation": "", "source": "src/params.f90", - "source_line": 301 + "source_line": 302 }, { "name": "field_tables_order", @@ -1953,7 +1979,7 @@ "default_value": "0", "documentation": "", "source": "src/params.f90", - "source_line": 302 + "source_line": 303 } ] }, diff --git a/docs/input-reference.rst b/docs/input-reference.rst index 9a5e66a9..55bc48e2 100644 --- a/docs/input-reference.rst +++ b/docs/input-reference.rst @@ -25,7 +25,7 @@ and ``DOC/config.md`` for additional usage, units and option interactions. &config ------- -Source: ``src/params.f90:304``. +Source: ``src/params.f90:305``. .. list-table:: :header-rows: 1 @@ -445,6 +445,18 @@ Source: ``src/params.f90:304``. - ``scalar`` - ``1d0`` - + * - ``allow_poor_equilibrium`` + - ``logical`` + - ``default`` + - ``scalar`` + - ``.false.`` + - Accept a VMEC equilibrium that fails libneo's Boozer quality check (for example radial force balance). The reason is required and is logged by libneo with the overridden status. + * - ``poor_equilibrium_reason`` + - ``character(len=256)`` + - ``default`` + - ``scalar`` + - ``''`` + - * - ``vmec_rz_scale`` - ``real`` - ``kind(1d0)`` diff --git a/examples/simple_full.in b/examples/simple_full.in index 6b07bc4f..a7c5860e 100644 --- a/examples/simple_full.in +++ b/examples/simple_full.in @@ -103,6 +103,9 @@ multharm = 5 ! VMEC angular spline grid: n_theta = m_max*mul ! n_phi = n_max*multharm + 1 vmec_B_scale = 1d0 ! factor applied to the VMEC magnetic field vmec_RZ_scale = 1d0 ! factor applied to the VMEC R and Z (device size) +allow_poor_equilibrium = .false. ! .true.: build Boozer coordinates from a VMEC file that fails +! libneo's quality check (e.g. radial force balance) +poor_equilibrium_reason = '' ! required with allow_poor_equilibrium; logged by libneo canonical_grid_nr = 62 ! MEISS/ALBERT canonical map grid, radial; 6..512 canonical_grid_ntheta = 63 ! MEISS/ALBERT canonical map grid, poloidal; 6..512 canonical_grid_nphi = 64 ! MEISS/ALBERT canonical map grid, toroidal; 6..512; diff --git a/src/field_can.f90 b/src/field_can.f90 index 1dd57845..73f89005 100644 --- a/src/field_can.f90 +++ b/src/field_can.f90 @@ -35,6 +35,12 @@ module field_can_mod !> chart evaluates it. logical :: regular_axis_field = .false. +!> Accept a VMEC equilibrium that fails libneo's Boozer quality check (for +!> example radial force balance). The reason is required and is logged by +!> libneo with the overridden status. + logical :: allow_poor_equilibrium = .false. + character(len=256) :: poor_equilibrium_reason = '' + contains subroutine set_regular_axis_field(enabled) @@ -188,6 +194,7 @@ subroutine init_field_can(field_id, field_noncan, n_r, n_th, n_phi, & transformation_relerr) use get_can_sub, only : get_canonical_coordinates, get_canonical_coordinates_with_field use boozer_sub, only : get_boozer_coordinates + use boozer_hybrid_quality, only: sfl_quality_config_t use boozer_chartmap, only : load_boozer_from_chartmap use field_can_meiss, only : get_meiss_coordinates use field_can_albert, only : get_albert_coordinates @@ -198,6 +205,12 @@ subroutine init_field_can(field_id, field_noncan, n_r, n_th, n_phi, & integer, intent(in), optional :: n_r, n_th, n_phi real(dp), intent(in), optional :: transformation_relerr type(vmec_field_t) :: vmec_field + type(sfl_quality_config_t) :: quality + + if (allow_poor_equilibrium .and. len_trim(poor_equilibrium_reason) == 0) error stop & + 'init_field_can: allow_poor_equilibrium needs poor_equilibrium_reason' + quality%allow_poor_equilibrium = allow_poor_equilibrium + quality%override_reason = poor_equilibrium_reason ! The libneo Boozer builders read this switch; set it on every ! initialisation so a library run that changes fields starts clean. @@ -219,7 +232,7 @@ subroutine init_field_can(field_id, field_noncan, n_r, n_th, n_phi, & integ_to_ref => integ_to_ref_boozer_chartmap ref_to_integ => ref_to_integ_boozer_chartmap class default - call get_boozer_coordinates() + call get_boozer_coordinates(quality=quality) end select case (MEISS) call get_meiss_coordinates @@ -242,7 +255,7 @@ subroutine init_field_can(field_id, field_noncan, n_r, n_th, n_phi, & call get_canonical_coordinates case (BOOZER) call field_can_from_id(field_id) - call get_boozer_coordinates + call get_boozer_coordinates(quality=quality) case (MEISS) call create_vmec_field(vmec_field) call field_can_from_id(field_id, vmec_field, n_r, n_th, n_phi, & diff --git a/src/params.f90 b/src/params.f90 index 83f78cc3..ffb84278 100644 --- a/src/params.f90 +++ b/src/params.f90 @@ -10,7 +10,8 @@ module params vmec_RZ_scale use velo_mod, only: isw_field_type use magfie_sub, only: TEST, BOOZER - use field_can_mod, only: eval_field => evaluate, field_can_t + use field_can_mod, only: eval_field => evaluate, field_can_t, & + allow_poor_equilibrium, poor_equilibrium_reason use field_can_base, only: set_radial_electric_potential_slope use orbit_symplectic_base, only: symplectic_integrator_t, multistage_integrator_t, & EXPL_IMPL_EULER, & @@ -319,6 +320,7 @@ module params canonical_ode_relerr, & tcut, nturns, debug, & class_plot, cut_in_per, fast_class, vmec_B_scale, & + allow_poor_equilibrium, poor_equilibrium_reason, & vmec_RZ_scale, swcoll, collision_model, collision_scheme, collision_noise, & collision_noise_seed, thermal_stop_factor, nu_star_standard, & lorentz_major_radius_cm, lorentz_iota, radial_electric_potential_slope, &