I am no simulation nor numerical expert and am absolutely not familiar with differential Equations.
So I am trying to simulate heat diffusion in a 2D non uniform material on a Cartesian rectilinear mesh (varying Δy and Δx) with the given properties for each cell at l, m coordinates
Ω : surface
ρ : volumic mass
cp : thermal capcity
λ : thermal conductivity
The Right hand side (laplacian?) of the equation is the following
I managed to implement easily a fairly efficient explicit version using with the following kernel
@parallel_indices (ix,iy) function step_explicit_2D_indices!(
H :: AbstractArray, # Temperature at time n
H2 :: AbstractArray, # Temperature at time n+1
if (ix>1 && ix<size(H,1) && iy>1 && iy<size(H,2)) H2[ix,iy] = H[ix,iy] + # Diffusivity (Δt * _ρcpΩ[ix,iy]) * #Right Hand Side/laplacian # X flux ((@avHarm_R(λ) * @d_R(H, ix, iy) * _avΔx[ix]) + (@avHarm_L(λ) * @d_L(H, ix, iy) * _avΔx[ix-1])* Δy[iy-1] + # Y Flux ((@avHarm_T(λ) * @d_T(H, ix, iy) * _avΔy[iy]) + (@avHarm_B(λ) * @d_B(H, ix, iy) * _avΔy[iy-1])* Δx[ix-1])); end return nothing
@avHarm<S> Harmonic average of λ on a given Side @d_<S> Heat difference on a given side _avΔx Arithmetic average of Deltas x/y
However I’d want it to be unconditionally stable given the time step Δt, so i have to solve it Implicitly.
I think (i might be wrong) that direct linear solver (Tn+1 = A \ Tn ) will not work well at all for large domains, I tried this approach, constructing a sparse five banded laplacian matrix (CSC format) ( nx* ny by nx*ny), the backslash Operator solving the linear system, utilizes a single thread.
Is it possible to solve linear systems in parallel?
I did find an example of Implicit iterative solver on the following Github repo of ParallelStencil workshop at Juliacon 2021
But I don’t have the knowledge to adapt it to my situation and fail to gasp the concept of iterative solving.
How could i iteratively solve the heat equation with ParallelStencil given my model?
There is also DifferentialEquations.jl but i fail to understand how to discretize my equation with it and it appears complicated to me. I am not sure if it can do distributed computing.
Could DifferentialEquation.jl be used in my case?
Thanks for any help