CFD Online Discussion Forums

CFD Online Discussion Forums (http://www.cfd-online.com/Forums/)
-   OpenFOAM (http://www.cfd-online.com/Forums/openfoam/)
-   -   how to add a new gas (http://www.cfd-online.com/Forums/openfoam/103167-how-add-new-gas.html)

conceptone June 12, 2012 15:15

how to add a new gas
 
hi everyone, I am a new openfoam user. I wonder how to add a gas and how to define its properties in the openfoam. The gas is not defined in openfoam dictionary, so I got to define it by myself. Below is the error message. Thanks your guys' help!


Selecting chemistryReader chemkinReader
[5]
[5]
[5] --> FOAM FATAL ERROR:
[5] C12H26 not found in table. Valid entries:
820
(
CL3SISICL
A2C2HB*
SIF3NH2
...)

adhiraj June 12, 2012 20:51

It seems you are running a solver like reactingFoam, and using CHEMKIN input.
You probably have a species defined in the chem.inp file that is missing in the therm.dat file. Just make sure the two files are compatible, and you should be good to go.

conceptone June 12, 2012 22:22

thanks dude!yep, you are right, I should check the two files.but the question is how can I reach the two files? I mean, in the thermophysicalProperties it states that
CHEMKINFile "$FOAM_CASE/chemkin/chem.inp";

CHEMKINThermoFile "~OpenFOAM/thermoData/therm.dat";
while if I enter "cd $FOAM_CASE/chemkin/chem.inp" or "cd ~OpenFOAM/thermoData/therm.dat" in linux the system errors there is no such variable. Meanwhile, I've already modified the chem.inp and therm.dat files which are included in the chemkin file. But it doesn't work. So what should I do?

adhiraj June 13, 2012 22:47

The tag
Quote:

$FOAM_CASE
refers to the working main directory for the case when you run it. It cannot be resolved by bash otherwise.
For the other one, maybe you do not have a directory with the name.
Just copy both files to a directory (say chemkin under the case directory) and then edit the paths in the constant/thermophysicalProperties file.
For instance, if you have both the chem.inp and therm.dat under chemkin directory, this is what you need:
Quote:

CHEMKINFile "$FOAM_CASE/chemkin/chem.inp";

CHEMKINThermoFile "
$FOAM_CASE/chemkin/therm.dat";
Hope this helps.

conceptone June 13, 2012 23:40

1 Attachment(s)
Quote:

Originally Posted by adhiraj (Post 366370)
The tag refers to the working main directory for the case when you run it. It cannot be resolved by bash otherwise.
For the other one, maybe you do not have a directory with the name.
Just copy both files to a directory (say chemkin under the case directory) and then edit the paths in the constant/thermophysicalProperties file.
For instance, if you have both the chem.inp and therm.dat under chemkin directory, this is what you need:
Hope this helps.

Hi adhiraj,thanks again for your help!
I did do that modification, but later I met a new problem.when the case runs a few steps, it cracks. It stopped at 0.00151s.The error is like below:

Courant Number mean: 3.71158e-05 max: 0.0695979
deltaT = 1.25e-06
Time = 0.001515

Solving cloud sprayCloud

--> Cloud: sprayCloud
Added 6 new parcels

[6] #0 Foam::error:rintStack(Foam::Ostream&) in "/usr/apps1/openfoam-2.1.0/OpenFOAM-2.1.0/platforms/linux64Gcc44DPOpt/lib/libOpenFOAM.so"
[6] #1 Foam::sigFpe::sigHandler(int) in "/usr/apps1/openfoam-2.1.0/OpenFOAM-2.1.0/platforms/linux64Gcc44DPOpt/lib/libOpenFOAM.so"
[6] #2 __restore_rt at sigaction.c:0
[6] #3 __ieee754_exp at interp.c:0
[6] #4 exp in "/lib64/libm.so.6"
[6] #5 Foam::LiquidEvaporation<Foam::ReactingCloud<Foam:: ThermoCloud<Foam::KinematicCloud<Foam::Cloud<Foam: :SprayParcel<Foam::ReactingParcel<Foam::ThermoParc el<Foam::KinematicParcel<Foam:article> > > > > > > > >::calculate(double, int, double, double, double, double, double, double, Foam::Field<double>&) const in "/usr/apps1/openfoam-2.1.0/OpenFOAM-2.1.0/platforms/linux64Gcc44DPOpt/lib/liblagrangianSpray.so"
[6] #6 void Foam::ReactingParcel<Foam::ThermoParcel<Foam::Kine maticParcel<Foam:article> > >::calc<Foam::ReactingParcel<Foam::ThermoParcel< Fo am::KinematicParcel<Foam:article> > >::TrackingData<Foam::SprayCloud<Foam::ReactingC lo ud<Foam::ThermoCloud<Foam::KinematicCloud<Foam::Cl oud<Foam::SprayParcel<Foam::ReactingParcel<Foam::T hermoParcel<Foam::KinematicParcel<Foam:article> > > > > > > > > > >(Foam::ReactingParcel<Foam::ThermoParcel<Foam:: Ki nematicParcel<Foam:article> > >::TrackingData<Foam::SprayCloud<Foam::ReactingC lo ud<Foam::ThermoCloud<Foam::KinematicCloud<Foam::Cl oud<Foam::SprayParcel<Foam::ReactingParcel<Foam::T hermoParcel<Foam::KinematicParcel<Foam:article> > > > > > > > > >&, double, int) in "/usr/apps1/openfoam-2.1.0/OpenFOAM-2.1.0/platforms/linux64Gcc44DPOpt/bin/sprayFoam"

......

what's the problem here? I guess it should be caused by particle or parcel parameters set in spraycloudProperties file, so I attached it. It can be open by word.
Thanks !

adhiraj June 15, 2012 04:03

Seems like floating point exception; I'd check the case set up, and numerical parameters for the case.
I am not familiar with the spray models and stuff, so unfortunately I cannot help with that.

mturcios777 June 15, 2012 12:37

Debugging the spray class can be quite painful since everything is templated to allow a completely runtime selectable spray model. I would recommend running the debug version so that you can find the line number of where things go wrong.

Just from the surface, it appears that the exponential function in the math library is having problems. Maybe the argument is far too large (or small). What is happening with your temperature and pressure at this point; judging from the time of the error and your dictionary the spray must already be evolving?

conceptone June 15, 2012 12:49

Yes, you're right, it's the floating point error. I forgot to copy this message.

But still thank man!

conceptone June 16, 2012 16:46

Thanks your help man! I'm gona try debug version. But what does "the spray must already be evolving?" mean at last? Sorry I didn't get you..

conceptone June 16, 2012 17:26

Oh by the way is it true that if I want to run the debug version the openfoam should be installed on my own computer? I mean my openfoam is installed on the service computer, so I can't modify the bashrc file.

wyldckat June 16, 2012 17:41

Quote:

Originally Posted by conceptone (Post 366825)
Oh by the way is it true that if I want to run the debug version the openfoam should be installed on my own computer? I mean my openfoam is installed on the service computer, so I can't modify the bashrc file.

Already answered here: http://www.cfd-online.com/Forums/ope...tml#post366828 - post #5 :p

conceptone June 21, 2012 12:24

Hi man, I have checked with debug version. I believe it's caused by the NSRDSfunction. Can you tell me the meaning of a,b,c,d,e,f in the function? Thanks. Below is the error message by debug version.

[6] #0 Foam::error:rintStack(Foam::Ostream&) at /usr/apps1/openfoam-2.1.1/OpenFOAM-2.1.1/src/OSspecific/POSIX/printStack.C:201
[6] #1 Foam::sigFpe::sigHandler(int) at /usr/apps1/openfoam-2.1.1/OpenFOAM-2.1.1/src/OSspecific/POSIX/signals/sigFpe.C:117
[6] #2 __restore_rt at sigaction.c:0
[6] #3 __ieee754_exp at interp.c:0
[6] #4 exp in "/lib64/libm.so.6"
[6] #5 Foam::exp(double) at /usr/apps1/openfoam-2.1.1/OpenFOAM-2.1.1/src/OpenFOAM/lnInclude/Scalar.H:260
[6] #6 Foam::NSRDSfunc1::f(double, double) const at /usr/apps1/openfoam-2.1.1/OpenFOAM-2.1.1/src/thermophysicalModels/thermophysicalFunctions/lnInclude/NSRDSfunc1.H:108
[6] #7 Foam::C12H26:v(double, double) const at /usr/apps1/openfoam-2.1.1/OpenFOAM-2.1.1/src/thermophysicalModels/properties/liquidProperties/C12H26/C12H26I.H:34
[6] #8 Foam::LiquidEvaporation<Foam::ReactingCloud<Foam:: ThermoCloud<Foam::KinematicCloud<Foam::Cloud<Foam: :SprayParcel<Foam::ReactingParcel<Foam::ThermoParc el<Foam::KinematicParcel<Foam:article> > > > > > > > >::calculate(double, int, double, double, double, double, double, double, double, double, Foam::Field<double> const&, Foam::Field<double>&) const at /usr/apps1/openfoam-2.1.1/OpenFOAM-2.1.1/src/lagrangian/intermediate/lnInclude/LiquidEvaporation.C:172
[6] #9 void Foam::ReactingParcel<Foam::ThermoParcel<Foam::Kine maticParcel<Foam:article> > >::calcPhaseChange<Foam::ReactingParcel<Foam::Th er moParcel<Foam::KinematicParcel<Foam:article> > >::TrackingData<Foam::SprayCloud<Foam::ReactingC lo ud<Foam::ThermoCloud<Foam::KinematicCloud<Foam::Cl oud<Foam::SprayParcel<Foam::ReactingParcel<Foam::T hermoParcel<Foam::KinematicParcel<Foam:article> > > > > > > > > > >(Foam::ReactingParcel<Foam::ThermoParcel<Foam:: Ki nematicParcel<Foam:article> > >::TrackingData<Foam::SprayCloud<Foam::ReactingC lo ud<Foam::ThermoCloud<Foam::KinematicCloud<Foam::Cl oud<Foam::SprayParcel<Foam::ReactingParcel<Foam::T hermoParcel<Foam::KinematicParcel<Foam:article> > > > > > > > > >&, double, int, double, double, double, double, double, double, double, int, double, Foam::Field<double> const&, Foam::Field<double>&, double&, double&, double&, Foam::Field<double>&) at /usr/apps1/openfoam-2.1.1/OpenFOAM-2.1.1/src/lagrangian/intermediate/lnInclude/ReactingParcel.C:517
...
[pn1:29034] [21] sprayFoam [0x472099]
[pn1:29034] *** End of error message ***
--------------------------------------------------------------------------
mpiexec noticed that process rank 6 with PID 29034 on node pn1 exited on signal 8 (Floating point exception).
------------------------------------------

mturcios777 June 21, 2012 12:40

The NSRDS function are mathematical fomulas that are frequently used when calculating material properties. You can find what the form of the function is by src/thermophysicalModels/thermophysicalFunctions/ NSRDSfunctions/NSRDSfunc1/NSRDSfunc1.H.

This tells you where the code is crashing, but I'm sure the problem is with the values you are passing to the NSRDS function. Look at the code in src/thermophysicalModels/properties/liquidProperties/C12H26, and look at what scalars are being passed to calculate the vapour pressure (pressure, temperature and the constant coefficients of the NSRDS function). One of these is causing the call to exp() to fail, which usually means there is something wrong with your case setup or boundary conditions that your pressure or temperature manages to get in that range.

When I mentioned spray evolution, I meant that your spray had already been injecting parcels into the domain for a few timesteps before the crash. In the solver code, you'll see the function that causes the spray to be calculated is called parcels.evolve().

conceptone June 21, 2012 16:47

Thanks at first.
I checked with the error message and found the bug should be caused by pv(p,T) function and NSRDS function1. The NSRDS function1, which returns the value exp(a_ + b_/T + c_*log(T) + d_*pow(T, e_)) with the coefficients pv_(137.47, -11976.0, -16.698, 8.0906e-06, 2.0), was calculated by myself and the value is 1235.9759. So I didn't see any problem here. But I am not sure about the T in the function. Should it be the fuel initial temperature or ambient temperature? In the pv(p,T) function, the vapour pressure looks to be calculated by pressure and temperature, are they fuel's values or ambient values? Thanks

mturcios777 June 21, 2012 16:51

I think its the ambient temperature, as we want to know what the vapour pressure should be to determine how much to evaporate (if call to pv happens through the liquidEvaporation model).

conceptone June 21, 2012 17:12

Then I really can't find where's wrong. The ambient temperature is 900k and pressure is 6MPa,which is set as follows:

FoamFile
{
version 2.0;
format ascii;
class volScalarField;
object p;
}
// ************************************************** *********************** //

dimensions [ 1 -1 -2 0 0 0 0 ];

internalField uniform 6e+06;

boundaryField
{
walls
{
type zeroGradient;
}
}


FoamFile
{
version 2.0;
format ascii;
class volScalarField;
object T;
}
// ************************************************** *********************** //

dimensions [ 0 0 0 1 0 0 0 ];

internalField uniform 900;

boundaryField
{
walls
{
type zeroGradient;
}
}

mturcios777 June 21, 2012 17:16

Your initial internal fields seem reasonable (though why are your walls zero gradient), but you should be looking at the pressure and temperature right before you crash (try writing every timestep for 10 timesteps before you crash).

conceptone June 21, 2012 17:50

If using the temperature ambient, the NSRDS fuction1 value should be 27517468.395187, it seems quite large. Previously I used the fuel temperature so the value is much smaller. But I don't think it has sth. to do with the floating point error.

By the way, how can I find the calculated pressure and temperature data? I mean in every time sub-file the results are binary files

mturcios777 June 21, 2012 18:01

You can post-process the results to find the values. Or switch to write ASCII to have the actual numbers output. This results in bigger files, but for debugging its quite useful.

Write out the last few timesteps before the crash and have a look. Exp usually only returns an error if the argument is out of bounds/wrong type/etc. There is a log(T), pow(T,e) and 1/T inside the exponential, which are the first culprits with this kind of thing. If your temperature becomes very small (or even <= 0) you could end up with problems here.

conceptone June 21, 2012 18:08

OK, I got you. Yes, if T is too small then floating point error occurs. But isn't T the ambient temperature? Then it should be a constant. I mean which file is calculating the temperature? And is the input of the calculation the initial ambient temperature?
Thanks


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