CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > OpenFOAM > OpenFOAM Programming & Development

Implementing variable Diffusion Coefficient

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   February 27, 2017, 11:52
Default Implementing variable Diffusion Coefficient
  #1
New Member
 
Peter im Hof
Join Date: Nov 2013
Posts: 9
Rep Power: 12
saimat is on a distinguished road
Dear foamers,

I am trying to expand the functionality of twoLiquidMixingFoam so that it can handle Diffusion coefficients which depend on the volume fraction of one of the liquids:

D = D(\alpha_1) = C_1 e^{C_2 \alpha_1},

in which C_1 and C_2 are positive constants. Given this dependency and assuming U=(0,0,0) (neglecting advection) the advection-diffusion-equation looks as follows:

\frac{\partial \alpha_1}{\partial t} = \nabla \cdot \left( D(\alpha_1) \nabla{\alpha_1} \right) = D(\alpha_1) \Delta{\alpha_1} + \nabla{D(\alpha_1)} \cdot \nabla{\alpha_1}

The first term is already implemented in twoLiquidMixingFoam/alphaDiffusionEqn.H, whereas the second one is missing:

Code:
    fvScalarMatrix alpha1Eqn
    (
        fvm::ddt(alpha1)
      - fvc::ddt(alpha1)
      - fvm::laplacian
        (
            volScalarField("Dab", Dab + alphatab*turbulence->nut()),
            alpha1
        )
    );
I tried to implement it in two ways and tried to validate the resulting solver in a simple 1-D configuration initially containing a jump from alpha1=0 to alpha1=1.

The first try was taking the values from the last timestep:
Code:
    Dab = C1*Foam::exp(C2*alpha1);

    volScalarField Sc = fvc::grad(Dab) & fvc::grad(alpha1);

    fvScalarMatrix alpha1Eqn
    (
        fvm::ddt(alpha1)
      - fvc::ddt(alpha1)
      - fvm::laplacian
        (
            volScalarField("Dab", Dab + alphatab*turbulence->nut()),
            alpha1
        )
      ==
        Sc
    );
The results showed a growing total volume fraction of alpha1, meaning a production of phase 1. Additionally, the alpha1 values exceeded 1.

Code:
Starting time loop

...

Courant Number mean: 0 max: 0
Interface Courant Number mean: 0 max: 0
Z number max: 0
deltaT = 0.0119976
Time = 0.0119976

MULES: Solving for alpha1
Phase-1 volume fraction = 0.027  Min(alpha1) = 0  Max(alpha1) = 1
...
ExecutionTime = 0.54 s  ClockTime = 0 s

Courant Number mean: 0 max: 0
Interface Courant Number mean: 0 max: 0
Z number max: 3382.27
deltaT = 7.0944e-06
Time = 0.0120047

MULES: Solving for alpha1
Phase-1 volume fraction = 0.0681488  Min(alpha1) = 0  Max(alpha1) = 15.1184
MULES: Solving for alpha1
...
Both of these effects are dependent on the grid resolution. Nevertheless, even with poor resolution, this non-physical, non-conservative behavour persists.

The second way I tried to implement the additional term was by using Picard's method (https://www.cfd-online.com/Wiki/Sour...inearization):

Code:
    Dab = C1*Foam::exp(C2*alpha1);

    volScalarField Sp = C1*C2*C2*Foam::exp(C2*alpha1) * fvc::grad(alpha1) & fvc::grad(alpha1);
    volScalarField Sc = (C1*C2*Foam::exp(C2*alpha1) * fvc::grad(alpha1) & fvc::grad(alpha1))*(1-C2*alpha1);

    fvScalarMatrix alpha1Eqn
    (
        fvm::ddt(alpha1)
      - fvc::ddt(alpha1)
      - fvm::laplacian
        (
            volScalarField("Dab", Dab + alphatab*turbulence->nut()),
            alpha1
        )
      ==
        fvm::Sp(Sp, alpha1) + Sc
    );
In that case I was not able to get a stable calculation/converging solution. The solver diverged after some timesteps.


Does anyone have an Idea how to improve the implementation? I would be very grateful if anyone could give me a hint how to solve the problem.

Last edited by saimat; February 28, 2017 at 09:02. Reason: use of [math][/math]
saimat is offline   Reply With Quote

Old   March 11, 2017, 03:58
Default
  #2
New Member
 
Peter im Hof
Join Date: Nov 2013
Posts: 9
Rep Power: 12
saimat is on a distinguished road
Quote:
Originally Posted by saimat View Post

\frac{\partial \alpha_1}{\partial t} = \nabla \cdot \left( D(\alpha_1) \nabla{\alpha_1} \right) = D(\alpha_1) \Delta{\alpha_1} + \nabla{D(\alpha_1)} \cdot \nabla{\alpha_1}

The first term is already implemented in twoLiquidMixingFoam/alphaDiffusionEqn.H, whereas the second one is missing:
I figured out, that the implementation in OpenFoam is already suitable for variable coefficients (see Programmers Guide table 2.2 / Chapter 2.4.1). I was just misrouted by the name "laplacian(D,alpha)". Consequently adding an additional term is not necessary.
saimat is offline   Reply With Quote

Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
diffusion Term for add. Variable Zaktatir CFX 9 July 16, 2011 09:51
how to detemine thermal diffusion coefficient in multi-component flow?? oilsok FLUENT 1 April 23, 2011 14:12
variable diffusion coefficient alinematollahi CFX 15 November 16, 2010 07:47
diffusion coefficient in scalar equaton mike Siemens 0 August 30, 2006 11:42


All times are GMT -4. The time now is 17:01.