simulkade / FVTool

Finite volume toolbox for Matlab/Octave
http://fvt.simulkade.com
BSD 2-Clause "Simplified" License
99 stars 56 forks source link

Explicit integration transport equation 1D #9

Closed Whatsoever closed 8 years ago

Whatsoever commented 8 years ago

Dear Dr. Eftekhari, I have another question which is probably kind of silly, although it could be quite helpful to me. If I want to solve a classical transport advection equation (without sources), I could end up with the following discrete system:

E*(C_n1 -C_n) / DT = L*( (1-thetha)*Cn_1+ (thetha)*C_n) + q

where E is a diagonal matrix with the values of the porosity C_n1 is the vector of dependent variable at time n+1 C_n is the vector of dependent variable at time n Dt is the time step L is a (probably tridiagonal matrix) matrix related to the spatial discretization for advection and diffusion. thetha is a factor from 1 to 0, when 1 forward euler and when 0 implicit euler. q is a vector of boundary conditions

In the propose discretization the spatial discretization order is not clear but the temporal is obviously first order (although if thetha is 1/2 it will be second order). I would like to work with a time explicit scheme, namely forward euler and thetha 1. First, for a 1D problem

In the tutorial folder, most of the problems in 1D are solved by an implicit approach, except (I think) ' diffusiontutorialExplicit .m'. Where the solution is given by the line:

% step 1: calculate divergence term RHS = divergenceTerm(Dave._gradientTerm(c_old)); % step 2: calculate the new value for internal cells c_old_int=internalCells(c_old); c_val_int = dt_excludeGhostRHS(meshstruct, RHS+constantSourceTerm(c_old))+c_old_int(:);

I have tried to add advection with the following modification:

% step 1: calculate divergence term RHSd = divergenceTerm(Dave._gradientTerm(c_old)); RHSv = divergenceTerm(u._arithmeticMean(c_old)); % step 2: calculate the new value for internal cells c_old_int=internalCells(c_old); c_val_int = subdt*excludeGhostRHS(m, -RHSv+RHSd+constantSourceTerm(c_old))+c_old_int(:);

Although the results are not satisfactory, I wonder if it is because the time step is big, the implementation that I use is wrong or maybe something to do with boundary conditions? Which ways there are to use a simple forward euler once the spatial discretization has been done with FVT tool?

Thanks again

Best, Daniel

simulkade commented 8 years ago

Hi Daniel,

At the beginning, I designed FVTool to solve PDE's with implicit methods. Unfortunately, this design is not convenient when you want to use an explicit integration. Choose a time step using the CFL condition: https://en.wikipedia.org/wiki/Courant%E2%80%93Friedrichs%E2%80%93Lewy_condition

I keep this issue open to find a better way of implementing Explicit methods. Most probably, I will write a function called phi_new=solveExplicitPDE(m, M_transient, RHS, BC). I really have to spend some time on it.

Whatsoever commented 8 years ago

ok. thanks again.

simulkade commented 8 years ago

I wrote an explicit solver. Please find an example here: https://github.com/simulkade/FVTool/blob/master/Examples/Tutorial/diffusiontutorialExplicit_new.m