CFD Online Discussion Forums

CFD Online Discussion Forums (http://www.cfd-online.com/Forums/)
-   OpenFOAM Programming & Development (http://www.cfd-online.com/Forums/openfoam-programming-development/)
-   -   Extending OpenFOAM ::: error (http://www.cfd-online.com/Forums/openfoam-programming-development/78773-extending-openfoam-error.html)

balkrishna August 2, 2010 08:18

Extending OpenFOAM ::: error
 
I am writing a solver for simulating mixing of 3 liquids of mass fractions alpha0 , alpha1 and alpha2 .... I have extended the twoLiquidMixing Foam solver to include 3 components mentioned above . The source is compiled ok but on running for a test case .... i get the following error .
Please can anyone suggest how to overcome this :

Reading field alpha0 word::stripInvalid() called for word alpha0 For debug level (= 2) > 1 this is considered fatal

l_r_mcglashan August 3, 2010 05:19

If you post the part of the code where you construct the alpha objects, and the alpha0 file and location, you may get some more help.

balkrishna August 3, 2010 05:25

Thanks for the reply .... I corrected my error .... The problem was with a space between alpha and 0 characters ....

balkrishna August 3, 2010 05:27

however I am facing another problem now .... :
I have tried to extend openfoam's two liquid mixing solver to n liquids where n is a number from the user .... However after a few iterations < 10 I get the following warning
-> FOAM Warning :
From function Time::operator++()
in file db/Time/Time.C at line 681
Increased the timePrecision from 7 to 8 to distinguish between timeNames at time 0.000250075
Time = 0.00025007459

and then the courant number suddenly shoots up to >10^8 ... how should I correct it ....

l_r_mcglashan August 3, 2010 05:32

First things to check:

1) Does this case you're running for 'n' components work with 2 components (i.e. have you compared your new code with the old code when n=2)?

2) Have you tried lowering the time step.

balkrishna August 3, 2010 05:36

Thanks for the reply .... I have tried lowering the time step ... but all this does is prolongs the blow up of the solution .

I am running this code for n=2 to confirm with the twoLiquidMixingFoam Solver ... although the code compiles without errors I get the above error ...

l_r_mcglashan August 3, 2010 05:48

Code compiling doesn't mean it will run correctly! To be honest it could be anything. Just glancing at the solver it strikes me that you may have to come up with a sensible way of solving for turbulence when n>2 (maybe you don't). But the physics is another matter...

It looks like the changes you would have had to make are:

1) PtrList of alphas.
2) Creation of an nPhaseMixture Class or equivalent.
3) Change the calculation of rho/rhoPhi in a few places.
4) Solve n-1 alphaEqns.

balkrishna August 3, 2010 05:56

I will review the physics for nComponents .
Regarding :
1) PtrList of alphas. => I have created suitable pointers in createFields.H

2)Creation of an nPhaseMixture Class or equivalent. => I have added this too .

3)Solve n-1 alpha Eqns => Is it ok to solve n alpha Eqns as long as they have been used carefully. Because for n components the nth is to be calculated by 1-sum(all other comp) .I dont have issues about speed as of now ....

4) Change the calculation of rho/rhoPhi in a few places. => Please can you elaborate on this . rhoPhi is calculated in alphaEqn and used in UEqn . The way the (twoLiquidMixing) solver calculates rhoPhi is

rhoPhi = alpha1Eqn.flux()*(rho1-rho2) + phi*rho2

The way I have done it is :
rhoPhi = rho1*alpha1Eqn.flux() + rho2*alpha2Eqn.flux()

Thanks again for ur help ....

l_r_mcglashan August 3, 2010 06:43

It's difficult to say what could be going wrong. You may have boundedness issues with rhoPhi.

You've made quite a few changes at the same time. When I'm writing new stuff I try to do it incrementally and test it after every change. I usually start with the infrastructure, so in your case sorting out the storage of alphas and the capability to solve more alpha equations. Then I would try changing the calculations of rhoPhi line by line -> often there are subtle numerical reasons for the way they are formulated.

balkrishna August 3, 2010 06:54

Thanks for the advice n help ....

balkrishna August 3, 2010 08:21

The precise error i get is :
Courant Number mean: 2.69878e+06 max: 6.18058e+08
#0 Foam::error::printStack(Foam::Ostream&) in "/home/ifmg/OpenFOAM/OpenFOAM-1.7.0/lib/linuxGccDPOpt/libOpenFOAM.so"
#1 Foam::sigFpe::sigFpeHandler(int) in "/home/ifmg/OpenFOAM/OpenFOAM-1.7.0/lib/linuxGccDPOpt/libOpenFOAM.so"
#2 Uninterpreted:
#3 Foam::Time::adjustDeltaT() in "/home/ifmg/OpenFOAM/OpenFOAM-1.7.0/lib/linuxGccDPOpt/libOpenFOAM.so"
#4 Foam::Time::setDeltaT(double) in "/home/ifmg/OpenFOAM/OpenFOAM-1.7.0/lib/linuxGccDPOpt/libOpenFOAM.so"
#5

#6 __libc_start_main in "/lib/tls/i686/cmov/libc.so.6"
#7

Floating point exception

balkrishna August 9, 2010 03:06

i modified twoLiquidMixingFoam source for n Components as a start I am testing it for 2 components . I get a very weird floating point exception error at the start of the iterations . On tracing the error with Info statements I found out that the program gives a fpe while calculating the kinematic viscosity in the calcNu function . specifically at the following point :
Code:

void nComponentMixture::calcNu()                                                                                                             
{                                                                                                                                           
    nuModel1_->correct();                                                                                                                   
    nuModel2_->correct();                                                                                                                   
                                                                                                                                             
    volScalarField limitedAlpha1                                                                                                             
    (                                                                                                                                       
        "limitedAlpha1",                                                                                                                     
        min(max(alpha1_, scalar(0)), scalar(1))                                                                                             
    );                                                                                                                                       
                                                                                                                                             
    volScalarField limitedAlpha2                                                                                                             
    (                                                                                                                                       
        "limitedAlpha2",                                                                                                                     
        min(max(alpha2_, scalar(0)), scalar(1))                                                                                             
    );                                                                                                                                       
    Info<<alpha1_<<endl<<alpha2_<<endl<<rho1_<<endl<<rho2_<<endl;                                                                           
// Average kinematic viscosity calculated from dynamic viscosity                                                                             
    nu_ = mu()/(limitedAlpha1*rho1_ +limitedAlpha2*rho2_ );                                                                                         
}

Where could the possible error be ?

balkrishna August 9, 2010 03:07

If i however comment the nu_ calculation statement the program runs till convergence ....

l_r_mcglashan August 9, 2010 04:27

Sounds like both your alphas are becoming zero at the same time? Have you checked their values?

balkrishna August 9, 2010 04:36

Yes . This is infact before any iteration is performed . I have checked values of the alpha's , rho's and mu() to be very sure and none of them are zero ...

l_r_mcglashan August 9, 2010 04:51

That's the only reason I can think of. Can you post your output up here?

balkrishna August 9, 2010 04:52

Code:

/*---------------------------------------------------------------------------*\
| =========                |                                                |
| \\      /  F ield        | OpenFOAM: The Open Source CFD Toolbox          |
|  \\    /  O peration    | Version:  1.7.0                                |
|  \\  /    A nd          | Web:      www.OpenFOAM.com                      |
|    \\/    M anipulation  |                                                |
\*---------------------------------------------------------------------------*/
Build  : 1.7.0-21131bcbd876
Exec  : ../balFoam
Date  : Aug 09 2010
Time  : 13:52:07
Host  : ifmg-desktop
PID    : 7157
Case  : /home/ifmg/mySol/balFoam/twoLiquid
nProcs : 1
SigFpe : Enabling floating point exception trapping (FOAM_SIGFPE).

// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
Create time

Create mesh for time = 0

Reading field p

Reading field U

Reading field massFrac1
Reading field massFrac2
Reading/calculating face flux field phi

Selecting incompressible transport model Newtonian
Selecting incompressible transport model Newtonian
#0  Foam::error::printStack(Foam::Ostream&) in "/home/ifmg/OpenFOAM/OpenFOAM-1.7.0/lib/linuxGccDPOpt/libOpenFOAM.so"
#1  Foam::sigFpe::sigFpeHandler(int) in "/home/ifmg/OpenFOAM/OpenFOAM-1.7.0/lib/linuxGccDPOpt/libOpenFOAM.so"
#2  Uninterpreted:
#3  Foam::divide(Foam::Field<double>&, double const&, Foam::UList<double> const&) in "/home/ifmg/OpenFOAM/OpenFOAM-1.7.0/lib/linuxGccDPOpt/libOpenFOAM.so"
#4  Foam::tmp<Foam::GeometricField<double, Foam::fvPatchField, Foam::volMesh> > Foam::operator/<Foam::fvPatchField, Foam::volMesh>(Foam::dimensioned<double> const&, Foam::tmp<Foam::GeometricField<double, Foam::fvPatchField, Foam::volMesh> > const&)
#5 

#6 

#7 

#8  __libc_start_main in "/lib/tls/i686/cmov/libc.so.6"
#9 

Floating point exception


balkrishna August 9, 2010 05:17

@l_r_mcglashan Sir , Would you mind if i did send you my solver entirely as a tar.gz file ?

l_r_mcglashan August 9, 2010 06:19

If you wish, I can take a quick look.

vonboett January 20, 2014 05:14

...although it is probably an old issue now, I want to add something in case somebody faces the same problem and reads through this thread: A typical error is that the phases add up to a higher value than 1 in a cell. Something you don't see because the single phase shares can be between 0 and 1, but the sum can exceed 1 and that is for incompressible flow fatal. Check that the initial field and the boundary values do not lead to alpha1+alpha2+alpha3 >1


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