From 0d8ab97fd45e007716e46f89967f0c90fd296066 Mon Sep 17 00:00:00 2001 From: Yingbo Ma Date: Sun, 29 Oct 2023 00:11:52 -0400 Subject: [PATCH] New formatter --- docs/src/tutorials/domain_connections.md | 8 +- ext/MTKBifurcationKitExt.jl | 16 +- ext/MTKDeepDiffsExt.jl | 2 +- src/bipartite_graph.jl | 26 +-- src/inputoutput.jl | 8 +- src/structural_transformation/bareiss.jl | 10 +- .../bipartite_tearing/modia_tearing.jl | 12 +- src/structural_transformation/codegen.jl | 46 ++-- .../partial_state_selection.jl | 6 +- .../symbolics_tearing.jl | 10 +- src/structural_transformation/tearing.jl | 2 +- src/structural_transformation/utils.jl | 8 +- src/systems/abstractsystem.jl | 34 +-- src/systems/alias_elimination.jl | 14 +- src/systems/callbacks.jl | 16 +- src/systems/clock_inference.jl | 4 +- src/systems/connectors.jl | 16 +- src/systems/dependency_graphs.jl | 10 +- src/systems/diffeqs/abstractodesystem.jl | 214 +++++++++--------- src/systems/diffeqs/odesystem.jl | 58 ++--- src/systems/diffeqs/sdesystem.jl | 76 +++---- .../discrete_system/discrete_system.jl | 100 ++++---- src/systems/jumps/jumpsystem.jl | 70 +++--- src/systems/model_parsing.jl | 10 +- src/systems/nonlinear/nonlinearsystem.jl | 92 ++++---- .../optimization/constraints_system.jl | 38 ++-- .../optimization/optimizationsystem.jl | 68 +++--- src/systems/pde/pdesystem.jl | 22 +- src/systems/sparsematrixclil.jl | 4 +- src/systems/systems.jl | 6 +- src/systems/systemstructure.jl | 8 +- src/systems/validation.jl | 6 +- src/utils.jl | 4 +- src/variables.jl | 14 +- test/domain_connectors.jl | 8 +- test/stream_connectors.jl | 24 +- test/symbolic_events.jl | 6 +- 37 files changed, 538 insertions(+), 538 deletions(-) diff --git a/docs/src/tutorials/domain_connections.md b/docs/src/tutorials/domain_connections.md index 7b56c8e0f1..836b6d3fc8 100644 --- a/docs/src/tutorials/domain_connections.md +++ b/docs/src/tutorials/domain_connections.md @@ -31,10 +31,10 @@ The fluid medium setter for `HydralicPort` may be defined as `HydraulicFluid` wi ```@example domain @connector function HydraulicFluid(; - density = 997, - bulk_modulus = 2.09e9, - viscosity = 0.0010016, - name) + density = 997, + bulk_modulus = 2.09e9, + viscosity = 0.0010016, + name) pars = @parameters begin ρ = density β = bulk_modulus diff --git a/ext/MTKBifurcationKitExt.jl b/ext/MTKBifurcationKitExt.jl index c85011b65f..285d348bf5 100644 --- a/ext/MTKBifurcationKitExt.jl +++ b/ext/MTKBifurcationKitExt.jl @@ -10,14 +10,14 @@ import BifurcationKit # When input is a NonlinearSystem. function BifurcationKit.BifurcationProblem(nsys::NonlinearSystem, - u0_bif, - ps, - bif_par, - args...; - plot_var = nothing, - record_from_solution = BifurcationKit.record_sol_default, - jac = true, - kwargs...) + u0_bif, + ps, + bif_par, + args...; + plot_var = nothing, + record_from_solution = BifurcationKit.record_sol_default, + jac = true, + kwargs...) # Creates F and J functions. ofun = NonlinearFunction(nsys; jac = jac) F = ofun.f diff --git a/ext/MTKDeepDiffsExt.jl b/ext/MTKDeepDiffsExt.jl index 1d361f96a3..2e9e8cbd8e 100644 --- a/ext/MTKDeepDiffsExt.jl +++ b/ext/MTKDeepDiffsExt.jl @@ -179,7 +179,7 @@ function Base.getindex(ssdpm::SystemStructureDiffPrintMatrix, i::Integer, j::Int end function DeepDiffs.deepdiff(old::Union{MatchedSystemStructure, SystemStructure}, - new::Union{MatchedSystemStructure, SystemStructure}) + new::Union{MatchedSystemStructure, SystemStructure}) new_sspm = SystemStructurePrintMatrix(new) old_sspm = SystemStructurePrintMatrix(old) Base.print_matrix(stdout, SystemStructureDiffPrintMatrix(new_sspm, old_sspm)) diff --git a/src/bipartite_graph.jl b/src/bipartite_graph.jl index a72ea7ef31..8b055c4e65 100644 --- a/src/bipartite_graph.jl +++ b/src/bipartite_graph.jl @@ -169,13 +169,13 @@ mutable struct BipartiteGraph{I <: Integer, M} <: Graphs.AbstractGraph{I} metadata::M end function BipartiteGraph(ne::Integer, fadj::AbstractVector, - badj::Union{AbstractVector, Integer} = maximum(maximum, fadj); - metadata = nothing) + badj::Union{AbstractVector, Integer} = maximum(maximum, fadj); + metadata = nothing) BipartiteGraph(ne, fadj, badj, metadata) end function BipartiteGraph(fadj::AbstractVector, - badj::Union{AbstractVector, Integer} = maximum(maximum, fadj); - metadata = nothing) + badj::Union{AbstractVector, Integer} = maximum(maximum, fadj); + metadata = nothing) BipartiteGraph(mapreduce(length, +, fadj; init = 0), fadj, badj, metadata) end @@ -325,7 +325,7 @@ $(SIGNATURES) Build an empty `BipartiteGraph` with `nsrcs` sources and `ndsts` destinations. """ function BipartiteGraph(nsrcs::T, ndsts::T, backedge::Val{B} = Val(true); - metadata = nothing) where {T, B} + metadata = nothing) where {T, B} fadjlist = map(_ -> T[], 1:nsrcs) badjlist = B ? map(_ -> T[], 1:ndsts) : ndsts BipartiteGraph(0, fadjlist, badjlist, metadata) @@ -359,11 +359,11 @@ end has_𝑠vertex(g::BipartiteGraph, v::Integer) = v in 𝑠vertices(g) has_𝑑vertex(g::BipartiteGraph, v::Integer) = v in 𝑑vertices(g) function 𝑠neighbors(g::BipartiteGraph, i::Integer, - with_metadata::Val{M} = Val(false)) where {M} + with_metadata::Val{M} = Val(false)) where {M} M ? zip(g.fadjlist[i], g.metadata[i]) : g.fadjlist[i] end function 𝑑neighbors(g::BipartiteGraph, j::Integer, - with_metadata::Val{M} = Val(false)) where {M} + with_metadata::Val{M} = Val(false)) where {M} require_complete(g) M ? zip(g.badjlist[j], (g.metadata[i][j] for i in g.badjlist[j])) : g.badjlist[j] end @@ -389,7 +389,7 @@ Try to construct an augmenting path in matching and if such a path is found, update the matching accordingly. """ function construct_augmenting_path!(matching::Matching, g::BipartiteGraph, vsrc, dstfilter, - dcolor = falses(ndsts(g)), scolor = nothing) + dcolor = falses(ndsts(g)), scolor = nothing) scolor === nothing || (scolor[vsrc] = true) # if a `vdst` is unassigned and the edge `vsrc <=> vdst` exists @@ -421,7 +421,7 @@ vertices, subject to the constraint that vertices for which `srcfilter` or `dstf return `false` may not be matched. """ function maximal_matching(g::BipartiteGraph, srcfilter = vsrc -> true, - dstfilter = vdst -> true, ::Type{U} = Unassigned) where {U} + dstfilter = vdst -> true, ::Type{U} = Unassigned) where {U} matching = Matching{U}(ndsts(g)) foreach(Iterators.filter(srcfilter, 𝑠vertices(g))) do vsrc construct_augmenting_path!(matching, g, vsrc, dstfilter) @@ -550,7 +550,7 @@ Base.length(it::BipartiteEdgeIter) = ne(it.g) Base.eltype(it::BipartiteEdgeIter) = edgetype(it.g) function Base.iterate(it::BipartiteEdgeIter{SRC, <:BipartiteGraph{T}}, - state = (1, 1, SRC)) where {T} + state = (1, 1, SRC)) where {T} @unpack g = it neqs = nsrcs(g) neqs == 0 && return nothing @@ -572,7 +572,7 @@ function Base.iterate(it::BipartiteEdgeIter{SRC, <:BipartiteGraph{T}}, end function Base.iterate(it::BipartiteEdgeIter{DST, <:BipartiteGraph{T}}, - state = (1, 1, DST)) where {T} + state = (1, 1, DST)) where {T} @unpack g = it nvars = ndsts(g) nvars == 0 && return nothing @@ -644,7 +644,7 @@ mutable struct DiCMOBiGraph{Transposed, I, G <: BipartiteGraph{I}, M <: Matching ne::Union{Missing, Int} matching::M function DiCMOBiGraph{Transposed}(g::G, ne::Union{Missing, Int}, - m::M) where {Transposed, I, G <: BipartiteGraph{I}, M} + m::M) where {Transposed, I, G <: BipartiteGraph{I}, M} new{Transposed, I, G, M}(g, ne, m) end end @@ -671,7 +671,7 @@ struct CMONeighbors{Transposed, V} g::DiCMOBiGraph{Transposed} v::V function CMONeighbors{Transposed}(g::DiCMOBiGraph{Transposed}, - v::V) where {Transposed, V} + v::V) where {Transposed, V} new{Transposed, V}(g, v) end end diff --git a/src/inputoutput.jl b/src/inputoutput.jl index fe3dfb29fb..5a9a354b38 100644 --- a/src/inputoutput.jl +++ b/src/inputoutput.jl @@ -192,10 +192,10 @@ f[1](x, inputs, p, t) ``` """ function generate_control_function(sys::AbstractODESystem, inputs = unbound_inputs(sys), - disturbance_inputs = disturbances(sys); - implicit_dae = false, - simplify = false, - kwargs...) + disturbance_inputs = disturbances(sys); + implicit_dae = false, + simplify = false, + kwargs...) isempty(inputs) && @warn("No unbound inputs were found in system.") if disturbance_inputs !== nothing diff --git a/src/structural_transformation/bareiss.jl b/src/structural_transformation/bareiss.jl index 3a65f74218..7957427e5d 100644 --- a/src/structural_transformation/bareiss.jl +++ b/src/structural_transformation/bareiss.jl @@ -115,7 +115,7 @@ else end function bareiss_update!(zero!, M::StridedMatrix, k, swapto, pivot, - prev_pivot::Base.BitInteger) + prev_pivot::Base.BitInteger) flag = zero(prev_pivot) prev_pivot = Base.MultiplicativeInverses.SignedMultiplicativeInverse(prev_pivot) @inbounds for i in (k + 1):size(M, 2) @@ -149,7 +149,7 @@ end end function bareiss_update_virtual_colswap!(zero!, M::AbstractMatrix, k, swapto, pivot, - prev_pivot) + prev_pivot) if prev_pivot isa Base.BitInteger prev_pivot = Base.MultiplicativeInverses.SignedMultiplicativeInverse(prev_pivot) end @@ -189,7 +189,7 @@ bareiss_colswap (the default) swaps the columns and rows normally. bareiss_virtcolswap pretends to swap the columns which can be faster for sparse matrices. """ function bareiss!(M::AbstractMatrix{T}, swap_strategy = bareiss_colswap; - find_pivot = find_pivot_any, column_pivots = nothing) where {T} + find_pivot = find_pivot_any, column_pivots = nothing) where {T} swapcols!, swaprows!, update!, zero! = swap_strategy prev = one(eltype(M)) n = size(M, 1) @@ -252,7 +252,7 @@ end ### ### https://github.com/Nemocas/AbstractAlgebra.jl/blob/4803548c7a945f3f7bd8c63f8bb7c79fac92b11a/LICENSE.md function reduce_echelon!(A::AbstractMatrix{T}, rank, d, - pivots_cache = zeros(Int, size(A, 2))) where {T} + pivots_cache = zeros(Int, size(A, 2))) where {T} m, n = size(A) isreduced = true @inbounds for i in 1:rank @@ -318,7 +318,7 @@ function reduce_echelon!(A::AbstractMatrix{T}, rank, d, end function reduced_echelon_nullspace(rank, A::AbstractMatrix{T}, - pivots_cache = zeros(Int, size(A, 2))) where {T} + pivots_cache = zeros(Int, size(A, 2))) where {T} n = size(A, 2) nullity = n - rank U = zeros(T, n, nullity) diff --git a/src/structural_transformation/bipartite_tearing/modia_tearing.jl b/src/structural_transformation/bipartite_tearing/modia_tearing.jl index f8be5ccd7b..26ba0278af 100644 --- a/src/structural_transformation/bipartite_tearing/modia_tearing.jl +++ b/src/structural_transformation/bipartite_tearing/modia_tearing.jl @@ -10,7 +10,7 @@ function try_assign_eq!(ict::IncrementalCycleTracker, vj::Integer, eq::Integer) end function try_assign_eq!(ict::IncrementalCycleTracker, vars, v_active, eq::Integer, - condition::F = _ -> true) where {F} + condition::F = _ -> true) where {F} G = ict.graph for vj in vars (vj in v_active && G.matching[vj] === unassigned && condition(vj)) || continue @@ -20,7 +20,7 @@ function try_assign_eq!(ict::IncrementalCycleTracker, vars, v_active, eq::Intege end function tearEquations!(ict::IncrementalCycleTracker, Gsolvable, es::Vector{Int}, - v_active::BitSet, isder′::F) where {F} + v_active::BitSet, isder′::F) where {F} check_der = isder′ !== nothing if check_der has_der = Ref(false) @@ -54,7 +54,7 @@ function tearEquations!(ict::IncrementalCycleTracker, Gsolvable, es::Vector{Int} end function tear_graph_block_modia!(var_eq_matching, ict, solvable_graph, eqs, vars, - isder::F) where {F} + isder::F) where {F} tearEquations!(ict, solvable_graph.fadjlist, eqs, vars, isder) for var in vars var_eq_matching[var] = ict.graph.matching[var] @@ -63,9 +63,9 @@ function tear_graph_block_modia!(var_eq_matching, ict, solvable_graph, eqs, vars end function tear_graph_modia(structure::SystemStructure, isder::F = nothing, - ::Type{U} = Unassigned; - varfilter::F2 = v -> true, - eqfilter::F3 = eq -> true) where {F, U, F2, F3} + ::Type{U} = Unassigned; + varfilter::F2 = v -> true, + eqfilter::F3 = eq -> true) where {F, U, F2, F3} # It would be possible here to simply iterate over all variables and attempt to # use tearEquations! to produce a matching that greedily selects the minimal # number of torn variables. However, we can do this process faster if we first diff --git a/src/structural_transformation/codegen.jl b/src/structural_transformation/codegen.jl index c6a957a6e5..1123420a87 100644 --- a/src/structural_transformation/codegen.jl +++ b/src/structural_transformation/codegen.jl @@ -5,7 +5,7 @@ using ModelingToolkit: isdifferenceeq, process_events, get_preprocess_constants const MAX_INLINE_NLSOLVE_SIZE = 8 function torn_system_with_nlsolve_jacobian_sparsity(state, var_eq_matching, var_sccs, - nlsolve_scc_idxs, eqs_idxs, states_idxs) + nlsolve_scc_idxs, eqs_idxs, states_idxs) graph = state.structure.graph # The sparsity pattern of `nlsolve(f, u, p)` w.r.t `p` is difficult to @@ -97,7 +97,7 @@ function torn_system_with_nlsolve_jacobian_sparsity(state, var_eq_matching, var_ end function gen_nlsolve!(is_not_prepended_assignment, eqs, vars, u0map::AbstractDict, - assignments, (deps, invdeps), var2assignment; checkbounds = true) + assignments, (deps, invdeps), var2assignment; checkbounds = true) isempty(vars) && throw(ArgumentError("vars may not be empty")) length(eqs) == length(vars) || throw(ArgumentError("vars must be of the same length as the number of equations to find the roots of")) @@ -226,11 +226,11 @@ function gen_nlsolve!(is_not_prepended_assignment, eqs, vars, u0map::AbstractDic end function build_torn_function(sys; - expression = false, - jacobian_sparsity = true, - checkbounds = false, - max_inlining_size = nothing, - kw...) + expression = false, + jacobian_sparsity = true, + checkbounds = false, + max_inlining_size = nothing, + kw...) max_inlining_size = something(max_inlining_size, MAX_INLINE_NLSOLVE_SIZE) rhss = [] eqs = equations(sys) @@ -382,14 +382,14 @@ function find_solve_sequence(sccs, vars) end function build_observed_function(state, ts, var_eq_matching, var_sccs, - is_solver_state_idxs, - assignments, - deps, - sol_states, - var2assignment; - expression = false, - output_type = Array, - checkbounds = true) + is_solver_state_idxs, + assignments, + deps, + sol_states, + var2assignment; + expression = false, + output_type = Array, + checkbounds = true) is_not_prepended_assignment = trues(length(assignments)) if (isscalar = !(ts isa AbstractVector)) ts = [ts] @@ -524,14 +524,14 @@ struct ODAEProblem{iip} end ODAEProblem(args...; kw...) = ODAEProblem{true}(args...; kw...) function ODAEProblem{iip}(sys, - u0map, - tspan, - parammap = DiffEqBase.NullParameters(); - callback = nothing, - use_union = true, - tofloat = true, - check = true, - kwargs...) where {iip} + u0map, + tspan, + parammap = DiffEqBase.NullParameters(); + callback = nothing, + use_union = true, + tofloat = true, + check = true, + kwargs...) where {iip} eqs = equations(sys) check && ModelingToolkit.check_operator_variables(eqs, Differential) fun, dvs = build_torn_function(sys; kwargs...) diff --git a/src/structural_transformation/partial_state_selection.jl b/src/structural_transformation/partial_state_selection.jl index aef149dd93..8ba4892fd9 100644 --- a/src/structural_transformation/partial_state_selection.jl +++ b/src/structural_transformation/partial_state_selection.jl @@ -28,7 +28,7 @@ function ascend_dg_all(xs, dg, level, maxlevel) end function pss_graph_modia!(structure::SystemStructure, maximal_top_matching, varlevel, - inv_varlevel, inv_eqlevel) + inv_varlevel, inv_eqlevel) @unpack eq_to_diff, var_to_diff, graph, solvable_graph = structure # var_eq_matching is a maximal matching on the top-differentiated variables. @@ -168,7 +168,7 @@ function partial_state_selection_graph!(structure::SystemStructure, var_eq_match end function dummy_derivative_graph!(state::TransformationState, jac = nothing; - state_priority = nothing, log = Val(false), kwargs...) + state_priority = nothing, log = Val(false), kwargs...) state.structure.solvable_graph === nothing && find_solvables!(state; kwargs...) complete!(state.structure) var_eq_matching = complete(pantelides!(state)) @@ -176,7 +176,7 @@ function dummy_derivative_graph!(state::TransformationState, jac = nothing; end function dummy_derivative_graph!(structure::SystemStructure, var_eq_matching, jac = nothing, - state_priority = nothing, ::Val{log} = Val(false)) where {log} + state_priority = nothing, ::Val{log} = Val(false)) where {log} @unpack eq_to_diff, var_to_diff, graph = structure diff_to_eq = invview(eq_to_diff) diff_to_var = invview(var_to_diff) diff --git a/src/structural_transformation/symbolics_tearing.jl b/src/structural_transformation/symbolics_tearing.jl index 5b0fa727fc..3839e77622 100644 --- a/src/structural_transformation/symbolics_tearing.jl +++ b/src/structural_transformation/symbolics_tearing.jl @@ -138,7 +138,7 @@ function solve_equation(eq, var, simplify) end function substitute_vars!(structure, subs, cache = Int[], callback! = nothing; - exclude = ()) + exclude = ()) @unpack graph, solvable_graph = structure for su in subs su === nothing && continue @@ -163,7 +163,7 @@ function substitute_vars!(structure, subs, cache = Int[], callback! = nothing; end function to_mass_matrix_form(neweqs, ieq, graph, fullvars, isdervar::F, - var_to_diff) where {F} + var_to_diff) where {F} eq = neweqs[ieq] if !(eq.lhs isa Number && eq.lhs == 0) eq = 0 ~ eq.rhs - eq.lhs @@ -218,7 +218,7 @@ end =# function tearing_reassemble(state::TearingState, var_eq_matching; - simplify = false, mm = nothing) + simplify = false, mm = nothing) @unpack fullvars, sys, structure = state @unpack solvable_graph, var_to_diff, eq_to_diff, graph = structure @@ -584,7 +584,7 @@ new residual equations after tearing. End users are encouraged to call [`structu instead, which calls this function internally. """ function tearing(sys::AbstractSystem, state = TearingState(sys); mm = nothing, - simplify = false, kwargs...) + simplify = false, kwargs...) var_eq_matching = tearing(state) invalidate_cache!(tearing_reassemble(state, var_eq_matching; mm, simplify)) end @@ -608,7 +608,7 @@ Perform index reduction and use the dummy derivative technique to ensure that the system is balanced. """ function dummy_derivative(sys, state = TearingState(sys); simplify = false, - mm = nothing, kwargs...) + mm = nothing, kwargs...) jac = let state = state (eqs, vars) -> begin symeqs = EquationsView(state)[eqs] diff --git a/src/structural_transformation/tearing.jl b/src/structural_transformation/tearing.jl index e8d69cb0d4..aa62a449dd 100644 --- a/src/structural_transformation/tearing.jl +++ b/src/structural_transformation/tearing.jl @@ -22,7 +22,7 @@ function masked_cumsum!(A::Vector) end function contract_variables(graph::BipartiteGraph, var_eq_matching::Matching, - var_rename, eq_rename, nelim_eq, nelim_var) + var_rename, eq_rename, nelim_eq, nelim_var) dig = DiCMOBiGraph{true}(graph, var_eq_matching) # Update bipartite graph diff --git a/src/structural_transformation/utils.jl b/src/structural_transformation/utils.jl index 7d9cc5964d..ff9ef2f82a 100644 --- a/src/structural_transformation/utils.jl +++ b/src/structural_transformation/utils.jl @@ -8,7 +8,7 @@ Find equation-variable maximal bipartite matching. `s.graph` is a bipartite graph. """ function BipartiteGraphs.maximal_matching(s::SystemStructure, eqfilter = eq -> true, - varfilter = v -> true) + varfilter = v -> true) maximal_matching(s.graph, eqfilter, varfilter) end @@ -131,7 +131,7 @@ function find_var_sccs(g::BipartiteGraph, assign = nothing) end function sorted_incidence_matrix(ts::TransformationState, val = true; only_algeqs = false, - only_algvars = false) + only_algvars = false) var_eq_matching, var_scc = algebraic_variables_scc(ts) s = ts.structure graph = ts.structure.graph @@ -180,8 +180,8 @@ end ### function find_eq_solvables!(state::TearingState, ieq, to_rm = Int[], coeffs = nothing; - may_be_zero = false, - allow_symbolic = false, allow_parameter = true, kwargs...) + may_be_zero = false, + allow_symbolic = false, allow_parameter = true, kwargs...) fullvars = state.fullvars @unpack graph, solvable_graph = state.structure eq = equations(state)[ieq] diff --git a/src/systems/abstractsystem.jl b/src/systems/abstractsystem.jl index 37f4a49e23..c34fd24885 100644 --- a/src/systems/abstractsystem.jl +++ b/src/systems/abstractsystem.jl @@ -483,9 +483,9 @@ function namespace_equations(sys::AbstractSystem, ivs = independent_variables(sy end function namespace_equation(eq::Equation, - sys, - n = nameof(sys); - ivs = independent_variables(sys)) + sys, + n = nameof(sys); + ivs = independent_variables(sys)) _lhs = namespace_expr(eq.lhs, sys, n; ivs) _rhs = namespace_expr(eq.rhs, sys, n; ivs) _lhs ~ _rhs @@ -1240,7 +1240,7 @@ function eliminate_constants(sys::AbstractSystem) end function io_preprocessing(sys::AbstractSystem, inputs, - outputs; simplify = false, kwargs...) + outputs; simplify = false, kwargs...) sys, input_idxs = structural_simplify(sys, (inputs, outputs); simplify, kwargs...) eqs = equations(sys) @@ -1285,12 +1285,12 @@ The `simplified_sys` has undergone [`structural_simplify`](@ref) and had any occ See also [`linearize`](@ref) which provides a higher-level interface. """ function linearization_function(sys::AbstractSystem, inputs, - outputs; simplify = false, - initialize = true, - op = Dict(), - p = DiffEqBase.NullParameters(), - zero_dummy_der = false, - kwargs...) + outputs; simplify = false, + initialize = true, + op = Dict(), + p = DiffEqBase.NullParameters(), + zero_dummy_der = false, + kwargs...) ssys, diff_idxs, alge_idxs, input_idxs = io_preprocessing(sys, inputs, outputs; simplify, kwargs...) @@ -1380,8 +1380,8 @@ y &= h(x, z, u) where `x` are differential state variables, `z` algebraic variables, `u` inputs and `y` outputs. """ function linearize_symbolic(sys::AbstractSystem, inputs, - outputs; simplify = false, allow_input_derivatives = false, - kwargs...) + outputs; simplify = false, allow_input_derivatives = false, + kwargs...) sys, diff_idxs, alge_idxs, input_idxs = io_preprocessing(sys, inputs, outputs; simplify, kwargs...) sts = states(sys) @@ -1584,7 +1584,7 @@ lsys_sym, _ = ModelingToolkit.linearize_symbolic(cl, [f.u], [p.x]) ``` """ function linearize(sys, lin_fun; t = 0.0, op = Dict(), allow_input_derivatives = false, - p = DiffEqBase.NullParameters()) + p = DiffEqBase.NullParameters()) x0 = merge(defaults(sys), op) u0, p2, _ = get_u0_p(sys, x0, p; use_union = false, tofloat = true) @@ -1630,9 +1630,9 @@ function linearize(sys, lin_fun; t = 0.0, op = Dict(), allow_input_derivatives = end function linearize(sys, inputs, outputs; op = Dict(), t = 0.0, - allow_input_derivatives = false, - zero_dummy_der = false, - kwargs...) + allow_input_derivatives = false, + zero_dummy_der = false, + kwargs...) lin_fun, ssys = linearization_function(sys, inputs, outputs; @@ -1780,7 +1780,7 @@ extend the `basesys` with `sys`, the resulting system would inherit `sys`'s name by default. """ function extend(sys::AbstractSystem, basesys::AbstractSystem; name::Symbol = nameof(sys), - gui_metadata = get_gui_metadata(sys)) + gui_metadata = get_gui_metadata(sys)) T = SciMLBase.parameterless_type(basesys) ivs = independent_variables(basesys) if !(sys isa T) diff --git a/src/systems/alias_elimination.jl b/src/systems/alias_elimination.jl index 0437cb72e6..3ddb88f77b 100644 --- a/src/systems/alias_elimination.jl +++ b/src/systems/alias_elimination.jl @@ -29,7 +29,7 @@ function aag_bareiss(sys::AbstractSystem) end function extreme_var(var_to_diff, v, level = nothing, ::Val{descend} = Val(true); - callback = _ -> nothing) where {descend} + callback = _ -> nothing) where {descend} g = descend ? invview(var_to_diff) : var_to_diff callback(v) while (v′ = g[v]) !== nothing @@ -149,9 +149,9 @@ Find the first linear variable such that `𝑠neighbors(adj, i)[j]` is true give the `constraint`. """ @inline function find_first_linear_variable(M::SparseMatrixCLIL, - range, - mask, - constraint) + range, + mask, + constraint) eadj = M.row_cols for i in range vertices = eadj[i] @@ -167,9 +167,9 @@ the `constraint`. end @inline function find_first_linear_variable(M::AbstractMatrix, - range, - mask, - constraint) + range, + mask, + constraint) for i in range row = @view M[i, :] if constraint(count(!iszero, row)) diff --git a/src/systems/callbacks.jl b/src/systems/callbacks.jl index 7544439104..b97112e9e8 100644 --- a/src/systems/callbacks.jl +++ b/src/systems/callbacks.jl @@ -265,7 +265,7 @@ Notes - `kwargs` are passed through to `Symbolics.build_function`. """ function compile_condition(cb::SymbolicDiscreteCallback, sys, dvs, ps; - expression = Val{true}, kwargs...) + expression = Val{true}, kwargs...) u = map(x -> time_varying_as_func(value(x), sys), dvs) p = map(x -> time_varying_as_func(value(x), sys), ps) t = get_iv(sys) @@ -301,8 +301,8 @@ Notes - `kwargs` are passed through to `Symbolics.build_function`. """ function compile_affect(eqs::Vector{Equation}, sys, dvs, ps; outputidxs = nothing, - expression = Val{true}, checkvars = true, - postprocess_affect_expr! = nothing, kwargs...) + expression = Val{true}, checkvars = true, + postprocess_affect_expr! = nothing, kwargs...) if isempty(eqs) if expression == Val{true} return :((args...) -> ()) @@ -362,14 +362,14 @@ function compile_affect(eqs::Vector{Equation}, sys, dvs, ps; outputidxs = nothin end function generate_rootfinding_callback(sys::AbstractODESystem, dvs = states(sys), - ps = parameters(sys); kwargs...) + ps = parameters(sys); kwargs...) cbs = continuous_events(sys) isempty(cbs) && return nothing generate_rootfinding_callback(cbs, sys, dvs, ps; kwargs...) end function generate_rootfinding_callback(cbs, sys::AbstractODESystem, dvs = states(sys), - ps = parameters(sys); kwargs...) + ps = parameters(sys); kwargs...) eqs = map(cb -> cb.eqs, cbs) num_eqs = length.(eqs) (isempty(eqs) || sum(num_eqs) == 0) && return nothing @@ -454,7 +454,7 @@ function compile_affect(affect::FunctionalAffect, sys, dvs, ps; kwargs...) end function generate_timed_callback(cb, sys, dvs, ps; postprocess_affect_expr! = nothing, - kwargs...) + kwargs...) cond = condition(cb) as = compile_affect(affects(cb), sys, dvs, ps; expression = Val{false}, postprocess_affect_expr!, kwargs...) @@ -468,7 +468,7 @@ function generate_timed_callback(cb, sys, dvs, ps; postprocess_affect_expr! = no end function generate_discrete_callback(cb, sys, dvs, ps; postprocess_affect_expr! = nothing, - kwargs...) + kwargs...) if is_timed_condition(cb) return generate_timed_callback(cb, sys, dvs, ps; postprocess_affect_expr!, kwargs...) @@ -481,7 +481,7 @@ function generate_discrete_callback(cb, sys, dvs, ps; postprocess_affect_expr! = end function generate_discrete_callbacks(sys::AbstractSystem, dvs = states(sys), - ps = parameters(sys); kwargs...) + ps = parameters(sys); kwargs...) has_discrete_events(sys) || return nothing symcbs = discrete_events(sys) isempty(symcbs) && return nothing diff --git a/src/systems/clock_inference.jl b/src/systems/clock_inference.jl index ed1ce93477..9ffeb56319 100644 --- a/src/systems/clock_inference.jl +++ b/src/systems/clock_inference.jl @@ -140,8 +140,8 @@ function split_system(ci::ClockInference{S}) where {S} end function generate_discrete_affect(syss, inputs, continuous_id, id_to_clock; - checkbounds = true, - eval_module = @__MODULE__, eval_expression = true) + checkbounds = true, + eval_module = @__MODULE__, eval_expression = true) @static if VERSION < v"1.7" error("The `generate_discrete_affect` function requires at least Julia 1.7") end diff --git a/src/systems/connectors.jl b/src/systems/connectors.jl index f760e510e8..ac3adcc77f 100644 --- a/src/systems/connectors.jl +++ b/src/systems/connectors.jl @@ -280,7 +280,7 @@ function generate_connection_set(sys::AbstractSystem, find = nothing, replace = end function generate_connection_set!(connectionsets, domain_csets, - sys::AbstractSystem, find, replace, namespace = nothing) + sys::AbstractSystem, find, replace, namespace = nothing) subsys = get_systems(sys) isouter = generate_isouter(sys) @@ -389,8 +389,8 @@ function partial_merge(csets::AbstractVector{<:ConnectionSet}, allouter = false) end function generate_connection_equations_and_stream_connections(csets::AbstractVector{ - <:ConnectionSet, -}) + <:ConnectionSet, + }) eqs = Equation[] stream_connections = ConnectionSet[] @@ -449,7 +449,7 @@ function domain_defaults(sys, domain_csets) end function expand_connections(sys::AbstractSystem, find = nothing, replace = nothing; - debug = false, tol = 1e-10) + debug = false, tol = 1e-10) sys, (csets, domain_csets) = generate_connection_set(sys, find, replace) ceqs, instream_csets = generate_connection_equations_and_stream_connections(csets) _sys = expand_instream(instream_csets, sys; debug = debug, tol = tol) @@ -473,8 +473,8 @@ function unnamespace(root, namespace) end function expand_instream(csets::AbstractVector{<:ConnectionSet}, sys::AbstractSystem, - namespace = nothing, prevnamespace = nothing; debug = false, - tol = 1e-8) + namespace = nothing, prevnamespace = nothing; debug = false, + tol = 1e-8) subsys = get_systems(sys) # post order traversal @set! sys.systems = map(s -> expand_instream(csets, s, @@ -659,7 +659,7 @@ end # instream runtime @generated function _instream_split(::Val{inner_n}, ::Val{outer_n}, - vars::NTuple{N, Any}) where {inner_n, outer_n, N} + vars::NTuple{N, Any}) where {inner_n, outer_n, N} #instream_rt(innerfvs..., innersvs..., outerfvs..., outersvs...) ret = Expr(:tuple) # mj.c.m_flow @@ -675,7 +675,7 @@ end end function instream_rt(ins::Val{inner_n}, outs::Val{outer_n}, - vars::Vararg{Any, N}) where {inner_n, outer_n, N} + vars::Vararg{Any, N}) where {inner_n, outer_n, N} @assert N == 2 * (inner_n + outer_n) # inner: mj.c.m_flow diff --git a/src/systems/dependency_graphs.jl b/src/systems/dependency_graphs.jl index 7a69d2bc18..68b43538b0 100644 --- a/src/systems/dependency_graphs.jl +++ b/src/systems/dependency_graphs.jl @@ -113,7 +113,7 @@ digr = asgraph(jumpsys) ``` """ function asgraph(sys::AbstractSystem; variables = states(sys), - variablestoids = Dict(v => i for (i, v) in enumerate(variables))) + variablestoids = Dict(v => i for (i, v) in enumerate(variables))) asgraph(equation_dependencies(sys, variables = variables), variablestoids) end @@ -140,7 +140,7 @@ variable_dependencies(jumpsys) ``` """ function variable_dependencies(sys::AbstractSystem; variables = states(sys), - variablestoids = nothing) + variablestoids = nothing) eqs = equations(sys) vtois = isnothing(variablestoids) ? Dict(v => i for (i, v) in enumerate(variables)) : variablestoids @@ -192,7 +192,7 @@ dg = asdigraph(digr, jumpsys) ``` """ function asdigraph(g::BipartiteGraph, sys::AbstractSystem; variables = states(sys), - equationsfirst = true) + equationsfirst = true) neqs = length(equations(sys)) nvars = length(variables) fadjlist = deepcopy(g.fadjlist) @@ -234,7 +234,7 @@ eqeqdep = eqeq_dependencies(asgraph(jumpsys), variable_dependencies(jumpsys)) ``` """ function eqeq_dependencies(eqdeps::BipartiteGraph{T}, - vardeps::BipartiteGraph{T}) where {T <: Integer} + vardeps::BipartiteGraph{T}) where {T <: Integer} g = SimpleDiGraph{T}(length(eqdeps.fadjlist)) for (eqidx, sidxs) in enumerate(vardeps.badjlist) @@ -273,6 +273,6 @@ varvardep = varvar_dependencies(asgraph(jumpsys), variable_dependencies(jumpsys) ``` """ function varvar_dependencies(eqdeps::BipartiteGraph{T}, - vardeps::BipartiteGraph{T}) where {T <: Integer} + vardeps::BipartiteGraph{T}) where {T <: Integer} eqeq_dependencies(vardeps, eqdeps) end diff --git a/src/systems/diffeqs/abstractodesystem.jl b/src/systems/diffeqs/abstractodesystem.jl index f11d1283c6..3ac137f6e3 100644 --- a/src/systems/diffeqs/abstractodesystem.jl +++ b/src/systems/diffeqs/abstractodesystem.jl @@ -14,7 +14,7 @@ function gen_quoted_kwargs(kwargs) end function calculate_tgrad(sys::AbstractODESystem; - simplify = false) + simplify = false) isempty(get_tgrad(sys)[]) || return get_tgrad(sys)[] # use cached tgrad, if possible # We need to remove explicit time dependence on the state because when we @@ -33,7 +33,7 @@ function calculate_tgrad(sys::AbstractODESystem; end function calculate_jacobian(sys::AbstractODESystem; - sparse = false, simplify = false, dvs = states(sys)) + sparse = false, simplify = false, dvs = states(sys)) if isequal(dvs, states(sys)) cache = get_jac(sys)[] if cache isa Tuple && cache[2] == (sparse, simplify) @@ -59,7 +59,7 @@ function calculate_jacobian(sys::AbstractODESystem; end function calculate_control_jacobian(sys::AbstractODESystem; - sparse = false, simplify = false) + sparse = false, simplify = false) cache = get_ctrl_jac(sys)[] if cache isa Tuple && cache[2] == (sparse, simplify) return cache[1] @@ -81,7 +81,7 @@ function calculate_control_jacobian(sys::AbstractODESystem; end function generate_tgrad(sys::AbstractODESystem, dvs = states(sys), ps = parameters(sys); - simplify = false, kwargs...) + simplify = false, kwargs...) tgrad = calculate_tgrad(sys, simplify = simplify) pre = get_preprocess_constants(tgrad) if ps isa Tuple @@ -102,7 +102,7 @@ function generate_tgrad(sys::AbstractODESystem, dvs = states(sys), ps = paramete end function generate_jacobian(sys::AbstractODESystem, dvs = states(sys), ps = parameters(sys); - simplify = false, sparse = false, kwargs...) + simplify = false, sparse = false, kwargs...) jac = calculate_jacobian(sys; simplify = simplify, sparse = sparse) pre = get_preprocess_constants(jac) if ps isa Tuple @@ -118,15 +118,15 @@ function generate_jacobian(sys::AbstractODESystem, dvs = states(sys), ps = param end function generate_control_jacobian(sys::AbstractODESystem, dvs = states(sys), - ps = parameters(sys); - simplify = false, sparse = false, kwargs...) + ps = parameters(sys); + simplify = false, sparse = false, kwargs...) jac = calculate_control_jacobian(sys; simplify = simplify, sparse = sparse) return build_function(jac, dvs, ps, get_iv(sys); kwargs...) end function generate_dae_jacobian(sys::AbstractODESystem, dvs = states(sys), - ps = parameters(sys); simplify = false, sparse = false, - kwargs...) + ps = parameters(sys); simplify = false, sparse = false, + kwargs...) jac_u = calculate_jacobian(sys; simplify = simplify, sparse = sparse) derivatives = Differential(get_iv(sys)).(states(sys)) jac_du = calculate_jacobian(sys; simplify = simplify, sparse = sparse, @@ -140,12 +140,12 @@ function generate_dae_jacobian(sys::AbstractODESystem, dvs = states(sys), end function generate_function(sys::AbstractODESystem, dvs = states(sys), ps = parameters(sys); - implicit_dae = false, - ddvs = implicit_dae ? map(Differential(get_iv(sys)), dvs) : - nothing, - isdde = false, - has_difference = false, - kwargs...) + implicit_dae = false, + ddvs = implicit_dae ? map(Differential(get_iv(sys)), dvs) : + nothing, + isdde = false, + has_difference = false, + kwargs...) if isdde eqs = delay_to_function(sys) else @@ -227,7 +227,7 @@ function delay_to_function(expr, iv, sts, ps, h) end function generate_difference_cb(sys::ODESystem, dvs = states(sys), ps = parameters(sys); - kwargs...) + kwargs...) eqs = equations(sys) check_operator_variables(eqs, Difference) @@ -333,29 +333,29 @@ function DiffEqBase.ODEFunction(sys::AbstractODESystem, args...; kwargs...) end function DiffEqBase.ODEFunction{true}(sys::AbstractODESystem, args...; - kwargs...) + kwargs...) ODEFunction{true, SciMLBase.AutoSpecialize}(sys, args...; kwargs...) end function DiffEqBase.ODEFunction{false}(sys::AbstractODESystem, args...; - kwargs...) + kwargs...) ODEFunction{false, SciMLBase.FullSpecialize}(sys, args...; kwargs...) end function DiffEqBase.ODEFunction{iip, specialize}(sys::AbstractODESystem, dvs = states(sys), - ps = parameters(sys), u0 = nothing; - version = nothing, tgrad = false, - jac = false, p = nothing, - t = nothing, - eval_expression = true, - sparse = false, simplify = false, - eval_module = @__MODULE__, - steady_state = false, - checkbounds = false, - sparsity = false, - analytic = nothing, - split_idxs = nothing, - kwargs...) where {iip, specialize} + ps = parameters(sys), u0 = nothing; + version = nothing, tgrad = false, + jac = false, p = nothing, + t = nothing, + eval_expression = true, + sparse = false, simplify = false, + eval_module = @__MODULE__, + steady_state = false, + checkbounds = false, + sparsity = false, + analytic = nothing, + split_idxs = nothing, + kwargs...) where {iip, specialize} f_gen = generate_function(sys, dvs, ps; expression = Val{eval_expression}, expression_module = eval_module, checkbounds = checkbounds, kwargs...) @@ -543,15 +543,15 @@ function DiffEqBase.DAEFunction(sys::AbstractODESystem, args...; kwargs...) end function DiffEqBase.DAEFunction{iip}(sys::AbstractODESystem, dvs = states(sys), - ps = parameters(sys), u0 = nothing; - ddvs = map(diff2term ∘ Differential(get_iv(sys)), dvs), - version = nothing, p = nothing, - jac = false, - eval_expression = true, - sparse = false, simplify = false, - eval_module = @__MODULE__, - checkbounds = false, - kwargs...) where {iip} + ps = parameters(sys), u0 = nothing; + ddvs = map(diff2term ∘ Differential(get_iv(sys)), dvs), + version = nothing, p = nothing, + jac = false, + eval_expression = true, + sparse = false, simplify = false, + eval_module = @__MODULE__, + checkbounds = false, + kwargs...) where {iip} f_gen = generate_function(sys, dvs, ps; implicit_dae = true, expression = Val{eval_expression}, expression_module = eval_module, checkbounds = checkbounds, @@ -623,10 +623,10 @@ function DiffEqBase.DDEFunction(sys::AbstractODESystem, args...; kwargs...) end function DiffEqBase.DDEFunction{iip}(sys::AbstractODESystem, dvs = states(sys), - ps = parameters(sys), u0 = nothing; - eval_module = @__MODULE__, - checkbounds = false, - kwargs...) where {iip} + ps = parameters(sys), u0 = nothing; + eval_module = @__MODULE__, + checkbounds = false, + kwargs...) where {iip} f_gen = generate_function(sys, dvs, ps; isdde = true, expression = Val{true}, expression_module = eval_module, checkbounds = checkbounds, @@ -647,10 +647,10 @@ function DiffEqBase.SDDEFunction(sys::AbstractODESystem, args...; kwargs...) end function DiffEqBase.SDDEFunction{iip}(sys::AbstractODESystem, dvs = states(sys), - ps = parameters(sys), u0 = nothing; - eval_module = @__MODULE__, - checkbounds = false, - kwargs...) where {iip} + ps = parameters(sys), u0 = nothing; + eval_module = @__MODULE__, + checkbounds = false, + kwargs...) where {iip} f_gen = generate_function(sys, dvs, ps; isdde = true, expression = Val{true}, expression_module = eval_module, checkbounds = checkbounds, @@ -695,15 +695,15 @@ end (f::ODEFunctionClosure)(du, u, p, t) = f.f_iip(du, u, p, t) function ODEFunctionExpr{iip}(sys::AbstractODESystem, dvs = states(sys), - ps = parameters(sys), u0 = nothing; - version = nothing, tgrad = false, - jac = false, p = nothing, - linenumbers = false, - sparse = false, simplify = false, - steady_state = false, - sparsity = false, - observedfun_exp = nothing, - kwargs...) where {iip} + ps = parameters(sys), u0 = nothing; + version = nothing, tgrad = false, + jac = false, p = nothing, + linenumbers = false, + sparse = false, simplify = false, + steady_state = false, + sparsity = false, + observedfun_exp = nothing, + kwargs...) where {iip} f_oop, f_iip = generate_function(sys, dvs, ps; expression = Val{true}, kwargs...) dict = Dict() @@ -766,11 +766,11 @@ end Take dictionaries with initial conditions and parameters and convert them to numeric arrays `u0` and `p`. Also return the merged dictionary `defs` containing the entire operating point. """ function get_u0_p(sys, - u0map, - parammap = nothing; - use_union = true, - tofloat = true, - symbolic_u0 = false) + u0map, + parammap = nothing; + use_union = true, + tofloat = true, + symbolic_u0 = false) dvs = states(sys) ps = parameters(sys) @@ -791,18 +791,18 @@ function get_u0_p(sys, end function process_DEProblem(constructor, sys::AbstractODESystem, u0map, parammap; - implicit_dae = false, du0map = nothing, - version = nothing, tgrad = false, - jac = false, - checkbounds = false, sparse = false, - simplify = false, - linenumbers = true, parallel = SerialForm(), - eval_expression = true, - use_union = true, - tofloat = true, - symbolic_u0 = false, - u0_constructor = identity, - kwargs...) + implicit_dae = false, du0map = nothing, + version = nothing, tgrad = false, + jac = false, + checkbounds = false, sparse = false, + simplify = false, + linenumbers = true, parallel = SerialForm(), + eval_expression = true, + use_union = true, + tofloat = true, + symbolic_u0 = false, + u0_constructor = identity, + kwargs...) eqs = equations(sys) dvs = states(sys) ps = parameters(sys) @@ -872,12 +872,12 @@ end (f::DAEFunctionClosure)(out, du, u, p, t) = f.f_iip(out, du, u, p, t) function DAEFunctionExpr{iip}(sys::AbstractODESystem, dvs = states(sys), - ps = parameters(sys), u0 = nothing; - version = nothing, tgrad = false, - jac = false, p = nothing, - linenumbers = false, - sparse = false, simplify = false, - kwargs...) where {iip} + ps = parameters(sys), u0 = nothing; + version = nothing, tgrad = false, + jac = false, p = nothing, + linenumbers = false, + sparse = false, simplify = false, + kwargs...) where {iip} f_oop, f_iip = generate_function(sys, dvs, ps; expression = Val{true}, implicit_dae = true, kwargs...) fsym = gensym(:f) @@ -927,11 +927,11 @@ end (d::DiscreteSaveAffect)(args...) = d.f(args..., d.s) function DiffEqBase.ODEProblem{iip, specialize}(sys::AbstractODESystem, u0map = [], - tspan = get_tspan(sys), - parammap = DiffEqBase.NullParameters(); - callback = nothing, - check_length = true, - kwargs...) where {iip, specialize} + tspan = get_tspan(sys), + parammap = DiffEqBase.NullParameters(); + callback = nothing, + check_length = true, + kwargs...) where {iip, specialize} has_difference = any(isdifferenceeq, equations(sys)) f, u0, p = process_DEProblem(ODEFunction{iip, specialize}, sys, u0map, parammap; t = tspan !== nothing ? tspan[1] : tspan, @@ -993,8 +993,8 @@ function DiffEqBase.DAEProblem(sys::AbstractODESystem, args...; kwargs...) end function DiffEqBase.DAEProblem{iip}(sys::AbstractODESystem, du0map, u0map, tspan, - parammap = DiffEqBase.NullParameters(); - check_length = true, kwargs...) where {iip} + parammap = DiffEqBase.NullParameters(); + check_length = true, kwargs...) where {iip} has_difference = any(isdifferenceeq, equations(sys)) f, du0, u0, p = process_DEProblem(DAEFunction{iip}, sys, u0map, parammap; implicit_dae = true, du0map = du0map, @@ -1023,11 +1023,11 @@ function DiffEqBase.DDEProblem(sys::AbstractODESystem, args...; kwargs...) DDEProblem{true}(sys, args...; kwargs...) end function DiffEqBase.DDEProblem{iip}(sys::AbstractODESystem, u0map = [], - tspan = get_tspan(sys), - parammap = DiffEqBase.NullParameters(); - callback = nothing, - check_length = true, - kwargs...) where {iip} + tspan = get_tspan(sys), + parammap = DiffEqBase.NullParameters(); + callback = nothing, + check_length = true, + kwargs...) where {iip} has_difference = any(isdifferenceeq, equations(sys)) f, u0, p = process_DEProblem(DDEFunction{iip}, sys, u0map, parammap; t = tspan !== nothing ? tspan[1] : tspan, @@ -1075,12 +1075,12 @@ function DiffEqBase.SDDEProblem(sys::AbstractODESystem, args...; kwargs...) SDDEProblem{true}(sys, args...; kwargs...) end function DiffEqBase.SDDEProblem{iip}(sys::AbstractODESystem, u0map = [], - tspan = get_tspan(sys), - parammap = DiffEqBase.NullParameters(); - callback = nothing, - check_length = true, - sparsenoise = nothing, - kwargs...) where {iip} + tspan = get_tspan(sys), + parammap = DiffEqBase.NullParameters(); + callback = nothing, + check_length = true, + sparsenoise = nothing, + kwargs...) where {iip} has_difference = any(isdifferenceeq, equations(sys)) f, u0, p = process_DEProblem(SDDEFunction{iip}, sys, u0map, parammap; t = tspan !== nothing ? tspan[1] : tspan, @@ -1157,8 +1157,8 @@ numerical enhancements. struct ODEProblemExpr{iip} end function ODEProblemExpr{iip}(sys::AbstractODESystem, u0map, tspan, - parammap = DiffEqBase.NullParameters(); check_length = true, - kwargs...) where {iip} + parammap = DiffEqBase.NullParameters(); check_length = true, + kwargs...) where {iip} f, u0, p = process_DEProblem(ODEFunctionExpr{iip}, sys, u0map, parammap; check_length, kwargs...) linenumbers = get(kwargs, :linenumbers, true) @@ -1199,8 +1199,8 @@ numerical enhancements. struct DAEProblemExpr{iip} end function DAEProblemExpr{iip}(sys::AbstractODESystem, du0map, u0map, tspan, - parammap = DiffEqBase.NullParameters(); check_length = true, - kwargs...) where {iip} + parammap = DiffEqBase.NullParameters(); check_length = true, + kwargs...) where {iip} f, du0, u0, p = process_DEProblem(DAEFunctionExpr{iip}, sys, u0map, parammap; implicit_dae = true, du0map = du0map, check_length, kwargs...) @@ -1247,8 +1247,8 @@ function SciMLBase.SteadyStateProblem(sys::AbstractODESystem, args...; kwargs... end function DiffEqBase.SteadyStateProblem{iip}(sys::AbstractODESystem, u0map, - parammap = SciMLBase.NullParameters(); - check_length = true, kwargs...) where {iip} + parammap = SciMLBase.NullParameters(); + check_length = true, kwargs...) where {iip} f, u0, p = process_DEProblem(ODEFunction{iip}, sys, u0map, parammap; steady_state = true, check_length, kwargs...) @@ -1275,9 +1275,9 @@ numerical enhancements. struct SteadyStateProblemExpr{iip} end function SteadyStateProblemExpr{iip}(sys::AbstractODESystem, u0map, - parammap = SciMLBase.NullParameters(); - check_length = true, - kwargs...) where {iip} + parammap = SciMLBase.NullParameters(); + check_length = true, + kwargs...) where {iip} f, u0, p = process_DEProblem(ODEFunctionExpr{iip}, sys, u0map, parammap; steady_state = true, check_length, kwargs...) diff --git a/src/systems/diffeqs/odesystem.jl b/src/systems/diffeqs/odesystem.jl index a173fd4a78..77975c91d9 100644 --- a/src/systems/diffeqs/odesystem.jl +++ b/src/systems/diffeqs/odesystem.jl @@ -149,13 +149,13 @@ struct ODESystem <: AbstractODESystem parent::Any function ODESystem(tag, deqs, iv, dvs, ps, tspan, var_to_name, ctrls, observed, tgrad, - jac, ctrl_jac, Wfact, Wfact_t, name, systems, defaults, - torn_matching, connector_type, preface, cevents, - devents, metadata = nothing, gui_metadata = nothing, - tearing_state = nothing, - substitutions = nothing, complete = false, - discrete_subsystems = nothing, unknown_states = nothing, - split_idxs = nothing, parent = nothing; checks::Union{Bool, Int} = true) + jac, ctrl_jac, Wfact, Wfact_t, name, systems, defaults, + torn_matching, connector_type, preface, cevents, + devents, metadata = nothing, gui_metadata = nothing, + tearing_state = nothing, + substitutions = nothing, complete = false, + discrete_subsystems = nothing, unknown_states = nothing, + split_idxs = nothing, parent = nothing; checks::Union{Bool, Int} = true) if checks == true || (checks & CheckComponents) > 0 check_variables(dvs, iv) check_parameters(ps, iv) @@ -174,21 +174,21 @@ struct ODESystem <: AbstractODESystem end function ODESystem(deqs::AbstractVector{<:Equation}, iv, dvs, ps; - controls = Num[], - observed = Equation[], - systems = ODESystem[], - tspan = nothing, - name = nothing, - default_u0 = Dict(), - default_p = Dict(), - defaults = _merge(Dict(default_u0), Dict(default_p)), - connector_type = nothing, - preface = nothing, - continuous_events = nothing, - discrete_events = nothing, - checks = true, - metadata = nothing, - gui_metadata = nothing) + controls = Num[], + observed = Equation[], + systems = ODESystem[], + tspan = nothing, + name = nothing, + default_u0 = Dict(), + default_p = Dict(), + defaults = _merge(Dict(default_u0), Dict(default_p)), + connector_type = nothing, + preface = nothing, + continuous_events = nothing, + discrete_events = nothing, + checks = true, + metadata = nothing, + gui_metadata = nothing) name === nothing && throw(ArgumentError("The `name` keyword must be provided. Please consider using the `@named` macro")) deqs = scalarize(deqs) @@ -317,13 +317,13 @@ Build the observed function assuming the observed equations are all explicit, i.e. there are no cycles. """ function build_explicit_observed_function(sys, ts; - inputs = nothing, - expression = false, - output_type = Array, - checkbounds = true, - drop_expr = drop_expr, - ps = parameters(sys), - throw = true) + inputs = nothing, + expression = false, + output_type = Array, + checkbounds = true, + drop_expr = drop_expr, + ps = parameters(sys), + throw = true) if (isscalar = !(ts isa AbstractVector)) ts = [ts] end diff --git a/src/systems/diffeqs/sdesystem.jl b/src/systems/diffeqs/sdesystem.jl index 49255b5c7d..a42c7aecfa 100644 --- a/src/systems/diffeqs/sdesystem.jl +++ b/src/systems/diffeqs/sdesystem.jl @@ -121,12 +121,12 @@ struct SDESystem <: AbstractODESystem parent::Any function SDESystem(tag, deqs, neqs, iv, dvs, ps, tspan, var_to_name, ctrls, observed, - tgrad, - jac, - ctrl_jac, Wfact, Wfact_t, name, systems, defaults, connector_type, - cevents, devents, metadata = nothing, gui_metadata = nothing, - complete = false, parent = nothing; - checks::Union{Bool, Int} = true) + tgrad, + jac, + ctrl_jac, Wfact, Wfact_t, name, systems, defaults, connector_type, + cevents, devents, metadata = nothing, gui_metadata = nothing, + complete = false, parent = nothing; + checks::Union{Bool, Int} = true) if checks == true || (checks & CheckComponents) > 0 check_variables(dvs, iv) check_parameters(ps, iv) @@ -144,20 +144,20 @@ struct SDESystem <: AbstractODESystem end function SDESystem(deqs::AbstractVector{<:Equation}, neqs::AbstractArray, iv, dvs, ps; - controls = Num[], - observed = Num[], - systems = SDESystem[], - tspan = nothing, - default_u0 = Dict(), - default_p = Dict(), - defaults = _merge(Dict(default_u0), Dict(default_p)), - name = nothing, - connector_type = nothing, - checks = true, - continuous_events = nothing, - discrete_events = nothing, - metadata = nothing, - gui_metadata = nothing) + controls = Num[], + observed = Num[], + systems = SDESystem[], + tspan = nothing, + default_u0 = Dict(), + default_p = Dict(), + defaults = _merge(Dict(default_u0), Dict(default_p)), + name = nothing, + connector_type = nothing, + checks = true, + continuous_events = nothing, + discrete_events = nothing, + metadata = nothing, + gui_metadata = nothing) name === nothing && throw(ArgumentError("The `name` keyword must be provided. Please consider using the `@named` macro")) deqs = scalarize(deqs) @@ -214,7 +214,7 @@ function Base.:(==)(sys1::SDESystem, sys2::SDESystem) end function generate_diffusion_function(sys::SDESystem, dvs = states(sys), - ps = parameters(sys); isdde = false, kwargs...) + ps = parameters(sys); isdde = false, kwargs...) eqs = get_noiseeqs(sys) if isdde eqs = delay_to_function(sys, eqs) @@ -386,12 +386,12 @@ function Girsanov_transform(sys::SDESystem, u; θ0 = 1.0) end function DiffEqBase.SDEFunction{iip}(sys::SDESystem, dvs = states(sys), - ps = parameters(sys), - u0 = nothing; - version = nothing, tgrad = false, sparse = false, - jac = false, Wfact = false, eval_expression = true, - checkbounds = false, - kwargs...) where {iip} + ps = parameters(sys), + u0 = nothing; + version = nothing, tgrad = false, sparse = false, + jac = false, Wfact = false, eval_expression = true, + checkbounds = false, + kwargs...) where {iip} dvs = scalarize.(dvs) ps = scalarize.(ps) @@ -509,11 +509,11 @@ variable and parameter vectors, respectively. struct SDEFunctionExpr{iip} end function SDEFunctionExpr{iip}(sys::SDESystem, dvs = states(sys), - ps = parameters(sys), u0 = nothing; - version = nothing, tgrad = false, - jac = false, Wfact = false, - sparse = false, linenumbers = false, - kwargs...) where {iip} + ps = parameters(sys), u0 = nothing; + version = nothing, tgrad = false, + jac = false, Wfact = false, + sparse = false, linenumbers = false, + kwargs...) where {iip} idx = iip ? 2 : 1 f = generate_function(sys, dvs, ps; expression = Val{true}, kwargs...)[idx] g = generate_diffusion_function(sys, dvs, ps; expression = Val{true}, kwargs...)[idx] @@ -569,9 +569,9 @@ function SDEFunctionExpr(sys::SDESystem, args...; kwargs...) end function DiffEqBase.SDEProblem{iip}(sys::SDESystem, u0map = [], tspan = get_tspan(sys), - parammap = DiffEqBase.NullParameters(); - sparsenoise = nothing, check_length = true, - callback = nothing, kwargs...) where {iip} + parammap = DiffEqBase.NullParameters(); + sparsenoise = nothing, check_length = true, + callback = nothing, kwargs...) where {iip} f, u0, p = process_DEProblem(SDEFunction{iip}, sys, u0map, parammap; check_length, kwargs...) cbs = process_events(sys; callback) @@ -628,9 +628,9 @@ numerical enhancements. struct SDEProblemExpr{iip} end function SDEProblemExpr{iip}(sys::SDESystem, u0map, tspan, - parammap = DiffEqBase.NullParameters(); - sparsenoise = nothing, check_length = true, - kwargs...) where {iip} + parammap = DiffEqBase.NullParameters(); + sparsenoise = nothing, check_length = true, + kwargs...) where {iip} f, u0, p = process_DEProblem(SDEFunctionExpr{iip}, sys, u0map, parammap; check_length, kwargs...) linenumbers = get(kwargs, :linenumbers, true) diff --git a/src/systems/discrete_system/discrete_system.jl b/src/systems/discrete_system/discrete_system.jl index d7f7920604..cb6118dfd2 100644 --- a/src/systems/discrete_system/discrete_system.jl +++ b/src/systems/discrete_system/discrete_system.jl @@ -92,12 +92,12 @@ struct DiscreteSystem <: AbstractTimeDependentSystem parent::Any function DiscreteSystem(tag, discreteEqs, iv, dvs, ps, tspan, var_to_name, ctrls, - observed, - name, - systems, defaults, preface, connector_type, - metadata = nothing, gui_metadata = nothing, - tearing_state = nothing, substitutions = nothing, - complete = false, parent = nothing; checks::Union{Bool, Int} = true) + observed, + name, + systems, defaults, preface, connector_type, + metadata = nothing, gui_metadata = nothing, + tearing_state = nothing, substitutions = nothing, + complete = false, parent = nothing; checks::Union{Bool, Int} = true) if checks == true || (checks & CheckComponents) > 0 check_variables(dvs, iv) check_parameters(ps, iv) @@ -119,19 +119,19 @@ end Constructs a DiscreteSystem. """ function DiscreteSystem(eqs::AbstractVector{<:Equation}, iv, dvs, ps; - controls = Num[], - observed = Num[], - systems = DiscreteSystem[], - tspan = nothing, - name = nothing, - default_u0 = Dict(), - default_p = Dict(), - defaults = _merge(Dict(default_u0), Dict(default_p)), - preface = nothing, - connector_type = nothing, - metadata = nothing, - gui_metadata = nothing, - kwargs...) + controls = Num[], + observed = Num[], + systems = DiscreteSystem[], + tspan = nothing, + name = nothing, + default_u0 = Dict(), + default_p = Dict(), + defaults = _merge(Dict(default_u0), Dict(default_p)), + preface = nothing, + connector_type = nothing, + metadata = nothing, + gui_metadata = nothing, + kwargs...) name === nothing && throw(ArgumentError("The `name` keyword must be provided. Please consider using the `@named` macro")) eqs = scalarize(eqs) @@ -208,11 +208,11 @@ end Generates an DiscreteProblem from an DiscreteSystem. """ function SciMLBase.DiscreteProblem(sys::DiscreteSystem, u0map = [], tspan = get_tspan(sys), - parammap = SciMLBase.NullParameters(); - eval_module = @__MODULE__, - eval_expression = true, - use_union = false, - kwargs...) + parammap = SciMLBase.NullParameters(); + eval_module = @__MODULE__, + eval_expression = true, + use_union = false, + kwargs...) dvs = states(sys) ps = parameters(sys) eqs = equations(sys) @@ -290,7 +290,7 @@ function get_delay_val(iv, x) end function generate_function(sys::DiscreteSystem, dvs = states(sys), ps = parameters(sys); - kwargs...) + kwargs...) eqs = equations(sys) check_operator_variables(eqs, Difference) rhss = [eq.rhs for eq in eqs] @@ -329,17 +329,17 @@ function SciMLBase.DiscreteFunction{false}(sys::DiscreteSystem, args...; kwargs. end function SciMLBase.DiscreteFunction{iip, specialize}(sys::DiscreteSystem, - dvs = states(sys), - ps = parameters(sys), - u0 = nothing; - version = nothing, - p = nothing, - t = nothing, - eval_expression = true, - eval_module = @__MODULE__, - analytic = nothing, - simplify = false, - kwargs...) where {iip, specialize} + dvs = states(sys), + ps = parameters(sys), + u0 = nothing; + version = nothing, + p = nothing, + t = nothing, + eval_expression = true, + eval_module = @__MODULE__, + analytic = nothing, + simplify = false, + kwargs...) where {iip, specialize} f_gen = generate_function(sys, dvs, ps; expression = Val{eval_expression}, expression_module = eval_module, kwargs...) f_oop, f_iip = eval_expression ? @@ -394,11 +394,11 @@ end (f::DiscreteFunctionClosure)(du, u, p, t) = f.f_iip(du, u, p, t) function DiscreteFunctionExpr{iip}(sys::DiscreteSystem, dvs = states(sys), - ps = parameters(sys), u0 = nothing; - version = nothing, p = nothing, - linenumbers = false, - simplify = false, - kwargs...) where {iip} + ps = parameters(sys), u0 = nothing; + version = nothing, p = nothing, + linenumbers = false, + simplify = false, + kwargs...) where {iip} f_oop, f_iip = generate_function(sys, dvs, ps; expression = Val{true}, kwargs...) fsym = gensym(:f) @@ -419,12 +419,12 @@ function DiscreteFunctionExpr(sys::DiscreteSystem, args...; kwargs...) end function process_DiscreteProblem(constructor, sys::DiscreteSystem, u0map, parammap; - version = nothing, - linenumbers = true, parallel = SerialForm(), - eval_expression = true, - use_union = false, - tofloat = !use_union, - kwargs...) + version = nothing, + linenumbers = true, parallel = SerialForm(), + eval_expression = true, + use_union = false, + tofloat = !use_union, + kwargs...) eqs = equations(sys) dvs = states(sys) ps = parameters(sys) @@ -445,9 +445,9 @@ function DiscreteProblemExpr(sys::DiscreteSystem, args...; kwargs...) end function DiscreteProblemExpr{iip}(sys::DiscreteSystem, u0map, tspan, - parammap = DiffEqBase.NullParameters(); - check_length = true, - kwargs...) where {iip} + parammap = DiffEqBase.NullParameters(); + check_length = true, + kwargs...) where {iip} f, u0, p = process_DiscreteProblem(DiscreteFunctionExpr{iip}, sys, u0map, parammap; check_length, kwargs...) linenumbers = get(kwargs, :linenumbers, true) diff --git a/src/systems/jumps/jumpsystem.jl b/src/systems/jumps/jumpsystem.jl index 19c2b2be64..df50834903 100644 --- a/src/systems/jumps/jumpsystem.jl +++ b/src/systems/jumps/jumpsystem.jl @@ -103,10 +103,10 @@ struct JumpSystem{U <: ArrayPartition} <: AbstractTimeDependentSystem complete::Bool function JumpSystem{U}(tag, ap::U, iv, states, ps, var_to_name, observed, name, systems, - defaults, connector_type, devents, - metadata = nothing, gui_metadata = nothing, - complete = false; - checks::Union{Bool, Int} = true) where {U <: ArrayPartition} + defaults, connector_type, devents, + metadata = nothing, gui_metadata = nothing, + complete = false; + checks::Union{Bool, Int} = true) where {U <: ArrayPartition} if checks == true || (checks & CheckComponents) > 0 check_variables(states, iv) check_parameters(ps, iv) @@ -120,19 +120,19 @@ struct JumpSystem{U <: ArrayPartition} <: AbstractTimeDependentSystem end function JumpSystem(eqs, iv, states, ps; - observed = Equation[], - systems = JumpSystem[], - default_u0 = Dict(), - default_p = Dict(), - defaults = _merge(Dict(default_u0), Dict(default_p)), - name = nothing, - connector_type = nothing, - checks = true, - continuous_events = nothing, - discrete_events = nothing, - metadata = nothing, - gui_metadata = nothing, - kwargs...) + observed = Equation[], + systems = JumpSystem[], + default_u0 = Dict(), + default_p = Dict(), + defaults = _merge(Dict(default_u0), Dict(default_p)), + name = nothing, + connector_type = nothing, + checks = true, + continuous_events = nothing, + discrete_events = nothing, + metadata = nothing, + gui_metadata = nothing, + kwargs...) name === nothing && throw(ArgumentError("The `name` keyword must be provided. Please consider using the `@named` macro")) eqs = scalarize(eqs) @@ -292,10 +292,10 @@ dprob = DiscreteProblem(js, u₀map, tspan, parammap) ``` """ function DiffEqBase.DiscreteProblem(sys::JumpSystem, u0map, tspan::Union{Tuple, Nothing}, - parammap = DiffEqBase.NullParameters(); - checkbounds = false, - use_union = true, - kwargs...) + parammap = DiffEqBase.NullParameters(); + checkbounds = false, + use_union = true, + kwargs...) dvs = states(sys) ps = parameters(sys) @@ -349,9 +349,9 @@ dprob = DiscreteProblem(js, u₀map, tspan, parammap) struct DiscreteProblemExpr{iip} end function DiscreteProblemExpr{iip}(sys::JumpSystem, u0map, tspan::Union{Tuple, Nothing}, - parammap = DiffEqBase.NullParameters(); - use_union = false, - kwargs...) where {iip} + parammap = DiffEqBase.NullParameters(); + use_union = false, + kwargs...) where {iip} dvs = states(sys) ps = parameters(sys) defs = defaults(sys) @@ -386,7 +386,7 @@ sol = solve(jprob, SSAStepper()) ``` """ function JumpProcesses.JumpProblem(js::JumpSystem, prob, aggregator; callback = nothing, - kwargs...) + kwargs...) statetoid = Dict(value(state) => i for (i, state) in enumerate(states(js))) eqs = equations(js) invttype = prob.tspan[1] === nothing ? Float64 : typeof(1 / prob.tspan[2]) @@ -473,7 +473,7 @@ function JumpSysMajParamMapper(js::JumpSystem, p; jseqs = nothing, rateconsttype end function updateparams!(ratemap::JumpSysMajParamMapper{U, V, W}, - params) where {U <: AbstractArray, V <: AbstractArray, W} + params) where {U <: AbstractArray, V <: AbstractArray, W} for (i, p) in enumerate(params) sympar = ratemap.sympars[i] ratemap.subdict[sympar] = p @@ -482,17 +482,17 @@ function updateparams!(ratemap::JumpSysMajParamMapper{U, V, W}, end function updateparams!(::JumpSysMajParamMapper{U, V, W}, - params::Nothing) where {U <: AbstractArray, V <: AbstractArray, W} + params::Nothing) where {U <: AbstractArray, V <: AbstractArray, W} nothing end # create the initial parameter vector for use in a MassActionJump function (ratemap::JumpSysMajParamMapper{ - U, - V, - W, -})(params) where {U <: AbstractArray, - V <: AbstractArray, W} + U, + V, + W, + })(params) where {U <: AbstractArray, + V <: AbstractArray, W} updateparams!(ratemap, params) [convert(W, value(substitute(paramexpr, ratemap.subdict))) for paramexpr in ratemap.paramexprs] @@ -500,9 +500,9 @@ end # update a maj with parameter vectors function (ratemap::JumpSysMajParamMapper{U, V, W})(maj::MassActionJump, newparams; - scale_rates, - kwargs...) where {U <: AbstractArray, - V <: AbstractArray, W} + scale_rates, + kwargs...) where {U <: AbstractArray, + V <: AbstractArray, W} updateparams!(ratemap, newparams) for i in 1:get_num_majumps(maj) maj.scaled_rates[i] = convert(W, diff --git a/src/systems/model_parsing.jl b/src/systems/model_parsing.jl index 3ee6c2800f..be8d066b35 100644 --- a/src/systems/model_parsing.jl +++ b/src/systems/model_parsing.jl @@ -84,7 +84,7 @@ function _model_macro(mod, name, expr, isconnector) end function parse_variable_def!(dict, mod, arg, varclass, kwargs; - def = nothing, indices::Union{Vector{UnitRange{Int}}, Nothing} = nothing) + def = nothing, indices::Union{Vector{UnitRange{Int}}, Nothing} = nothing) metatypes = [(:connection_type, VariableConnectType), (:description, VariableDescription), (:unit, VariableUnit), @@ -154,7 +154,7 @@ function parse_variable_def!(dict, mod, arg, varclass, kwargs; end function generate_var(a, varclass; - indices::Union{Vector{UnitRange{Int}}, Nothing} = nothing) + indices::Union{Vector{UnitRange{Int}}, Nothing} = nothing) var = indices === nothing ? Symbolics.variable(a) : first(@variables $a[indices...]) if varclass == :parameters var = toparam(var) @@ -163,7 +163,7 @@ function generate_var(a, varclass; end function generate_var!(dict, a, varclass; - indices::Union{Vector{UnitRange{Int}}, Nothing} = nothing) + indices::Union{Vector{UnitRange{Int}}, Nothing} = nothing) vd = get!(dict, varclass) do Dict{Symbol, Dict{Symbol, Any}}() end @@ -173,7 +173,7 @@ function generate_var!(dict, a, varclass; end function generate_var!(dict, a, b, varclass; - indices::Union{Vector{UnitRange{Int}}, Nothing} = nothing) + indices::Union{Vector{UnitRange{Int}}, Nothing} = nothing) iv = generate_var(b, :variables) prev_iv = get!(dict, :independent_variable) do iv @@ -243,7 +243,7 @@ function get_var(mod::Module, b) end function parse_model!(exprs, comps, ext, eqs, icon, vs, ps, sps, - dict, mod, arg, kwargs) + dict, mod, arg, kwargs) mname = arg.args[1] body = arg.args[end] if mname == Symbol("@components") diff --git a/src/systems/nonlinear/nonlinearsystem.jl b/src/systems/nonlinear/nonlinearsystem.jl index 9bbaea7d10..0eca0ce7d3 100644 --- a/src/systems/nonlinear/nonlinearsystem.jl +++ b/src/systems/nonlinear/nonlinearsystem.jl @@ -82,11 +82,11 @@ struct NonlinearSystem <: AbstractTimeIndependentSystem parent::Any function NonlinearSystem(tag, eqs, states, ps, var_to_name, observed, jac, name, - systems, - defaults, connector_type, metadata = nothing, - gui_metadata = nothing, - tearing_state = nothing, substitutions = nothing, - complete = false, parent = nothing; checks::Union{Bool, Int} = true) + systems, + defaults, connector_type, metadata = nothing, + gui_metadata = nothing, + tearing_state = nothing, substitutions = nothing, + complete = false, parent = nothing; checks::Union{Bool, Int} = true) if checks == true || (checks & CheckUnits) > 0 all_dimensionless([states; ps]) || check_units(eqs) end @@ -97,18 +97,18 @@ struct NonlinearSystem <: AbstractTimeIndependentSystem end function NonlinearSystem(eqs, states, ps; - observed = [], - name = nothing, - default_u0 = Dict(), - default_p = Dict(), - defaults = _merge(Dict(default_u0), Dict(default_p)), - systems = NonlinearSystem[], - connector_type = nothing, - continuous_events = nothing, # this argument is only required for ODESystems, but is added here for the constructor to accept it without error - discrete_events = nothing, # this argument is only required for ODESystems, but is added here for the constructor to accept it without error - checks = true, - metadata = nothing, - gui_metadata = nothing) + observed = [], + name = nothing, + default_u0 = Dict(), + default_p = Dict(), + defaults = _merge(Dict(default_u0), Dict(default_p)), + systems = NonlinearSystem[], + connector_type = nothing, + continuous_events = nothing, # this argument is only required for ODESystems, but is added here for the constructor to accept it without error + discrete_events = nothing, # this argument is only required for ODESystems, but is added here for the constructor to accept it without error + checks = true, + metadata = nothing, + gui_metadata = nothing) continuous_events === nothing || isempty(continuous_events) || throw(ArgumentError("NonlinearSystem does not accept `continuous_events`, you provided $continuous_events")) discrete_events === nothing || isempty(discrete_events) || @@ -165,7 +165,7 @@ function calculate_jacobian(sys::NonlinearSystem; sparse = false, simplify = fal end function generate_jacobian(sys::NonlinearSystem, vs = states(sys), ps = parameters(sys); - sparse = false, simplify = false, kwargs...) + sparse = false, simplify = false, kwargs...) jac = calculate_jacobian(sys, sparse = sparse, simplify = simplify) pre = get_preprocess_constants(jac) return build_function(jac, vs, ps; postprocess_fbody = pre, kwargs...) @@ -183,14 +183,14 @@ function calculate_hessian(sys::NonlinearSystem; sparse = false, simplify = fals end function generate_hessian(sys::NonlinearSystem, vs = states(sys), ps = parameters(sys); - sparse = false, simplify = false, kwargs...) + sparse = false, simplify = false, kwargs...) hess = calculate_hessian(sys, sparse = sparse, simplify = simplify) pre = get_preprocess_constants(hess) return build_function(hess, vs, ps; postprocess_fbody = pre, kwargs...) end function generate_function(sys::NonlinearSystem, dvs = states(sys), ps = parameters(sys); - kwargs...) + kwargs...) rhss = [deq.rhs for deq in equations(sys)] pre, sol_states = get_substitutions_and_solved_states(sys) @@ -227,12 +227,12 @@ function SciMLBase.NonlinearFunction(sys::NonlinearSystem, args...; kwargs...) end function SciMLBase.NonlinearFunction{iip}(sys::NonlinearSystem, dvs = states(sys), - ps = parameters(sys), u0 = nothing; - version = nothing, - jac = false, - eval_expression = true, - sparse = false, simplify = false, - kwargs...) where {iip} + ps = parameters(sys), u0 = nothing; + version = nothing, + jac = false, + eval_expression = true, + sparse = false, simplify = false, + kwargs...) where {iip} f_gen = generate_function(sys, dvs, ps; expression = Val{eval_expression}, kwargs...) f_oop, f_iip = eval_expression ? (drop_expr(@RuntimeGeneratedFunction(ex)) for ex in f_gen) : f_gen @@ -289,12 +289,12 @@ variable and parameter vectors, respectively. struct NonlinearFunctionExpr{iip} end function NonlinearFunctionExpr{iip}(sys::NonlinearSystem, dvs = states(sys), - ps = parameters(sys), u0 = nothing; - version = nothing, tgrad = false, - jac = false, - linenumbers = false, - sparse = false, simplify = false, - kwargs...) where {iip} + ps = parameters(sys), u0 = nothing; + version = nothing, tgrad = false, + jac = false, + linenumbers = false, + sparse = false, simplify = false, + kwargs...) where {iip} idx = iip ? 2 : 1 f = generate_function(sys, dvs, ps; expression = Val{true}, kwargs...)[idx] @@ -321,15 +321,15 @@ function NonlinearFunctionExpr{iip}(sys::NonlinearSystem, dvs = states(sys), end function process_NonlinearProblem(constructor, sys::NonlinearSystem, u0map, parammap; - version = nothing, - jac = false, - checkbounds = false, sparse = false, - simplify = false, - linenumbers = true, parallel = SerialForm(), - eval_expression = true, - use_union = false, - tofloat = !use_union, - kwargs...) + version = nothing, + jac = false, + checkbounds = false, sparse = false, + simplify = false, + linenumbers = true, parallel = SerialForm(), + eval_expression = true, + use_union = false, + tofloat = !use_union, + kwargs...) eqs = equations(sys) dvs = states(sys) ps = parameters(sys) @@ -363,8 +363,8 @@ function DiffEqBase.NonlinearProblem(sys::NonlinearSystem, args...; kwargs...) end function DiffEqBase.NonlinearProblem{iip}(sys::NonlinearSystem, u0map, - parammap = DiffEqBase.NullParameters(); - check_length = true, kwargs...) where {iip} + parammap = DiffEqBase.NullParameters(); + check_length = true, kwargs...) where {iip} f, u0, p = process_NonlinearProblem(NonlinearFunction{iip}, sys, u0map, parammap; check_length, kwargs...) pt = something(get_metadata(sys), StandardNonlinearProblem()) @@ -392,9 +392,9 @@ function NonlinearProblemExpr(sys::NonlinearSystem, args...; kwargs...) end function NonlinearProblemExpr{iip}(sys::NonlinearSystem, u0map, - parammap = DiffEqBase.NullParameters(); - check_length = true, - kwargs...) where {iip} + parammap = DiffEqBase.NullParameters(); + check_length = true, + kwargs...) where {iip} f, u0, p = process_NonlinearProblem(NonlinearFunctionExpr{iip}, sys, u0map, parammap; check_length, kwargs...) linenumbers = get(kwargs, :linenumbers, true) diff --git a/src/systems/optimization/constraints_system.jl b/src/systems/optimization/constraints_system.jl index f49df5fc51..46def83701 100644 --- a/src/systems/optimization/constraints_system.jl +++ b/src/systems/optimization/constraints_system.jl @@ -71,11 +71,11 @@ struct ConstraintsSystem <: AbstractTimeIndependentSystem substitutions::Any function ConstraintsSystem(tag, constraints, states, ps, var_to_name, observed, jac, - name, - systems, - defaults, connector_type, metadata = nothing, - tearing_state = nothing, substitutions = nothing; - checks::Union{Bool, Int} = true) + name, + systems, + defaults, connector_type, metadata = nothing, + tearing_state = nothing, substitutions = nothing; + checks::Union{Bool, Int} = true) if checks == true || (checks & CheckUnits) > 0 all_dimensionless([states; ps]) || check_units(constraints) end @@ -88,17 +88,17 @@ end equations(sys::ConstraintsSystem) = constraints(sys) # needed for Base.show function ConstraintsSystem(constraints, states, ps; - observed = [], - name = nothing, - default_u0 = Dict(), - default_p = Dict(), - defaults = _merge(Dict(default_u0), Dict(default_p)), - systems = ConstraintsSystem[], - connector_type = nothing, - continuous_events = nothing, # this argument is only required for ODESystems, but is added here for the constructor to accept it without error - discrete_events = nothing, # this argument is only required for ODESystems, but is added here for the constructor to accept it without error - checks = true, - metadata = nothing) + observed = [], + name = nothing, + default_u0 = Dict(), + default_p = Dict(), + defaults = _merge(Dict(default_u0), Dict(default_p)), + systems = ConstraintsSystem[], + connector_type = nothing, + continuous_events = nothing, # this argument is only required for ODESystems, but is added here for the constructor to accept it without error + discrete_events = nothing, # this argument is only required for ODESystems, but is added here for the constructor to accept it without error + checks = true, + metadata = nothing) continuous_events === nothing || isempty(continuous_events) || throw(ArgumentError("ConstraintsSystem does not accept `continuous_events`, you provided $continuous_events")) discrete_events === nothing || isempty(discrete_events) || @@ -153,7 +153,7 @@ function calculate_jacobian(sys::ConstraintsSystem; sparse = false, simplify = f end function generate_jacobian(sys::ConstraintsSystem, vs = states(sys), ps = parameters(sys); - sparse = false, simplify = false, kwargs...) + sparse = false, simplify = false, kwargs...) jac = calculate_jacobian(sys, sparse = sparse, simplify = simplify) return build_function(jac, vs, ps; kwargs...) end @@ -170,13 +170,13 @@ function calculate_hessian(sys::ConstraintsSystem; sparse = false, simplify = fa end function generate_hessian(sys::ConstraintsSystem, vs = states(sys), ps = parameters(sys); - sparse = false, simplify = false, kwargs...) + sparse = false, simplify = false, kwargs...) hess = calculate_hessian(sys, sparse = sparse, simplify = simplify) return build_function(hess, vs, ps; kwargs...) end function generate_function(sys::ConstraintsSystem, dvs = states(sys), ps = parameters(sys); - kwargs...) + kwargs...) lhss = generate_canonical_form_lhss(sys) pre, sol_states = get_substitutions_and_solved_states(sys) diff --git a/src/systems/optimization/optimizationsystem.jl b/src/systems/optimization/optimizationsystem.jl index ab2f302a10..e1ab36c9ae 100644 --- a/src/systems/optimization/optimizationsystem.jl +++ b/src/systems/optimization/optimizationsystem.jl @@ -62,9 +62,9 @@ struct OptimizationSystem <: AbstractOptimizationSystem parent::Any function OptimizationSystem(tag, op, states, ps, var_to_name, observed, - constraints, name, systems, defaults, metadata = nothing, - gui_metadata = nothing, complete = false, parent = nothing; - checks::Union{Bool, Int} = true) + constraints, name, systems, defaults, metadata = nothing, + gui_metadata = nothing, complete = false, parent = nothing; + checks::Union{Bool, Int} = true) if checks == true || (checks & CheckUnits) > 0 unwrap(op) isa Symbolic && check_units(op) check_units(observed) @@ -79,16 +79,16 @@ end equations(sys::AbstractOptimizationSystem) = objective(sys) # needed for Base.show function OptimizationSystem(op, states, ps; - observed = [], - constraints = [], - default_u0 = Dict(), - default_p = Dict(), - defaults = _merge(Dict(default_u0), Dict(default_p)), - name = nothing, - systems = OptimizationSystem[], - checks = true, - metadata = nothing, - gui_metadata = nothing) + observed = [], + constraints = [], + default_u0 = Dict(), + default_p = Dict(), + defaults = _merge(Dict(default_u0), Dict(default_p)), + name = nothing, + systems = OptimizationSystem[], + checks = true, + metadata = nothing, + gui_metadata = nothing) name === nothing && throw(ArgumentError("The `name` keyword must be provided. Please consider using the `@named` macro")) constraints = value.(scalarize(constraints)) @@ -125,7 +125,7 @@ function calculate_gradient(sys::OptimizationSystem) end function generate_gradient(sys::OptimizationSystem, vs = states(sys), ps = parameters(sys); - kwargs...) + kwargs...) grad = calculate_gradient(sys) pre = get_preprocess_constants(grad) return build_function(grad, vs, ps; postprocess_fbody = pre, @@ -137,7 +137,7 @@ function calculate_hessian(sys::OptimizationSystem) end function generate_hessian(sys::OptimizationSystem, vs = states(sys), ps = parameters(sys); - sparse = false, kwargs...) + sparse = false, kwargs...) if sparse hess = sparsehessian(objective(sys), states(sys)) else @@ -149,7 +149,7 @@ function generate_hessian(sys::OptimizationSystem, vs = states(sys), ps = parame end function generate_function(sys::OptimizationSystem, vs = states(sys), ps = parameters(sys); - kwargs...) + kwargs...) eqs = subs_constants(objective(sys)) return build_function(eqs, vs, ps; kwargs...) @@ -224,15 +224,15 @@ function DiffEqBase.OptimizationProblem(sys::OptimizationSystem, args...; kwargs DiffEqBase.OptimizationProblem{true}(sys::OptimizationSystem, args...; kwargs...) end function DiffEqBase.OptimizationProblem{iip}(sys::OptimizationSystem, u0map, - parammap = DiffEqBase.NullParameters(); - lb = nothing, ub = nothing, - grad = false, - hess = false, sparse = false, - cons_j = false, cons_h = false, - cons_sparse = false, checkbounds = false, - linenumbers = true, parallel = SerialForm(), - use_union = false, - kwargs...) where {iip} + parammap = DiffEqBase.NullParameters(); + lb = nothing, ub = nothing, + grad = false, + hess = false, sparse = false, + cons_j = false, cons_h = false, + cons_sparse = false, checkbounds = false, + linenumbers = true, parallel = SerialForm(), + use_union = false, + kwargs...) where {iip} if haskey(kwargs, :lcons) || haskey(kwargs, :ucons) Base.depwarn("`lcons` and `ucons` are deprecated. Specify constraints directly instead.", :OptimizationProblem, force = true) @@ -423,15 +423,15 @@ function OptimizationProblemExpr(sys::OptimizationSystem, args...; kwargs...) end function OptimizationProblemExpr{iip}(sys::OptimizationSystem, u0map, - parammap = DiffEqBase.NullParameters(); - lb = nothing, ub = nothing, - grad = false, - hess = false, sparse = false, - cons_j = false, cons_h = false, - checkbounds = false, - linenumbers = false, parallel = SerialForm(), - use_union = false, - kwargs...) where {iip} + parammap = DiffEqBase.NullParameters(); + lb = nothing, ub = nothing, + grad = false, + hess = false, sparse = false, + cons_j = false, cons_h = false, + checkbounds = false, + linenumbers = false, parallel = SerialForm(), + use_union = false, + kwargs...) where {iip} if haskey(kwargs, :lcons) || haskey(kwargs, :ucons) Base.depwarn("`lcons` and `ucons` are deprecated. Specify constraints directly instead.", :OptimizationProblem, force = true) diff --git a/src/systems/pde/pdesystem.jl b/src/systems/pde/pdesystem.jl index c8c7d6dcc9..f0d8ec3869 100644 --- a/src/systems/pde/pdesystem.jl +++ b/src/systems/pde/pdesystem.jl @@ -86,17 +86,17 @@ struct PDESystem <: ModelingToolkit.AbstractMultivariateSystem """ gui_metadata::Union{Nothing, GUIMetadata} @add_kwonly function PDESystem(eqs, bcs, domain, ivs, dvs, - ps = SciMLBase.NullParameters(); - defaults = Dict(), - systems = [], - connector_type = nothing, - metadata = nothing, - analytic = nothing, - analytic_func = nothing, - gui_metadata = nothing, - eval_module = @__MODULE__, - checks::Union{Bool, Int} = true, - name) + ps = SciMLBase.NullParameters(); + defaults = Dict(), + systems = [], + connector_type = nothing, + metadata = nothing, + analytic = nothing, + analytic_func = nothing, + gui_metadata = nothing, + eval_module = @__MODULE__, + checks::Union{Bool, Int} = true, + name) if checks == true || (checks & CheckUnits) > 0 all_dimensionless([dvs; ivs; ps]) || check_units(eqs) end diff --git a/src/systems/sparsematrixclil.jl b/src/systems/sparsematrixclil.jl index a44b0d9a8c..8be632e556 100644 --- a/src/systems/sparsematrixclil.jl +++ b/src/systems/sparsematrixclil.jl @@ -130,7 +130,7 @@ end nonzerosmap(a::CLILVector) = NonZeros(a) function bareiss_update_virtual_colswap_mtk!(zero!, M::SparseMatrixCLIL, k, swapto, pivot, - last_pivot; pivot_equal_optimization = true) + last_pivot; pivot_equal_optimization = true) # for ei in nzrows(>= k) eadj = M.row_cols old_cadj = M.row_vals @@ -213,7 +213,7 @@ function bareiss_update_virtual_colswap_mtk!(zero!, M::SparseMatrixCLIL, k, swap end function bareiss_update_virtual_colswap_mtk!(zero!, M::AbstractMatrix, k, swapto, pivot, - last_pivot; pivot_equal_optimization = true) + last_pivot; pivot_equal_optimization = true) if pivot_equal_optimization error("MTK pivot micro-optimization not implemented for `$(typeof(M))`. Turn off the optimization for debugging or use a different matrix type.") diff --git a/src/systems/systems.jl b/src/systems/systems.jl index bdf8f31808..39a527003a 100644 --- a/src/systems/systems.jl +++ b/src/systems/systems.jl @@ -1,5 +1,5 @@ function System(eqs::AbstractVector{<:Equation}, iv = nothing, args...; name = nothing, - kw...) + kw...) ODESystem(eqs, iv, args...; name, kw..., checks = false) end @@ -17,7 +17,7 @@ This will convert all `inputs` to parameters and allow them to be unconnected, i simplification will allow models where `n_states = n_equations - n_inputs`. """ function structural_simplify(sys::AbstractSystem, io = nothing; simplify = false, - kwargs...) + kwargs...) newsys′ = __structural_simplify(sys, io; simplify, kwargs...) if newsys′ isa Tuple @assert length(newsys′) == 2 @@ -34,7 +34,7 @@ function structural_simplify(sys::AbstractSystem, io = nothing; simplify = false end end function __structural_simplify(sys::AbstractSystem, io = nothing; simplify = false, - kwargs...) + kwargs...) sys = expand_connections(sys) sys isa DiscreteSystem && return sys state = TearingState(sys) diff --git a/src/systems/systemstructure.jl b/src/systems/systemstructure.jl index 18e50afc9b..69077b452f 100644 --- a/src/systems/systemstructure.jl +++ b/src/systems/systemstructure.jl @@ -553,8 +553,8 @@ function merge_io(io, inputs) end function structural_simplify!(state::TearingState, io = nothing; simplify = false, - check_consistency = true, fully_determined = true, - kwargs...) + check_consistency = true, fully_determined = true, + kwargs...) if state.sys isa ODESystem ci = ModelingToolkit.ClockInference(state) ModelingToolkit.infer_clocks!(ci) @@ -595,8 +595,8 @@ function structural_simplify!(state::TearingState, io = nothing; simplify = fals end function _structural_simplify!(state::TearingState, io; simplify = false, - check_consistency = true, fully_determined = true, - kwargs...) + check_consistency = true, fully_determined = true, + kwargs...) check_consistency &= fully_determined has_io = io !== nothing orig_inputs = Set() diff --git a/src/systems/validation.jl b/src/systems/validation.jl index 97bb999de3..d3ce0ea9a4 100644 --- a/src/systems/validation.jl +++ b/src/systems/validation.jl @@ -212,8 +212,8 @@ function _validate(conn::Connection; info::String = "") end function validate(jump::Union{ModelingToolkit.VariableRateJump, - ModelingToolkit.ConstantRateJump}, t::Symbolic; - info::String = "") + ModelingToolkit.ConstantRateJump}, t::Symbolic; + info::String = "") newinfo = replace(info, "eq." => "jump") _validate([jump.rate, 1 / t], ["rate", "1/t"], info = newinfo) && # Assuming the rate is per time units validate(jump.affect!, info = newinfo) @@ -243,7 +243,7 @@ function validate(eq::ModelingToolkit.Equation; info::String = "") end end function validate(eq::ModelingToolkit.Equation, - term::Union{Symbolic, Unitful.Quantity, Num}; info::String = "") + term::Union{Symbolic, Unitful.Quantity, Num}; info::String = "") _validate([eq.lhs, eq.rhs, term], ["left", "right", "noise"]; info) end function validate(eq::ModelingToolkit.Equation, terms::Vector; info::String = "") diff --git a/src/utils.jl b/src/utils.jl index f66ed48772..b7cd1af651 100644 --- a/src/utils.jl +++ b/src/utils.jl @@ -753,7 +753,7 @@ struct StatefulPreOrderDFS{T} <: AbstractSimpleTreeIter{T} t::T end function Base.iterate(it::StatefulPreOrderDFS, - state = (eltype(it)[it.t], reverse_buffer(it))) + state = (eltype(it)[it.t], reverse_buffer(it))) stack, rev_buff = state isempty(stack) && return nothing t = pop!(stack) @@ -766,7 +766,7 @@ struct StatefulPostOrderDFS{T} <: AbstractSimpleTreeIter{T} t::T end function Base.iterate(it::StatefulPostOrderDFS, - state = (eltype(it)[it.t], falses(1), reverse_buffer(it))) + state = (eltype(it)[it.t], falses(1), reverse_buffer(it))) isempty(state[2]) && return nothing vstack, sstack, rev_buff = state while true diff --git a/src/variables.jl b/src/variables.jl index 854680998e..e0addefe6b 100644 --- a/src/variables.jl +++ b/src/variables.jl @@ -57,8 +57,8 @@ and creates the array of values in the correct order with default values when applicable. """ function varmap_to_vars(varmap, varlist; defaults = Dict(), check = true, - toterm = default_toterm, promotetoconcrete = nothing, - tofloat = true, use_union = true) + toterm = default_toterm, promotetoconcrete = nothing, + tofloat = true, use_union = true) varlist = collect(map(unwrap, varlist)) # Edge cases where one of the arguments is effectively empty. @@ -104,7 +104,7 @@ function varmap_to_vars(varmap, varlist; defaults = Dict(), check = true, end function _varmap_to_vars(varmap::Dict, varlist; defaults = Dict(), check = false, - toterm = Symbolics.diff2term) + toterm = Symbolics.diff2term) varmap = merge(defaults, varmap) # prefers the `varmap` varmap = Dict(toterm(value(k)) => value(varmap[k]) for k in keys(varmap)) # resolve symbolic parameter expressions @@ -129,10 +129,10 @@ Intercept the call to `process_p_u0_symbolic` and process symbolic maps of `p` a user has `ModelingToolkit` loaded. """ function SciMLBase.process_p_u0_symbolic(prob::Union{SciMLBase.AbstractDEProblem, - NonlinearProblem, OptimizationProblem, - SciMLBase.AbstractOptimizationCache}, - p, - u0) + NonlinearProblem, OptimizationProblem, + SciMLBase.AbstractOptimizationCache}, + p, + u0) # check if a symbolic remake is possible if eltype(p) <: Pair hasproperty(prob.f, :sys) && hasfield(typeof(prob.f.sys), :ps) || diff --git a/test/domain_connectors.jl b/test/domain_connectors.jl index 685ff583fd..3f42808664 100644 --- a/test/domain_connectors.jl +++ b/test/domain_connectors.jl @@ -21,10 +21,10 @@ D = Differential(t) end @connector function HydraulicFluid(; - density = 997, - bulk_modulus = 2.09e9, - viscosity = 0.0010016, - name) + density = 997, + bulk_modulus = 2.09e9, + viscosity = 0.0010016, + name) pars = @parameters begin ρ = density β = bulk_modulus diff --git a/test/stream_connectors.jl b/test/stream_connectors.jl index e4365876cf..8a7facb09f 100644 --- a/test/stream_connectors.jl +++ b/test/stream_connectors.jl @@ -36,8 +36,8 @@ end end function MassFlowSource_h(; name, - h_in = 420e3, - m_flow_in = -0.01) + h_in = 420e3, + m_flow_in = -0.01) pars = @parameters begin h_in = h_in m_flow_in = m_flow_in @@ -62,7 +62,7 @@ end # Simplified components. function AdiabaticStraightPipe(; name, - kwargs...) + kwargs...) vars = [] pars = [] @@ -79,8 +79,8 @@ function AdiabaticStraightPipe(; name, end function SmallBoundary_Ph(; name, - P_in = 1e6, - h_in = 400e3) + P_in = 1e6, + h_in = 400e3) vars = [] pars = @parameters begin @@ -102,9 +102,9 @@ end # N1M1 model and test code. function N1M1(; name, - P_in = 1e6, - h_in = 400e3, - kwargs...) + P_in = 1e6, + h_in = 400e3, + kwargs...) @named port_a = TwoPhaseFluidPort() @named source = SmallBoundary_Ph(P_in = P_in, h_in = h_in) @@ -177,9 +177,9 @@ ssort(eqs) = sort(eqs, by = string) # N1M2 model and test code. function N1M2(; name, - P_in = 1e6, - h_in = 400e3, - kwargs...) + P_in = 1e6, + h_in = 400e3, + kwargs...) @named port_a = TwoPhaseFluidPort() @named port_b = TwoPhaseFluidPort() @@ -224,7 +224,7 @@ eqns = [connect(n1m2.port_a, pipe1.port_a) # N2M2 model and test code. function N2M2(; name, - kwargs...) + kwargs...) @named port_a = TwoPhaseFluidPort() @named port_b = TwoPhaseFluidPort() @named pipe = AdiabaticStraightPipe() diff --git a/test/symbolic_events.jl b/test/symbolic_events.jl index 1ecf87eb40..4620fbaddb 100644 --- a/test/symbolic_events.jl +++ b/test/symbolic_events.jl @@ -340,7 +340,7 @@ sys = structural_simplify(model) let function testsol(osys, u0, p, tspan; tstops = Float64[], skipparamtest = false, - kwargs...) + kwargs...) oprob = ODEProblem(osys, u0, tspan, p; kwargs...) sol = solve(oprob, Tsit5(); tstops = tstops, abstol = 1e-10, reltol = 1e-10) @test isapprox(sol(1.0000000001)[1] - sol(0.999999999)[1], 1.0; rtol = 1e-6) @@ -414,7 +414,7 @@ end let function testsol(ssys, u0, p, tspan; tstops = Float64[], skipparamtest = false, - kwargs...) + kwargs...) sprob = SDEProblem(ssys, u0, tspan, p; kwargs...) sol = solve(sprob, RI5(); tstops = tstops, abstol = 1e-10, reltol = 1e-10) @test isapprox(sol(1.0000000001)[1] - sol(0.999999999)[1], 1.0; rtol = 1e-4) @@ -494,7 +494,7 @@ end let rng = rng function testsol(jsys, u0, p, tspan; tstops = Float64[], skipparamtest = false, - N = 40000, kwargs...) + N = 40000, kwargs...) dprob = DiscreteProblem(jsys, u0, tspan, p) jprob = JumpProblem(jsys, dprob, Direct(); kwargs...) sol = solve(jprob, SSAStepper(); tstops = tstops)