CFD Online Discussion Forums

CFD Online Discussion Forums (http://www.cfd-online.com/Forums/)
-   OpenFOAM (http://www.cfd-online.com/Forums/openfoam/)
-   -   H2 injection temperature as IC under janaf limit (modifying janafThermoI.H) (http://www.cfd-online.com/Forums/openfoam/86854-h2-injection-temperature-ic-under-janaf-limit-modifying-janafthermoi-h.html)

Hýr0 April 4, 2011 11:25

H2 injection temperature as IC under janaf limit (modifying janafThermoI.H)
 
Hi everybody,
I'm newby in OpenFOAM and in C++ programming language and I try to simulate combustion air-H2 inside a scramjet combustion chamber. For my thesis I need to set a injection temperature of hydrogen around 133K but it is already out of temperature range. I have calculated coefficients for the lower temperature using Chemkin Fitdata function, but I don't know how to modify OpenFoam to read this new file (i.e therm_lowrange.dat). Looking around the code I found the file where temperature is checked, janafThermoI.H:

template<class equationOfState>
inline void Foam::janafThermo<equationOfState>::checkT(const scalar T) const
{
if (T < Tlow_ || T > Thigh_)
{
FatalErrorIn
(
"janafThermo<equationOfState>::checkT(const scalar T) const"
) << "attempt to use janafThermo<equationOfState>"
" out of temperature range "
<< Tlow_ << " -> " << Thigh_ << "; T = " << T
<< abort(FatalError);
}
}

I would like to bypass this check for example say OpenFoam to read something like that from thermophysicalProperties file:

CHEMKINThermoFile_lowrange "$FOAM_CASE/chemkin/therm_lowrange.dat"

before abort (if doesn't exist). What is the easy way to do it? Do you know if foamChemistryReader can do this?

Thanks for any suggestions!

Luigi

Hýr0 April 11, 2011 18:32

This is my new janafThemoI:
Code:

template<class equationOfState>
inline void Foam::janafThermo<equationOfState>::checkT(scalar T) const
{
    if (T <  Tlow_)
    {
        Info<< "Warning: out of temperature range "
            << Tlow_ << " -> " << Thigh_ << ";  T = " << T << endl;
        T = Tlow_;
        Info<< "Temperature limited at T = " << T << endl;
    }
    if (T > Thigh_)
    {
        Info<< "Warning: out of temperature range "
            << Tlow_ << " -> " << Thigh_ << ";  T = " << T << endl;
        T = Thigh_;
        Info<< "Temperature limited at T = " << T << endl;
    }
    /*if (T <  Tlow_ || T > Thigh_)
    {
        FatalErrorIn
        (
            "janafThermo<equationOfState>::checkT(const scalar T) const"
        )  << "attempt to use janafThermo<equationOfState>"
              " out of temperature range "
            << Tlow_ << " -> " << Thigh_ << ";  T = " << T
            << abort(FatalError);
    }*/
}


template<class equationOfState>
inline const typename Foam::janafThermo<equationOfState>::coeffArray&
Foam::janafThermo<equationOfState>::coeffs
(
    scalar T  // const scalar T
) const
{
    checkT(T);

    if (T < Tcommon_)
    {
        return lowCpCoeffs_;
    }
    else
    {
        return highCpCoeffs_;
    }
}

I also replaced const scalar T with scalar T in line 56 and line 89...but if I run a test case (T is 1204 K in all domain except in one point where T=50K) I see that T field is not updated. Why?

Code:

Solving chemistry
diagonal:  Solving for rho, Initial residual = 0, Final residual = 0, No Iterations 0
DILUPBiCG:  Solving for Ux, Initial residual = 0.126810514, Final residual = 1.17492806e-09, No Iterations 1
DILUPBiCG:  Solving for Uy, Initial residual = 0.0715419851, Final residual = 2.01756428e-08, No Iterations 1
DILUPBiCG:  Solving for Uz, Initial residual = 0.377246649, Final residual = 5.3260308e-09, No Iterations 1
DILUPBiCG:  Solving for H2, Initial residual = 0.0323321349, Final residual = 1.97452836e-08, No Iterations 1
DILUPBiCG:  Solving for O2, Initial residual = 0.0324333194, Final residual = 1.99863629e-08, No Iterations 1
DILUPBiCG:  Solving for H2O, Initial residual = 0, Final residual = 0, No Iterations 0
DILUPBiCG:  Solving for hs, Initial residual = 0.0703365119, Final residual = 3.26754347e-09, No Iterations 1
Warning: out of temperature range 100 -> 5000;  T = 50
Temperature limited at T = 100
Warning: out of temperature range 100 -> 5000;  T = 50
Temperature limited at T = 100
Warning: out of temperature range 100 -> 5000;  T = 50.000762
Temperature limited at T = 100
Warning: out of temperature range 100 -> 5000;  T = 50.000762
Temperature limited at T = 100
Warning: out of temperature range 100 -> 5000;  T = 50
Temperature limited at T = 100
Warning: out of temperature range 100 -> 5000;  T = 50
Temperature limited at T = 100
Warning: out of temperature range 100 -> 5000;  T = 50.0007507
Temperature limited at T = 100
Warning: out of temperature range 100 -> 5000;  T = 50.0007507
Temperature limited at T = 100
T gas min/max  = 50.0007507, 1204.00116

Where the temperature is calculated and written?


All times are GMT -4. The time now is 09:54.