Skip to content

Commit

Permalink
minor improvements to fluxmatcher and running of tglf(nn)
Browse files Browse the repository at this point in the history
  • Loading branch information
orso82 committed Sep 13, 2023
1 parent 29f726b commit 7667c74
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
6 changes: 3 additions & 3 deletions src/actors/transport/flux_matcher_actor.jl
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ function _step(actor::ActorFluxMatcher)
if par.optimizer_algorithm == :anderson
res = NLsolve.nlsolve(z -> flux_match_errors(actor, z; z_history, err_history), z_init, show_trace=par.verbose, store_trace=par.verbose, method=:anderson, m=0, beta=-par.step_size, iterations=par.max_iterations, ftol=1E-3, xtol=1E-2)
elseif par.optimizer_algorithm == :jacobian_based
res = NLsolve.nlsolve(z -> flux_match_errors(actor, z; z_history, err_history), z_init,factor=1e-2, show_trace=par.verbose, store_trace=par.verbose, iterations=par.max_iterations, ftol=1E-3)
res = NLsolve.nlsolve(z -> flux_match_errors(actor, z; z_history, err_history), z_init, factor=1e-2, show_trace=par.verbose, store_trace=par.verbose, iterations=par.max_iterations, ftol=1E-3)
end
res
finally
Expand Down Expand Up @@ -105,7 +105,7 @@ end
Update the profiles, evaluates neoclassical and turbulent fluxes, sources (ie target fluxes), and returns error between the two
"""
function flux_match_errors(actor::ActorFluxMatcher, z_profiles::AbstractVector{<:Real}; z_history::Vector{Vector{Float64}}=Vector{Float64}[], err_history::Vector{Float64}=Float64[])
push!(z_history,z_profiles)
push!(z_history, z_profiles)
z_profiles = z_profiles ./ 100
dd = actor.dd
par = actor.par
Expand Down Expand Up @@ -153,7 +153,7 @@ function flux_match_errors(dd::IMAS.dd, par::FUSEparameters__ActorFluxMatcher)
end

cp1d = dd.core_profiles.profiles_1d[]
total_sources = IMAS.total_sources(dd.core_sources, cp1d)
total_sources = IMAS.total_sources(dd.core_sources, cp1d; fields=[:particles, :j_parallel, :momentum_tor, :energy])
total_fluxes = IMAS.total_fluxes(dd.core_transport)

cs_gridpoints = [argmin((rho_x .- total_sources.grid.rho_tor_norm) .^ 2) for rho_x in par.rho_transport]
Expand Down
4 changes: 2 additions & 2 deletions src/actors/transport/tglf_actor.jl
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,9 @@ function _step(actor::ActorTGLF)
m1d.grid_flux.rho_tor_norm = par.rho_transport

if par.nn
actor.flux_solutions = map(input_tglf -> TGLFNN.run_tglfnn(input_tglf; par.warn_nn_train_bounds, model_filename), actor.input_tglfs)
actor.flux_solutions = TGLFNN.run_tglfnn(actor.input_tglfs; par.warn_nn_train_bounds, model_filename)
else
actor.flux_solutions = asyncmap(input_tglf -> TGLFNN.run_tglf(input_tglf), actor.input_tglfs)
actor.flux_solutions = TGLFNN.run_tglf(actor.input_tglfs)
end

return actor
Expand Down

0 comments on commit 7667c74

Please sign in to comment.