diff --git a/Project.toml b/Project.toml index a5addab..029363f 100644 --- a/Project.toml +++ b/Project.toml @@ -9,6 +9,7 @@ DSP = "717857b8-e6f2-59f4-9121-6e50c889abd2" DelimitedFiles = "8bb1440f-4735-579b-a4ab-409b98df4dab" GGDUtils = "b7b5e640-9b39-4803-84eb-376048795def" IMASDD = "06b86afa-9f21-11ec-2ef8-e51b8960cfc5" +IMAS = "13ead8c1-b7d1-41bb-a6d0-5b8b65ed587a" Interpolations = "a98d9a8b-a2ab-59e6-89dd-64a1c18fca59" LsqFit = "2fda8390-95c7-5789-9bda-21331edee243" PhysicalConstants = "5ad8b20f-a522-5ce9-bfc9-ddf1d5bda6ab" @@ -24,7 +25,6 @@ ArgParse = "1" DSP = "0.7.9" DelimitedFiles = "1.9.1" GGDUtils = "1.0.2" -IMASDD = "0.1, 1" Interpolations = "0.15.1" LsqFit = "0.15.0" PhysicalConstants = "0.2.3" diff --git a/src/SynthDiag.jl b/src/SynthDiag.jl index 6b89906..7a5feec 100644 --- a/src/SynthDiag.jl +++ b/src/SynthDiag.jl @@ -1,6 +1,6 @@ module SynthDiag -using IMASDD: IMASDD +using IMAS: IMAS include("$(@__DIR__)/noise.jl") diff --git a/src/derived.jl b/src/derived.jl index 3c9760e..d8f86e2 100644 --- a/src/derived.jl +++ b/src/derived.jl @@ -14,7 +14,7 @@ export get_powr_from_dd, find_OMP_RZ, read_B_theta_OMP """ - function find_OMP_RZ(dd::IMASDD.dd; + function find_OMP_RZ(dd::IMAS.dd; grid_ggd_idx::Int=1, space_number::Int=1, midplane_grid_subset::Int=11, @@ -30,7 +30,7 @@ Reads poloidal magnetic field at the outer midplane separatrix. - midplane_grid_subset: index of the subset that contains the 1D outboard midplane - separatrix_grid_subset: index of the subset that contains the 1D separatrix """ -function find_OMP_RZ(dd::IMASDD.dd; +function find_OMP_RZ(dd::IMAS.dd; grid_ggd_idx::Int=1, space_number::Int=1, midplane_grid_subset::Int=11, @@ -45,7 +45,7 @@ function find_OMP_RZ(dd::IMASDD.dd; end """ - function find_OMP_RZ(grid_ggd::IMASDD.edge_profiles__grid_ggd{Float64}; + function find_OMP_RZ(grid_ggd::IMAS.edge_profiles__grid_ggd{Float64}; space_number::Int=1, midplane_grid_subset::Int=11, separatrix_grid_subset::Int=16, @@ -59,7 +59,7 @@ Reads poloidal magnetic field at the outer midplane separatrix. - midplane_grid_subset: index of the subset that contains the 1D outboard midplane - separatrix_grid_subset: index of the subset that contains the 1D separatrix """ -function find_OMP_RZ(grid_ggd::IMASDD.edge_profiles__grid_ggd{Float64}; +function find_OMP_RZ(grid_ggd::IMAS.edge_profiles__grid_ggd{Float64}; space_number::Int=1, midplane_grid_subset::Int=11, separatrix_grid_subset::Int=16, @@ -78,7 +78,7 @@ function find_OMP_RZ(grid_ggd::IMASDD.edge_profiles__grid_ggd{Float64}; end """ - read_B_theta_OMP(dd::IMASDD.dd; + read_B_theta_OMP(dd::IMAS.dd; grid_ggd_idx::Int=1, grid_ggds=nothing, space_number::Int=1, @@ -102,7 +102,7 @@ Reads poloidal magnetic field at the outer midplane separatrix. - midplane_grid_subset: index of the subset that contains the 1D outboard midplane - separatrix_grid_subset: index of the subset that contains the 1D separatrix """ -function read_B_theta_OMP(dd::IMASDD.dd; +function read_B_theta_OMP(dd::IMAS.dd; grid_ggd_idx::Int=1, grid_ggds=nothing, space_number::Int=1, @@ -167,12 +167,12 @@ function read_B_theta_OMP(dd::IMASDD.dd; end """ - function read_B_theta_OMP_no_ggd(dd::IMASDD.dd; time_idx::Int=1) + function read_B_theta_OMP_no_ggd(dd::IMAS.dd; time_idx::Int=1) Uses flux map in equilibrium (which is normally on a rectangular grid) to get the magnetic field at the midplane """ -function read_B_theta_OMP_no_ggd(dd::IMASDD.dd; time_idx::Int=1) +function read_B_theta_OMP_no_ggd(dd::IMAS.dd; time_idx::Int=1) # r0 = dd.summary.global_quantities.r0.value # b0 = dd.summary.global_quantities.b0.value[time_idx] @@ -190,7 +190,7 @@ function read_B_theta_OMP_no_ggd(dd::IMASDD.dd; time_idx::Int=1) psin = (psirz .- psia) ./ (psib .- psia) - dpsidr, dpsidz = IMASDD.gradient(r, z, psirz) + dpsidr, dpsidz = IMAS.gradient(r, z, psirz) br = -dpsidz ./ r bz = dpsidr ./ r #bphi = r0 * b0 ./ r @@ -229,14 +229,14 @@ end # """ # function mag_field_from_equil_to_ggd!( -# dd::IMASDD.dd; time_idx::Int=1, grid_ggd_source=nothing +# dd::IMAS.dd; time_idx::Int=1, grid_ggd_source=nothing # ) # Uses flux map in equilibrium (which is normally on a rectangular grid) along with a # grid_ggd definition instance to define magnetic field components on the ggd mesh. # """ # function mag_field_from_equil_to_ggd!( -# dd::IMASDD.dd; time_idx::Int=1, grid_ggd_source=nothing, +# dd::IMAS.dd; time_idx::Int=1, grid_ggd_source=nothing, # ) # if grid_ggd_source == nothing # grid_ggd_source = dd.edge_profiles.grid_ggd[1] @@ -264,11 +264,11 @@ end # end """ - get_power_from_dd(dd::IMASDD.dd) + get_power_from_dd(dd::IMAS.dd) Utility for extracting power values from the data dictionary. Intended for internal use. """ -function get_power_from_dd(dd::IMASDD.dd) +function get_power_from_dd(dd::IMAS.dd) time = dd.summary.time W = dd.summary.global_quantities.energy_mhd.value P_rad_core = dd.summary.global_quantities.power_radiated_inside_lcfs.value @@ -341,7 +341,7 @@ end Simple calculation of loss power if only conducted power is considered (neglecting radiation). This normally would function as an inner layer and be called by the version -of this function that accepts an IMASDD.dd instance. +of this function that accepts an IMAS.dd instance. """ function calc_conducted_loss_power( time::Array{Float64}, @@ -364,7 +364,7 @@ function calc_conducted_loss_power( P_fusion=P_fusion, P_other=P_other, ) - dWdt = IMASDD.gradient(time, W) + dWdt = IMAS.gradient(time, W) P_cond = [ calc_conducted_loss_power( dWdt[i], @@ -394,7 +394,7 @@ end Simple calculation of loss power if only conducted power is considered (neglecting radiation). This normally would function as an inner layer and be called by the version -of this function that accepts an IMASDD.dd instance. +of this function that accepts an IMAS.dd instance. """ function calc_conducted_loss_power( dWdt::Float64, @@ -427,7 +427,7 @@ end Simple calculation of loss power across the separatrix. Core radiation is included. This normally would function as an inner layer and be called by the version of this function -that accepts an IMASDD.dd instance. +that accepts an IMAS.dd instance. """ function calc_loss_power( time::Array{Float64}, @@ -441,7 +441,7 @@ function calc_loss_power( P_fusion=nothing, P_other=nothing, )::Array{Float64} - dWdt = IMASDD.gradient(time, W) + dWdt = IMAS.gradient(time, W) nt = length(time) P_NBI, P_ECH, P_ICH, P_LH, P_fusion, P_other = set_default_power_arrays( nt; @@ -483,7 +483,7 @@ end Simple calculation of loss power across the separatrix. Core radiation is included. This normally would function as an inner layer and be called by the version of this function -that accepts an IMASDD.dd instance. +that accepts an IMAS.dd instance. """ function calc_loss_power( dWdt::Float64, @@ -511,11 +511,11 @@ function calc_loss_power( end """ - function calc_loss_power(dd::IMASDD.dd)::Array{Float64} + function calc_loss_power(dd::IMAS.dd)::Array{Float64} Simple calculation of loss power across the separatrix. Core radiation is included. """ -function calc_loss_power(dd::IMASDD.dd)::Array{Float64} +function calc_loss_power(dd::IMAS.dd)::Array{Float64} time, W, P_rad_core, P_OHM, P_NBI, P_ECH, P_ICH, P_LH, P_fusion, P_other = get_power_from_dd(dd) P_SOL = calc_loss_power( @@ -565,7 +565,7 @@ function calc_q_cyl( end """ - calc_heat_flux_width(dd::IMASDD.dd; version::Int=1) + calc_heat_flux_width(dd::IMAS.dd; version::Int=1) Calculates heat flux width from a scaling law. Different regressions are available by selecting different versions of the scaling law. @@ -575,7 +575,7 @@ top row of table 6 from [Eich 2013 NF] Version 2 is a simple constant times the poloidal field at the outboard midplane from regression #14 in table 3 of [Eich 2013 NF] """ -function calc_heat_flux_width(dd::IMASDD.dd; version::Int=1)::Array{Float64} +function calc_heat_flux_width(dd::IMAS.dd; version::Int=1)::Array{Float64} if version == 1 B_ϕ_axis = dd.equilibrium.time_slice[:].global_quantities.magnetic_axis.b_field_tor diff --git a/src/gas_injection.jl b/src/gas_injection.jl index 202f81b..7b0b360 100644 --- a/src/gas_injection.jl +++ b/src/gas_injection.jl @@ -12,22 +12,22 @@ default_gas_injection = "$(@__DIR__)/default_gas_injection.json" """ add_gas_injection!( config::String=default_gas_injection, - @nospecialize(ids::IMASDD.dd)=IMASDD.dd(); + @nospecialize(ids::IMAS.dd)=IMAS.dd(); overwrite::Bool=false, verbose::Bool=false, - )::IMASDD.dd + )::IMAS.dd Add gas valves from a JSON file and compute the gas flow rate based on the command signal in the gas valves. """ function add_gas_injection!( config::String=default_gas_injection, - @nospecialize(ids::IMASDD.dd)=IMASDD.dd(); + @nospecialize(ids::IMAS.dd)=IMAS.dd(); overwrite::Bool=false, verbose::Bool=false, -)::IMASDD.dd +)::IMAS.dd if endswith(config, ".json") - config_dict = convert_strings_to_symbols(IMASDD.JSON.parsefile(config)) + config_dict = convert_strings_to_symbols(IMAS.IMASDD.JSON.parsefile(config)) add_gas_injection!(config_dict, ids; overwrite=overwrite, verbose=verbose) else error("Only JSON files are supported.") @@ -38,20 +38,20 @@ end """ add_gas_injection!( config::Dict{Symbol, Any}, - @nospecialize(ids::IMASDD.dd)=IMASDD.dd(); + @nospecialize(ids::IMAS.dd)=IMAS.dd(); overwrite::Bool=false, verbose::Bool=false, - )::IMASDD.dd + )::IMAS.dd Add gas valves from a dictionary and compute the gas flow rate based on the command signal in the gas valves. """ function add_gas_injection!( config::Dict{Symbol, Any}, - @nospecialize(ids::IMASDD.dd)=IMASDD.dd(); + @nospecialize(ids::IMAS.dd)=IMAS.dd(); overwrite::Bool=false, verbose::Bool=false, -)::IMASDD.dd +)::IMAS.dd # Check for duplicates if length(ids.gas_injection.valve) > 0 duplicate_indices = [] @@ -85,11 +85,11 @@ function add_gas_injection!( config[:gas_injection] = mergewith( append!, - IMASDD.imas2dict(ids.gas_injection), + IMAS.imas2dict(ids.gas_injection), config[:gas_injection], ) end - IMASDD.dict2imas(config, ids; verbose=verbose) + IMAS.dict2imas(config, ids; verbose=verbose) valves = Dict{String, Dict{Symbol, Any}}( valve[:name] => valve for valve ∈ config[:gas_injection][:valve] ) @@ -99,19 +99,19 @@ end """ compute_gas_injection!( - ids::IMASDD.dd; + ids::IMAS.dd; valves::Dict{String, Dict{Symbol, Any}}=Dict{String, Dict{Symbol, Any}}(), )::Array{Vector{Float64}} Compute the gas flow rate based on the command signal in the all gas valves. """ function compute_gas_injection!( - ids::IMASDD.dd; + ids::IMAS.dd; valves::Dict{String, Dict{Symbol, Any}}=Dict{String, Dict{Symbol, Any}}(), )::Array{Vector{Float64}} - if IMASDD.ismissing(ids.gas_injection, :latency) + if IMAS.ismissing(ids.gas_injection, :latency) global_latency = 0.0 - elseif IMASDD.isempty(ids.gas_injection.latency) + elseif IMAS.isempty(ids.gas_injection.latency) global_latency = 0.0 else global_latency = ids.gas_injection.latency @@ -121,13 +121,13 @@ function compute_gas_injection!( for (vind, valve) ∈ enumerate(ids.gas_injection.valve) future_flow_rates[vind] = Float64[] proceed = - !IMASDD.ismissing(valve.response_curve, :flow_rate) && - !IMASDD.ismissing(valve.response_curve, :voltage) && - !IMASDD.ismissing(valve.voltage, :data) && - !IMASDD.ismissing(valve.voltage, :time) + !IMAS.ismissing(valve.response_curve, :flow_rate) && + !IMAS.ismissing(valve.response_curve, :voltage) && + !IMAS.ismissing(valve.voltage, :data) && + !IMAS.ismissing(valve.voltage, :time) if proceed - if !IMASDD.isempty(valve.response_curve.flow_rate) && - !IMASDD.isempty(valve.response_curve.voltage) + if !IMAS.isempty(valve.response_curve.flow_rate) && + !IMAS.isempty(valve.response_curve.voltage) if length(valve.response_curve.flow_rate) != length(valve.response_curve.voltage) error( @@ -142,8 +142,8 @@ function compute_gas_injection!( "Skipping computation of flow rate.", ) end - if !IMASDD.isempty(valve.voltage.data) && - !IMASDD.isempty(valve.voltage.time) + if !IMAS.isempty(valve.voltage.data) && + !IMAS.isempty(valve.voltage.time) if length(valve.voltage.data) != length(valve.voltage.time) error( "$(valve.name): Length of data and time in voltage " * @@ -244,7 +244,7 @@ end compute_gas_injection( tt::Vector{Float64}, cmd_voltage::Vector{Float64}, - response_curve::IMASDD.gas_injection__valve___response_curve; + response_curve::IMAS.gas_injection__valve___response_curve; valve_model::Dict{Symbol, Any}=Dict{Symbol, Any}(), global_latency::Float64=0.0, )::Tuple{Vector{Float64}, Vector{Float64}, Vector{Float64}} @@ -255,7 +255,7 @@ everything else is provided in base Julia types. function compute_gas_injection( tt::Vector{Float64}, cmd_voltage::Vector{Float64}, - response_curve::IMASDD.gas_injection__valve___response_curve; + response_curve::IMAS.gas_injection__valve___response_curve; valve_model::Dict{Symbol, Any}=Dict{Symbol, Any}(), global_latency::Float64=0.0, )::Tuple{Vector{Float64}, Vector{Float64}, Vector{Float64}} @@ -271,7 +271,7 @@ end """ compute_gas_injection( - valve::IMASDD.gas_injection__valve; + valve::IMAS.gas_injection__valve; valve_model::Dict{Symbol, Any}=Dict{Symbol, Any}(), global_latency::Float64=0.0, )::Tuple{Vector{Float64}, Vector{Float64}, Vector{Float64}} @@ -279,7 +279,7 @@ end Top most level function to compute gas flow rate for a single valve. """ function compute_gas_injection( - valve::IMASDD.gas_injection__valve; + valve::IMAS.gas_injection__valve; valve_model::Dict{Symbol, Any}=Dict{Symbol, Any}(), global_latency::Float64=0.0, )::Tuple{Vector{Float64}, Vector{Float64}, Vector{Float64}} @@ -294,7 +294,7 @@ end """ compute_gas_injection!( - valve::IMASDD.gas_injection__valve; + valve::IMAS.gas_injection__valve; valve_model::Dict{Symbol, Any}=Dict{Symbol, Any}(), global_latency::Float64=0.0, )::Vector{Float64} @@ -302,7 +302,7 @@ end In-place version of [`compute_gas_injection`](@ref) function for a single valve. """ function compute_gas_injection!( - valve::IMASDD.gas_injection__valve; + valve::IMAS.gas_injection__valve; valve_model::Dict{Symbol, Any}=Dict{Symbol, Any}(), global_latency::Float64=0.0, )::Vector{Float64} @@ -508,7 +508,7 @@ end resample_dt::Float64=0.02, gi_fit_guess::Vector{Float64}=[1.0, 1.0], response_curve_voltage::Vector{Float64}=collect(0:0.001:11), - )::Tuple{IMASDD.gas_injection__valve___response_curve, Dict{Symbol, Any}} + )::Tuple{IMAS.gas_injection__valve___response_curve, Dict{Symbol, Any}} Function to fit a gas calibration shot data to a gas injection model. It requires 2 set of data: @@ -535,7 +535,7 @@ function get_gas_injection_response( resample_dt::Float64=0.02, gi_fit_guess::Vector{Float64}=[1.0, 1.0], response_curve_voltage::Vector{Float64}=collect(0:0.001:11), -)::Tuple{IMASDD.gas_injection__valve___response_curve, Dict{Symbol, Any}} +)::Tuple{IMAS.gas_injection__valve___response_curve, Dict{Symbol, Any}} tt = collect(min(cmd_tt[1], P_ves_tt[1]):resample_dt:max(cmd_tt[end], P_ves_tt[end])) cmd = downsample_smooth(cmd_tt, cmd, tt) @@ -561,7 +561,7 @@ function get_gas_injection_response( ) # Calculate the response curve - response_curve = IMASDD.gas_injection__valve___response_curve() + response_curve = IMAS.gas_injection__valve___response_curve() response_curve.voltage = response_curve_voltage response_curve.flow_rate = gi_model(response_curve_voltage, coef(fit)) @@ -573,14 +573,14 @@ end """ get_required_gas_cmd( required_flow_rate::Float64, - response_curve::IMASDD.gas_injection__valve___response_curve, + response_curve::IMAS.gas_injection__valve___response_curve, )::Float64 Function to get the required gas command voltage to achieve the required flow rate. """ function get_required_gas_cmd( required_flow_rate::Float64, - response_curve::IMASDD.gas_injection__valve___response_curve, + response_curve::IMAS.gas_injection__valve___response_curve, )::Float64 gas_cmd = linear_interpolation(response_curve.flow_rate, response_curve.voltage) return gas_cmd(required_flow_rate) @@ -589,14 +589,14 @@ end """ get_required_gas_cmd( required_flow_rate::Vector{Float64}, - response_curve::IMASDD.gas_injection__valve___response_curve, + response_curve::IMAS.gas_injection__valve___response_curve, )::Vector{Float64} Function to get the required gas command voltage to achieve the required flow rate. """ function get_required_gas_cmd( required_flow_rate::Vector{Float64}, - response_curve::IMASDD.gas_injection__valve___response_curve, + response_curve::IMAS.gas_injection__valve___response_curve, )::Vector{Float64} gas_cmd = linear_interpolation(response_curve.flow_rate, response_curve.voltage) return gas_cmd.(required_flow_rate) diff --git a/src/interferometer.jl b/src/interferometer.jl index 94f5205..a823ce3 100644 --- a/src/interferometer.jl +++ b/src/interferometer.jl @@ -10,20 +10,20 @@ default_ifo = "$(@__DIR__)/default_interferometer.json" """ add_interferometer!( config::String=default_ifo, - @nospecialize(ids::IMASDD.dd)=IMASDD.dd(); + @nospecialize(ids::IMAS.dd)=IMAS.dd(); overwrite::Bool=false, verbose::Bool=false, rtol::Float64=1e-3, n_e_gsi::Int=5, - )::IMASDD.dd + )::IMAS.dd Add interferometer to IMAS structure using a JSON file and compute the line integrated electron density if not present """ function add_interferometer!( config::String=default_ifo, - @nospecialize(ids::IMASDD.dd)=IMASDD.dd(); + @nospecialize(ids::IMAS.dd)=IMAS.dd(); overwrite::Bool=false, verbose::Bool=false, rtol::Float64=1e-3, n_e_gsi::Int=5, -)::IMASDD.dd +)::IMAS.dd if endswith(config, ".json") - config_dict = convert_strings_to_symbols(IMASDD.JSON.parsefile(config)) + config_dict = convert_strings_to_symbols(IMAS.IMASDD.JSON.parsefile(config)) add_interferometer!( config_dict, ids; @@ -41,18 +41,18 @@ end """ add_interferometer!( config::Dict{Symbol, Any}, - @nospecialize(ids::IMASDD.dd)=IMASDD.dd(); + @nospecialize(ids::IMAS.dd)=IMAS.dd(); overwrite::Bool=false, verbose::Bool=false, rtol::Float64=1e-3, n_e_gsi::Int=5, - )::IMASDD.dd + )::IMAS.dd Add interferometer to IMAS structure using a Dict and compute the line integrated electron density if not present """ function add_interferometer!( config::Dict{Symbol, Any}, - @nospecialize(ids::IMASDD.dd)=IMASDD.dd(); + @nospecialize(ids::IMAS.dd)=IMAS.dd(); overwrite::Bool=false, verbose::Bool=false, rtol::Float64=1e-3, n_e_gsi::Int=5, -)::IMASDD.dd +)::IMAS.dd # Check for duplicates if length(ids.interferometer.channel) > 0 duplicate_indices = [] @@ -91,18 +91,18 @@ function add_interferometer!( config[:interferometer] = mergewith( append!, - IMASDD.imas2dict(ids.interferometer), + IMAS.imas2dict(ids.interferometer), config[:interferometer], ) end - IMASDD.dict2imas(config, ids; verbose=verbose) + IMAS.dict2imas(config, ids; verbose=verbose) compute_interferometer!(ids; rtol=rtol, n_e_gsi=n_e_gsi) return ids end """ compute_interferometer!( - @nospecialize(ids::IMASDD.dd); + @nospecialize(ids::IMAS.dd); rtol::Float64=1e-3, n_e_gsi::Int=5, ) @@ -112,7 +112,7 @@ IDS structure for all the chords. The computation is based on the edge profile d and core profile data present in the IDS structure. """ function compute_interferometer!( - @nospecialize(ids::IMASDD.dd); + @nospecialize(ids::IMAS.dd); rtol::Float64=1e-3, n_e_gsi::Int=5, ) @@ -122,7 +122,7 @@ function compute_interferometer!( for i1 ∈ 1:2 lam = ch.wavelength[i1] i2 = i1 % 2 + 1 - if IMASDD.ismissing(lam, :phase_to_n_e_line) + if IMAS.ismissing(lam, :phase_to_n_e_line) # Taken from https://doi.org/10.1063/1.1138037 lam.phase_to_n_e_line = ( @@ -165,7 +165,7 @@ function compute_interferometer!( # Special case when measurement has not been made for some time steps # but edge profile data exists proceed = - (IMASDD.ismissing(ch.n_e_line, :time) || IMASDD.isempty(ch.n_e_line.time)) + (IMAS.ismissing(ch.n_e_line, :time) || IMAS.isempty(ch.n_e_line.time)) if !proceed proceed = length(ch.n_e_line.time) < length(epggd) end @@ -196,7 +196,7 @@ function compute_interferometer!( sp = rzphi2xyz(ch.line_of_sight.second_point) tp = rzphi2xyz(ch.line_of_sight.third_point) if ch.line_of_sight.third_point == - IMASDD.interferometer__channel___line_of_sight__third_point() + IMAS.interferometer__channel___line_of_sight__third_point() chord_points = (fp, sp) else chord_points = (fp, sp, tp) @@ -256,7 +256,7 @@ function get_sep_bnd(ep_grid_ggd) ep_space = ep_grid_ggd.space[1] core = get_grid_subset(ep_grid_ggd, 22) sol = get_grid_subset(ep_grid_ggd, 23) - sep_bnd = IMASDD.edge_profiles__grid_ggd___grid_subset() + sep_bnd = IMAS.edge_profiles__grid_ggd___grid_subset() sep_bnd.element = subset_do( intersect, @@ -267,9 +267,9 @@ function get_sep_bnd(ep_grid_ggd) end @inline function rzphi2xyz( - point::Union{IMASDD.interferometer__channel___line_of_sight__first_point, - IMASDD.interferometer__channel___line_of_sight__second_point, - IMASDD.interferometer__channel___line_of_sight__third_point}, + point::Union{IMAS.interferometer__channel___line_of_sight__first_point, + IMAS.interferometer__channel___line_of_sight__second_point, + IMAS.interferometer__channel___line_of_sight__third_point}, ) r, z, phi = point.r, point.z, point.phi return r * cos(phi), r * sin(phi), z diff --git a/src/langmuir_probes.jl b/src/langmuir_probes.jl index dd3f377..bfffa13 100644 --- a/src/langmuir_probes.jl +++ b/src/langmuir_probes.jl @@ -8,19 +8,19 @@ default_lp = "$(@__DIR__)/default_langmuir_probes.json" """ add_langmuir_probes!( config::String=default_lp, - @nospecialize(ids::IMASDD.dd)=IMASDD.dd(); + @nospecialize(ids::IMAS.dd)=IMAS.dd(); overwrite=false, verbose=false, kwargs..., - )::IMASDD.dd + )::IMAS.dd Add langmuir probes positions and other parameters from `JSON` file to ids structure """ function add_langmuir_probes!( config::String=default_lp, - @nospecialize(ids::IMASDD.dd)=IMASDD.dd(); + @nospecialize(ids::IMAS.dd)=IMAS.dd(); overwrite=false, verbose=false, kwargs..., -)::IMASDD.dd +)::IMAS.dd if endswith(config, ".json") - config_dict = convert_strings_to_symbols(IMASDD.JSON.parsefile(config)) + config_dict = convert_strings_to_symbols(IMAS.IMASDD.JSON.parsefile(config)) add_langmuir_probes!( config_dict, ids; @@ -37,17 +37,17 @@ end """ add_langmuir_probes!( config::Dict{Symbol, Any}, - @nospecialize(ids::IMASDD.dd)=IMASDD.dd(); + @nospecialize(ids::IMAS.dd)=IMAS.dd(); overwrite=false, verbose=false, kwargs..., - )::IMASDD.dd + )::IMAS.dd Add langmuir probes positions and other parameters from Dictionary to ids structure """ function add_langmuir_probes!( config::Dict{Symbol, Any}, - @nospecialize(ids::IMASDD.dd)=IMASDD.dd(); + @nospecialize(ids::IMAS.dd)=IMAS.dd(); overwrite=false, verbose=false, kwargs..., -)::IMASDD.dd +)::IMAS.dd # Check for duplicates if length(ids.langmuir_probes.embedded) > 0 new_lps = Dict() @@ -116,18 +116,18 @@ function add_langmuir_probes!( config[:langmuir_probes] = mergewith( append!, - IMASDD.imas2dict(ids.langmuir_probes), + IMAS.imas2dict(ids.langmuir_probes), config[:langmuir_probes], ) end - IMASDD.dict2imas(config, ids; verbose=verbose) + IMAS.dict2imas(config, ids; verbose=verbose) compute_langmuir_probes!(ids; kwargs...) return ids end """ compute_langmuir_probes!( - ids::IMASDD.dd; + ids::IMAS.dd; v_plasma::Union{Float64, Vector{Float64}, Nothing}=nothing, v_floating::Union{Float64, Vector{Float64}, Nothing}=nothing, v_probe::Union{Float64, Vector{Float64}, Nothing}=nothing, @@ -150,7 +150,7 @@ densities using data type [`Noise`](@ref). Input arguments: - - `ids`: IMASDD.dd object + - `ids`: IMAS.dd object - `v_plasma`: Plasma potential (in V) or a vector of plasma potentials for each time step - `v_floating`: Floating potential (in V) or a vector of floating potentials for each @@ -167,7 +167,7 @@ Input arguments: electron temperature, and average ion temperature. """ function compute_langmuir_probes!( - ids::IMASDD.dd; + ids::IMAS.dd; v_plasma::Union{Float64, Vector{Float64}, Nothing}=nothing, v_floating::Union{Float64, Vector{Float64}, Nothing}=nothing, v_probe::Union{Float64, Vector{Float64}, Nothing}=nothing, @@ -266,7 +266,7 @@ function compute_langmuir_probes!( if !isnothing(v_plasma) && isnothing(v_floating) emb_lp.v_floating.data = Te .* log.(abs.(I_isc ./ I_esc)) end - if !isnothing(v_probe) && !IMASDD.ismissing(emb_lp.v_plasma.data) + if !isnothing(v_probe) && !IMAS.ismissing(emb_lp.v_plasma.data) i_probe = langmuir_probe_current.( v_probe - emb_lp.v_plasma.data, @@ -369,7 +369,7 @@ function langmuir_probe_current( return i_probe end -lp_data_types = Union{get_types_with(IMASDD.langmuir_probes, :data)...} +lp_data_types = Union{get_types_with(IMAS.langmuir_probes, :data)...} """ init_data!(q::lp_data_types, nt::Int) @@ -385,9 +385,9 @@ end """ init_data!( q::Union{ - IMASDD.langmuir_probes__embedded, - IMASDD.langmuir_probes__reciprocating___plunge, - IMASDD.langmuir_probes__reciprocating___plunge___collector, + IMAS.langmuir_probes__embedded, + IMAS.langmuir_probes__reciprocating___plunge, + IMAS.langmuir_probes__reciprocating___plunge___collector, }, nt::Int, ) @@ -399,9 +399,9 @@ they can have different lengths. """ function init_data!( q::Union{ - IMASDD.langmuir_probes__embedded, - IMASDD.langmuir_probes__reciprocating___plunge, - IMASDD.langmuir_probes__reciprocating___plunge___collector, + IMAS.langmuir_probes__embedded, + IMAS.langmuir_probes__reciprocating___plunge, + IMAS.langmuir_probes__reciprocating___plunge___collector, }, nt::Int, ) @@ -415,7 +415,7 @@ function init_data!( setproperty!(q, f, zeros(Float64, nt)) elseif type_fobj <: AbstractArray if eltype(fobj) <: - IMASDD.langmuir_probes__reciprocating___plunge___collector + IMAS.langmuir_probes__reciprocating___plunge___collector init_data!.(fobj, nt) end end @@ -425,9 +425,9 @@ end """ init_data!( q::Union{ - IMASDD.langmuir_probes__embedded, - IMASDD.langmuir_probes__reciprocating___plunge, - IMASDD.langmuir_probes__reciprocating___plunge___collector, + IMAS.langmuir_probes__embedded, + IMAS.langmuir_probes__reciprocating___plunge, + IMAS.langmuir_probes__reciprocating___plunge___collector, }, t::Vector{Float64}, ) @@ -437,9 +437,9 @@ which is :time for embedded probes and :time_within_plunge for reciprocating pro """ function init_data!( q::Union{ - IMASDD.langmuir_probes__embedded, - IMASDD.langmuir_probes__reciprocating___plunge, - IMASDD.langmuir_probes__reciprocating___plunge___collector, + IMAS.langmuir_probes__embedded, + IMAS.langmuir_probes__reciprocating___plunge, + IMAS.langmuir_probes__reciprocating___plunge___collector, }, t::Vector{Float64}, ) @@ -453,21 +453,21 @@ function init_data!( end """ - init_data!(q::IMASDD.langmuir_probes__reciprocating, nt::Int) + init_data!(q::IMAS.langmuir_probes__reciprocating, nt::Int) Initialize each plunge in a reciprocating probe with nt length zeros. """ -init_data!(q::IMASDD.langmuir_probes__reciprocating, nt::Int) = +init_data!(q::IMAS.langmuir_probes__reciprocating, nt::Int) = for p ∈ q.plunge init_data!(p, nt) end """ - init_data!(q::IMASDD.langmuir_probes__reciprocating, t::Vector{Float64}) + init_data!(q::IMAS.langmuir_probes__reciprocating, t::Vector{Float64}) Initialize each plunge in a reciprocating probe with a time vector t. """ -function init_data!(q::IMASDD.langmuir_probes__reciprocating, t::Vector{Float64}) +function init_data!(q::IMAS.langmuir_probes__reciprocating, t::Vector{Float64}) for p ∈ q.plunge init_data!(p, t) end diff --git a/src/magic.jl b/src/magic.jl index 59b5751..1d8326c 100644 --- a/src/magic.jl +++ b/src/magic.jl @@ -15,7 +15,7 @@ export magic_nesep """ magic_nesep( - dd::IMASDD.dd; + dd::IMAS.dd; grid_ggd_idx::Int=1, space_number::Int=1, cell_grid_subset::Int=5, @@ -28,7 +28,7 @@ The value is interpolated from the model. Inputs: - - dd: a data dictionary instance from IMASDD + - dd: a data dictionary instance from IMAS - grid_ggd_idx: index of the grid_ggd to use. Many cases will have only one grid_ggd. - space_number: space index to use. You may only have one space. - cell_grid_subset: index of the grid subset for cells. This is normally 5, but could be @@ -44,7 +44,7 @@ nesep: an array of n_e,sep values in m^-3 vs time. If the dd has only one timesl the array will only have one element but it will still be an array. """ function magic_nesep( - dd::IMASDD.dd; + dd::IMAS.dd; grid_ggd_idx::Int=1, space_number::Int=1, cell_grid_subset::Int=5, diff --git a/test/runtests.jl b/test/runtests.jl index 1f42eb3..f3048ae 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -1,9 +1,9 @@ -using SynthDiag: IMASDD, add_interferometer!, add_langmuir_probes!, add_gas_injection!, +using SynthDiag: IMAS, add_interferometer!, add_langmuir_probes!, add_gas_injection!, compute_gas_injection!, get_gas_injection_response, Noise, OverwriteAttemptError, langmuir_probe_current, magic_nesep, calc_loss_power, calc_conducted_loss_power, calc_q_cyl, calc_heat_flux_width, find_OMP_RZ, read_B_theta_OMP -using IMASDD: json2imas, gradient +using IMAS: json2imas, gradient using Test using Printf using Plots @@ -195,7 +195,7 @@ if args["langmuir_probes"] end function test_gas_response(config, excitation, plot_title, figname; fit=false) - ids = IMASDD.dd() + ids = IMAS.dd() add_gas_injection!(config, ids) ttotal = 5 nt = Int(ttotal * 1000) + 1 diff --git a/test/speedtest.jl b/test/speedtest.jl index f309d8d..0d656ab 100644 --- a/test/speedtest.jl +++ b/test/speedtest.jl @@ -1,7 +1,7 @@ using SynthDiag: add_interferometer!, add_langmuir_probes!, Noise, OverwriteAttemptError, add_gas_injection!, compute_gas_injection, get_gas_injection_response -using SynthDiag.IMASDD: json2imas, dd +using SynthDiag.IMAS: json2imas, dd using DelimitedFiles: readdlm println("-----------------------------------------------------------------------------")