Skip to content

Commit e2979a5

Browse files
allow naming system types
1 parent a914076 commit e2979a5

File tree

2 files changed

+24
-16
lines changed

2 files changed

+24
-16
lines changed

src/systems/diffeqs/odesystem.jl

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -77,9 +77,21 @@ struct ODESystem <: AbstractODESystem
7777
[`generate_factorized_W`](@ref) is called on the system.
7878
"""
7979
Wfact_t::RefValue{Matrix{Expression}}
80+
"""
81+
Name: the name of the system
82+
"""
83+
name::Symbol
84+
end
85+
86+
function ODESystem(deqs::AbstractVector{ODEExpr}, iv, dvs, ps; name=gensym(:ODESystem))
87+
tgrad = RefValue(Vector{Expression}(undef, 0))
88+
jac = RefValue(Matrix{Expression}(undef, 0, 0))
89+
Wfact = RefValue(Matrix{Expression}(undef, 0, 0))
90+
Wfact_t = RefValue(Matrix{Expression}(undef, 0, 0))
91+
ODESystem(deqs, iv, dvs, ps, tgrad, jac, Wfact, Wfact_t, name)
8092
end
8193

82-
function ODESystem(eqs)
94+
function ODESystem(eqs; kwargs...)
8395
reformatted = convert.(ODEExpr,eqs)
8496

8597
ivs = unique(r[1] for r reformatted)
@@ -93,22 +105,14 @@ function ODESystem(eqs)
93105
x.known & !isequal(x, iv)
94106
end |> collect
95107

96-
ODESystem(deqs, iv, dvs, ps)
97-
end
98-
99-
function ODESystem(deqs::AbstractVector{ODEExpr}, iv, dvs, ps)
100-
tgrad = RefValue(Vector{Expression}(undef, 0))
101-
jac = RefValue(Matrix{Expression}(undef, 0, 0))
102-
Wfact = RefValue(Matrix{Expression}(undef, 0, 0))
103-
Wfact_t = RefValue(Matrix{Expression}(undef, 0, 0))
104-
ODESystem(deqs, iv, dvs, ps, tgrad, jac, Wfact, Wfact_t)
108+
ODESystem(deqs, iv, dvs, ps; kwargs...)
105109
end
106110

107-
function ODESystem(deqs::AbstractVector{<:Equation}, iv, dvs, ps)
111+
function ODESystem(deqs::AbstractVector{<:Equation}, iv, dvs, ps; kwargs...)
108112
_dvs = [deq.op for deq dvs]
109113
_iv = iv.op
110114
_ps = [p.op for p ps]
111-
ODESystem(getindex.(convert.(ODEExpr,deqs),2), _iv, _dvs, _ps)
115+
ODESystem(getindex.(convert.(ODEExpr,deqs),2), _iv, _dvs, _ps; kwargs...)
112116
end
113117

114118
function _eq_unordered(a, b)

src/systems/diffeqs/sdesystem.jl

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,21 +29,25 @@ struct SDESystem <: AbstractODESystem
2929
[`generate_factorized_W`](@ref) is called on the system.
3030
"""
3131
Wfact_t::RefValue{Matrix{Expression}}
32+
"""
33+
Name: the name of the system
34+
"""
35+
name::Symbol
3236
end
3337

34-
function SDESystem(deqs::AbstractVector{ODEExpr}, neqs, iv, dvs, ps)
38+
function SDESystem(deqs::AbstractVector{ODEExpr}, neqs, iv, dvs, ps; name = gensym(:SDESystem))
3539
tgrad = RefValue(Vector{Expression}(undef, 0))
3640
jac = RefValue(Matrix{Expression}(undef, 0, 0))
3741
Wfact = RefValue(Matrix{Expression}(undef, 0, 0))
3842
Wfact_t = RefValue(Matrix{Expression}(undef, 0, 0))
39-
SDESystem(deqs, neqs, iv, dvs, ps, tgrad, jac, Wfact, Wfact_t)
43+
SDESystem(deqs, neqs, iv, dvs, ps, tgrad, jac, Wfact, Wfact_t, name)
4044
end
4145

42-
function SDESystem(deqs::AbstractVector{<:Equation}, neqs, iv, dvs, ps)
46+
function SDESystem(deqs::AbstractVector{<:Equation}, neqs, iv, dvs, ps; kwargs...)
4347
_dvs = [deq.op for deq dvs]
4448
_iv = iv.op
4549
_ps = [p.op for p ps]
46-
SDESystem(getindex.(convert.(ODEExpr,deqs),2), neqs, _iv, _dvs, _ps)
50+
SDESystem(getindex.(convert.(ODEExpr,deqs),2), neqs, _iv, _dvs, _ps; kwargs...)
4751
end
4852

4953
function generate_diffusion_function(sys::SDESystem, dvs = sys.dvs, ps = sys.ps, expression = Val{true}; kwargs...)

0 commit comments

Comments
 (0)