Hello all. I am trying to discretize and solve the following PDE using DiffEqOperators.jl
\frac{\partial C}{\partial t} = D\nabla^2 C - \vec{v} \cdot \nabla C + R
for solving non-steady convection diffusion of a generic chemical species with a generic velocity profile v_x(y).
So far I have been able to generate and solve the problem using scalar values for the velocity field in each direction in both 2D and 3D using the following code:
# Loading Dependencies
using DifferentialEquations
using DiffEqOperators
using Plots
# Physical Constants
α = 0.05 # Diffusion Coefficient
v_x = 0.5; # Advection speed in x [m/s]
v_y = 0.25; # Advection speed in y [m/s]
γ=0.05 # Source Term
# Discretization Parameters
s = x, y = (-5:0.2:5, -5:0.2:5)
dx = dy = x[2] - x[1]
t0 = 0.0
t1 = 20.0
# Initial Distribution
u_low = convert(Int64, round(2 / 10 * length(x)))
u_high = convert(Int64, round(4 / 10 * length(x)))
u0 = fill(0.0, (length(x), length(y)));
u0[u_low:u_high,u_low:u_high] .= 5.0; # a small square in the middle of the domain
# Generate Coefficient Matrices
laplacianx = CenteredDifference{1}(2, 4, dx, length(x))
laplaciany = CenteredDifference{2}(2, 4, dy, length(y))
Δ = laplacianx + laplaciany
divx = CenteredDifference{1}(1, 4, dx, length(x))
divy = CenteredDifference{2}(1, 4, dy, length(y))
# Generate Boundary Conditions
Qx, Qy = Neumann0BC(Float64, (dx, dy), 4, (length(x), length(y)))
Q = compose(Qx, Qy)
# Define matrix system and solve
function f!(du, u, p, t)
du .= α .* (Δ * Q * u) + (((-v_x * divx) + (-v_y * divy)) * Q * u) + γ .* u
### #Diffusion #Advection in x #Advection in y #Source
end
prob = ODEProblem(f!, u0, (t0, t1))
alg = Tsit5()
sol2D = solve(prob, alg)
My question is whether or not it is possible to use a velocity profile for the v_x, v_y, v_w terms and some recommendations on how to go about it. Likewise I was wondering if there is a more compact form of the \vec{v} \cdot \nabla C expression that can be expressed using DiffEqOperators.jl. Thanks!