diff --git a/docs/src/basics/Composition.md b/docs/src/basics/Composition.md index d11bbd06a0..ab25459298 100644 --- a/docs/src/basics/Composition.md +++ b/docs/src/basics/Composition.md @@ -279,7 +279,7 @@ function UnitMassWithFriction(k; name) D(x) ~ v D(v) ~ sin(t) - k*sign(v) # f = ma, sinusoidal force acting on the mass, and Coulomb friction opposing the movement ] - ODESystem(eqs, t, continuous_events=[v ~ 0], name=name) # when v = 0 there is a discontinuity + ODESystem(eqs, t; continuous_events=[v ~ 0], name) # when v = 0 there is a discontinuity end @named m = UnitMassWithFriction(0.7) prob = ODEProblem(m, Pair[], (0, 10pi)) @@ -300,7 +300,7 @@ affect = [v ~ -v] # the effect is that the velocity changes sign @named ball = ODESystem([ D(x) ~ v D(v) ~ -9.8 -], t, continuous_events = root_eqs => affect) # equation => affect +], t; continuous_events = root_eqs => affect) # equation => affect ball = structural_simplify(ball) @@ -327,7 +327,7 @@ continuous_events = [ # This time we have a vector of pairs D(y) ~ vy, D(vx) ~ -9.8-0.1vx, # gravity + some small air resistance D(vy) ~ -0.1vy, -], t, continuous_events = continuous_events) +], t; continuous_events) ball = structural_simplify(ball) diff --git a/src/systems/validation.jl b/src/systems/validation.jl index 9fc10611f4..814a573e9b 100644 --- a/src/systems/validation.jl +++ b/src/systems/validation.jl @@ -173,10 +173,10 @@ function validate(jump::ModelingToolkit.MassActionJump, t::Symbolic; info::Strin left_symbols = [x[1] for x in jump.reactant_stoch] #vector of pairs of symbol,int -> vector symbols net_symbols = [x[1] for x in jump.net_stoch] all_symbols = vcat(left_symbols,net_symbols) - allgood = _validate(all_symbols, string.(all_symbols), info = info) + allgood = _validate(all_symbols, string.(all_symbols); info) n = sum(x->x[2],jump.reactant_stoch,init = 0) base_unitful = all_symbols[1] #all same, get first - allgood && _validate([jump.scaled_rates, 1/(t*base_unitful^n)], ["scaled_rates", "1/(t*reactants^$n))"], info = info) + allgood && _validate([jump.scaled_rates, 1/(t*base_unitful^n)], ["scaled_rates", "1/(t*reactants^$n))"]; info) end function validate(jumps::ArrayPartition{<:Union{Any, Vector{<:JumpType}}}, t::Symbolic) @@ -184,9 +184,9 @@ function validate(jumps::ArrayPartition{<:Union{Any, Vector{<:JumpType}}}, t::Sy all([validate(jumps.x[idx], t, info = labels[idx]) for idx in 1:3]) end -validate(eq::ModelingToolkit.Equation; info::String = "") = _validate([eq.lhs, eq.rhs], ["left", "right"], info = info) -validate(eq::ModelingToolkit.Equation, term::Union{Symbolic,Unitful.Quantity,Num}; info::String = "") = _validate([eq.lhs, eq.rhs, term], ["left","right","noise"], info = info) -validate(eq::ModelingToolkit.Equation, terms::Vector; info::String = "") = _validate(vcat([eq.lhs, eq.rhs], terms), vcat(["left", "right"], "noise #".*string.(1:length(terms))), info = info) +validate(eq::ModelingToolkit.Equation; info::String = "") = _validate([eq.lhs, eq.rhs], ["left", "right"]; info) +validate(eq::ModelingToolkit.Equation, term::Union{Symbolic,Unitful.Quantity,Num}; info::String = "") = _validate([eq.lhs, eq.rhs, term], ["left","right","noise"]; info) +validate(eq::ModelingToolkit.Equation, terms::Vector; info::String = "") = _validate(vcat([eq.lhs, eq.rhs], terms), vcat(["left", "right"], "noise #".*string.(1:length(terms))); info) "Returns true iff units of equations are valid." validate(eqs::Vector; info::String = "") = all([validate(eqs[idx], info = info*" in eq. #$idx") for idx in 1:length(eqs)]) diff --git a/test/nonlinearsystem.jl b/test/nonlinearsystem.jl index 3fb6686e74..7cb7df426e 100644 --- a/test/nonlinearsystem.jl +++ b/test/nonlinearsystem.jl @@ -126,7 +126,7 @@ np = NonlinearProblem(ns, [0,0,0], [1,2,3], jac=true, sparse=true) @parameters a @variables x f - NonlinearSystem([0 ~ -a * x + f], [x,f], [a], name = name) + NonlinearSystem([0 ~ -a * x + f], [x,f], [a]; name) end function issue819() diff --git a/test/odesystem.jl b/test/odesystem.jl index cc06e9018d..93862eee41 100644 --- a/test/odesystem.jl +++ b/test/odesystem.jl @@ -298,7 +298,7 @@ eq = D(x) ~ r*x @variables x(t) f(t) D = Differential(t) - ODESystem([D(x) ~ -a*x + f], name = name) + ODESystem([D(x) ~ -a*x + f]; name) end function issue808() diff --git a/test/root_equations.jl b/test/root_equations.jl index ba43fd3959..f5a12f1236 100644 --- a/test/root_equations.jl +++ b/test/root_equations.jl @@ -232,7 +232,7 @@ continuous_events = [ D(y) ~ vy D(vx) ~ -9.8 D(vy) ~ -0.01vy # there is some small air resistance -], t, continuous_events = continuous_events) +], t; continuous_events) @@ -274,7 +274,7 @@ continuous_events = [ D(y) ~ vy D(vx) ~ -1 D(vy) ~ 0 -], t, continuous_events = continuous_events) +], t; continuous_events) ball = structural_simplify(ball) @@ -304,4 +304,4 @@ sys = structural_simplify(sys) prob = ODAEProblem(sys, zeros(2), (0.0, 5.1)) sol = solve(prob, Tsit5()) @test all(minimum((0:0.1:5) .- sol.t', dims=2) .< 0.0001) # test that the solver stepped every 0.1s as dictated by event -@test sol([0.25])[vmeasured][] == sol([0.23])[vmeasured][] # test the hold property \ No newline at end of file +@test sol([0.25])[vmeasured][] == sol([0.23])[vmeasured][] # test the hold property