Skip to content

Commit 87f9276

Browse files
add other README example
1 parent 870b331 commit 87f9276

File tree

2 files changed

+40
-0
lines changed

2 files changed

+40
-0
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,3 +103,5 @@ sol = solve(prob,Rodas5())
103103

104104
using Plots; plot(sol,vars=(,Symbol(lorenz1.x),Symbol(lorenz2.y)))
105105
```
106+
107+
![](https://user-images.githubusercontent.com/1814174/79122361-6fdaca80-7d65-11ea-87fd-0f6c4a85cd0d.png)

test/lowering_solving.jl

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,3 +24,41 @@ tspan = (0.0,100.0)
2424
prob = ODEProblem(sys,u0,tspan,p,jac=true)
2525
sol = solve(prob,Tsit5())
2626
#using Plots; plot(sol,vars=(:x,:y))
27+
28+
@parameters t σ ρ β
29+
@variables x(t) y(t) z(t)
30+
@derivatives D'~t
31+
32+
eqs = [D(x) ~ σ*(y-x),
33+
D(y) ~ x*-z)-y,
34+
D(z) ~ x*y - β*z]
35+
36+
lorenz1 = ODESystem(eqs,name=:lorenz1)
37+
lorenz2 = ODESystem(eqs,name=:lorenz2)
38+
39+
@variables α
40+
@parameters γ
41+
connections = [0 ~ lorenz1.x + lorenz2.y + α*γ]
42+
connected = ODESystem(connections,t,[α],[γ],systems=[lorenz1,lorenz2])
43+
44+
u0 = [lorenz1.x => 1.0,
45+
lorenz1.y => 0.0,
46+
lorenz1.z => 0.0,
47+
lorenz2.x => 0.0,
48+
lorenz2.y => 1.0,
49+
lorenz2.z => 0.0,
50+
α => 2.0]
51+
52+
p = [lorenz1.σ => 10.0,
53+
lorenz1.ρ => 28.0,
54+
lorenz1.β => 8/3,
55+
lorenz2.σ => 10.0,
56+
lorenz2.ρ => 28.0,
57+
lorenz2.β => 8/3,
58+
γ => 2.0]
59+
60+
tspan = (0.0,100.0)
61+
prob = ODEProblem(connected,u0,tspan,p)
62+
sol = solve(prob,Rodas5())
63+
64+
#using Plots; plot(sol,vars=(:α,Symbol(lorenz1.x),Symbol(lorenz2.y)))

0 commit comments

Comments
 (0)