Skip to content

Commit 6ad3c84

Browse files
committed
WIP
1 parent 4d5edfa commit 6ad3c84

File tree

3 files changed

+60
-12
lines changed

3 files changed

+60
-12
lines changed

benchmark/thermalfluid.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ function (this::CircularWall{Ne, Nn})(inner_heatport, outer_heatport) where {Ne,
103103
Qe = ntuple(_->continuous(), Ne)
104104

105105
ntuple(i->initial!(Tn[i] - this.T0), Nn)
106+
ntuple(i->initial!(Qe[i] - this.T0), Ne)
106107

107108
dn = (this.d, (this.d .+ 2.0 .* cumsum(this.t_layer))...)
108109
Cni = Cn_circular_wall_inner.(dn[1:Ne], dn[2:Nn], this.cp, this.ρ)

docs/src/architecture.md

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
```mermaid
2+
flowchart TD
3+
US[Uncompressed State]
4+
P[Parameters]
5+
subgraph init
6+
isicm([Init SICM])
7+
ICS[Init Compressed State]
8+
IB[Init Blob]
9+
irhs([Init RHS])
10+
IR[Init Residual]
11+
nlsolve([nlsolve])
12+
pr([Project])
13+
end
14+
subgraph dae
15+
osicm([ODE/DAE SICM])
16+
OCS[DAE/ODE Compressed State]
17+
OB[DAE/ODE Blob]
18+
orhs([ODE/DAE RHS])
19+
OR[ODE/DAE Residual]
20+
osolve([ODE solver])
21+
cmp([Compress])
22+
end
23+
prep([Prepare])
24+
US --> pr --> ICS
25+
US --> cmp --> OCS
26+
P --> isicm --> IB
27+
P --> osicm --> OB
28+
US --> osicm
29+
ICS --> irhs
30+
IB --> irhs
31+
irhs --> IR
32+
IR --> nlsolve
33+
nlsolve --> ICS
34+
OB --> orhs
35+
OCS --> orhs
36+
orhs --> OR
37+
OR --> osolve
38+
osolve --> OCS
39+
ICS --> prep
40+
IB --> prep
41+
prep --> OCS
42+
prep --> OB
43+
```

test/ipo.jl

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,14 @@ using OrdinaryDiffEq
1111
#= Basic IPO: We need to read the incidence of the contained `-` =#
1212
@noinline function onecall!()
1313
x = continuous()
14+
initial!(x - 1.0)
1415
always!(ddt(x) - x)
1516
end
1617

1718
onecall!()
18-
sol = solve(DAECProblem(onecall!, (1,) .=> 1.), IDA())
19+
sol = solve(DAECProblem(onecall!), DFBDF(autodiff=false))
1920
@test all(map((x,y)->isapprox(x[], y, atol=1e-2), sol[1, :], exp.(sol.t)))
20-
sol = solve(ODECProblem(onecall!, (1,) .=> 1.), Rodas5(autodiff=false))
21+
sol = solve(ODECProblem(onecall!), Rodas5(autodiff=false))
2122
@test all(map((x,y)->isapprox(x[], y, atol=1e-2), sol[1, :], exp.(sol.t)))
2223

2324
#==== Contained Equations ============#
@@ -27,23 +28,24 @@ function twocall!()
2728
end
2829

2930
twocall!()
30-
dae_sol = solve(DAECProblem(twocall!, (1, 2) .=> 1.), IDA())
31-
ode_sol = solve(ODECProblem(twocall!, (1, 2) .=> 1.), Rodas5(autodiff=false))
31+
dae_sol = solve(DAECProblem(twocall!), DFBDF(autodiff=false))
32+
ode_sol = solve(ODECProblem(twocall!), Rodas5(autodiff=false))
3233
for (sol, i) in Iterators.product((dae_sol, ode_sol), 1:2)
3334
@test all(map((x,y)->isapprox(x[], y, atol=1e-2), sol[i, :], exp.(sol.t)))
3435
end
3536

3637
#============== NonLinear ============#
3738
@noinline function sin!()
3839
x = continuous()
40+
initial!(x - 1.0)
3941
always!(ddt(x) - sin(x))
4042
end
4143
function sin2!()
4244
sin!(); sin!();
4345
return nothing
4446
end
45-
dae_sol = solve(DAECProblem(sin2!, (1, 2) .=> 1.), IDA())
46-
ode_sol = solve(ODECProblem(sin2!, (1, 2) .=> 1.), Rodas5(autodiff=false))
47+
dae_sol = solve(DAECProblem(sin2!), DFBDF(autodiff=false))
48+
ode_sol = solve(ODECProblem(sin2!), Rodas5(autodiff=false))
4749
for (sol, i) in Iterators.product((dae_sol, ode_sol), 1:2)
4850
@test all(map((x,y)->isapprox(x[], y, atol=1e-2), sol[i, :], 2*acot.(exp.(-sol.t).*cot(1/2))))
4951
end
@@ -52,10 +54,11 @@ end
5254
@noinline sink!(x, v) = always!(x - v)
5355
function sinsink!()
5456
x = continuous()
57+
initial!(x - 1.0)
5558
sink!(ddt(x), sin(x))
5659
end
57-
dae_sol = solve(DAECProblem(sinsink!, (1,) .=> 1.), IDA())
58-
ode_sol = solve(ODECProblem(sinsink!, (1,) .=> 1.), Rodas5(autodiff=false))
60+
dae_sol = solve(DAECProblem(sinsink!), DFBDF(autodiff=false))
61+
ode_sol = solve(ODECProblem(sinsink!), Rodas5(autodiff=false))
5962
for sol in (dae_sol, ode_sol)
6063
@test all(map((x,y)->isapprox(x[], y, atol=1e-2), sol[1, :], 2*acot.(exp.(-sol.t).*cot(1/2))))
6164
end
@@ -66,7 +69,7 @@ function sinsink2!()
6669
x = continuous()
6770
sink2!(x, sin(x))
6871
end
69-
dae_sol = solve(DAECProblem(sinsink2!, (1,) .=> 1.), IDA())
72+
dae_sol = solve(DAECProblem(sinsink2!, (1,) .=> 1.), DFBDF(autodiff=false))
7073
ode_sol = solve(ODECProblem(sinsink2!, (1,) .=> 1.), Rodas5(autodiff=false))
7174
for sol in (dae_sol, ode_sol)
7275
@test all(map((x,y)->isapprox(x[], y, atol=1e-2), sol[1, :], 2*acot.(exp.(-sol.t).*cot(1/2))))
@@ -91,7 +94,7 @@ function (this::sicm2!)()
9194
sicm!(this.a)(); sicm!(this.b)();
9295
return nothing
9396
end
94-
dae_sol = solve(DAECProblem(sicm2!(1., 1.), (1, 2) .=> 1.), IDA())
97+
dae_sol = solve(DAECProblem(sicm2!(1., 1.), (1, 2) .=> 1.), DFBDF(autodiff=false))
9598
ode_sol = solve(ODECProblem(sicm2!(1., 1.), (1, 2) .=> 1.), Rodas5(autodiff=false))
9699
for (sol, i) in Iterators.product((dae_sol, ode_sol), 1:2)
97100
@test all(map((x,y)->isapprox(x[], y, atol=1e-2), sol[i, :], 1. .+ sol.t))
@@ -104,6 +107,7 @@ end
104107

105108
@noinline function (this::nlsicm!)()
106109
x = continuous()
110+
initial!(x - 1.0)
107111
always!(ddt(x) - sin(this.arg))
108112
end
109113

@@ -116,8 +120,8 @@ function (this::nlsicm2!)()
116120
nlsicm!(this.a)(); nlsicm!(this.b)();
117121
return nothing
118122
end
119-
dae_sol = solve(DAECProblem(nlsicm2!(1., 1.), (1, 2) .=> 1.), IDA())
120-
ode_sol = solve(ODECProblem(nlsicm2!(1., 1.), (1, 2) .=> 1.), Rodas5(autodiff=false))
123+
dae_sol = solve(DAECProblem(nlsicm2!(1., 1.)), DFBDF(autodiff=false))
124+
ode_sol = solve(ODECProblem(nlsicm2!(1., 1.)), Rodas5(autodiff=false))
121125
for (sol, i) in Iterators.product((dae_sol, ode_sol), 1:2)
122126
@test all(map((x,y)->isapprox(x[], y, atol=1e-2), sol[i, :], 1. .+ sin(1.)*sol.t))
123127
end

0 commit comments

Comments
 (0)