Skip to content

Commit 7f2bd9c

Browse files
committed
Add 'balanced' computation to main.jl
1 parent 1475d48 commit 7f2bd9c

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

examples/L96m/main.jl

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,8 @@ print(rpad("(JIT compilation)", RPAD))
5555
elapsed_jit = @elapsed begin
5656
pb_jit = DE.ODEProblem(full, z00, (0.0, T_compile), l96)
5757
DE.solve(pb_jit, SOLVER, reltol = reltol, abstol = abstol, dtmax = dtmax)
58+
pb_jit = DE.ODEProblem(balanced, z00[1:l96.K], (0.0, T_compile), l96)
59+
DE.solve(pb_jit, SOLVER, reltol = reltol, abstol = abstol, dtmax = dtmax)
5860
end
5961
println(" " ^ (LPAD_INTEGER + 6),
6062
"\t\telapsed:", lpad(elapsed_jit, LPAD_FLOAT))
@@ -88,13 +90,31 @@ end
8890
println("steps:", lpad(length(sol_dns.t), LPAD_INTEGER),
8991
"\t\telapsed:", lpad(elapsed_dns, LPAD_FLOAT))
9092

93+
# balanced L96m integration
94+
print(rpad("(balanced)", RPAD))
95+
elapsed_bal = @elapsed begin
96+
pb_bal = DE.ODEProblem(balanced, z0[1:l96.K], (0.0, T), l96)
97+
sol_bal = DE.solve(pb_bal,
98+
SOLVER,
99+
reltol = reltol,
100+
abstol = abstol,
101+
dtmax = dtmax
102+
)
103+
end
104+
println("steps:", lpad(length(sol_bal.t), LPAD_INTEGER),
105+
"\t\telapsed:", lpad(elapsed_bal, LPAD_FLOAT))
106+
91107
################################################################################
92108
# plot section #################################################################
93109
################################################################################
110+
# plot DNS
94111
plt.plot(sol_dns.t, sol_dns[k,:], label = "DNS")
95112
plt.plot(sol_dns.t, sol_dns[l96.K + (k-1)*l96.J + j,:],
96113
lw = 0.6, alpha = 0.6, color="gray")
97114

115+
# plot balanced
116+
plt.plot(sol_bal.t, sol_bal[k,:], label = "balanced")
117+
98118
plt.legend()
99119
plt.show()
100120

0 commit comments

Comments
 (0)