Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Flattop duration fix #773

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/actors/build/fluxswing_actor.jl
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ function _step(actor::ActorFluxSwing)
bd.flux_swing.rampup = rampup_flux_estimates(eqt, cp)
bd.flux_swing.pf = pf_flux_estimates(eqt)
if !ismissing(requirements, :flattop_duration) && !par.operate_oh_at_j_crit
bd.flux_swing.flattop = flattop_flux_estimates(requirements, cp1d; requirements.coil_j_margin) # flattop flux based on requirements duration
bd.flux_swing.flattop = flattop_flux_estimates(requirements, cp1d) # flattop flux based on requirements duration
oh_required_J_B!(bd)
else
oh_maximum_J_B!(bd; requirements.coil_j_margin)
Expand Down Expand Up @@ -109,15 +109,15 @@ function rampup_flux_estimates(eqt::IMAS.equilibrium__time_slice, cp::IMAS.core_
end

"""
flattop_flux_estimates(requirements::IMAS.requirements, cp1d::IMAS.core_profiles__profiles_1d; coil_j_margin::Float64)
flattop_flux_estimates(requirements::IMAS.requirements, cp1d::IMAS.core_profiles__profiles_1d)

Estimate OH flux requirement during flattop
"""
function flattop_flux_estimates(requirements::IMAS.requirements, cp1d::IMAS.core_profiles__profiles_1d; coil_j_margin::Float64)
function flattop_flux_estimates(requirements::IMAS.requirements, cp1d::IMAS.core_profiles__profiles_1d)
j_ohmic = cp1d.j_ohmic
conductivity_parallel = cp1d.conductivity_parallel
f = (k, x) -> j_ohmic[k] / conductivity_parallel[k]
return abs(trapz(cp1d.grid.area, f)) * requirements.flattop_duration * (1.0 + coil_j_margin) # V*s
return abs(trapz(cp1d.grid.area, f)) * requirements.flattop_duration # V*s
end

"""
Expand Down
6 changes: 3 additions & 3 deletions src/actors/build/hfs_actor.jl
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ function _step(actor::ActorHFSsizing)

# flattop
if (dd.requirements.coil_j_margin >= 0) && !ismissing(dd.requirements, :flattop_duration)
c_flt = -target_value(dd.build.oh.flattop_duration, dd.requirements.flattop_duration, dd.requirements.coil_j_margin)
c_flt = -target_value(dd.build.oh.flattop_duration, dd.requirements.flattop_duration, 0.0)
else
c_flt = 0.0
end
Expand All @@ -144,7 +144,7 @@ function _step(actor::ActorHFSsizing)
push!(margins, cs.properties.yield_strength.pl / maximum(cs.stress.vonmises.pl) - 1.0 - dd.requirements.coil_stress_margin)
end
if (dd.requirements.coil_j_margin >= 0) && !ismissing(dd.requirements, :flattop_duration)
push!(margins, dd.build.oh.flattop_duration / dd.requirements.flattop_duration - 1.0 - dd.requirements.coil_j_margin)
push!(margins, dd.build.oh.flattop_duration / dd.requirements.flattop_duration - 1.0)
end

c_mgn = norm(margins)
Expand Down Expand Up @@ -365,4 +365,4 @@ function assert_conditions(passing_condition::Bool, message::String, do_raise::B
@warn message
end
return success && !(do_raise && !passing_condition)
end
end
Loading