Skip to content

Commit

Permalink
make FRESCO work
Browse files Browse the repository at this point in the history
  • Loading branch information
orso82 committed Dec 18, 2024
1 parent 10fe724 commit 6e49a8a
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 12 deletions.
8 changes: 5 additions & 3 deletions src/actors/compound/whole_facility_actor.jl
Original file line number Diff line number Diff line change
Expand Up @@ -105,9 +105,11 @@ function _step(actor::ActorWholeFacility)
if par.update_plasma
# remove the wall from the calculation to avoid switching between limited/diverted plasma
wall_bkp = deepcopy(dd.wall)
empty!(dd.wall)
if !isempty(dd.pf_active.coil)
IMAS.first_wall!(dd.wall, IMAS.first_wall(dd.pf_active)...)
if par.update_build && act.ActorCXbuild.rebuild_wall
empty!(dd.wall)
if !isempty(dd.pf_active.coil)
IMAS.first_wall!(dd.wall, IMAS.first_wall(dd.pf_active)...)
end
end
actor.StationaryPlasma = ActorStationaryPlasma(dd, act)
dd.wall = wall_bkp
Expand Down
2 changes: 1 addition & 1 deletion src/actors/equilibrium/equilibrium_actor.jl
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ function ActorEquilibrium(dd::IMAS.dd, par::FUSEparameters__ActorEquilibrium, ac
logging_actor_init(ActorEquilibrium)
par = par(kw...)
if par.model == :FRESCO
eq_actor = ActorFRESCO(dd, act.ActorFRESCO)
eq_actor = ActorFRESCO(dd, act.ActorFRESCO, act)
elseif par.model == :CHEASE
eq_actor = ActorCHEASE(dd, act.ActorCHEASE, act)
elseif par.model == :TEQUILA
Expand Down
21 changes: 13 additions & 8 deletions src/actors/equilibrium/fresco_actor.jl
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ end
mutable struct ActorFRESCO{D,P} <: SingleAbstractActor{D,P}
dd::IMAS.dd{D}
par::FUSEparameters__ActorFRESCO{P}
act::ParametersAllActors{P}
canvas::Union{Nothing,FRESCO.Canvas}
profile::Union{Nothing,FRESCO.PressureJt}
end
Expand All @@ -35,16 +36,16 @@ end
Runs the Fixed boundary equilibrium solver FRESCO
"""
function ActorFRESCO(dd::IMAS.dd, act::ParametersAllActors; kw...)
actor = ActorFRESCO(dd, act.ActorFRESCO; kw...)
actor = ActorFRESCO(dd, act.ActorFRESCO, act; kw...)
step(actor)
finalize(actor)
return actor
end

function ActorFRESCO(dd::IMAS.dd{D}, par::FUSEparameters__ActorFRESCO{P}; kw...) where {D<:Real,P<:Real}
function ActorFRESCO(dd::IMAS.dd{D}, par::FUSEparameters__ActorFRESCO{P}, act::ParametersAllActors{P}; kw...) where {D<:Real,P<:Real}
logging_actor_init(ActorFRESCO)
par = par(kw...)
return ActorFRESCO(dd, par, nothing, nothing)
return ActorFRESCO(dd, par, act, nothing, nothing)
end

"""
Expand All @@ -55,20 +56,24 @@ Runs FRESCO on the r_z boundary, equilibrium pressure and equilibrium j_tor
function _step(actor::ActorFRESCO{D,P}) where {D<:Real,P<:Real}
dd = actor.dd
par = actor.par
act = actor.act

eqt = dd.equilibrium.time_slice[]

ΔR = maximum(eqt.boundary.outline.r) - minimum(eqt.boundary.outline.r)
ΔZ = maximum(eqt.boundary.outline.z) - minimum(eqt.boundary.outline.z)
Rs = range(minimum(eqt.boundary.outline.r) - ΔR / 3, maximum(eqt.boundary.outline.r) + ΔR / 3, par.nR)
Zs = range(minimum(eqt.boundary.outline.z) - ΔZ / 3, maximum(eqt.boundary.outline.z) + ΔZ / 3, par.nZ)
# FRESCO requires the wall to be always fully contained inside of the computation domain
fw_r, fw_z = IMAS.first_wall(dd.wall)
ΔR = maximum(fw_r) - minimum(fw_r)
ΔZ = maximum(fw_z) - minimum(fw_z)
Rs = range(max(0.01, minimum(fw_r) - ΔR / 100), maximum(fw_r) + ΔR / 100, par.nR)
Zs = range(minimum(fw_z) - ΔZ / 100, maximum(fw_z) + ΔZ / 100, par.nZ)

if isempty(dd.pf_active.coil)
coils = encircling_coils(eqt.boundary.outline.r, eqt.boundary.outline.z, eqt.boundary.geometric_axis.r, eqt.boundary.geometric_axis.z, 8)
else
coils = nothing
end

actor.canvas = FRESCO.Canvas(dd, Rs, Zs; coils, load_pf_passive=false)
actor.canvas = FRESCO.Canvas(dd, Rs, Zs; coils, load_pf_passive=false, act.ActorPFactive.strike_points_weight, act.ActorPFactive.x_points_weight)

actor.profile = FRESCO.PressureJt(dd)

Expand Down

0 comments on commit 6e49a8a

Please sign in to comment.