You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/src/examples/beeler_reuter.md
+11-11Lines changed: 11 additions & 11 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -348,27 +348,27 @@ u0[90:102, 90:102] .= v1; # a small square in the middle of the domain
348
348
The initial condition is a small square in the middle of the domain.
349
349
350
350
```julia
351
-
using Plots
352
-
heatmap(u0)
351
+
import Plots
352
+
Plots.heatmap(u0)
353
353
```
354
354
355
355
Next, the problem is defined:
356
356
357
357
```julia
358
-
using DifferentialEquations, Sundials
358
+
import DifferentialEquations as DE, Sundials
359
359
360
360
deriv_cpu =BeelerReuterCpu(u0, 1.0);
361
-
prob =ODEProblem(deriv_cpu, u0, (0.0, 50.0));
361
+
prob =DE.ODEProblem(deriv_cpu, u0, (0.0, 50.0));
362
362
```
363
363
364
364
For stiff reaction-diffusion equations, CVODE_BDF from Sundial library is an excellent solver.
365
365
366
366
```julia
367
-
@time sol =solve(prob, CVODE_BDF(linear_solver =:GMRES), saveat =100.0);
367
+
@time sol =DE.solve(prob, Sundials.CVODE_BDF(linear_solver =:GMRES), saveat =100.0);
368
368
```
369
369
370
370
```julia
371
-
heatmap(sol.u[end])
371
+
Plots.heatmap(sol.u[end])
372
372
```
373
373
374
374
## CPU/GPU Beeler-Reuter Solver
@@ -402,7 +402,7 @@ The key to fast CUDA programs is to minimize CPU/GPU memory transfers and global
402
402
We modify ``BeelerReuterCpu`` into ``BeelerReuterGpu`` by defining the state variables as *CuArray*s instead of standard Julia *Array*s. The name of each variable defined on the GPU is prefixed by *d_* for clarity. Note that $\Delta{v}$ is a temporary storage for the Laplacian and stays on the CPU side.
403
403
404
404
```julia
405
-
using CUDA
405
+
import CUDA
406
406
407
407
mutable struct BeelerReuterGpu <:Function
408
408
t::Float64# the last timestep time to calculate Δt
@@ -651,15 +651,15 @@ end
651
651
Ready to test!
652
652
653
653
```julia
654
-
using DifferentialEquations, Sundials
654
+
import DifferentialEquations as DE, Sundials
655
655
656
656
deriv_gpu =BeelerReuterGpu(u0, 1.0);
657
-
prob =ODEProblem(deriv_gpu, u0, (0.0, 50.0));
658
-
@time sol =solve(prob, CVODE_BDF(linear_solver =:GMRES), saveat =100.0);
657
+
prob =DE.ODEProblem(deriv_gpu, u0, (0.0, 50.0));
658
+
@time sol =DE.solve(prob, Sundials.CVODE_BDF(linear_solver =:GMRES), saveat =100.0);
0 commit comments