FFT PDE solvers in Julia language.
WARNING: This package is under development!!!
]add PhysicalFDM
or
using Pkg; Pkg.add("PhysicalFDM")
or
using Pkg; Pkg.add("https://github.com/JuliaAstroSim/PhysicalFDM.jl")
To test the Package:
]test PhysicalFDM
This package is extracted from AstroNbodySim.jl. You may find more advanced examples there.
You can also reference the usage of finite differencing solver PhysicalFDM.jl.
Feature | PhysicalFDM.jl |
PhysicalFFT.jl |
---|---|---|
1D Poisson | √ | √ |
2D Poisson | √ | √ |
3D Poisson | √ | √ |
Periodic BCs | √ | √ |
Dirichlet BCs | √ | √ |
Vacuum BCs | √ | × |
GPU | √ | √ |
The main disadvantage of PhysicalFDM.jl
is that the computational complexity (the matrix size) scales with d
is the dimension of the problem.
Consequently, for meshes
PhysicalFFT.jl
supports resolution of PhysicalFFT.jl
.
Nevertheless, the errors from periodic boundary conditions are tolerable if the simulation box is sufficiently large compared to the system's length scale.
using PhysicalFFT
using PhysicalFFT.PhysicalMeshes
using PhysicalMeshes.PhysicalParticles
sol(p::PVector) = sin(2*pi*p.x) * sin(2*pi*p.y) * sin(2*pi*p.z) + sin(32*pi*p.x) * sin(32*pi*p.y) * sin(2*pi*p.z) / 256
init_rho(p::PVector) = -12 * pi * pi * sin(2*pi*p.x) * sin(2*pi*p.y) * sin(2*pi*p.z) - 12 * pi * pi * sin(32*pi*p.x) * sin(32*pi*p.y) * sin(32*pi*p.z)
function test_fft3D(Nx, boundary=Periodic())
m = MeshCartesianStatic(;
xMin = 0.0,
yMin = 0.0,
zMin = 0.0,
xMax = 1.0,
yMax = 1.0,
zMax = 1.0,
Nx = Nx - 1,
Ny = Nx - 1,
Nz = Nx - 1,
NG = 0,
dim = 3,
boundary,
)
m.rho .= init_rho.(m.pos)
fft_poisson!(m, m.rho, m.config.boundary)
s = sol.(m.pos)
r = m.phi .- s
return L2norm(r)
end
test_fft3D(8, Periodic())
- Vacuum boundary conditions for isolated system
- Test GPU
- FFT spectral solver for Schrödinger-Poisson equation (SPE)
- Basic data structure: PhysicalParticles.jl
- File I/O: AstroIO.jl
- Initial Condition: AstroIC.jl
- Parallelism: ParallelOperations.jl
- Trees: PhysicalTrees.jl
- Meshes: PhysicalMeshes.jl
- Finite differencing solver PhysicalFDM.jl
- FFT solver PhysicalFFT.jl
- Plotting: AstroPlot.jl
- Simulation: AstroNbodySim.jl