Skip to content

Commit be590b2

Browse files
committed
ActorDynamicPlasma automatically trims last time-slice on failure
ping @bclyons12
1 parent 084a774 commit be590b2

File tree

1 file changed

+45
-26
lines changed

1 file changed

+45
-26
lines changed

src/actors/compound/dynamic_plasma_actor.jl

Lines changed: 45 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -34,42 +34,47 @@ end
3434
3535
Evolves plasma profiles forward in time using coupled physics models.
3636
37-
This compound actor advances the plasma state through time by coordinating multiple
38-
physics models with proper temporal splitting and time step management. It handles
39-
the complex coupling between transport, current evolution, heating, equilibrium,
37+
This compound actor advances the plasma state through time by coordinating multiple
38+
physics models with proper temporal splitting and time step management. It handles
39+
the complex coupling between transport, current evolution, heating, equilibrium,
4040
and magnetic control systems.
4141
4242
Time integration strategy:
43-
- Uses second-order accurate time-stepping with sub-cycling
44-
- Splits fast (equilibrium, PF) and slow (transport, pedestal) physics appropriately
45-
- Handles time-dependent boundary conditions from pulse schedule
46-
- Supports plasma current control via feedback systems
43+
44+
- Uses second-order accurate time-stepping with sub-cycling
45+
- Splits fast (equilibrium, PF) and slow (transport, pedestal) physics appropriately
46+
- Handles time-dependent boundary conditions from pulse schedule
47+
- Supports plasma current control via feedback systems
4748
4849
Evolution workflow (each time step):
49-
1. **Phase 1**: Current evolution and heating sources (δt steps)
50-
2. **Phase 2**: Pedestal and transport evolution (δt steps)
51-
3. **Both phases**: Sawteeth, equilibrium, and PF control (δt/2 sub-steps)
50+
51+
1. **Phase 1**: Current evolution and heating sources (δt steps)
52+
2. **Phase 2**: Pedestal and transport evolution (δt steps)
53+
3. **Both phases**: Sawteeth, equilibrium, and PF control (δt/2 sub-steps)
5254
5355
Key features:
54-
- Configurable evolution of individual physics components
55-
- Optional plasma current feedback control via loop voltage
56-
- Time derivative sources for energy and particle balance
57-
- Progress tracking and convergence monitoring
58-
- Automatic cleanup of post-simulation time data
56+
57+
- Configurable evolution of individual physics components
58+
- Optional plasma current feedback control via loop voltage
59+
- Time derivative sources for energy and particle balance
60+
- Progress tracking and convergence monitoring
61+
- Automatic cleanup of post-simulation time data
5962
6063
Physics models coordinated:
61-
- **ActorCurrent**: Current density diffusion and resistive evolution
62-
- **ActorHCD**: Time-dependent heating and current drive
63-
- **ActorPedestal**: Pedestal evolution and L-H transitions
64-
- **ActorCoreTransport**: Transport flux evolution
65-
- **ActorSawteeth**: Sawtooth instability cycling
66-
- **ActorEquilibrium**: MHD equilibrium with evolving profiles
67-
- **ActorPFactive**: PF coil current control for plasma shape
64+
65+
- **ActorCurrent**: Current density diffusion and resistive evolution
66+
- **ActorHCD**: Time-dependent heating and current drive
67+
- **ActorPedestal**: Pedestal evolution and L-H transitions
68+
- **ActorCoreTransport**: Transport flux evolution
69+
- **ActorSawteeth**: Sawtooth instability cycling
70+
- **ActorEquilibrium**: MHD equilibrium with evolving profiles
71+
- **ActorPFactive**: PF coil current control for plasma shape
6872
6973
Control options:
70-
- `ip_controller`: Feedback control of plasma current via loop voltage
71-
- Individual physics component enable/disable switches
72-
- Configurable time step size and number of steps
74+
75+
- `ip_controller`: Feedback control of plasma current via loop voltage
76+
- Individual physics component enable/disable switches
77+
- Configurable time step size and number of steps
7378
"""
7479
function ActorDynamicPlasma(dd::IMAS.dd, act::ParametersAllActors; kw...)
7580
actor = ActorDynamicPlasma(dd, act.ActorDynamicPlasma, act; kw...)
@@ -175,6 +180,10 @@ function _step(actor::ActorDynamicPlasma)
175180
substep(actor, Val(:run_pf_active), δt / 2; progr)
176181
end
177182

183+
catch e
184+
@warn "ActorDynamicPlasma failed at $(dd.global_time) [s], trimming the last time slice which might be in a corrupted state"
185+
IMAS.trim_time!(dd, (-Inf, dd.global_time - 1E-6))
186+
rethrow(e)
178187
finally
179188
actor_logging(dd, old_logging)
180189
end
@@ -508,7 +517,17 @@ function plot_plasma_overview(dd::IMAS.dd, time0::Float64=dd.global_time;
508517
plot!(dd1.thomson_scattering, :n_e; time0, lw=2.0, xlabel="", ylabel="", label="", primary=false)
509518
end
510519
if IMAS.hasdata(dd1.charge_exchange)
511-
plot!(dd1.charge_exchange, :n_imp; time0, lw=2.0, xlabel="", ylabel="", label="", normalization=dd1.core_profiles.profiles_1d[time0].ion[2].element[1].z_n, primary=false)
520+
plot!(
521+
dd1.charge_exchange,
522+
:n_imp;
523+
time0,
524+
lw=2.0,
525+
xlabel="",
526+
ylabel="",
527+
label="",
528+
normalization=dd1.core_profiles.profiles_1d[time0].ion[2].element[1].z_n,
529+
primary=false
530+
)
512531
end
513532
end
514533
if dd !== dd1

0 commit comments

Comments
 (0)