Skip to content

Commit

Permalink
Always make discrete_control callback, add docsring to `apply_discret…
Browse files Browse the repository at this point in the history
…e_control!`
  • Loading branch information
SouthEndMusic committed Jun 11, 2024
1 parent 0f624fe commit a2c2d35
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions core/src/callback.jl
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,10 @@ function create_callbacks(
push!(callbacks, export_cb)
end

saved = SavedResults(saved_flow, saved_vertical_flux, saved_subgrid_level)
discrete_control_cb = FunctionCallingCallback(apply_discrete_control!)
push!(callbacks, discrete_control_cb)

if !isempty(discrete_control.logic_mapping)
discrete_control_cb = FunctionCallingCallback(apply_discrete_control!)
push!(callbacks, discrete_control_cb)
end
saved = SavedResults(saved_flow, saved_vertical_flux, saved_subgrid_level)
callback = CallbackSet(callbacks...)

return callback, saved
Expand Down Expand Up @@ -196,6 +194,13 @@ function save_vertical_flux(u, t, integrator)
return vertical_flux_mean
end

"""
Apply the discrete control logic. Each DiscreteControl node has one or more variables associated with it,
and these variables are a linear combination of one or more state/time derived parameters of the model.
The values of these variables are compared against 'greater_than' thresholds. These conditions yield a 'truth_state'
consisting of 'truth_values' for a DiscreteControl node. This truth_state then corresponds with a 'control_state',
and nodes controlled by a DiscreteControl node have parameter values associated with this control_state.
"""
function apply_discrete_control!(u, t, integrator)::Nothing
(; p) = integrator
(; discrete_control) = p
Expand Down

0 comments on commit a2c2d35

Please sign in to comment.