CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   OpenFOAM Running, Solving & CFD (https://www.cfd-online.com/Forums/openfoam-solving/)
-   -   simultaneously solve number of diffusion equations (https://www.cfd-online.com/Forums/openfoam-solving/140929-simultaneously-solve-number-diffusion-equations.html)

Shakil Masum August 26, 2014 08:21

simultaneously solve number of diffusion equations
 
1 Attachment(s)
Hi,

I want to solve these equations using OpenFOAM. The diffusion equations are:

dC0/dt = D1 d2/dx2 C0
dC1/dt = D1 d2/dx2 C1 + D2 d2/dx2 C0 (please check the attachment, I have typed them properly in the attachment).

I can solve the equations using Laplacian Foam individually. But, I want to solve both equations simultaneously, I mean in every time steps. The problem is the second equation needs the value of C0 (from first equation) in every time step. What changes are required in laplacianFoam.C and also in the '0', 'constant' and 'system' folders? It will be much appreciated.

thanks
shakil

al_pr August 27, 2014 06:04

You could try to define your concentrations C1 and C0 as a vector and solve one PDE system instead of two separate PDEs.

That means a volVectorfield instead of a volScalarField in your createFields.H.

Best regards,
Al

Shakil Masum August 27, 2014 08:59

simultaneously solve number of diffusion equations
 
Thanks for your reply al_pr.

But I am worried that you cannot consider C0 and C1 as vectors. These are concentrations which are scalars and direction independent.

Henning86 August 27, 2014 09:45

you could formulate it is explicit.

Equations.
dC0/dt = D1 d2/dx2 C0
dC1/dt = D1 d2/dx2 C1 + D2 d2/dx2 C0 (please check the attachment, I have typed them properly in the attachment).

in OpenFOAM:

C0Eqn
{
fvm::ddt(C0) == fvm::laplacian(D1,C0)
}
C1Eqn
{
fvm::ddt(C1) == fvm::laplacian(D1,C1) +fvc::laplacian(D2,C0)
}

Shakil Masum August 27, 2014 13:07

Dear Henning86,

Thanks a lot. I think this is a brilliant idea.

I believe it will also solve the the problem of solving two equations simultaneously in every time step with the updated value of C0 to calculate C1. Am I right to interpret in this way?

Thanks again

Henning86 August 29, 2014 05:02

yes you are right.


As C1Eqn has an explicit term you are limited by the time step.


All times are GMT -4. The time now is 16:43.