FUSE Introductory Tutorial
Download this tutorial from the FuseExamples repository
Basic concepts
To make sense of this tutorial, you'll need to know the following organization concepts of FUSE:
- 📂 Data storage: All data is stored in the
dd
structure, which follows the ITER IMAS ontology. - 🧠 Actors: The core components of FUSE simulations are physics and engineering actors.
- 🕹️ Control: Actor functionality is governed by
act
parameters. - 🚀 Initialization: The data structure can be initialized from 0D
ini
parameters. - 🔧 Use cases: FUSE includes templates for various machines (e.g., FPP, ITER, ARC).
- 🔄 Workflows: Self-contained studies and optimizations are conducted via workflows, typically involving multiple FUSE simulations.
- 🌍 Interoperability: FUSE interfaces with existing modeling tools like OMFIT/OMAS and the IMAS ecosystem.
A diagram illustrating these concepts is provided below:
Let's get started!
NOTE: Julia is a Just In Time (JIT) programming language. The first time something is executed it will take longer because of the compilation process. Subsequent calls the the same code will be blazingly fast.
Import the necessary packages
using Plots # for plotting
using FUSE # this will also import IMAS in the current namespace
Starting from a use-case
FUSE comes with some predefined use-cases, some of which are used for regression testing.
Note that some use cases are for non-nuclear experiments and certain Actors like Blankets or BalanceOfPlant will not perform any actions.
FUSE.test_cases
ARC ini, act = FUSE.case_parameters(:ARC)
CAT ini, act = FUSE.case_parameters(:CAT)
D3D ini, act = FUSE.case_parameters(:D3D, :default)
D3D_Hmode ini, act = FUSE.case_parameters(:D3D, :H_mode)
D3D_Lmode ini, act = FUSE.case_parameters(:D3D, :L_mode)
DTT ini, act = FUSE.case_parameters(:DTT)
EXCITE ini, act = FUSE.case_parameters(:EXCITE)
FPP ini, act = FUSE.case_parameters(:FPP)
ITER_ods ini, act = FUSE.case_parameters(:ITER; init_from=:ods)
ITER_scalars ini, act = FUSE.case_parameters(:ITER; init_from=:scalars)
JET_HDB5 ini, act = FUSE.case_parameters(:HDB5; case=500, tokamak=:JET)
KDEMO ini, act = FUSE.case_parameters(:KDEMO)
KDEMO_compact ini, act = FUSE.case_parameters(:KDEMO_compact)
MANTA ini, act = FUSE.case_parameters(:MANTA)
SPARC ini, act = FUSE.case_parameters(:SPARC; init_from=:ods)
UNIT ini, act = FUSE.case_parameters(:UNIT)
Get initial parameters (ini
) and actions (act
) for a given use-case
ini, act = FUSE.case_parameters(:KDEMO);
Modifying ini
parameters.
ini.equilibrium.B0 = 7.8
ini.equilibrium.R0 = 6.5;
Modifying act
parameters.
act.ActorCoreTransport.model = :FluxMatcher;
Initialize the data dictionary (dd
) using the 0D parameters.
NOTE: init()
does not return a self-consistent solution, just a plausible starting point to initialize our simulations!
dd = IMAS.dd() # an empty dd
FUSE.init(dd, ini, act);
actors: Equilibrium
actors: TEQUILA
actors: CXbuild
actors: HCD
actors: SimpleEC
actors: SimpleIC
actors: Current
actors: QED
actors: PassiveStructures
We can @checkin
and @checkout
variables with an associated tag.
This is handy to save and restore our progress (we'll use this later).
@checkin :init dd ini act
Exploring the data dictionary
- FUSE stores data following the IMAS data schema.
- The root of the data structure is
dd
, which stands for "Data Dictionary". - More details are available in the documentation.
Display part of the equilibrium data in dd
dd.equilibrium.time_slice[1].boundary
boundary
├─ elongation ➡ 1.9957
├─ elongation_lower ➡ Function
├─ elongation_upper ➡ Function
├─ geometric_axis
│ ├─ r ➡ 6.49994 [m]
│ └─ z ➡ -0.0220736 [m]
├─ minor_radius ➡ 2.00733 [m]
├─ outline
│ ├─ r ➡ 239-element Vector{Float64} [m]
│ │ min:4.52 avg:6.27 max:8.49
│ └─ z ➡ 239-element Vector{Float64} [m]
│ min:-4.07 avg:-0.0905 max:3.85
├─ ovality ➡ 0.00699545
├─ squareness ➡ -0.0127582
├─ squareness_lower_inner ➡ Function
├─ squareness_lower_outer ➡ Function
├─ squareness_upper_inner ➡ Function
├─ squareness_upper_outer ➡ Function
├─ strike_point
│ ├─ 1
│ │ ├─ last_closed_flux_surface_gap ➡ 1.04919e-08 [m]
│ │ ├─ r ➡ 4.22333 [m]
│ │ └─ z ➡ -4.49341 [m]
│ └─ 2
│ ├─ last_closed_flux_surface_gap ➡ 1.04919e-08 [m]
│ ├─ r ➡ 5.50748 [m]
│ └─ z ➡ -5.0981 [m]
├─ tilt ➡ -0.00586781
├─ triangularity ➡ 0.58633
├─ triangularity_lower ➡ Function
├─ triangularity_upper ➡ Function
├─ twist ➡ 0.00468628
└─ x_point
├─ 1
│ ├─ r ➡ 5.11638 [m]
│ └─ z ➡ -4.07303 [m]
└─ 2
├─ r ➡ 4.85135 [m]
└─ z ➡ 4.30185 [m]
this can be done up to a certain depth with print_tree
print_tree(dd.equilibrium.time_slice[1].boundary; maxdepth=1)
boundary
├─ elongation ➡ 1.9957
├─ elongation_lower ➡ Function
├─ elongation_upper ➡ Function
├─ geometric_axis
│ ⋮
│
├─ minor_radius ➡ 2.00733 [m]
├─ outline
│ ⋮
│
├─ ovality ➡ 0.00699545
├─ squareness ➡ -0.0127582
├─ squareness_lower_inner ➡ Function
├─ squareness_lower_outer ➡ Function
├─ squareness_upper_inner ➡ Function
├─ squareness_upper_outer ➡ Function
├─ strike_point
│ ⋮
│
├─ tilt ➡ -0.00586781
├─ triangularity ➡ 0.58633
├─ triangularity_lower ➡ Function
├─ triangularity_upper ➡ Function
├─ twist ➡ 0.00468628
└─ x_point
⋮
Plotting data from dd
FUSE uses Plots.jl
recipes for visualizing data from dd
.
This allows different plots to be shown when calling plot()
on different items in the data structure.
Learn more about Plots.jl here
For example plotting the equilibrium...
plot(dd.equilibrium)
...or the core profiles
plot(dd.core_profiles)
Whant to know what arguments can be passed? use help_plot()
function
help_plot(dd.equilibrium; core_profiles_overlay=true, levels_in=21, levels_out=5, show_secondary_separatrix=true, coordinate=:rho_tor_norm)
These plots can be composed by calling plot!()
instead of plot()
plot(dd.equilibrium; color=:gray, cx=true)
plot!(dd.build.layer)
plot!(dd.pf_active)
plot!(dd.pf_passive)
plot!(dd.pulse_schedule.position_control; color=:red)
Plotting an array...
plot(dd.core_profiles.profiles_1d[1].pressure_thermal)
...is different from plotting a field from the IDS (which plots the quantity against its coordinate and with units)
plot(dd.core_profiles.profiles_1d[1], :pressure_thermal)
Customizing plot attributes:
plot(dd.core_profiles.profiles_1d[1], :pressure_thermal; label="", linewidth=2, color=:red, labelfontsize=25)
Use findall(ids, r"...")
to search for certain fields. In Julia, string starting with r
are regular expressions.
findall(dd, r"\.psi")
[1] dd.core_profiles.profiles_1d[1].grid.psi [Wb] [101-element Vector{Float64}] (min:-63.8, avg:-38, max:-0.972)
[2] dd.equilibrium.time_slice[1].global_quantities.psi_boundary [Wb] [Float64] (all:-0.972)
[3] dd.equilibrium.time_slice[1].global_quantities.psi_axis [Wb] [Float64] (all:-63.8)
[4] dd.equilibrium.time_slice[1].profiles_1d.psi_norm [129-element Vector{Float64}] (min:0, avg:0.5, max:1)
[5] dd.equilibrium.time_slice[1].profiles_1d.psi [Wb] [129-element Vector{Float64}] (min:-63.8, avg:-32.4, max:-0.972)
[6] dd.equilibrium.time_slice[1].profiles_2d[1].psi [Wb] [31×13 Matrix{Float64}] (min:-0.0684, avg:0.654, max:6.68)
[7] dd.equilibrium.time_slice[1].profiles_2d[2].psi [Wb] [66×129 Matrix{Float64}] (min:-63.7, avg:14.1, max:110)
findall(ids, r"...")
can be combined with plot()
to plot multiple fields
plot(findall(dd, r"\.psi"))
Working with time series
The IMAS data structure supports time-dependent data, and IMAS.jl provides ways to handle time data efficiently.
Each dd
has a global_time
attribute, which is used throughout FUSE and IMAS to indicate the time at which things should be operate.
dd.global_time
0.0
For the sake of demonstrating handling of time, let's add a new time_slice to the equilibrium.
NOTE: time dependent arrays of structures can be resized with resize!(ids, time0::Float64)
in addition to the usual resize!(ids, n::Int)
.
resize the time dependent array of structure
resize!(dd.equilibrium.time_slice, 1.0);
let's just populate it with the data from the previous time slice
dd.equilibrium.time_slice[2] = deepcopy(dd.equilibrium.time_slice[1]);
dd.equilibrium.time_slice[2].time = 1.0
1.0
Here we see that equilibrium has mulitiple time_slices
dd.equilibrium.time
2-element Vector{Float64}:
0.0
1.0
We can access time-dependent arrays of structures via integer index...
eqt = dd.equilibrium.time_slice[2]
eqt.time
1.0
...or at a given time, by passing the time as a floating point number (in seconds)
eqt = dd.equilibrium.time_slice[1.0]
eqt.time
1.0
NOTE: If we ask a time that is not exactly in the arrays of structures, we'll get the closest (causal!) time-slice
eqt = dd.equilibrium.time_slice[0.9]
eqt.time
eqt = dd.equilibrium.time_slice[1.1]
eqt.time
1.0
... or at the current dd.global_time
by leaving the square brackets empty []
NOTE: This is what you want to use in most situations that involve arrays of structures!
dd.global_time = 0.0
eqt = dd.equilibrium.time_slice[]
eqt.time
dd.global_time = 1.0
eqt = dd.equilibrium.time_slice[]
eqt.time
1.0
What we described above was for time-dependent arrays of structures.
The other place where time comes in, is when dealing with time-dependent arrays of data.
In this case, we can use the @ddtime
macro to manipulate these time-dependent arrays at dd.global_time
.
NOTE: Also in this case, @ddtime
will operate on the closest (causal!) time point
dd.equilibrium.vacuum_toroidal_field.b0
dd.global_time = 1.0
@ddtime(dd.equilibrium.vacuum_toroidal_field.b0 = 10.0)
dd.equilibrium.vacuum_toroidal_field.b0
dd.global_time = 0.0
@ddtime(dd.equilibrium.vacuum_toroidal_field.b0)
dd.global_time = 1.0
@ddtime(dd.equilibrium.vacuum_toroidal_field.b0)
10.0
Expressions in dd
Some fields in the data dictionary are expressions (ie. Functions). For example dd.core_profiles.profiles_1d[].pressure
is dynamically calculated as the product of thermal densities and temperature with addition of fast ions contributions
dd.global_time = 0.0
print_tree(dd.core_profiles.profiles_1d[]; maxdepth=1)
1
├─ conductivity_parallel ➡ Function [ohm^-1.m^-1]
├─ electrons
│ ⋮
│
├─ grid
│ ⋮
│
├─ ion
│ ⋮
│
├─ j_bootstrap ➡ 101-element Vector{Float64} [A/m^2]
│ min:3.2e+03 avg:1.39e+05 max:1.86e+05
├─ j_non_inductive ➡ 101-element Vector{Float64} [A/m^2]
│ min:3.2e+03 avg:9.28e+05 max:5.7e+06
├─ j_ohmic ➡ 101-element Vector{Float64} [A/m^2]
│ min:620 avg:3.7e+05 max:6.95e+05
├─ j_tor ➡ 101-element Vector{Float64} [A/m^2]
│ min:3.25e+03 avg:1.31e+06 max:6.5e+06
├─ j_total ➡ 101-element Vector{Float64} [A/m^2]
│ min:3.82e+03 avg:1.3e+06 max:6.38e+06
├─ pressure ➡ Function [Pa]
├─ pressure_ion_total ➡ Function [Pa]
├─ pressure_parallel ➡ Function [Pa]
├─ pressure_perpendicular ➡ Function [Pa]
├─ pressure_thermal ➡ Function [Pa]
├─ rotation_frequency_tor_sonic ➡ 101-element Vector{Float64} [s^-1]
│ all:0
├─ t_i_average ➡ Function [eV]
├─ time ➡ 0 [s]
└─ zeff ➡ 101-element Vector{Float64}
all:2
accessing a dynamic expression, automatically evaluates it
dd.core_profiles.profiles_1d[].conductivity_parallel
101-element Vector{Float64}:
2.4470924195702033e9
2.3906557300310144e9
2.3158174279464374e9
2.238068625143165e9
2.159425321368308e9
2.0804179815145836e9
2.001293246630804e9
1.9222171732192056e9
1.866075940409718e9
1.8130093083926377e9
⋮
2.850023461541433e7
2.69516054832103e7
2.5216918645387363e7
2.28106246678863e7
1.909156375505396e7
1.3671137661162425e7
7.726394818289964e6
3.078828501832661e6
599300.9947993492
In addition to evaluating expressions by accessing them, expressions in the tree can be evaluated using IMAS.freeze(ids)
NOTE: IMAS.freeze(ids, field::Symbol)
works on a single field and IMAS.refreeze!(ids, field)
forces re-evaluation of an expression. Also, IMAS.empty!(ids, field::Symbol)
can be used to revert a frozen field back into an expression.
print_tree(IMAS.freeze(dd.core_profiles.profiles_1d[1]); maxdepth=1)
core_profiles
├─ conductivity_parallel ➡ 101-element Vector{Float64} [ohm^-1.m^-1]
│ min:5.99e+05 avg:7.09e+08 max:2.45e+09
├─ electrons
│ ⋮
│
├─ grid
│ ⋮
│
├─ ion
│ ⋮
│
├─ j_bootstrap ➡ 101-element Vector{Float64} [A/m^2]
│ min:3.2e+03 avg:1.39e+05 max:1.86e+05
├─ j_non_inductive ➡ 101-element Vector{Float64} [A/m^2]
│ min:3.2e+03 avg:9.28e+05 max:5.7e+06
├─ j_ohmic ➡ 101-element Vector{Float64} [A/m^2]
│ min:620 avg:3.7e+05 max:6.95e+05
├─ j_tor ➡ 101-element Vector{Float64} [A/m^2]
│ min:3.25e+03 avg:1.31e+06 max:6.5e+06
├─ j_total ➡ 101-element Vector{Float64} [A/m^2]
│ min:3.82e+03 avg:1.3e+06 max:6.38e+06
├─ pressure ➡ 101-element Vector{Float64} [Pa]
│ min:363 avg:3.72e+05 max:8.21e+05
├─ pressure_ion_total ➡ 101-element Vector{Float64} [Pa]
│ min:171 avg:1.47e+05 max:2.99e+05
├─ pressure_parallel ➡ 101-element Vector{Float64} [Pa]
│ min:121 avg:1.24e+05 max:2.74e+05
├─ pressure_perpendicular ➡ 101-element Vector{Float64} [Pa]
│ min:121 avg:1.24e+05 max:2.74e+05
├─ pressure_thermal ➡ 101-element Vector{Float64} [Pa]
│ min:363 avg:3.11e+05 max:6.34e+05
├─ rotation_frequency_tor_sonic ➡ 101-element Vector{Float64} [s^-1]
│ all:0
├─ t_i_average ➡ 101-element Vector{Float64} [eV]
│ min:80 avg:1.32e+04 max:2.5e+04
├─ time ➡ 0 [s]
└─ zeff ➡ 101-element Vector{Float64}
all:2
Whole facility design
Here we restore the :init
checkpoint that we had previously stored. Resetting any changes to dd
, ini
, and act
that we did in the meantime.
@checkout :init dd ini act
Actors in FUSE can be executed by passing two arguments to them: dd
and act
. Internally, actors can call other actors, creating workflows. For example, the ActorWholeFacility
can be used to to get a self-consistent stationary whole facility design. The actors:
print statements with their nested output tell us what actors are calling other actors.
FUSE.ActorWholeFacility(dd, act);
actors: WholeFacility
actors: PFdesign
actors: StationaryPlasma
actors: --------------- 1/5
actors: HCD
actors: SimpleEC
actors: SimpleIC
actors: Current
actors: QED
actors: Pedestal
actors: EPED
actors: CoreTransport
actors: FluxMatcher
actors: Current
actors: QED
actors: Equilibrium
actors: TEQUILA
actors: --------------- 1/5 @ 422.96%
actors: HCD
actors: SimpleEC
actors: SimpleIC
actors: Current
actors: QED
actors: Pedestal
actors: EPED
actors: CoreTransport
actors: FluxMatcher
actors: Current
actors: QED
actors: Equilibrium
actors: TEQUILA
actors: --------------- 2/5 @ 447.37%
actors: HCD
actors: SimpleEC
actors: SimpleIC
actors: Current
actors: QED
actors: Pedestal
actors: EPED
actors: CoreTransport
actors: FluxMatcher
actors: Current
actors: QED
actors: Equilibrium
actors: TEQUILA
actors: --------------- 3/5 @ 339.44%
actors: HCD
actors: SimpleEC
actors: SimpleIC
actors: Current
actors: QED
actors: Pedestal
actors: EPED
actors: CoreTransport
actors: FluxMatcher
actors: Current
actors: QED
actors: Equilibrium
actors: TEQUILA
actors: --------------- 4/5 @ 313.23%
actors: HCD
actors: SimpleEC
actors: SimpleIC
actors: Current
actors: QED
actors: Pedestal
actors: EPED
actors: CoreTransport
actors: FluxMatcher
actors: Current
actors: QED
actors: Equilibrium
actors: TEQUILA
actors: --------------- 5/5 @ 259.13%
┌ Warning: Max number of iterations (5) has been reached with convergence error of (1)[0.211, 0.224, 0.17, 0.157, 0.13](5) compared to threshold of 0.05
└ @ FUSE ~/work/FUSE.jl/FUSE.jl/src/actors/compound/stationary_plasma_actor.jl:204
actors: HFSsizing
actors: FluxSwing
actors: Stresses
actors: LFSsizing
actors: CXbuild
actors: PFdesign
actors: Equilibrium
actors: TEQUILA
actors: CXbuild
actors: Neutronics
actors: Blanket
actors: CXbuild
actors: PassiveStructures
actors: Divertors
actors: PlasmaLimits
actors: VerticalStability
actors: TroyonBetaNN
┌ Warning: act.ActorPlasmaLimits.models = [:vertical_stability, :beta_troyon_nn, :q95_gt_2, :gw_density, :κ_controllability]
│
│ Some stability rules exceed their limit threshold:
│ 113% of: Vertical stability margin > 0.15 for stability
│ 105% of: βn < BetaTroyonNN n=1
│
│ Some stability rules satisfy their limit threshold:
│ 93% of: Normalized vertical growth rate < 10 for stability
│ 20% of: βn < BetaTroyonNN n=2
│ 32% of: βn < BetaTroyonNN n=3
│ 34% of: q(rho=0.95) > 2.0
│ 77% of: greenwald_fraction < 1.0
│ 82% of: elongation < IMAS.elongation_limit
└ @ FUSE ~/work/FUSE.jl/FUSE.jl/src/actors/stability/limits_actor.jl:92
actors: BalanceOfPlant
actors: ThermalPlant
actors: PowerNeeds
actors: Costing
actors: CostingARIES
Let's check what we got at a glance with the FUSE.digest(dd)
function:
FUSE.digest(dd)
GEOMETRY EQUILIBRIUM TEMPERATURES
──────────────────────────────────── ──────────────────────────────────── ────────────────────────────────────
R0 → 6.5 [m] B0 → 7.8 [T] Te0 → 16.3 [keV]
a → 2.01 [m] ip → 12.7 [MA] Ti0 → 19.6 [keV]
1/ϵ → 3.24 q95 → 6.03 <Te> → 8.4 [keV]
κ → 2 <Bpol> → 0.8 [T] <Ti> → 7.83 [keV]
δ → 0.586 βpol_MHD → 0.728 Te0/<Te> → 1.94
ζ → -0.0128 βtor_MHD → 0.00798 Ti0/<Ti> → 2.5
Volume → 927 [m³] βn_MHD → 0.977
Surface → 755 [m²]
DENSITIES PRESSURES TRANSPORT
──────────────────────────────────── ──────────────────────────────────── ────────────────────────────────────
ne0 → 8.54e+19 [m⁻³] P0 → 0.538 [MPa] τe → 1.79 [s]
ne_ped → 5.96e+19 [m⁻³] <P> → 0.194 [MPa] τe_exp → 2.26 [s]
ne_line → 7.71e+19 [m⁻³] P0/<P> → 2.77 H98y2 → 0.767
<ne> → 7.19e+19 [m⁻³] βn → 0.99 H98y2_exp → 0.824
ne0/<ne> → 1.19 βn_th → 0.95 Hds03 → 0.556
fGW → 0.77 Hds03_exp → 0.618
zeff_ped → 2 τα_thermalization → 0.837 [s]
<zeff> → 2 τα_slowing_down → 0.866 [s]
impurities → DT Ne20 He4
SOURCES EXHAUST CURRENTS
──────────────────────────────────── ──────────────────────────────────── ────────────────────────────────────
Pec → 50 [MW] Psol → 114 [MW] ip_bs_aux_ohm → 12.9 [MA]
rho0_ec → 0.57 [MW] PLH → 129 [MW] ip_ni → 7.36 [MA]
Pnbi → NaN [MW] Bpol_omp → 1.12 [T] ip_bs → 2.59 [MA]
Enbi1 → NaN [MeV] λq → 0.971 [mm] ip_aux → 4.78 [MA]
Pic → 50 [MW] qpol → 2.21e+03 [MW/m²] ip_ohm → 5.57 [MA]
Plh → NaN [MW] qpar → 1.2e+04 [MW/m²] ejima → 0.4
Paux_tot → 100 [MW] P/R0 → 17.6 [MW/m] flattop → 0.7 [Hours]
Pα → 44.2 [MW] PB/R0 → 137 [MW T/m]
Pohm → 0.468 [MW] PBp/R0 → 14.1 [MW T/m]
Pheat → 145 [MW] PBϵ/R0q95 → 7.04 [MW T/m]
Prad_tot → -30.2 [MW] neutrons_peak → 0.294 [MW/m²]
BOP BUILD COSTING
──────────────────────────────────── ──────────────────────────────────── ────────────────────────────────────
Pfusion → 221 [MW] PF_material → nb3sn capital_cost → 7.1 [$B]
Qfusion → 2.21 TF_material → nb3sn_kdemo levelized_CoE → Inf [$/kWh]
thermal_cycle_type → rankine OH_material → nb3sn TF_of_total → 16.4 [%]
thermal_efficiency_plant → 22.7 [%] TF_max_b → 15.4 [T] BOP_of_total → 1.6 [%]
thermal_efficiency_cycle → NaN [%] OH_max_b → 16 [T] blanket_of_total → 21.1 [%]
power_electric_generated → 16.6 [MW] TF_j_margin → 6.59 cryostat_of_total → 2.88 [%]
Pelectric_net → -128 [MW] OH_j_margin → 1.41
Qplant → 0.115 TF_stress_margin → 3.03
TBR → 0.0691 OH_stress_margin → 1.2
@ time = 0.0 [s]
GKS: could not find font middle.ttf
Like before we can checkpoint results for later use
@checkin :awf dd ini act
Running a custom workflow
Let's now run a series of actors similar to what ActorWholeFacility
does and play around with plotting to get a sense of what each individual actor does.
Let's start again from after the initialization stage
@checkout :init dd ini act
Let's start by positioning the PF coils, so that we stand a chance to reproduce the desired plasma shape. This will be important to ensure the stability of the ActorStationaryPlasma
that we are going to run next.
FUSE.ActorPFdesign(dd, act; do_plot=true); # instead of setting `act.ActorPFdesign.do_plot=true` we can just pass `do_plot=true` as argument without chaning `act`
actors: PFdesign
The ActorStationaryPlasma
iterates between plasma transport, pedestal, equilibrium and sources to return a self-consistent plasma solution
peq = plot(dd.equilibrium; label="before")
pcp = plot(dd.core_profiles; color=:gray, label="before")
FUSE.ActorStationaryPlasma(dd, act);
actors: StationaryPlasma
actors: --------------- 1/5
actors: HCD
actors: SimpleEC
actors: SimpleIC
actors: Current
actors: QED
actors: Pedestal
actors: EPED
actors: CoreTransport
actors: FluxMatcher
actors: Current
actors: QED
actors: Equilibrium
actors: TEQUILA
actors: --------------- 1/5 @ 422.96%
actors: HCD
actors: SimpleEC
actors: SimpleIC
actors: Current
actors: QED
actors: Pedestal
actors: EPED
actors: CoreTransport
actors: FluxMatcher
actors: Current
actors: QED
actors: Equilibrium
actors: TEQUILA
actors: --------------- 2/5 @ 447.37%
actors: HCD
actors: SimpleEC
actors: SimpleIC
actors: Current
actors: QED
actors: Pedestal
actors: EPED
actors: CoreTransport
actors: FluxMatcher
actors: Current
actors: QED
actors: Equilibrium
actors: TEQUILA
actors: --------------- 3/5 @ 339.44%
actors: HCD
actors: SimpleEC
actors: SimpleIC
actors: Current
actors: QED
actors: Pedestal
actors: EPED
actors: CoreTransport
actors: FluxMatcher
actors: Current
actors: QED
actors: Equilibrium
actors: TEQUILA
actors: --------------- 4/5 @ 313.23%
actors: HCD
actors: SimpleEC
actors: SimpleIC
actors: Current
actors: QED
actors: Pedestal
actors: EPED
actors: CoreTransport
actors: FluxMatcher
actors: Current
actors: QED
actors: Equilibrium
actors: TEQUILA
actors: --------------- 5/5 @ 259.13%
┌ Warning: Max number of iterations (5) has been reached with convergence error of (1)[0.211, 0.224, 0.17, 0.157, 0.13](5) compared to threshold of 0.05
└ @ FUSE ~/work/FUSE.jl/FUSE.jl/src/actors/compound/stationary_plasma_actor.jl:204
we can compare equilibrium before and after the self-consistency loop
plot!(peq, dd.equilibrium; label="after")
we can compare core_profiles before and after the self-consistency loop
plot!(pcp, dd.core_profiles; label="after")
here are the sources
plot(dd.core_sources)
and the flux-matched transport
plot(dd.core_transport)
HFS sizing actor changes the thickness of the OH and TF layers on the high field side to satisfy current and stresses constraints
plot(dd.build)
FUSE.ActorHFSsizing(dd, act);
plot!(dd.build; cx=false)
The stresses on the center stack are stored in the solid_mechanics
IDS
plot(dd.solid_mechanics.center_stack.stress)
LFS sizing actors change location of the outer TF leg to meet ripple requirements
plot(dd.build)
FUSE.ActorLFSsizing(dd, act);
plot!(dd.build; cx=false)
A custom show()
method is defined to print the summary of dd.build.layer
dd.build.layer
23×10 DataFrame
Row │ group details type ΔR R_start R_end material area volume shape
│ String String String Float64 Float64 Float64 String Float64 Float64 String
─────┼───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
1 │ in 1.29698 0.0 1.29698 steel 20.1595 99.4243
2 │ in oh 0.307663 1.29698 1.60465 nb3sn 6.99333 80.9454
3 │ hfs tf 1.69336 1.60465 3.298 nb3sn_kdemo 43.0617 892.324 convex hull
4 │ hfs gap tf vacuum vessel 0.0 3.298 3.298 vacuum 7.4963 494.593 double ellipse
5 │ hfs vacuum outer vessel 0.0983012 3.298 3.39631 steel 3.07275 125.557 negative offset
6 │ hfs gap water 0.147452 3.39631 3.54376 water 4.49526 183.795 negative offset
7 │ hfs vacuum inner vessel 0.0983012 3.54376 3.64206 steel 2.92092 119.502 negative offset
8 │ hfs gap high temp shield vacuum vess… 0.00983012 3.64206 3.65189 vacuum 0.288752 11.817 negative offset
9 │ hfs high temp shield 0.196602 3.65189 3.84849 steel 5.64751 231.253 negative offset
10 │ hfs blanket 0.373544 3.84849 4.22204 lithium_lead 21.3842 977.884 negative offset
11 │ hfs first wall 0.0196602 4.22204 4.2417 tungsten 1.01628 33.3615 offset
12 │ lhfs plasma 4.51649 4.2417 8.75818 plasma 32.1139 1252.25
13 │ lfs first wall 0.0196602 8.75818 8.77785 tungsten 1.01545 33.3208 offset
14 │ lfs blanket 1.17961 8.77785 9.95746 lithium_lead 21.385 977.925 negative offset
15 │ lfs high temp shield 0.196602 9.95746 10.1541 steel 5.64751 231.253 negative offset
16 │ lfs gap high temp shield vacuum vess… 0.0441736 10.1541 10.1982 vacuum 0.288752 11.817 negative offset
17 │ lfs vacuum inner vessel 0.0983012 10.1982 10.2965 steel 2.92092 119.502 negative offset
18 │ lfs gap water 0.147452 10.2965 10.444 water 4.49526 183.795 negative offset
19 │ lfs vacuum outer vessel 0.0983012 10.444 10.5423 steel 3.07275 125.557 negative offset
20 │ lfs gap tf vacuum vessel 0.775596 10.5423 11.3179 vacuum 7.4963 494.593 double ellipse
21 │ lfs tf 1.69336 11.3179 13.0112 nb3sn_kdemo 43.0617 892.324 convex hull
22 │ out 1.96602 0.0 14.9773 vacuum 164.538 8369.78
23 │ out cryostat 0.0983012 0.0 15.0756 steel 4.87258 310.002 silo
ActorHFSsizing and ActorLFSsizing only change the layer's thicknesses, so we then need to trigger a build of the 2D cross-sections after them:
FUSE.ActorCXbuild(dd, act);
plot(dd.build)
Generate passive structures information (for now the vacuum vessel)
FUSE.ActorPassiveStructures(dd, act)
plot(dd.pf_passive)
We can now give the PF coils their final position given the new build
actor = FUSE.ActorPFdesign(dd, act);
plot(actor) # some actors define their own plot
With information about both pfactive and pfpassive we can now evaluate vertical stability
FUSE.ActorVerticalStability(dd, act)
IMAS.freeze(dd.mhd_linear)
mhd_linear
├─ time ➡ [0] [s]
└─ time_slice
└─ 1
├─ time ➡ 0 [s]
└─ toroidal_mode
├─ 1
│ ├─ n_tor ➡ 0
│ ├─ perturbation_type
│ │ ├─ description ➡ "Vertical stability margin > 0.15 for stability"
│ │ └─ name ➡ "m_s"
│ └─ stability_metric ➡ 0.126555
└─ 2
├─ n_tor ➡ 0
├─ perturbation_type
│ ├─ description ➡ "Normalized vertical growth rate < 10 for stability"
│ └─ name ➡ "γτ"
└─ stability_metric ➡ 9.82138
The ActorNeutronics
calculates the heat flux on the first wall
FUSE.ActorNeutronics(dd, act);
p = plot(; layout=2, size=(900, 350))
plot!(p, dd.neutronics.time_slice[].wall_loading, subplot=1)
plot!(p, FUSE.define_neutrons(dd, 100000)[1], dd.equilibrium.time_slice[]; subplot=1, colorbar_entry=false)
plot!(p, dd.neutronics.time_slice[].wall_loading; cx=false, subplot=2, ylabel="")
The ActorBlanket
will change the thickess of the first wall, breeder, shield, and Li6 enrichment to achieve target TBR
FUSE.ActorBlanket(dd, act);
print_tree(IMAS.freeze(dd.blanket); maxdepth=5)
actors: Blanket
blanket
├─ module
│ └─ 1
│ ├─ layer
│ │ ├─ 1
│ │ │ ├─ material ➡ "tungsten"
│ │ │ ├─ midplane_thickness ➡ 0.0199667 [m]
│ │ │ └─ name ➡ "lfs first wall"
│ │ ├─ 2
│ │ │ ├─ material ➡ "lithium-lead: Li6/7=90.000%"
│ │ │ ├─ midplane_thickness ➡ 1.35591 [m]
│ │ │ └─ name ➡ "lfs blanket"
│ │ └─ 3
│ │ ├─ material ➡ "steel"
│ │ ├─ midplane_thickness ➡ 0.020003 [m]
│ │ └─ name ➡ "lfs high temp shield"
│ ├─ name ➡ "blanket"
│ └─ time_slice
│ └─ 1
│ ├─ peak_escape_flux ➡ 145703 [W/m^2]
│ ├─ peak_wall_flux ➡ 761380 [W/m^2]
│ ├─ power_incident_neutrons ➡ 8.07731e+06 [W]
│ ├─ power_incident_radiated ➡ 0 [W]
│ ├─ power_thermal_extracted ➡ 9.69277e+06 [W]
│ ├─ power_thermal_neutrons ➡ 9.69277e+06 [W]
│ ├─ power_thermal_radiated ➡ 0 [W]
│ ├─ time ➡ 0 [s]
│ └─ tritium_breeding_ratio ➡ 1.50827
├─ time ➡ [0] [s]
└─ tritium_breeding_ratio ➡ [0.0689823]
The ActorDivertors
actor calculates the divertors heat flux
FUSE.ActorDivertors(dd, act);
print_tree(IMAS.freeze(dd.divertors); maxdepth=4)
actors: Divertors
divertors
├─ divertor
│ └─ 1
│ ├─ power_black_body
│ │ ├─ data ➡ [0] [W]
│ │ └─ time ➡ [0] [s]
│ ├─ power_conducted
│ │ ├─ data ➡ [1.14429e+08] [W]
│ │ └─ time ➡ [0] [s]
│ ├─ power_convected
│ │ ├─ data ➡ [0] [W]
│ │ └─ time ➡ [0] [s]
│ ├─ power_currents
│ │ ├─ data ➡ [0] [W]
│ │ └─ time ➡ [0] [s]
│ ├─ power_incident
│ │ ├─ data ➡ [3.37671e+07] [W]
│ │ └─ time ➡ [0] [s]
│ ├─ power_neutrals
│ │ ├─ data ➡ [0] [W]
│ │ └─ time ➡ [0] [s]
│ ├─ power_radiated
│ │ ├─ data ➡ [0] [W]
│ │ └─ time ➡ [0] [s]
│ ├─ power_recombination_neutrals
│ │ ├─ data ➡ [0] [W]
│ │ └─ time ➡ [0] [s]
│ ├─ power_recombination_plasma
│ │ ├─ data ➡ [0] [W]
│ │ └─ time ➡ [0] [s]
│ ├─ power_thermal_extracted
│ │ ├─ data ➡ [3.37671e+07] [W]
│ │ └─ time ➡ [0] [s]
│ └─ target
│ ├─ 1
│ │ ⋮
│ │
│ └─ 2
│ ⋮
│
└─ time ➡ [0] [s]
The ActorBalanceOfPlant
calculates the optimal cooling flow rates for the heat sources (breeder, divertor, and wall) and get an efficiency for the electricity conversion cycle
FUSE.ActorBalanceOfPlant(dd, act);
IMAS.freeze(dd.balance_of_plant)
balance_of_plant
├─ Q_plant ➡ [0.115439]
├─ power_electric_net ➡ [-1.28261e+08] [W]
├─ power_electric_plant_operation
│ ├─ system
│ │ ├─ 1
│ │ │ ├─ index ➡ 1
│ │ │ ├─ name ➡ "HCD"
│ │ │ ├─ power ➡ [1e+08] [W]
│ │ │ └─ subsystem
│ │ │ ├─ 1
│ │ │ │ ├─ index ➡ 1
│ │ │ │ ├─ name ➡ "nbi"
│ │ │ │ └─ power ➡ [0] [W]
│ │ │ ├─ 2
│ │ │ │ ├─ index ➡ 2
│ │ │ │ ├─ name ➡ "ec_launchers"
│ │ │ │ └─ power ➡ [5e+07] [W]
│ │ │ ├─ 3
│ │ │ │ ├─ index ➡ 3
│ │ │ │ ├─ name ➡ "ic_antennas"
│ │ │ │ └─ power ➡ [5e+07] [W]
│ │ │ └─ 4
│ │ │ ├─ index ➡ 4
│ │ │ ├─ name ➡ "lh_antennas"
│ │ │ └─ power ➡ [0] [W]
│ │ ├─ 2
│ │ │ ├─ index ➡ 3
│ │ │ ├─ name ➡ "cryostat"
│ │ │ └─ power ➡ [3e+07] [W]
│ │ ├─ 3
│ │ │ ├─ index ➡ 4
│ │ │ ├─ name ➡ "tritium_handling"
│ │ │ └─ power ➡ [1.5e+07] [W]
│ │ └─ 4
│ │ ├─ index ➡ 6
│ │ ├─ name ➡ "pf_active"
│ │ └─ power ➡ [0] [W]
│ └─ total_power ➡ [1.45e+08] [W]
├─ power_plant
│ ├─ heat_load
│ │ ├─ breeder ➡ [9.69277e+06] [W]
│ │ ├─ divertor ➡ [3.37671e+07] [W]
│ │ └─ wall ➡ [3.01875e+07] [W]
│ ├─ power_cycle_type ➡ "rankine"
│ ├─ power_electric_generated ➡ [1.67387e+07] [W]
│ └─ total_heat_supplied ➡ [7.36474e+07] [W]
├─ thermal_efficiency_plant ➡ [0.227282]
└─ time ➡ [0] [s]
ActorCosting
will break down the capital and operational costs
FUSE.ActorCosting(dd, act)
plot(dd.costing)
Let's checkpoint our results
@checkin :manual dd ini act
Saving and loading data
tutorial_temp_dir = tempdir()
filename = joinpath(tutorial_temp_dir, "$(ini.general.casename).json")
"/tmp/K-DEMO.json"
When saving data to be shared outside of FUSE, one can set freeze=true
so that all expressions in the dd are evaluated and saved to file.
IMAS.imas2json(dd, filename; freeze=false, strict=false);
Load from JSON
dd1 = IMAS.json2imas(filename);
Comparing two IDSs
We can introduce a change in the dd1
and spot it with the diff
function
dd1.equilibrium.time_slice[1].time = -100.0
IMAS.diff(dd.equilibrium, dd1.equilibrium)
Dict{String, String} with 1 entry:
"time_slice[1].time" => "value: 0.0 -- -100.0"
Summary
Snapshot of dd
in 0D quantities (evaluated at dd.global_time
).
Extract + plots saved to PDF (printed to screen it filename
is omitted)
filename = joinpath(tutorial_temp_dir, "$(ini.general.casename).pdf")
FUSE.extract(dd)#, filename)
GEOMETRY EQUILIBRIUM TEMPERATURES
──────────────────────────────────── ──────────────────────────────────── ────────────────────────────────────
R0 → 6.5 [m] B0 → 7.8 [T] Te0 → 16.3 [keV]
a → 2.01 [m] ip → 12.7 [MA] Ti0 → 19.6 [keV]
1/ϵ → 3.24 q95 → 6.03 <Te> → 8.4 [keV]
κ → 2 <Bpol> → 0.799 [T] <Ti> → 7.83 [keV]
δ → 0.586 βpol_MHD → 0.729 Te0/<Te> → 1.94
ζ → -0.0128 βtor_MHD → 0.00799 Ti0/<Ti> → 2.5
Volume → 926 [m³] βn_MHD → 0.978
Surface → 755 [m²]
DENSITIES PRESSURES TRANSPORT
──────────────────────────────────── ──────────────────────────────────── ────────────────────────────────────
ne0 → 8.54e+19 [m⁻³] P0 → 0.538 [MPa] τe → 1.79 [s]
ne_ped → 5.96e+19 [m⁻³] <P> → 0.194 [MPa] τe_exp → 2.26 [s]
ne_line → 7.71e+19 [m⁻³] P0/<P> → 2.77 H98y2 → 0.768
<ne> → 7.19e+19 [m⁻³] βn → 0.991 H98y2_exp → 0.825
ne0/<ne> → 1.19 βn_th → 0.95 Hds03 → 0.556
fGW → 0.77 Hds03_exp → 0.618
zeff_ped → 2 τα_thermalization → 0.837 [s]
<zeff> → 2 τα_slowing_down → 0.866 [s]
impurities → DT Ne20 He4
SOURCES EXHAUST CURRENTS
──────────────────────────────────── ──────────────────────────────────── ────────────────────────────────────
Pec → 50 [MW] Psol → 114 [MW] ip_bs_aux_ohm → 12.9 [MA]
rho0_ec → 0.57 [MW] PLH → 129 [MW] ip_ni → 7.37 [MA]
Pnbi → NaN [MW] Bpol_omp → 1.12 [T] ip_bs → 2.59 [MA]
Enbi1 → NaN [MeV] λq → 0.968 [mm] ip_aux → 4.78 [MA]
Pic → 50 [MW] qpol → 2.22e+03 [MW/m²] ip_ohm → 5.57 [MA]
Plh → NaN [MW] qpar → 1.2e+04 [MW/m²] ejima → 0.4
Paux_tot → 100 [MW] P/R0 → 17.6 [MW/m] flattop → 0.7 [Hours]
Pα → 44.2 [MW] PB/R0 → 137 [MW T/m]
Pohm → 0.467 [MW] PBp/R0 → 14.1 [MW T/m]
Pheat → 145 [MW] PBϵ/R0q95 → 7.03 [MW T/m]
Prad_tot → -30.2 [MW] neutrons_peak → 0.293 [MW/m²]
BOP BUILD COSTING
──────────────────────────────────── ──────────────────────────────────── ────────────────────────────────────
Pfusion → 221 [MW] PF_material → nb3sn capital_cost → 7.11 [$B]
Qfusion → 2.21 TF_material → nb3sn_kdemo levelized_CoE → Inf [$/kWh]
thermal_cycle_type → rankine OH_material → nb3sn TF_of_total → 16.4 [%]
thermal_efficiency_plant → 22.7 [%] TF_max_b → 15.4 [T] BOP_of_total → 1.6 [%]
thermal_efficiency_cycle → NaN [%] OH_max_b → 16 [T] blanket_of_total → 17.9 [%]
power_electric_generated → 16.7 [MW] TF_j_margin → 6.59 cryostat_of_total → 2.88 [%]
Pelectric_net → -128 [MW] OH_j_margin → 1.41
Qplant → 0.115 TF_stress_margin → 3.03
TBR → 0.069 OH_stress_margin → 1.2