Solving the 10-dimensional Fisher-KPP equation with DeepSplitting
Consider the Fisher-KPP equation with non-local competition
\[\partial_t u = u (1 - \int_\Omega u(t,y)dy) + \frac{1}{2}\sigma^2\Delta_xu \tag{1}\]
where $\Omega = [-1/2, 1/2]^d$, and let's assume Neumann Boundary condition on $\Omega$.
Let's solve Eq. (1) with the DeepSplitting
solver.
using HighDimPDE, Flux
## Definition of the problem
d = 10 # dimension of the problem
tspan = (0.0, 0.5) # time horizon
x0 = fill(0.0f0, d) # initial point
g(x) = exp.(-sum(x .^ 2, dims = 1)) # initial condition
μ(x, p, t) = 0.0f0 # advection coefficients
σ(x, p, t) = 0.1f0 # diffusion coefficients
x0_sample = UniformSampling(fill(-5.0f-1, d), fill(5.0f-1, d))
f(x, y, v_x, v_y, ∇v_x, ∇v_y, p, t) = v_x .* (1.0f0 .- v_y)
f (generic function with 1 method)
Since this is a non-local equation, we will define our problem as a PIDEProblem
prob = PIDEProblem(μ, σ, x0, tspan, g, f; x0_sample = x0_sample)
PIDEProblem with uType Vector{Float32} and tType Float64. In-place: false
timespan: (0.0, 0.5)
u0: 1-element Vector{Float32}:
1.0
## Definition of the neural network to use
hls = d + 50 #hidden layer size
nn = Flux.Chain(Dense(d, hls, tanh),
Dense(hls, hls, tanh),
Dense(hls, 1)) # neural network used by the scheme
opt = ADAM(1e-2)
## Definition of the algorithm
alg = DeepSplitting(nn,
opt = opt,
mc_sample = x0_sample)
sol = solve(prob,
alg,
0.1,
verbose = true,
abstol = 2e-3,
maxiters = 1000,
batch_size = 1000)
PIDESolution
timespan: 0.0:0.09999988228082657:0.49999941140413284
u(x,t): Float32[1.0, 0.88800585, 0.92086375, 0.968639, 1.0079371, 1.0508362]
Solving on the GPU
DeepSplitting
can run on the GPU for (much) improved performance. To do so, just set use_cuda = true
.
sol = solve(prob,
alg,
0.1,
verbose = true,
abstol = 2e-3,
maxiters = 1000,
batch_size = 1000,
use_cuda = true)
Solving local Allen Cahn Equation with Neumann BC
using HighDimPDE, Flux, StochasticDiffEq
batch_size = 1000
train_steps = 1000
tspan = (0.0f0, 5.0f-1)
dt = 5.0f-2 # time step
μ(x, p, t) = 0.0f0 # advection coefficients
σ(x, p, t) = 1.0f0 # diffusion coefficients
d = 10
∂ = fill(5.0f-1, d)
hls = d + 50 #hidden layer size
nn = Flux.Chain(Dense(d, hls, relu),
Dense(hls, hls, relu),
Dense(hls, 1)) # Neural network used by the scheme
opt = Flux.Optimise.Adam(1e-2) #optimiser
alg = DeepSplitting(nn, opt = opt)
X0 = fill(0.0f0, d) # initial point
g(X) = exp.(-0.25f0 * sum(X .^ 2, dims = 1)) # initial condition
a(u) = u - u^3
f(y, v_y, ∇v_y, p, t) = a.(v_y) # nonlocal nonlinear function
f (generic function with 1 method)
Since we are dealing with a local problem here, i.e. no integration term used, we use ParabolicPDEProblem
to define the problem.
# defining the problem
prob = ParabolicPDEProblem(μ, σ, X0, tspan; g, f, neumann_bc = [-∂, ∂])
ParabolicPDEProblem with uType Vector{Float32} and tType Float32. In-place: false
timespan: (0.0f0, 0.5f0)
u0: 1-element Vector{Float32}:
1.0
# solving
@time sol = solve(prob,
alg,
dt,
verbose = false,
abstol = 1e-5,
use_cuda = false,
maxiters = train_steps,
batch_size = batch_size)
PIDESolution
timespan: 0.0f0:0.04999988f0:0.4999988f0
u(x,t): Float32[1.0, 0.8913597, 0.857315, 0.85404426, 0.8615301, 0.8712508, 0.8812882, 0.8907581, 0.8997964, 0.9083965, 0.9162859]