-
Notifications
You must be signed in to change notification settings - Fork 3
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
Input time dependent signals for time dependent simulation #402
Conversation
cases/FPPv2.jl
Outdated
@@ -60,7 +60,7 @@ function case_parameters(::Type{Val{:FPPv2}})::Tuple{ParametersAllInits,Paramete | |||
ini.equilibrium.κ = 0.8826 | |||
ini.equilibrium.δ = 0.7 | |||
ini.equilibrium.pressure_core = 1.2e6 | |||
ini.equilibrium.ip = 8.0e6 | |||
ini.equilibrium.ip = t -> @. trap(t / Δt, 0.9) * 8.0e6 + trap((t - Δt / 4) / (Δt / 2), 0.75) * 1.0E6 - trap((t - Δt * 3 / 8) / (Δt / 4), 0.25) * 2.0E6 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rather that putting @.
inside the function, it would be better to treat it as a scalar and then have the user call ini.equilibrium.ip.(t)
if t
is an array.
src/actors/build/hfs_actor.jl
Outdated
# first run primes for second run | ||
res = Optim.optimize( | ||
x0 -> cost(x0), | ||
[OH.thickness, TFhfs.thickness, dd.build.oh.technology.fraction_steel, dd.build.tf.technology.fraction_steel], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This allocates a small array. Probably trivial, but a Tuple or SVector would be better if they work.
src/ddinit/init_pulse_schedule.jl
Outdated
|
||
Initialize `dd.pulse_schedule` starting from `ini` and `act` parameters | ||
""" | ||
function init_pulse_schedule(dd::IMAS.dd, ini::ParametersAllInits, act::ParametersAllActors) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
init_pulse_schedule!(dd, ini, act)
? since it modifies dd
?
src/parameters_inits.jl
Outdated
κ::Entry{T} = Entry{T}("-", "Plasma elongation. NOTE: If < 1.0 it defines the fraction of maximum controllable elongation estimate.") | ||
δ::Entry{T} = Entry{T}(IMAS.equilibrium__time_slice___boundary, :triangularity) | ||
ζ::Entry{T} = Entry{T}(IMAS.equilibrium__time_slice___boundary, :squareness; default=0.0) | ||
B0::Entry{Union{Function,T}} = Entry{Union{Function,T}}(IMAS.equilibrium__vacuum_toroidal_field, :b0) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this all type stable?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Again, I would not do @.
like this inside functions. The user should call them as step.(t)
, etc.
src/signal.jl
Outdated
function ramp(t::T)::T where T | ||
a = @. t * (t < 1) * (t > 0) | ||
b = @. t >= 1 | ||
return @. a + b |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually this is more than just style. If t
is an array, a
and b
will allocate here. If it was called as ramp.(t)
, they would not be allocated.
mention #387
mention #407 Co-Authored-By: Brendan Lyons <[email protected]>
FUSE input
ini
now supports input of time dependent quantities.Few handy functions make it quite convenient to specify complex behaviors fe39669
for example: