] add https://github.com/simulkade/JFVM.jl
] add https://github.com/simulkade/JFVMvis.jl
You can solve the following PDE (or a subset of it):
with the following boundary conditions:
Believe it or not, the above equations describe the majority of the transport phenomena in chemical and petroleum engineering and similar fields.
This code is a Matlabesque implementation of my Matlab finite volume tool. The code is not in its most beautiful form, but it works if you believe my words. Please remember that the code is written by a chemical/petroleum engineer. Petroleum engineers are known for being simple-minded folks and chemical engineers have only one rule: "any answer is better than no answer". You can expect to easily discretize a linear transient advection-diffusion PDE into the matrix of coefficients and RHS vectors. Domain shape is limited to rectangles, circles (or a section of a circle), cylinders, and soon spheres. The mesh can be uniform or nonuniform:
You can have the following boundary conditions or a combination of them on each boundary:
It is relatively easy to use the code to solve a system of coupled linear PDE's and not too difficult to solve nonlinear PDE's.
You need to have matplotlib (only for visualization)
In Ubuntu-based systems, try
sudo apt-get install python-matplotlib
Then install JFVM
by the following commands:
] add https://github.com/simulkade/JFVM.jl
Julia
and type
] add https://github.com/simulkade/JFVM.jl
anaconda command prompt
(as administrator) and install matplotlib
by
conda install matplotlib
Please let me know if it does not work on your windows machines.
I have written a short tutorial, which will be extended gradually.
Copy and paste the following code to solve a transient diffusion equation:
using JFVM, JFVMvis
Nx = 10
Lx = 1.0
m = createMesh1D(Nx, Lx)
BC = createBC(m)
BC.left.a[:].=BC.right.a[:].=0.0
BC.left.b[:].=BC.right.b[:].=1.0
BC.left.c[:].=1.0
BC.right.c[:].=0.0
c_init = 0.0 # initial value of the variable
c_old = createCellVariable(m, 0.0, BC)
D_val = 1.0 # value of the diffusion coefficient
D_cell = createCellVariable(m, D_val) # assigned to cells
# Harmonic average
D_face = harmonicMean(D_cell)
N_steps = 20 # number of time steps
dt= sqrt(Lx^2/D_val)/N_steps # time step
M_diff = diffusionTerm(D_face) # matrix of coefficient for diffusion term
(M_bc, RHS_bc)=boundaryConditionTerm(BC) # matrix of coefficient and RHS for the BC
for i =1:5
(M_t, RHS_t)=transientTerm(c_old, dt, 1.0)
M=M_t-M_diff+M_bc # add all the [sparse] matrices of coefficient
RHS=RHS_bc+RHS_t # add all the RHS's together
c_old = solveLinearPDE(m, M, RHS) # solve the PDE
end
visualizeCells(c_old)
Now change the 4th line to m=createMesh2D(Nx, Nx, Lx, Lx)
and see this:
TO DO
If you have used the code in your research, please cite it as
Ali A Eftekhari. (2017, August 23). JFVM.jl: A Finite Volume Tool for Solving Advection-Diffusion Equations. Zenodo. http://doi.org/10.5281/zenodo.847056
@misc{ali_a_eftekhari_2017_847056, author = {Ali A Eftekhari}, title = {{JFVM.jl: A Finite Volume Tool for Solving Advection-Diffusion Equations}}, month = aug, year = 2017, doi = {10.5281/zenodo.847056}, url = {https://doi.org/10.5281/zenodo.847056} }