second upload the fully integrated real gas library

This commit is contained in:
Christian Lucas 2011-02-11 17:45:52 +01:00 committed by Henrik Rusche
parent 0a151e7e5b
commit 6a2c85bd4a
68 changed files with 32599 additions and 0 deletions

View file

@ -149,6 +149,8 @@ void Foam::basicThermo::eBoundaryCorrection(volScalarField& e)
} }
} }
//real Gas Boundary Conditions
Foam::wordList Foam::basicThermo::hRealBoundaryTypes() Foam::wordList Foam::basicThermo::hRealBoundaryTypes()
{ {
const volScalarField::GeometricBoundaryField& tbf = T_.boundaryField(); const volScalarField::GeometricBoundaryField& tbf = T_.boundaryField();

View file

@ -0,0 +1,147 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd |
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 2 of the License, or (at your
option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM; if not, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Modified by
Christian Lucas
Institut für Thermodynamik
Technische Universität Braunschweig
Germany
\*---------------------------------------------------------------------------*/
#include "fixedEnthalpyRealFluids.H"
#include "addToRunTimeSelectionTable.H"
#include "fvPatchFieldMapper.H"
#include "volFields.H"
#include "basicPsiThermo.H"
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::fixedEnthalpyRealFluids::fixedEnthalpyRealFluids
(
const fvPatch& p,
const DimensionedField<scalar, volMesh>& iF
)
:
fixedValueFvPatchScalarField(p, iF)
{}
Foam::fixedEnthalpyRealFluids::fixedEnthalpyRealFluids
(
const fixedEnthalpyRealFluids& ptf,
const fvPatch& p,
const DimensionedField<scalar, volMesh>& iF,
const fvPatchFieldMapper& mapper
)
:
fixedValueFvPatchScalarField(ptf, p, iF, mapper)
{}
Foam::fixedEnthalpyRealFluids::fixedEnthalpyRealFluids
(
const fvPatch& p,
const DimensionedField<scalar, volMesh>& iF,
const dictionary& dict
)
:
fixedValueFvPatchScalarField(p, iF, dict)
{}
Foam::fixedEnthalpyRealFluids::fixedEnthalpyRealFluids
(
const fixedEnthalpyRealFluids& tppsf
)
:
fixedValueFvPatchScalarField(tppsf)
{}
Foam::fixedEnthalpyRealFluids::fixedEnthalpyRealFluids
(
const fixedEnthalpyRealFluids& tppsf,
const DimensionedField<scalar, volMesh>& iF
)
:
fixedValueFvPatchScalarField(tppsf, iF)
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void Foam::fixedEnthalpyRealFluids::updateCoeffs()
{
if (updated())
{
return;
}
const basicPsiThermo& thermo = db().lookupObject<basicPsiThermo>
(
"thermophysicalProperties"
);
const label patchi = patch().index();
fvPatchScalarField& Tw =
const_cast<fvPatchScalarField&>(thermo.T().boundaryField()[patchi]);
Tw.evaluate();
fvPatchScalarField& pw =
const_cast<fvPatchScalarField&>(thermo.p().boundaryField()[patchi]);
pw.evaluate();
if (dimensionedInternalField().name() == "h")
{
operator==(thermo.h(pw,Tw, patchi));
}
else
{
operator==(thermo.hs(Tw, patchi));
}
fixedValueFvPatchScalarField::updateCoeffs();
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
makePatchTypeField
(
fvPatchScalarField,
fixedEnthalpyRealFluids
);
}
// ************************************************************************* //

View file

@ -0,0 +1,146 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd |
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 2 of the License, or (at your
option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM; if not, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Class
Foam::fixedEnthalpyRealFluids
Description
A fixed boundary condition for enthalpy
SourceFiles
fixedEnthalpyRealFluids.C
Modified by
Christian Lucas
Institut für Thermodynamik
Technische Universität Braunschweig
Germany
\*---------------------------------------------------------------------------*/
#ifndef fixedEnthalpyRealFluids_H
#define fixedEnthalpyRealFluids_H
#include "fixedValueFvPatchFields.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
/*---------------------------------------------------------------------------*\
Class fixedEnthalpyRealFluids Declaration
\*---------------------------------------------------------------------------*/
class fixedEnthalpyRealFluids
:
public fixedValueFvPatchScalarField
{
public:
//- Runtime type information
TypeName("fixedEnthalpy");
// Constructors
//- Construct from patch and internal field
fixedEnthalpyRealFluids
(
const fvPatch&,
const DimensionedField<scalar, volMesh>&
);
//- Construct from patch, internal field and dictionary
fixedEnthalpyRealFluids
(
const fvPatch&,
const DimensionedField<scalar, volMesh>&,
const dictionary&
);
//- Construct by mapping given fixedEnthalpyFvPatchScalarField
// onto a new patch
fixedEnthalpyRealFluids
(
const fixedEnthalpyRealFluids&,
const fvPatch&,
const DimensionedField<scalar, volMesh>&,
const fvPatchFieldMapper&
);
//- Construct as copy
fixedEnthalpyRealFluids
(
const fixedEnthalpyRealFluids&
);
//- Construct and return a clone
virtual tmp<fvPatchScalarField> clone() const
{
return tmp<fvPatchScalarField>
(
new fixedEnthalpyRealFluids(*this)
);
}
//- Construct as copy setting internal field reference
fixedEnthalpyRealFluids
(
const fixedEnthalpyRealFluids&,
const DimensionedField<scalar, volMesh>&
);
//- Construct and return a clone setting internal field reference
virtual tmp<fvPatchScalarField> clone
(
const DimensionedField<scalar, volMesh>& iF
) const
{
return tmp<fvPatchScalarField>
(
new fixedEnthalpyRealFluids(*this, iF)
);
}
// Member functions
// Evaluation functions
//- Update the coefficients associated with the patch field
virtual void updateCoeffs();
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View file

@ -0,0 +1,137 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd |
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 2 of the License, or (at your
option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM; if not, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Modified by
Christian Lucas
Institut für Thermodynamik
Technische Universität Braunschweig
Germany
\*---------------------------------------------------------------------------*/
#include "fixedInternalEnergyRealFluids.H"
#include "addToRunTimeSelectionTable.H"
#include "fvPatchFieldMapper.H"
#include "volFields.H"
#include "basicPsiThermo.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
fixedInternalEnergyRealFluids::fixedInternalEnergyRealFluids
(
const fvPatch& p,
const DimensionedField<scalar, volMesh>& iF
)
:
fixedValueFvPatchScalarField(p, iF)
{}
fixedInternalEnergyRealFluids::fixedInternalEnergyRealFluids
(
const fixedInternalEnergyRealFluids& ptf,
const fvPatch& p,
const DimensionedField<scalar, volMesh>& iF,
const fvPatchFieldMapper& mapper
)
:
fixedValueFvPatchScalarField(ptf, p, iF, mapper)
{}
fixedInternalEnergyRealFluids::fixedInternalEnergyRealFluids
(
const fvPatch& p,
const DimensionedField<scalar, volMesh>& iF,
const dictionary& dict
)
:
fixedValueFvPatchScalarField(p, iF, dict)
{}
fixedInternalEnergyRealFluids::fixedInternalEnergyRealFluids
(
const fixedInternalEnergyRealFluids& tppsf
)
:
fixedValueFvPatchScalarField(tppsf)
{}
fixedInternalEnergyRealFluids::fixedInternalEnergyRealFluids
(
const fixedInternalEnergyRealFluids& tppsf,
const DimensionedField<scalar, volMesh>& iF
)
:
fixedValueFvPatchScalarField(tppsf, iF)
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void fixedInternalEnergyRealFluids::updateCoeffs()
{
if (updated())
{
return;
}
const basicPsiThermo& thermo = db().lookupObject<basicPsiThermo>
(
"thermophysicalProperties"
);
const label patchi = patch().index();
fvPatchScalarField& Tw =
const_cast<fvPatchScalarField&>(thermo.T().boundaryField()[patchi]);
Tw.evaluate();
fvPatchScalarField& pw =
const_cast<fvPatchScalarField&>(thermo.p().boundaryField()[patchi]);
pw.evaluate();
operator==(thermo.e(pw,Tw, patchi));
fixedValueFvPatchScalarField::updateCoeffs();
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
makePatchTypeField(fvPatchScalarField, fixedInternalEnergyRealFluids);
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// ************************************************************************* //

View file

@ -0,0 +1,146 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd |
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 2 of the License, or (at your
option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM; if not, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Class
Foam::fixedInternalEnergyRealFluids
Description
A fixed boundary condition for internal energy
SourceFiles
fixedInternalEnergyRealFluids.C
Modified by
Christian Lucas
Institut für Thermodynamik
Technische Universität Braunschweig
Germany
\*---------------------------------------------------------------------------*/
#ifndef fixedInternalEnergyRealFluids_H
#define fixedInternalEnergyRealFluids_H
#include "fixedValueFvPatchFields.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
/*---------------------------------------------------------------------------*\
Class fixedInternalEnergyRealFluids Declaration
\*---------------------------------------------------------------------------*/
class fixedInternalEnergyRealFluids
:
public fixedValueFvPatchScalarField
{
public:
//- Runtime type information
TypeName("fixedInternalEnergy");
// Constructors
//- Construct from patch and internal field
fixedInternalEnergyRealFluids
(
const fvPatch&,
const DimensionedField<scalar, volMesh>&
);
//- Construct from patch, internal field and dictionary
fixedInternalEnergyRealFluids
(
const fvPatch&,
const DimensionedField<scalar, volMesh>&,
const dictionary&
);
//- Construct by mapping given fixedInternalEnergyRealFluids
// onto a new patch
fixedInternalEnergyRealFluids
(
const fixedInternalEnergyRealFluids&,
const fvPatch&,
const DimensionedField<scalar, volMesh>&,
const fvPatchFieldMapper&
);
//- Construct as copy
fixedInternalEnergyRealFluids
(
const fixedInternalEnergyRealFluids&
);
//- Construct and return a clone
virtual tmp<fvPatchScalarField> clone() const
{
return tmp<fvPatchScalarField>
(
new fixedInternalEnergyRealFluids(*this)
);
}
//- Construct as copy setting internal field reference
fixedInternalEnergyRealFluids
(
const fixedInternalEnergyRealFluids&,
const DimensionedField<scalar, volMesh>&
);
//- Construct and return a clone setting internal field reference
virtual tmp<fvPatchScalarField> clone
(
const DimensionedField<scalar, volMesh>& iF
) const
{
return tmp<fvPatchScalarField>
(
new fixedInternalEnergyRealFluids(*this, iF)
);
}
// Member functions
// Evaluation functions
//- Update the coefficients associated with the patch field
virtual void updateCoeffs();
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View file

@ -0,0 +1,154 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright held by original author
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 2 of the License, or (at your
option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM; if not, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Modified by
Christian Lucas
Institut für Thermodynamik
Technische Universität Braunschweig
Germany
\*---------------------------------------------------------------------------*/
#include "gradientEnthalpyRealFluids.H"
#include "addToRunTimeSelectionTable.H"
#include "fvPatchFieldMapper.H"
#include "volFields.H"
#include "basicPsiThermo.H"
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::gradientEnthalpyRealFluids::gradientEnthalpyRealFluids
(
const fvPatch& p,
const DimensionedField<scalar, volMesh>& iF
)
:
fixedGradientFvPatchScalarField(p, iF)
{}
Foam::gradientEnthalpyRealFluids::gradientEnthalpyRealFluids
(
const gradientEnthalpyRealFluids& ptf,
const fvPatch& p,
const DimensionedField<scalar, volMesh>& iF,
const fvPatchFieldMapper& mapper
)
:
fixedGradientFvPatchScalarField(ptf, p, iF, mapper)
{}
Foam::gradientEnthalpyRealFluids::gradientEnthalpyRealFluids
(
const fvPatch& p,
const DimensionedField<scalar, volMesh>& iF,
const dictionary& dict
)
:
fixedGradientFvPatchScalarField(p, iF, dict)
{}
Foam::gradientEnthalpyRealFluids::gradientEnthalpyRealFluids
(
const gradientEnthalpyRealFluids& tppsf
)
:
fixedGradientFvPatchScalarField(tppsf)
{}
Foam::gradientEnthalpyRealFluids::gradientEnthalpyRealFluids
(
const gradientEnthalpyRealFluids& tppsf,
const DimensionedField<scalar, volMesh>& iF
)
:
fixedGradientFvPatchScalarField(tppsf, iF)
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void Foam::gradientEnthalpyRealFluids::updateCoeffs()
{
if (updated())
{
return;
}
const basicPsiThermo& thermo = db().lookupObject<basicPsiThermo>
(
"thermophysicalProperties"
);
const label patchi = patch().index();
fvPatchScalarField& pw =
const_cast<fvPatchScalarField&>(thermo.p().boundaryField()[patchi]);
pw.evaluate();
fvPatchScalarField& Tw =
const_cast<fvPatchScalarField&>(thermo.T().boundaryField()[patchi]);
Tw.evaluate();
if (dimensionedInternalField().name() == "h")
{
gradient() = thermo.Cp(pw,Tw, patchi)*Tw.snGrad()
+ patch().deltaCoeffs()*
(
thermo.h(pw,Tw, patchi)
- thermo.h(pw,Tw, patch().faceCells())
);
}
/* else
{
gradient() = thermo.Cp(Tw, patchi)*Tw.snGrad()
+ patch().deltaCoeffs()*
(
thermo.hs(Tw, patchi)
- thermo.hs(Tw, patch().faceCells())
);
}
*/
fixedGradientFvPatchScalarField::updateCoeffs();
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
makePatchTypeField
(
fvPatchScalarField,
gradientEnthalpyRealFluids
);
}
// ************************************************************************* //

View file

@ -0,0 +1,146 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright held by original author
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 2 of the License, or (at your
option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM; if not, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Class
Foam::gradientEnthalpyRealFluids
Description
Gradient boundary condition for enthalpy
SourceFiles
gradientEnthalpyRealFluids.C
Modified by
Christian Lucas
Institut für Thermodynamik
Technische Universität Braunschweig
Germany
\*---------------------------------------------------------------------------*/
#ifndef gradientEnthalpyRealFluids_H
#define gradientEnthalpyRealFluids_H
#include "fixedGradientFvPatchFields.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
/*---------------------------------------------------------------------------*\
Class gradientEnthalpyRealFluids Declaration
\*---------------------------------------------------------------------------*/
class gradientEnthalpyRealFluids
:
public fixedGradientFvPatchScalarField
{
public:
//- Runtime type information
TypeName("gradientEnthalpy");
// Constructors
//- Construct from patch and internal field
gradientEnthalpyRealFluids
(
const fvPatch&,
const DimensionedField<scalar, volMesh>&
);
//- Construct from patch, internal field and dictionary
gradientEnthalpyRealFluids
(
const fvPatch&,
const DimensionedField<scalar, volMesh>&,
const dictionary&
);
//- Construct by mapping given gradientEnthalpyRealFluids
// onto a new patch
gradientEnthalpyRealFluids
(
const gradientEnthalpyRealFluids&,
const fvPatch&,
const DimensionedField<scalar, volMesh>&,
const fvPatchFieldMapper&
);
//- Construct as copy
gradientEnthalpyRealFluids
(
const gradientEnthalpyRealFluids&
);
//- Construct and return a clone
virtual tmp<fvPatchScalarField> clone() const
{
return tmp<fvPatchScalarField>
(
new gradientEnthalpyRealFluids(*this)
);
}
//- Construct as copy setting internal field reference
gradientEnthalpyRealFluids
(
const gradientEnthalpyRealFluids&,
const DimensionedField<scalar, volMesh>&
);
//- Construct and return a clone setting internal field reference
virtual tmp<fvPatchScalarField> clone
(
const DimensionedField<scalar, volMesh>& iF
) const
{
return tmp<fvPatchScalarField>
(
new gradientEnthalpyRealFluids(*this, iF)
);
}
// Member functions
// Evaluation functions
//- Update the coefficients associated with the patch field
virtual void updateCoeffs();
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View file

@ -0,0 +1,146 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd |
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 2 of the License, or (at your
option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM; if not, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Modified by
Christian Lucas
Institut für Thermodynamik
Technische Universität Braunschweig
Germany
\*---------------------------------------------------------------------------*/
#include "gradientInternalEnergyRealFluids.H"
#include "addToRunTimeSelectionTable.H"
#include "fvPatchFieldMapper.H"
#include "volFields.H"
#include "basicPsiThermo.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
gradientInternalEnergyRealFluids::gradientInternalEnergyRealFluids
(
const fvPatch& p,
const DimensionedField<scalar, volMesh>& iF
)
:
fixedGradientFvPatchScalarField(p, iF)
{}
gradientInternalEnergyRealFluids::gradientInternalEnergyRealFluids
(
const gradientInternalEnergyRealFluids& ptf,
const fvPatch& p,
const DimensionedField<scalar, volMesh>& iF,
const fvPatchFieldMapper& mapper
)
:
fixedGradientFvPatchScalarField(ptf, p, iF, mapper)
{}
gradientInternalEnergyRealFluids::gradientInternalEnergyRealFluids
(
const fvPatch& p,
const DimensionedField<scalar, volMesh>& iF,
const dictionary& dict
)
:
fixedGradientFvPatchScalarField(p, iF, dict)
{}
gradientInternalEnergyRealFluids::gradientInternalEnergyRealFluids
(
const gradientInternalEnergyRealFluids& tppsf
)
:
fixedGradientFvPatchScalarField(tppsf)
{}
gradientInternalEnergyRealFluids::gradientInternalEnergyRealFluids
(
const gradientInternalEnergyRealFluids& tppsf,
const DimensionedField<scalar, volMesh>& iF
)
:
fixedGradientFvPatchScalarField(tppsf, iF)
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void gradientInternalEnergyRealFluids::updateCoeffs()
{
if (updated())
{
return;
}
const basicPsiThermo& thermo = db().lookupObject<basicPsiThermo>
(
"thermophysicalProperties"
);
const label patchi = patch().index();
fvPatchScalarField& Tw =
const_cast<fvPatchScalarField&>(thermo.T().boundaryField()[patchi]);
Tw.evaluate();
fvPatchScalarField& pw =
const_cast<fvPatchScalarField&>(thermo.p().boundaryField()[patchi]);
pw.evaluate();
gradient() = thermo.Cv(pw,Tw, patchi)*Tw.snGrad()
+ patch().deltaCoeffs()*
(
thermo.e(pw,Tw, patchi)
- thermo.e(pw,Tw, patch().faceCells())
);
fixedGradientFvPatchScalarField::updateCoeffs();
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
makePatchTypeField(fvPatchScalarField, gradientInternalEnergyRealFluids);
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// ************************************************************************* //

View file

@ -0,0 +1,146 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd |
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 2 of the License, or (at your
option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM; if not, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Class
Foam::gradientInternalEnergyRealFluids
Description
Gradient boundary condition for internal energy
SourceFiles
gradientInternalEnergyRealFluids.C
Modified by
Christian Lucas
Institut für Thermodynamik
Technische Universität Braunschweig
Germany
\*---------------------------------------------------------------------------*/
#ifndef gradientInternalEnergyRealFluids_H
#define gradientInternalEnergyRealFluids_H
#include "fixedGradientFvPatchFields.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
/*---------------------------------------------------------------------------*\
Class gradientInternalEnergyRealFluids Declaration
\*---------------------------------------------------------------------------*/
class gradientInternalEnergyRealFluids
:
public fixedGradientFvPatchScalarField
{
public:
//- Runtime type information
TypeName("gradientInternalEnergy");
// Constructors
//- Construct from patch and internal field
gradientInternalEnergyRealFluids
(
const fvPatch&,
const DimensionedField<scalar, volMesh>&
);
//- Construct from patch, internal field and dictionary
gradientInternalEnergyRealFluids
(
const fvPatch&,
const DimensionedField<scalar, volMesh>&,
const dictionary&
);
//- Construct by mapping given gradientInternalEnergyRealFluids
// onto a new patch
gradientInternalEnergyRealFluids
(
const gradientInternalEnergyRealFluids&,
const fvPatch&,
const DimensionedField<scalar, volMesh>&,
const fvPatchFieldMapper&
);
//- Construct as copy
gradientInternalEnergyRealFluids
(
const gradientInternalEnergyRealFluids&
);
//- Construct and return a clone
virtual tmp<fvPatchScalarField> clone() const
{
return tmp<fvPatchScalarField>
(
new gradientInternalEnergyRealFluids(*this)
);
}
//- Construct as copy setting internal field reference
gradientInternalEnergyRealFluids
(
const gradientInternalEnergyRealFluids&,
const DimensionedField<scalar, volMesh>&
);
//- Construct and return a clone setting internal field reference
virtual tmp<fvPatchScalarField> clone
(
const DimensionedField<scalar, volMesh>& iF
) const
{
return tmp<fvPatchScalarField>
(
new gradientInternalEnergyRealFluids(*this, iF)
);
}
// Member functions
// Evaluation functions
//- Update the coefficients associated with the patch field
virtual void updateCoeffs();
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View file

@ -0,0 +1,164 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd |
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 2 of the License, or (at your
option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM; if not, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Modified by
Christian Lucas
Institut für Thermodynamik
Technische Universität Braunschweig
Germany
\*---------------------------------------------------------------------------*/
#include "mixedEnthalpyRealFluids.H"
#include "addToRunTimeSelectionTable.H"
#include "fvPatchFieldMapper.H"
#include "volFields.H"
#include "basicPsiThermo.H"
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::mixedEnthalpyRealFluids::mixedEnthalpyRealFluids
(
const fvPatch& p,
const DimensionedField<scalar, volMesh>& iF
)
:
mixedFvPatchScalarField(p, iF)
{
valueFraction() = 0.0;
refValue() = 0.0;
refGrad() = 0.0;
}
Foam::mixedEnthalpyRealFluids::mixedEnthalpyRealFluids
(
const mixedEnthalpyRealFluids& ptf,
const fvPatch& p,
const DimensionedField<scalar, volMesh>& iF,
const fvPatchFieldMapper& mapper
)
:
mixedFvPatchScalarField(ptf, p, iF, mapper)
{}
Foam::mixedEnthalpyRealFluids::mixedEnthalpyRealFluids
(
const fvPatch& p,
const DimensionedField<scalar, volMesh>& iF,
const dictionary& dict
)
:
mixedFvPatchScalarField(p, iF, dict)
{}
Foam::mixedEnthalpyRealFluids::mixedEnthalpyRealFluids
(
const mixedEnthalpyRealFluids& tppsf
)
:
mixedFvPatchScalarField(tppsf)
{}
Foam::mixedEnthalpyRealFluids::mixedEnthalpyRealFluids
(
const mixedEnthalpyRealFluids& tppsf,
const DimensionedField<scalar, volMesh>& iF
)
:
mixedFvPatchScalarField(tppsf, iF)
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void Foam::mixedEnthalpyRealFluids::updateCoeffs()
{
if (updated())
{
return;
}
const basicPsiThermo& thermo = db().lookupObject<basicPsiThermo>
(
"thermophysicalProperties"
);
const label patchi = patch().index();
mixedFvPatchScalarField& Tw = refCast<mixedFvPatchScalarField>
(
const_cast<fvPatchScalarField&>(thermo.T().boundaryField()[patchi])
);
Tw.evaluate();
fvPatchScalarField& pw =
const_cast<fvPatchScalarField&>(thermo.p().boundaryField()[patchi]);
pw.evaluate();
valueFraction() = Tw.valueFraction();
if (dimensionedInternalField().name() == "h")
{
refValue() = thermo.h(pw,Tw.refValue(), patchi);
refGrad() = thermo.Cp(pw,Tw, patchi)*Tw.refGrad()
+ patch().deltaCoeffs()*
(
thermo.h(pw,Tw, patchi)
- thermo.h(pw,Tw, patch().faceCells())
);
}
/* else
{
refValue() = thermo.hs(Tw.refValue(), patchi);
refGrad() = thermo.CpBC(pw,Tw, patchi)*Tw.refGrad()
+ patch().deltaCoeffs()*
(
thermo.hs(Tw, patchi)
- thermo.hs(Tw, patch().faceCells())
);
}*/
mixedFvPatchScalarField::updateCoeffs();
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
makePatchTypeField
(
fvPatchScalarField,
mixedEnthalpyRealFluids
);
}
// ************************************************************************* //

View file

@ -0,0 +1,146 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd |
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 2 of the License, or (at your
option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM; if not, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Class
Foam::mixedEnthalpyRealFluids
Description
Mixed boundary conditions for enthalpy
SourceFiles
mixedEnthalpyRealFluids.C
Modified by
Christian Lucas
Institut für Thermodynamik
Technische Universität Braunschweig
Germany
\*---------------------------------------------------------------------------*/
#ifndef mixedEnthalpyRealFluids_H
#define mixedEnthalpyRealFluids_H
#include "mixedFvPatchFields.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
/*---------------------------------------------------------------------------*\
Class mixedEnthalpyRealFluids Declaration
\*---------------------------------------------------------------------------*/
class mixedEnthalpyRealFluids
:
public mixedFvPatchScalarField
{
public:
//- Runtime type information
TypeName("mixedEnthalpy");
// Constructors
//- Construct from patch and internal field
mixedEnthalpyRealFluids
(
const fvPatch&,
const DimensionedField<scalar, volMesh>&
);
//- Construct from patch, internal field and dictionary
mixedEnthalpyRealFluids
(
const fvPatch&,
const DimensionedField<scalar, volMesh>&,
const dictionary&
);
//- Construct by mapping given mixedEnthalpyRealFluids
// onto a new patch
mixedEnthalpyRealFluids
(
const mixedEnthalpyRealFluids&,
const fvPatch&,
const DimensionedField<scalar, volMesh>&,
const fvPatchFieldMapper&
);
//- Construct as copy
mixedEnthalpyRealFluids
(
const mixedEnthalpyRealFluids&
);
//- Construct and return a clone
virtual tmp<fvPatchScalarField> clone() const
{
return tmp<fvPatchScalarField>
(
new mixedEnthalpyRealFluids(*this)
);
}
//- Construct as copy setting internal field reference
mixedEnthalpyRealFluids
(
const mixedEnthalpyRealFluids&,
const DimensionedField<scalar, volMesh>&
);
//- Construct and return a clone setting internal field reference
virtual tmp<fvPatchScalarField> clone
(
const DimensionedField<scalar, volMesh>& iF
) const
{
return tmp<fvPatchScalarField>
(
new mixedEnthalpyRealFluids(*this, iF)
);
}
// Member functions
// Evaluation functions
//- Update the coefficients associated with the patch field
virtual void updateCoeffs();
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View file

@ -0,0 +1,151 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd |
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 2 of the License, or (at your
option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM; if not, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Modified by
Christian Lucas
Institut für Thermodynamik
Technische Universität Braunschweig
Germany
\*---------------------------------------------------------------------------*/
#include "mixedInternalEnergyRealFluids.H"
#include "addToRunTimeSelectionTable.H"
#include "fvPatchFieldMapper.H"
#include "volFields.H"
#include "basicPsiThermo.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
mixedInternalEnergyRealFluids::mixedInternalEnergyRealFluids
(
const fvPatch& p,
const DimensionedField<scalar, volMesh>& iF
)
:
mixedFvPatchScalarField(p, iF)
{
valueFraction() = 0.0;
refValue() = 0.0;
refGrad() = 0.0;
}
mixedInternalEnergyRealFluids::mixedInternalEnergyRealFluids
(
const mixedInternalEnergyRealFluids& ptf,
const fvPatch& p,
const DimensionedField<scalar, volMesh>& iF,
const fvPatchFieldMapper& mapper
)
:
mixedFvPatchScalarField(ptf, p, iF, mapper)
{}
mixedInternalEnergyRealFluids::mixedInternalEnergyRealFluids
(
const fvPatch& p,
const DimensionedField<scalar, volMesh>& iF,
const dictionary& dict
)
:
mixedFvPatchScalarField(p, iF, dict)
{}
mixedInternalEnergyRealFluids::mixedInternalEnergyRealFluids
(
const mixedInternalEnergyRealFluids& tppsf
)
:
mixedFvPatchScalarField(tppsf)
{}
mixedInternalEnergyRealFluids::mixedInternalEnergyRealFluids
(
const mixedInternalEnergyRealFluids& tppsf,
const DimensionedField<scalar, volMesh>& iF
)
:
mixedFvPatchScalarField(tppsf, iF)
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void mixedInternalEnergyRealFluids::updateCoeffs()
{
if (updated())
{
return;
}
const basicPsiThermo& thermo = db().lookupObject<basicPsiThermo>
(
"thermophysicalProperties"
);
const label patchi = patch().index();
mixedFvPatchScalarField& Tw = refCast<mixedFvPatchScalarField>
(
const_cast<fvPatchScalarField&>(thermo.T().boundaryField()[patchi])
);
Tw.evaluate();
fvPatchScalarField& pw =
const_cast<fvPatchScalarField&>(thermo.p().boundaryField()[patchi]);
pw.evaluate();
valueFraction() = Tw.valueFraction();
refValue() = thermo.e(pw,Tw.refValue(), patchi);
refGrad() = thermo.Cv(pw,Tw, patchi)*Tw.refGrad()
+ patch().deltaCoeffs()*
(
thermo.e(pw,Tw, patchi)
- thermo.e(pw,Tw, patch().faceCells())
);
mixedFvPatchScalarField::updateCoeffs();
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
makePatchTypeField(fvPatchScalarField, mixedInternalEnergyRealFluids);
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// ************************************************************************* //

View file

@ -0,0 +1,146 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd |
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 2 of the License, or (at your
option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM; if not, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Class
Foam::mixedInternalEnergyRealFluids
Description
Mixed boundary conditions for internal energy
SourceFiles
mixedInternalEnergyRealFluids.C
Modified by
Christian Lucas
Institut für Thermodynamik
Technische Universität Braunschweig
Germany
\*---------------------------------------------------------------------------*/
#ifndef mixedInternalEnergyRealFluids_H
#define mixedInternalEnergyRealFluids_H
#include "mixedFvPatchFields.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
/*---------------------------------------------------------------------------*\
Class mixedInternalEnergyRealFluids Declaration
\*---------------------------------------------------------------------------*/
class mixedInternalEnergyRealFluids
:
public mixedFvPatchScalarField
{
public:
//- Runtime type information
TypeName("mixedInternalEnergy");
// Constructors
//- Construct from patch and internal field
mixedInternalEnergyRealFluids
(
const fvPatch&,
const DimensionedField<scalar, volMesh>&
);
//- Construct from patch, internal field and dictionary
mixedInternalEnergyRealFluids
(
const fvPatch&,
const DimensionedField<scalar, volMesh>&,
const dictionary&
);
//- Construct by mapping given mixedInternalEnergyRealFluids
// onto a new patch
mixedInternalEnergyRealFluids
(
const mixedInternalEnergyRealFluids&,
const fvPatch&,
const DimensionedField<scalar, volMesh>&,
const fvPatchFieldMapper&
);
//- Construct as copy
mixedInternalEnergyRealFluids
(
const mixedInternalEnergyRealFluids&
);
//- Construct and return a clone
virtual tmp<fvPatchScalarField> clone() const
{
return tmp<fvPatchScalarField>
(
new mixedInternalEnergyRealFluids(*this)
);
}
//- Construct as copy setting internal field reference
mixedInternalEnergyRealFluids
(
const mixedInternalEnergyRealFluids&,
const DimensionedField<scalar, volMesh>&
);
//- Construct and return a clone setting internal field reference
virtual tmp<fvPatchScalarField> clone
(
const DimensionedField<scalar, volMesh>& iF
) const
{
return tmp<fvPatchScalarField>
(
new mixedInternalEnergyRealFluids(*this, iF)
);
}
// Member functions
// Evaluation functions
//- Update the coefficients associated with the patch field
virtual void updateCoeffs();
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View file

@ -0,0 +1,198 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd |
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 2 of the License, or (at your
option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM; if not, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Modified by
Christian Lucas
Institut für Thermodynamik
Technische Universität Braunschweig
Germany
\*---------------------------------------------------------------------------*/
#include "realFluidWallHeatTransferFvPatchScalarField.H"
#include "addToRunTimeSelectionTable.H"
#include "fvPatchFieldMapper.H"
#include "volFields.H"
#include "basicPsiThermo.H"
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::realFluidWallHeatTransferFvPatchScalarField::realFluidWallHeatTransferFvPatchScalarField
(
const fvPatch& p,
const DimensionedField<scalar, volMesh>& iF
)
:
mixedFvPatchScalarField(p, iF),
Tinf_(p.size(), 0.0),
alphaWall_(p.size(), 0.0)
{
refValue() = 0.0;
refGrad() = 0.0;
valueFraction() = 0.0;
}
Foam::realFluidWallHeatTransferFvPatchScalarField::realFluidWallHeatTransferFvPatchScalarField
(
const realFluidWallHeatTransferFvPatchScalarField& ptf,
const fvPatch& p,
const DimensionedField<scalar, volMesh>& iF,
const fvPatchFieldMapper& mapper
)
:
mixedFvPatchScalarField(ptf, p, iF, mapper),
Tinf_(ptf.Tinf_, mapper),
alphaWall_(ptf.alphaWall_, mapper)
{}
Foam::realFluidWallHeatTransferFvPatchScalarField::realFluidWallHeatTransferFvPatchScalarField
(
const fvPatch& p,
const DimensionedField<scalar, volMesh>& iF,
const dictionary& dict
)
:
mixedFvPatchScalarField(p, iF),
Tinf_("Tinf", dict, p.size()),
alphaWall_("alphaWall", dict, p.size())
{
refValue() = Tinf_;
refGrad() = 0.0;
valueFraction() = 0.0;
if (dict.found("value"))
{
fvPatchField<scalar>::operator=
(
scalarField("value", dict, p.size())
);
}
else
{
evaluate();
}
}
Foam::realFluidWallHeatTransferFvPatchScalarField::realFluidWallHeatTransferFvPatchScalarField
(
const realFluidWallHeatTransferFvPatchScalarField& tppsf
)
:
mixedFvPatchScalarField(tppsf),
Tinf_(tppsf.Tinf_),
alphaWall_(tppsf.alphaWall_)
{}
Foam::realFluidWallHeatTransferFvPatchScalarField::realFluidWallHeatTransferFvPatchScalarField
(
const realFluidWallHeatTransferFvPatchScalarField& tppsf,
const DimensionedField<scalar, volMesh>& iF
)
:
mixedFvPatchScalarField(tppsf, iF),
Tinf_(tppsf.Tinf_),
alphaWall_(tppsf.alphaWall_)
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void Foam::realFluidWallHeatTransferFvPatchScalarField::autoMap
(
const fvPatchFieldMapper& m
)
{
scalarField::autoMap(m);
Tinf_.autoMap(m);
alphaWall_.autoMap(m);
}
void Foam::realFluidWallHeatTransferFvPatchScalarField::rmap
(
const fvPatchScalarField& ptf,
const labelList& addr
)
{
mixedFvPatchScalarField::rmap(ptf, addr);
const realFluidWallHeatTransferFvPatchScalarField& tiptf =
refCast<const realFluidWallHeatTransferFvPatchScalarField>(ptf);
Tinf_.rmap(tiptf.Tinf_, addr);
alphaWall_.rmap(tiptf.alphaWall_, addr);
}
void Foam::realFluidWallHeatTransferFvPatchScalarField::updateCoeffs()
{
if (updated())
{
return;
}
const basicPsiThermo& thermo = db().lookupObject<basicPsiThermo>
(
"thermophysicalProperties"
);
const label patchi = patch().index();
const scalarField& Tw = thermo.T().boundaryField()[patchi];
const scalarField& pw = thermo.p().boundaryField()[patchi];
scalarField Cpw = thermo.Cp(pw,Tw, patchi);
valueFraction() =
1.0/
(
1.0
+ Cpw*thermo.alpha().boundaryField()[patchi]
*patch().deltaCoeffs()/alphaWall_
);
mixedFvPatchScalarField::updateCoeffs();
}
void Foam::realFluidWallHeatTransferFvPatchScalarField::write(Ostream& os) const
{
fvPatchScalarField::write(os);
Tinf_.writeEntry("Tinf", os);
alphaWall_.writeEntry("alphaWall", os);
writeEntry("value", os);
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
makePatchTypeField(fvPatchScalarField, realFluidWallHeatTransferFvPatchScalarField);
}
// ************************************************************************* //

View file

@ -0,0 +1,201 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd |
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 2 of the License, or (at your
option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM; if not, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Class
Foam::realFluidWallHeatTransferFvPatchScalarField
Description
Enthalpy boundary conditions for wall heat transfer
SourceFiles
realFluidWallHeatTransferFvPatchScalarField.C
Modified by
Christian Lucas
Institut für Thermodynamik
Technische Universität Braunschweig
Germany
\*---------------------------------------------------------------------------*/
#ifndef realFluidWallHeatTransferFvPatchScalarField_H
#define realFluidWallHeatTransferFvPatchScalarField_H
#include "mixedFvPatchFields.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
/*---------------------------------------------------------------------------*\
Class wallHeatTransferFvPatch Declaration
\*---------------------------------------------------------------------------*/
class realFluidWallHeatTransferFvPatchScalarField
:
public mixedFvPatchScalarField
{
// Private data
//- Tinf
scalarField Tinf_;
//- alphaWall
scalarField alphaWall_;
public:
//- Runtime type information
TypeName("realFluidWallHeatTransfer");
// Constructors
//- Construct from patch and internal field
realFluidWallHeatTransferFvPatchScalarField
(
const fvPatch&,
const DimensionedField<scalar, volMesh>&
);
//- Construct from patch, internal field and dictionary
realFluidWallHeatTransferFvPatchScalarField
(
const fvPatch&,
const DimensionedField<scalar, volMesh>&,
const dictionary&
);
//- Construct by mapping given realFluidWallHeatTransferFvPatchScalarField
// onto a new patch
realFluidWallHeatTransferFvPatchScalarField
(
const realFluidWallHeatTransferFvPatchScalarField&,
const fvPatch&,
const DimensionedField<scalar, volMesh>&,
const fvPatchFieldMapper&
);
//- Construct as copy
realFluidWallHeatTransferFvPatchScalarField
(
const realFluidWallHeatTransferFvPatchScalarField&
);
//- Construct and return a clone
virtual tmp<fvPatchScalarField> clone() const
{
return tmp<fvPatchScalarField>
(
new realFluidWallHeatTransferFvPatchScalarField(*this)
);
}
//- Construct as copy setting internal field reference
realFluidWallHeatTransferFvPatchScalarField
(
const realFluidWallHeatTransferFvPatchScalarField&,
const DimensionedField<scalar, volMesh>&
);
//- Construct and return a clone setting internal field reference
virtual tmp<fvPatchScalarField> clone
(
const DimensionedField<scalar, volMesh>& iF
) const
{
return tmp<fvPatchScalarField>
(
new realFluidWallHeatTransferFvPatchScalarField(*this, iF)
);
}
// Member functions
// Access
//- Return Tinf
const scalarField& Tinf() const
{
return Tinf_;
}
//- Return reference to Tinf to allow adjustment
scalarField& Tinf()
{
return Tinf_;
}
//- Return alphaWall
const scalarField& alphaWall() const
{
return alphaWall_;
}
//- Return reference to alphaWall to allow adjustment
scalarField& alphaWall()
{
return alphaWall_;
}
// Mapping functions
//- Map (and resize as needed) from self given a mapping object
virtual void autoMap
(
const fvPatchFieldMapper&
);
//- Reverse map the given fvPatchField onto this fvPatchField
virtual void rmap
(
const fvPatchScalarField&,
const labelList&
);
// Evaluation functions
//- Update the coefficients associated with the patch field
virtual void updateCoeffs();
//- Write
virtual void write(Ostream&) const;
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View file

@ -0,0 +1,460 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd |
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 2 of the License, or (at your
option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM; if not, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Author
Christian Lucas
Institut für Thermodynamik
Technische Universität Braunschweig
Germany
\*---------------------------------------------------------------------------*/
#include "realGasHThermo.H"
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
template<class MixtureType>
void Foam::realGasHThermo<MixtureType>::calculate()
{
const scalarField& hCells = h_.internalField();
const scalarField& pCells = this->p_.internalField();
scalarField& TCells = this->T_.internalField();
scalarField& rhoCells= this->rho_.internalField();
scalarField& psiCells = this->psi_.internalField();
scalarField& muCells = this->mu_.internalField();
scalarField& alphaCells = this->alpha_.internalField();
forAll(TCells, celli)
{
const typename MixtureType::thermoType& mixture_ =
this->cellMixture(celli);
mixture_.TH(hCells[celli], TCells[celli],pCells[celli],rhoCells[celli]);
psiCells[celli]=mixture_.psi(rhoCells[celli],TCells[celli]);
muCells[celli] = mixture_.mu(TCells[celli]);
alphaCells[celli] = mixture_.alpha(rhoCells[celli], TCells[celli]);
}
forAll(T_.boundaryField(), patchi)
{
fvPatchScalarField& pp = this->p_.boundaryField()[patchi];
fvPatchScalarField& pT = this->T_.boundaryField()[patchi];
fvPatchScalarField& ppsi = this->psi_.boundaryField()[patchi];
fvPatchScalarField& prho = this->rho_.boundaryField()[patchi];
fvPatchScalarField& ph = h_.boundaryField()[patchi];
fvPatchScalarField& pmu = this->mu_.boundaryField()[patchi];
fvPatchScalarField& palpha = this->alpha_.boundaryField()[patchi];
if (pT.fixesValue())
{
forAll(pT, facei)
{
const typename MixtureType::thermoType& mixture_ =
this->patchFaceMixture(patchi, facei);
prho[facei] = mixture_.rho(pp[facei], pT[facei],prho[facei]);
ppsi[facei]=mixture_.psi(prho[facei],pT[facei]);
ph[facei] = mixture_.H(prho[facei], pT[facei]);
pmu[facei] = mixture_.mu(pT[facei]);
palpha[facei] = mixture_.alpha(prho[facei],pT[facei]);
}
}
else
{
forAll(pT, facei)
{
const typename MixtureType::thermoType& mixture_ =
this->patchFaceMixture(patchi, facei);
mixture_.TH(ph[facei], pT[facei],pp[facei],prho[facei]);
pmu[facei] = mixture_.mu(pT[facei]);
ppsi[facei]=mixture_.psi(prho[facei],pT[facei]);
palpha[facei] = mixture_.alpha(prho[facei],pT[facei]);
}
}
}
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
template<class MixtureType>
Foam::realGasHThermo<MixtureType>::realGasHThermo(const fvMesh& mesh)
:
basicPsiThermo(mesh),
MixtureType(*this, mesh),
h_
(
IOobject
(
"h",
mesh.time().timeName(),
mesh,
IOobject::NO_READ,
IOobject::NO_WRITE
),
mesh,
dimensionSet(0, 2, -2, 0, 0),
this->hRealBoundaryTypes()
),
rho_
(
IOobject
(
"rho1",
mesh.time().timeName(),
mesh,
IOobject::READ_IF_PRESENT,
IOobject::NO_WRITE
),
mesh,
dimDensity
)
{
scalarField& hCells = h_.internalField();
const scalarField& TCells = this->T_.internalField();
const scalarField& pCells =this->p_.internalField();
scalarField& rhoCells =this->rho_.internalField();
forAll(rhoCells, celli)
{
rhoCells[celli]=this->cellMixture(celli).rho(pCells[celli],TCells[celli]);
}
forAll(rho_.boundaryField(), patchi)
{
rho_.boundaryField()[patchi] ==
rho( this->p_.boundaryField()[patchi] , this->T_.boundaryField()[patchi], patchi);
}
forAll(hCells, celli)
{
hCells[celli] = this->cellMixture(celli).H(rhoCells[celli],TCells[celli]);
}
forAll(h_.boundaryField(), patchi)
{
h_.boundaryField()[patchi] ==
h((this->rho_.boundaryField()[patchi]) , this->T_.boundaryField()[patchi], patchi);
}
hRealBoundaryCorrection(h_);
calculate();
// Switch on saving old time
this->psi_.oldTime();
}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
template<class MixtureType>
Foam::realGasHThermo<MixtureType>::~realGasHThermo()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class MixtureType>
void Foam::realGasHThermo<MixtureType>::correct()
{
if (debug)
{
Info<< "entering realGasHThermo<MixtureType>::correct()" << endl;
}
// force the saving of the old-time values
this->psi_.oldTime();
calculate();
if (debug)
{
Info<< "exiting realGasHThermo<MixtureType>::correct()" << endl;
}
}
template<class MixtureType>
Foam::tmp<Foam::scalarField> Foam::realGasHThermo<MixtureType>::h
(
const scalarField& p,
const scalarField& T,
const labelList& cells
) const
{
tmp<scalarField> th(new scalarField(T.size()));
scalarField& h = th();
forAll(T, celli)
{
h[celli] = this->cellMixture(cells[celli]).H(this->cellMixture(cells[celli]).rho(p[celli],T[celli]),T[celli]);
}
return th;
}
template<class MixtureType>
Foam::tmp<Foam::scalarField> Foam::realGasHThermo<MixtureType>::h
(
const scalarField& p,
const scalarField& T,
const label patchi
) const
{
tmp<scalarField> th(new scalarField(T.size()));
scalarField& h = th();
forAll(T, facei)
{
h[facei] = this->patchFaceMixture(patchi, facei).H(this->patchFaceMixture(patchi, facei).rho(p[facei], T[facei]),T[facei]);
}
return th;
}
template<class MixtureType>
Foam::tmp<Foam::scalarField> Foam::realGasHThermo<MixtureType>::psi
(
const scalarField& rho,
const scalarField& T,
const label patchi
) const
{
tmp<scalarField> tpsi(new scalarField(T.size()));
scalarField& psi = tpsi();
forAll(T, facei)
{
psi[facei] = this->patchFaceMixture(patchi, facei).psi(rho[facei], T[facei]);
}
return tpsi;
}
template<class MixtureType>
Foam::tmp<Foam::scalarField> Foam::realGasHThermo<MixtureType>::rho
(
const scalarField& p,
const scalarField& T,
const label patchi
) const
{
tmp<scalarField> trho(new scalarField(T.size()));
scalarField& rho = trho();
forAll(T, facei)
{
rho[facei] = this->patchFaceMixture(patchi, facei).rho(p[facei], T[facei]);
}
return trho;
}
template<class MixtureType>
Foam::tmp<Foam::scalarField> Foam::realGasHThermo<MixtureType>::Cp
(
const scalarField& p,
const scalarField& T,
const label patchi
) const
{
tmp<scalarField> tCp(new scalarField(T.size()));
scalarField& cp = tCp();
forAll(T, facei)
{
cp[facei] = this->patchFaceMixture(patchi, facei).Cp(this->patchFaceMixture(patchi, facei).rho(p[facei], T[facei]),T[facei]);
}
return tCp;
}
template<class MixtureType>
Foam::tmp<Foam::volScalarField> Foam::realGasHThermo<MixtureType>::Cp() const
{
const fvMesh& mesh = this->T_.mesh();
tmp<volScalarField> tCp
(
new volScalarField
(
IOobject
(
"Cp",
mesh.time().timeName(),
mesh,
IOobject::NO_READ,
IOobject::AUTO_WRITE
),
mesh,
dimensionSet(0, 2, -2, -1, 0),
this->T_.boundaryField().types()
)
);
volScalarField& cp = tCp();
forAll(this->T_, celli)
{
cp[celli] = this->cellMixture(celli).Cp(this->rho_[celli], this->T_[celli]);
}
forAll(this->T_.boundaryField(), patchi)
{
const fvPatchScalarField& pT = this->T_.boundaryField()[patchi];
const fvPatchScalarField& prho = this->rho_.boundaryField()[patchi];
fvPatchScalarField& pCp = cp.boundaryField()[patchi];
forAll(pT, facei)
{
pCp[facei] = this->patchFaceMixture(patchi, facei).Cp(prho[facei], pT[facei]);
}
}
return tCp;
}
template<class MixtureType>
Foam::tmp<Foam::scalarField> Foam::realGasHThermo<MixtureType>::Cv
(
const scalarField& rho,
const scalarField& T,
const label patchi
) const
{
tmp<scalarField> tCv(new scalarField(T.size()));
scalarField& cv = tCv();
forAll(T, facei)
{
cv[facei] = this->patchFaceMixture(patchi, facei).Cv(rho[facei], T[facei]);
}
return tCv;
}
template<class MixtureType>
Foam::tmp<Foam::volScalarField> Foam::realGasHThermo<MixtureType>::Cv() const
{
const fvMesh& mesh = this->T_.mesh();
tmp<volScalarField> tCv
(
new volScalarField
(
IOobject
(
"Cv",
mesh.time().timeName(),
mesh,
IOobject::NO_READ,
IOobject::AUTO_WRITE
),
mesh,
dimensionSet(0, 2, -2, -1, 0)
)
);
volScalarField& cv = tCv();
forAll(this->T_, celli)
{
cv[celli] = this->cellMixture(celli).Cv(this->rho_[celli], this->T_[celli]);
}
forAll(this->T_.boundaryField(), patchi)
{
cv.boundaryField()[patchi] =
Cv(this->rho_.boundaryField()[patchi] , this->T_.boundaryField()[patchi], patchi);
}
return tCv;
}
template<class MixtureType>
bool Foam::realGasHThermo<MixtureType>::read()
{
if (basicPsiThermo::read())
{
MixtureType::read(*this);
return true;
}
else
{
return false;
}
}
// ************************************************************************* //

View file

@ -0,0 +1,226 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | .
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 2 of the License, or (at your
option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM; if not, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Class
Foam::realGasHThermo
Description
Enthalpy for a real gas fluid libary
SourceFiles
realGasHThermo.C
Author
Christian Lucas
Institut für Thermodynamik
Technische Universität Braunschweig
Germany
\*---------------------------------------------------------------------------*/
#ifndef realGasHThermo_H
#define realGasHThermo_H
#include "basicPsiThermo.H"
#include "basicMixture.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
/*---------------------------------------------------------------------------*\
Class hPsiThermo Declaration
\*---------------------------------------------------------------------------*/
template<class MixtureType>
class realGasHThermo
:
public basicPsiThermo,
public MixtureType
{
// Private data
//- Enthalpy field
volScalarField h_;
//- DensityField
volScalarField rho_;
// Private member functions
//- Calculate the thermo variables
void calculate();
//- Construct as copy (not implemented)
realGasHThermo(const realGasHThermo<MixtureType>&);
public:
//- Runtime type information
TypeName("realGasHThermo");
// Constructors
//- Construct from mesh
realGasHThermo(const fvMesh&);
//- Destructor
virtual ~realGasHThermo();
// Member functions
//- Return the compostion of the mixture
virtual basicMixture& composition()
{
return *this;
}
//- Return the compostion of the mixture
virtual const basicMixture& composition() const
{
return *this;
}
//- Update properties
virtual void correct();
// Access to thermodynamic state variables
//- Enthalpy [J/kg]
// Non-const access allowed for transport equations
virtual volScalarField& h()
{
return h_;
}
//- Enthalpy [J/kg]
virtual const volScalarField& h() const
{
return h_;
}
// Fields derived from thermodynamic state variables
//- Enthalpy for cell-set [J/kg]
virtual tmp<scalarField> h
(
const scalarField& p,
const scalarField& T,
const labelList& cells
) const;
//- Enthalpy for patch [J/kg]
virtual tmp<scalarField> h
(
const scalarField& p,
const scalarField& T,
const label patchi
) const;
//- Psi for patch [J/kg]
virtual tmp<scalarField> psi
(
const scalarField& rho,
const scalarField& T,
const label patchi
) const;
//- Density for patch [J/kg]
virtual tmp<scalarField> rho
(
const scalarField& p,
const scalarField& T,
const label patchi
) const;
//- Heat capacity at constant pressure for patch [J/kg/K]
virtual tmp<scalarField> Cp
(
const scalarField& p,
const scalarField& T,
const label patchi
) const;
//- Heat capacity at constant pressure [J/kg/K]
virtual tmp<volScalarField> Cp() const;
//- Heat capacity at constant volume for patch [J/kg/K]
virtual tmp<scalarField> Cv
(
const scalarField& rho,
const scalarField& T,
const label patchi
) const;
//- Heat capacity at constant volume [J/kg/K]
virtual tmp<volScalarField> Cv() const;
//- Density [kg/m^3] - uses current value of pressure
virtual tmp<volScalarField> rho() const
{
return rho_*1;
}
//- Read thermophysicalProperties dictionary
virtual bool read();
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
#ifdef NoRepository
# include "realGasHThermo.C"
#endif
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View file

@ -0,0 +1,163 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd |
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 2 of the License, or (at your
option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM; if not, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Author
Christian Lucas
Institut für Thermodynamik
Technische Universität Braunschweig
Germany
\*---------------------------------------------------------------------------*/
#include "makeBasicPsiThermo.H"
#include "redlichKwong.H"
#include "pengRobinson.H"
#include "aungierRedlichKwong.H"
#include "soaveRedlichKwong.H"
#include "nasaHeatCapacityPolynomial.H"
#include "realGasSpecieThermo.H"
#include "pureMixture.H"
#include "realGasSutherlandTransport.H"
#include "realGasConstTransport.H"
#include "realGasHThermo.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
/* * * * * * * * * * * * * * * private static data * * * * * * * * * * * * * */
makeBasicRealGasThermo
(
realGasHThermo,
pureMixture,
realGasSutherlandTransport,
realGasSpecieThermo,
nasaHeatCapacityPolynomial,
pengRobinson
);
makeBasicRealGasThermo
(
realGasHThermo,
pureMixture,
realGasSutherlandTransport,
realGasSpecieThermo,
nasaHeatCapacityPolynomial,
aungierRedlichKwong
);
makeBasicRealGasThermo
(
realGasHThermo,
pureMixture,
realGasSutherlandTransport,
realGasSpecieThermo,
nasaHeatCapacityPolynomial,
redlichKwong
);
makeBasicRealGasThermo
(
realGasHThermo,
pureMixture,
realGasSutherlandTransport,
realGasSpecieThermo,
nasaHeatCapacityPolynomial,
soaveRedlichKwong
);
makeBasicRealGasThermo
(
realGasHThermo,
pureMixture,
realGasConstTransport,
realGasSpecieThermo,
nasaHeatCapacityPolynomial,
pengRobinson
);
makeBasicRealGasThermo
(
realGasHThermo,
pureMixture,
realGasConstTransport,
realGasSpecieThermo,
nasaHeatCapacityPolynomial,
aungierRedlichKwong
);
makeBasicRealGasThermo
(
realGasHThermo,
pureMixture,
realGasConstTransport,
realGasSpecieThermo,
nasaHeatCapacityPolynomial,
redlichKwong
);
makeBasicRealGasThermo
(
realGasHThermo,
pureMixture,
realGasConstTransport,
realGasSpecieThermo,
nasaHeatCapacityPolynomial,
soaveRedlichKwong
);
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// ************************************************************************* //

View file

@ -0,0 +1,78 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd |
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 2 of the License, or (at your
option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM; if not, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Description
Aungier Redlich Kwong equation of state.
Author
Christian Lucas
Institut für Thermodynamik
Technische Universität Braunschweig
Germany
\*---------------------------------------------------------------------------*/
#include "aungierRedlichKwong.H"
#include "IOstreams.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
aungierRedlichKwong::aungierRedlichKwong(Istream& is)
:
specie(is),
pcrit_(readScalar(is)),
Tcrit_(readScalar(is)),
azentricFactor_(readScalar(is)),
rhocrit_(readScalar(is))
{
is.check("aungierRedlichKwong::aungierRedlichKwong(Istream& is)");
rhostd_=this->rho(Pstd,Tstd,Pstd*this->W()/(Tstd*this->R()));
rhoMax_=1500;
rhoMin_=0.001;
}
// * * * * * * * * * * * * * * * Ostream Operator * * * * * * * * * * * * * //
Ostream& operator<<(Ostream& os, const aungierRedlichKwong& pg)
{
os << static_cast<const specie&>(pg)<< tab
<< pg.pcrit_ << tab<< pg.Tcrit_<<tab<<pg.azentricFactor_<<tab<<pg.rhocrit_;
os.check("Ostream& operator<<(Ostream& os, const aungierRedlichKwong& st)");
return os;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// ************************************************************************* //

View file

@ -0,0 +1,194 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd |
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 2 of the License, or (at your
option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM; if not, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Class
Foam::aungierRedlichKwong
Description
Aungier Redlich Kwong equation of state.
SourceFiles
aungierRedlichKwongI.H
aungierRedlichKwong.C
Author
Christian Lucas
Institut für Thermodynamik
Technische Universität Braunschweig
Germany
\*---------------------------------------------------------------------------*/
#ifndef aungierRedlichKwong_H
#define aungierRedlichKwong_H
#include "specie.H"
#include "autoPtr.H"
#include "word.H"
#include "scalar.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
/*---------------------------------------------------------------------------*\
Class aungierRedlichKwong Declaration
\*---------------------------------------------------------------------------*/
class aungierRedlichKwong
:
public specie
{
public:
// Constructors
//- Construct from components
inline aungierRedlichKwong(
const specie& sp,
scalar pcrit,
scalar Tcrit,
scalar azentricFactor,
scalar rhocrit
);
//- Construct from Istream
aungierRedlichKwong(Istream&);
//- Construct as named copy
inline aungierRedlichKwong(const word& name, aungierRedlichKwong&);
//- Construct and return a clone
inline autoPtr<aungierRedlichKwong> clone() const;
// Selector from Istream
inline static autoPtr<aungierRedlichKwong> New(Istream& is);
//Member Variabels
scalar pcrit_;
scalar Tcrit_;
scalar rhostd_;
scalar azentricFactor_;
scalar rhocrit_;
scalar rhoMax_; //should be read from the fvSolution file where rhoMax and rhoMin values must be define ( for rhoSimpleFoam)
scalar rhoMin_;
// Member functions
inline scalar pcrit() const;
inline scalar Tcrit() const;
inline scalar azentricFactor() const;
inline scalar rhostd()const;
inline scalar rhocrit() const;
inline scalar pReturn(const scalar rho, const scalar T) const;
//-Redlich Kwong factors
inline scalar a() const;
inline scalar b() const;
inline scalar c() const;
inline scalar n() const;
//derivatives
inline scalar dpdv(const scalar rho,const scalar T) const;
inline scalar dpdT(const scalar rho, const scalar T) const;
inline scalar dvdT(const scalar rho,const scalar T) const;
inline scalar dvdp(const scalar rho, const scalar T) const;
inline scalar isobarExpCoef(const scalar rho,const scalar T) const;
inline scalar isothermalCompressiblity(const scalar rho,const scalar T) const;
inline scalar integral_d2pdT2_dv(const scalar rho,const scalar T) const ; // Used for cv
inline scalar d2pdv2(const scalar rho,const scalar T) const; // not Used At The Moment
inline scalar d2pdT2(const scalar rho,const scalar T) const; // not Used At The Moment
inline scalar d2pdvdT(const scalar rho,const scalar T) const; // not Used At The Moment
inline scalar d2vdT2(const scalar rho,const scalar T) const; // not Used At The Moment
inline scalar integral_p_dv(const scalar rho,const scalar T) const; //Used for internal Energy
inline scalar integral_dpdT_dv(const scalar rho,const scalar T) const; //Used for Entropy
//- Return density [kg/m^3] // rho0 is the starting point of the newton solver used to calculate rho
inline scalar rho(const scalar p,const scalar T,const scalar rho0) const;
inline scalar rho(const scalar p,const scalar T) const;
//- Return compressibility drho/dp [s^2/m^2]
inline scalar psi(const scalar rho, const scalar T) const;
//- Return compression factor [] // rho0 is the starting point of the newton solver used to calculate rho
inline scalar Z(const scalar p,const scalar T,const scalar rho0) const;
// Member operators
inline void operator+=(const aungierRedlichKwong&);
inline void operator-=(const aungierRedlichKwong&);
inline void operator*=(const scalar);
/* // Friend operators
inline friend aungierRedlichKwong operator+
(
const aungierRedlichKwong&,
const aungierRedlichKwong&
);
inline friend aungierRedlichKwong operator-
(
const aungierRedlichKwong&,
const aungierRedlichKwong&
);
inline friend aungierRedlichKwong operator*
(
const scalar s,
const aungierRedlichKwong&
);
inline friend aungierRedlichKwong operator==
(
const aungierRedlichKwong&,
const aungierRedlichKwong&
);
*/
// Ostream Operator
friend Ostream& operator<<(Ostream&, const aungierRedlichKwong&);
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#include "aungierRedlichKwongI.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View file

@ -0,0 +1,497 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd |
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 2 of the License, or (at your
option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM; if not, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Author
Christian Lucas
Institut für Thermodynamik
Technische Universität Braunschweig
Germany
\*---------------------------------------------------------------------------*/
#include "aungierRedlichKwong.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
inline scalar aungierRedlichKwong::pcrit()const
{
return pcrit_;
}
inline scalar aungierRedlichKwong::Tcrit()const
{
return Tcrit_;
}
inline scalar aungierRedlichKwong::rhostd()const
{
return rhostd_;
}
inline scalar aungierRedlichKwong::rhocrit()const
{
return rhocrit_;
}
// Returns the Azentric Factor (Acentric Factor)
inline scalar aungierRedlichKwong::azentricFactor() const
{
return azentricFactor_;
}
//returns the pressure for a given density and temperature
inline scalar aungierRedlichKwong::pReturn(const scalar rho,const scalar T) const
{
return this->RR*T/((this->W()/rho)-this->b()+this->c())
-this->a()*pow(T,-this->n())/(pow(this->Tcrit(),-this->n())*(this->W()/rho)*((this->W()/rho)+this->b()));
}
// Factor a of the redlich Kwong equation of state
//(molar values)
inline scalar aungierRedlichKwong::a() const
{
return 0.42747*pow(this->RR,2)*pow(this->Tcrit(),2)/this->pcrit();
}
// Faktor b of the redlich Kwong equation of state
//(molar values)
inline scalar aungierRedlichKwong::b() const
{
return 0.08664*this->RR*this->Tcrit()/this->pcrit();
}
// Factor c of the redlich Kwong equation of state
//(molar values)
inline scalar aungierRedlichKwong::c() const
{
return this->RR*this->Tcrit()/(this->pcrit()+(this->a()/(this->W()/this->rhocrit()*(this->W()/this->rhocrit()+this->b()))))+this->b()-this->W()/this->rhocrit();
}
// Factor n of the redlich Kwong equation of state
inline scalar aungierRedlichKwong::n() const
{
return 0.4986+1.2735*this->azentricFactor()+0.4754*pow(this->azentricFactor(),2);
}
//* * * * * * * * * * * * * Derivatives * * * * * * * * * * * //
//Real deviative dp/dv at constant temperature
//(molar values)
inline scalar aungierRedlichKwong::dpdv(const scalar rho, const scalar T) const
{
return this->a()*pow(T,-this->n())*pow(this->Tcrit(),this->n())*(this->b()+2*(this->W()/rho))/(pow((this->W()/rho),2)*pow((this->b()+(this->W()/rho)),2))-this->RR*T/(pow((this->b()-(this->W()/rho)-this->c()),2));
}
//Real deviative dp/dT at constant molar volume
//(molar values)
inline scalar aungierRedlichKwong::dpdT(const scalar rho, const scalar T) const
{
return this->a()*this->n()*pow(T,-this->n()-1)*pow(this->Tcrit(),this->n())/((this->W()/rho)*((this->W()/rho)+this->b()))-
this->RR/(this->b()-(this->W()/rho)-this->c());
}
//Real deviative dv/dT at constant pressure
//using implicit differentiation
//(molar values)
inline scalar aungierRedlichKwong::dvdT(const scalar rho,const scalar T) const
{
return (-1)*this->dpdT(rho,T)/this->dpdv(rho,T);
}
//Real deviative dv/dp at constant temperature
//(molar values)
inline scalar aungierRedlichKwong::dvdp(const scalar rho,const scalar T) const
{
return 1/this->dpdv(rho,T);
}
//needed to calculate the internal energy
//(molar values)
inline scalar aungierRedlichKwong::integral_p_dv(const scalar rho,const scalar T) const
{
return -pow((T/this->Tcrit()),-this->n())*(this->a()*log((this->W()/rho))/(this->b())-this->a()*log(this->b()+(this->W()/rho))/this->b())+this->RR*T*log((this->W()/rho)-this->b()+this->c());
}
//needed to calculate the entropy
//(molar values)
inline scalar aungierRedlichKwong::integral_dpdT_dv(const scalar rho,const scalar T) const
{
return pow(T,-this->n()-1)*pow(this->Tcrit(),this->n())*
(this->a()*this->n()*log((this->W()/rho))/(this->b())
-this->a()*this->n()*log(this->b()+(this->W()/rho))/(this->b()))
+ this->RR*log(-this->b()+this->c()+(this->W()/rho));
}
//* * * * * * * * * * * * * second order Derivative based functions * * * * * * * * * * * //
//(molar values)
inline scalar aungierRedlichKwong::d2pdT2(const scalar rho,const scalar T) const
{
return -this->a()*this->n()*pow(T,-this->n()-2)*pow(this->Tcrit(),this->n())*(this->n()+1)/((this->W()/rho)*(this->b()+(this->W()/rho)));
}
//(molar values)
inline scalar aungierRedlichKwong::d2pdv2(const scalar rho,const scalar T) const
{
return -2*this->a()*pow(T,-this->n())*pow(this->Tcrit(),this->n())*(pow(this->b(),2)+3*this->b()*(this->W()/rho)+3*pow((this->W()/rho),2))/(pow((this->W()/rho),3)*pow((this->b()+(this->W()/rho)),3))-2*this->RR*T/(pow((this->b()-(this->W()/rho)-this->c()),3));
}
//(molar values)
//using second order implicit differentiation
inline scalar aungierRedlichKwong::d2vdT2(const scalar rho, const scalar T) const
{
return -(pow(this->dpdT(rho,T),2)*this->d2pdv2(rho,T)+ pow(this->dpdv(rho,T),2) *this->d2pdT2(rho,T)- 2*this->dpdv(rho,T)*this->dpdT(rho,T)*this->d2pdvdT(rho,T))/( pow(this->dpdv(rho,T),3));
}
//(molar values)
inline scalar aungierRedlichKwong::d2pdvdT(const scalar rho, const scalar T) const
{
return -this->a()*this->n()*pow(T,-this->n()-1)*pow(this->Tcrit(),this->n())*(this->b()+2*(this->W()/rho))/(pow((this->W()/rho),2)*pow((this->b()+(this->W()/rho)),2))-this->RR/(pow((this->b()-this->c()-(this->W()/rho)),2));
}
// the result of this intergal is needed for the nasa based cp polynomial
//(molar values)
inline scalar aungierRedlichKwong::integral_d2pdT2_dv(const scalar rho,const scalar T) const
{
return pow(T,-this->n()-2)*pow(this->Tcrit(),this->n())*(this->a()*this->n()*(this->n()+1)*log(this->b()+(this->W()/rho))/this->b()-this->a()*this->n()*(1+this->n())*log((this->W()/rho))/this->b());
}
//* * * * * * * * * * * * * thermodynamic properties * * * * * * * * * * * //
//Isobar expansion Coefficent beta = 1/v (dv/dt) at constant p
//(molar values)
inline scalar aungierRedlichKwong::isobarExpCoef(const scalar rho,const scalar T) const
{
return this->dvdT(rho, T)*rho/this->W();
}
//isothemal compressiblity kappa
//(molar values)
inline scalar aungierRedlichKwong::isothermalCompressiblity(const scalar rho,const scalar T) const
{
return this->isobarExpCoef(rho, T)/this->dpdT(rho, T);
//also possible : return -this->dvdp(rho,T)*rho/this->W();
}
// Construct from components
// Starting GUESS for the density by ideal gas law
inline aungierRedlichKwong::aungierRedlichKwong
(
const specie& sp,
scalar pcrit,
scalar Tcrit,
scalar azentricFactor,
scalar rhocrit
)
:
specie(sp),
pcrit_(pcrit),
Tcrit_(Tcrit),
azentricFactor_(azentricFactor),
rhocrit_(rhocrit)
{
rhostd_=this->rho(Pstd,Tstd,Pstd*this->W()/(Tstd*this->R())); // Starting GUESS for the density by ideal gas law
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
// Construct as named copy
inline aungierRedlichKwong::aungierRedlichKwong(const word& name, aungierRedlichKwong& pg)
:
specie(name, pg),
pcrit_(pg.pcrit_),
Tcrit_(pg.Tcrit_),
azentricFactor_(pg.azentricFactor_)
{
pg.rhostd_=this->rho(Pstd,Tstd, (Pstd*this->W()/(Tstd*this->R()))); // Starting GUESS for the density by ideal gas law
}
// Construct and return a clone
inline autoPtr<aungierRedlichKwong> aungierRedlichKwong::clone() const
{
return autoPtr<aungierRedlichKwong>(new aungierRedlichKwong(*this));
}
// Selector from Istream
inline autoPtr<aungierRedlichKwong> aungierRedlichKwong::New(Istream& is)
{
return autoPtr<aungierRedlichKwong>(new aungierRedlichKwong(is));
}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
//- Return density [kg/m^3]
inline scalar aungierRedlichKwong::rho(const scalar p,const scalar T,const scalar rho0) const
{
scalar molarVolumePrevIteration;
scalar molarVolume;
int iter=0;
int maxIter_=400;
scalar tol_=1e-8;
int i;
scalar rho1=rhoMax_, rho2=rhoMin_,rho3, f1,f2,f3;
molarVolume=this->W()/rho0;
do
{
molarVolumePrevIteration= molarVolume;
i=0;
do
{
molarVolume=molarVolumePrevIteration-((this->pReturn((this->W()/molarVolumePrevIteration),T)-p)/(this->dpdv((this->W()/
molarVolumePrevIteration),T)))/(pow(2,i));
i++;
if(i>8)
{
//using bisection methode as backup, solution must be between rho=0.001 to rho=1500;
for(i=0;i<200;i++)
{
f1= (this->pReturn(rho1,T)-p);
f2= (this->pReturn(rho2,T)-p);
rho3=(rho1+rho2)/2;
f3=(this->pReturn(rho3,T)-p);
if ((f2<0 && f3>0)||(f2>0 &&f3<0))
{
rho1=rho3;
}
else if ((f1<0 && f3>0)||(f1>0 &&f3<0))
{
rho2=rho3;
}
else
{
rho2=(rho2+rho3)/2;
}
if(mag(f3)<p*tol_)
{
molarVolume=this->W()/rho3;
molarVolumePrevIteration=this->W()/rho3;
break;
}
else
{
molarVolumePrevIteration=this->W()/rho3;
}
}
}
}
while(mag(this->pReturn((this->W()/molarVolume),T)-p)>mag(this->pReturn((this->W()/molarVolumePrevIteration),T)-p));
if (iter++ > maxIter_)
{
FatalErrorIn
(
"inline scalar aungierRedlichKwong::rho(const scalar p,const scalar T,const scalar rho0) const "
) << "Maximum number of iterations exceeded"
<< abort(FatalError);
}
}
while(mag(molarVolumePrevIteration-molarVolume)>tol_*(this->W()/rho0));
return this->W()/molarVolume;
}
//- Return density [kg/m^3]on
inline scalar aungierRedlichKwong::rho(const scalar p,const scalar T) const
{
scalar rho0=p/(this->R()*T); //using perfect gas equation as starting point
return rho(p,T,rho0);
}
//- Return compressibility drho/dp [s^2/m^2]
inline scalar aungierRedlichKwong::psi(const scalar rho, const scalar T) const
{
return -this->dvdp(rho,T)*pow(rho,2)/this->W();
}
//- Return compression factor []
inline scalar aungierRedlichKwong::Z( const scalar p, const scalar T,const scalar rho0) const
{
return (p*this->rho(p,T,rho0))/(this->R()*T);
}
// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
inline void aungierRedlichKwong::operator+=(const aungierRedlichKwong& pg)
{
specie::operator+=(pg);
}
inline void aungierRedlichKwong::operator-=(const aungierRedlichKwong& pg)
{
specie::operator-=(pg);
}
inline void aungierRedlichKwong::operator*=(const scalar s)
{
specie::operator*=(s);
}
// * * * * * * * * * * * * * * * Friend Operators * * * * * * * * * * * * * //
//****************not working**************//
/*
inline aungierRedlichKwong operator+
(
const aungierRedlichKwong& pg1,
const aungierRedlichKwong& pg2
)
{
return aungierRedlichKwong
(
static_cast<const specie&>(pg1)
+ static_cast<const specie&>(pg2)
);
}
inline aungierRedlichKwong operator-
(
const aungierRedlichKwong& pg1,
const aungierRedlichKwong& pg2
)
{
return aungierRedlichKwong
(
static_cast<const specie&>(pg1)
- static_cast<const specie&>(pg2)
);
}
inline aungierRedlichKwong operator*
(
const scalar s,
const aungierRedlichKwong& pg
)
{
return aungierRedlichKwong(s*static_cast<const specie&>(pg));
}
inline aungierRedlichKwong operator==
(
const aungierRedlichKwong& pg1,
const aungierRedlichKwong& pg2
)
{
return pg2 - pg1;
}
*/
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// ************************************************************************* //

View file

@ -0,0 +1,79 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd |
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 2 of the License, or (at your
option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM; if not, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Description
Peng Robinson equation of state.
Author
Christian Lucas
Institut für Thermodynamik
Technische Universität Braunschweig
Germany
\*---------------------------------------------------------------------------*/
#include "pengRobinson.H"
#include "IOstreams.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
pengRobinson::pengRobinson(Istream& is)
:
specie(is),
pcrit_(readScalar(is)),
Tcrit_(readScalar(is)),
azentricFactor_(readScalar(is))
{
is.check("pengRobinson::pengRobinson(Istream& is)");
rhostd_=this->rho(Pstd,Tstd,Pstd*this->W()/(Tstd*this->R()));
rhoMax_=1500;
rhoMin_=0.001;
}
// * * * * * * * * * * * * * * * Ostream Operator * * * * * * * * * * * * * //
Ostream& operator<<(Ostream& os, const pengRobinson& pg)
{
os << static_cast<const specie&>(pg)<< tab
<< pg.pcrit_ << tab<< pg.Tcrit_<< tab << pg.azentricFactor_;
os.check("Ostream& operator<<(Ostream& os, const pengRobinson& st)");
return os;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// ************************************************************************* //

View file

@ -0,0 +1,192 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd |
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 2 of the License, or (at your
option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM; if not, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Class
Foam::pengRobinson
Description
Peng Robinson equation of state.
SourceFiles
pengRobinsonI.H
pengRobinson.C
Author
Christian Lucas
Institut für Thermodynamik
Technische Universität Braunschweig
Germany
\*---------------------------------------------------------------------------*/
#ifndef pengRobinson_H
#define pengRobinson_H
#include "specie.H"
#include "autoPtr.H"
#include "word.H"
#include "scalar.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
/*---------------------------------------------------------------------------*\
Class perfectGas Declaration
\*---------------------------------------------------------------------------*/
class pengRobinson
:
public specie
{
public:
// Constructors
//- Construct from components
inline pengRobinson(
const specie& sp,
scalar pcrit,
scalar Tcrit,
scalar azentricFactor
);
//- Construct from Istream
pengRobinson(Istream&);
//- Construct as named copy
inline pengRobinson(const word& name, pengRobinson&);
//- Construct and return a clone
inline autoPtr<pengRobinson> clone() const;
// Selector from Istream
inline static autoPtr<pengRobinson> New(Istream& is);
//Member Variabels
scalar pcrit_;
scalar Tcrit_;
scalar rhostd_;
scalar azentricFactor_;
scalar rhoMax_; //should be read from the fvSolution file where rhoMax and rhoMin values must be define ( for rhoSimpleFoam)
scalar rhoMin_;
// Member functions
inline scalar pcrit() const;
inline scalar Tcrit() const;
inline scalar azentricFactor() const;
inline scalar rhostd()const;
inline scalar pReturn(const scalar rho, const scalar T) const;
//-Redlich Kwong factors
inline scalar a() const;
inline scalar b() const;
inline scalar n() const;
//derivatives
inline scalar dpdv(const scalar rho,const scalar T) const;
inline scalar dpdT(const scalar rho, const scalar T) const;
inline scalar dvdT(const scalar rho,const scalar T) const;
inline scalar dvdp(const scalar rho, const scalar T) const;
inline scalar isobarExpCoef(const scalar rho,const scalar T) const;
inline scalar isothermalCompressiblity(const scalar rho,const scalar T) const;
inline scalar integral_d2pdT2_dv(const scalar rho,const scalar T) const ; // Used for cv
inline scalar d2pdv2(const scalar rho,const scalar T) const; // not Used At The Moment
inline scalar d2pdT2(const scalar rho,const scalar T) const; // not Used At The Moment
inline scalar d2pdvdT(const scalar rho,const scalar T) const; // not Used At The Moment
inline scalar d2vdT2(const scalar rho,const scalar T) const; // not Used At The Moment
inline scalar integral_p_dv(const scalar rho,const scalar T) const; //Used for internal Energy
inline scalar integral_dpdT_dv(const scalar rho,const scalar T) const; //Used for Entropy
//- Return density [kg/m^3] // rho0 is the starting point of the newton solver used to calculate rho
inline scalar rho(const scalar p,const scalar T,const scalar rho0) const;
inline scalar rho(const scalar p,const scalar T) const;
//- Return compressibility rho/p [s^2/m^2] // rho0 is the starting point of the newton solver used to calculate rho
inline scalar psi(const scalar rho, const scalar T) const;
//- Return compression factor []
inline scalar Z(const scalar p,const scalar T,const scalar rho0) const;
// Member operators
inline void operator+=(const pengRobinson&);
inline void operator-=(const pengRobinson&);
inline void operator*=(const scalar);
/* // Friend operators
inline friend pengRobinson operator+
(
const pengRobinson&,
const pengRobinson&
);
inline friend pengRobinson operator-
(
const pengRobinson&,
const pengRobinson&
);
inline friend pengRobinson operator*
(
const scalar s,
const pengRobinson&
);
inline friend pengRobinson operator==
(
const pengRobinson&,
const pengRobinson&
);
*/
// Ostream Operator
friend Ostream& operator<<(Ostream&, const pengRobinson&);
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#include "pengRobinsonI.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View file

@ -0,0 +1,513 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd |
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 2 of the License, or (at your
option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM; if not, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Author
Christian Lucas
Institut für Thermodynamik
Technische Universität Braunschweig
Germany
\*---------------------------------------------------------------------------*/
#include "pengRobinson.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
inline scalar pengRobinson::pcrit()const
{
return pcrit_;
}
inline scalar pengRobinson::Tcrit()const
{
return Tcrit_;
}
inline scalar pengRobinson::rhostd()const
{
return rhostd_;
}
// Returns the Azentric Factor (Acentric Factor)
inline scalar pengRobinson::azentricFactor() const
{
return azentricFactor_;
}
//returns the pressure for a given density and temperature
inline scalar pengRobinson::pReturn(const scalar rho,const scalar T) const
{
return this->RR*T/((this->W()/rho)-this->b())-(this->a()*pow((1+this->n()*(1-pow((T/this->Tcrit()),0.5))),2))/(pow((this->W()/rho),2)+2*this->b()*(this->W()/rho)-pow(this->b(),2));
}
// Factor a of the pengRobinson equation of state
//(molar values)
inline scalar pengRobinson::a() const
{
return 0.457235*pow(this->RR,2)*pow(this->Tcrit(),2)/this->pcrit();
}
// Factor b of the pengRobinson equation of state
//(molar values)
inline scalar pengRobinson::b() const
{
return 0.077796*this->RR*this->Tcrit()/this->pcrit();
}
// Factor nb of the pengRobinson equation of state
//(molar values)
inline scalar pengRobinson::n() const
{
// this equation is only valid for asentricFactors <0.49.
return 0.37464+1.54226*this->azentricFactor()-0.26992*pow(this->azentricFactor(),2);
}
//* * * * * * * * * * * * * Derivatives * * * * * * * * * * * //
//Real deviative dp/dv at constant temperature
//(molar values)
inline scalar pengRobinson::dpdv(const scalar rho, const scalar T) const
{
return -(4*this->a()*this->n()*this->Tcrit()*(this->b()-(this->W()/rho))*(pow(this->b(),2)-pow((this->W()/rho),2))*(this->n()+1)
*pow((T/this->Tcrit()),0.5)
+this->Tcrit()*(-2*this->a()*pow((this->n()+1),2)*(pow(this->b(),3)-pow(this->b(),2)*(this->W()/rho)
-this->b()*pow((this->W()/rho),2)+pow((this->W()/rho),3))
+this->RR*T*(pow(this->b(),4)-4*pow(this->b(),3)*(this->W()/rho)+2*pow(this->b(),2)*pow((this->W()/rho),2)
+4*this->b()*pow((this->W()/rho),3)+pow((this->W()/rho),4)))
-2*this->a()*pow(this->n(),2)*T*(pow(this->b(),3)-pow(this->b(),2)*(this->W()/rho)-this->b()*pow((this->W()/rho),2)+pow((this->W()/rho),3)))
/(this->Tcrit()*pow((this->b()-(this->W()/rho)),2)*pow((pow(this->b(),2)-2*this->b()*(this->W()/rho)-pow((this->W()/rho),2)),2));
}
//Real deviative dp/dT at constant molar volume
//(molar values)
inline scalar pengRobinson::dpdT(const scalar rho, const scalar T) const
{
return (-this->a()*this->n()*(this->n()+1)*pow((T/this->Tcrit()),0.5)/(T*(pow(this->b(),2)-2*this->b()*(this->W()/rho)-pow((this->W()/rho),2)))+this->a()*pow(this->n(),2)/(this->Tcrit()*(pow(this->b(),2)-2*this->b()*(this->W()/rho)-pow((this->W()/rho),2)))-this->RR/(this->b()-(this->W()/rho)));
}
//Real deviative dv/dT at constant pressure
//by using implicit differentiation
//(molar values)
inline scalar pengRobinson::dvdT(const scalar rho,const scalar T) const
{
return (-1)*this->dpdT(rho,T)/this->dpdv(rho,T);
}
//(molar values)
inline scalar pengRobinson::dvdp(const scalar rho,const scalar T) const
{
return 1/this->dpdv(rho,T);
}
//(molar values)
//needed to calculate the internal energy
inline scalar pengRobinson::integral_p_dv(const scalar rho,const scalar T) const
{
return pow(2,0.5)*this->a()*(2*this->n()*this->Tcrit()*(this->n()+1)*pow(T/this->Tcrit(),0.5)
-this->Tcrit()*(pow(this->n(),2)+2*this->n()+1)-pow(this->n(),2)*T)*log(this->b()*(1-pow(2,0.5))+(this->W()/rho))/(4*this->b()*this->Tcrit())
+this->RR*T*log((this->W()/rho)-this->b())
-pow(2,0.5)*this->a()*(2*this->n()*this->Tcrit()*(this->n()+1)*pow(T/this->Tcrit(),0.5)
-this->Tcrit()*(pow(this->n(),2)+2*this->n()+1)-pow(this->n(),2)*T)
*log(this->b()*(pow(2,0.5)+1)+(this->W()/rho))/(4*this->b()*this->Tcrit());
}
//(molar values)
//needed to calculate the entropy
inline scalar pengRobinson::integral_dpdT_dv(const scalar rho,const scalar T) const
{
return (pow(2,0.5)*this->a()*this->n()*(this->n()+1)*pow(T/this->Tcrit(),0.5)/(4*this->b()*T)
-pow(2,0.5)*this->a()*pow(this->n(),2)/(4*this->b()*this->Tcrit()))
*log(this->b()*(1-pow(2,0.5))+(this->W()/rho))
+this->RR*log((this->W()/rho)-this->b())
+(pow(2,0.5)*this->a()*pow(this->n(),2)/(4*this->b()*this->Tcrit())
-pow(2,0.5)*this->a()*this->n()*(this->n()+1)*pow(T/this->Tcrit(),0.5)/(4*this->b()*T))
*log(this->b()*(pow(2,0.5)+1)+(this->W()/rho));
}
//* * * * * * * * * * * * * second order Derivative based functions * * * * * * * * * * * //
//(molar values)
inline scalar pengRobinson::d2pdT2(const scalar rho,const scalar T) const
{
return this->a()*this->n()*(this->n()+1)*pow((T/this->Tcrit()),0.5)/(2*pow(T,2)*(pow(this->b(),2)-2*this->b()*(this->W()/rho)-pow((this->W()/rho),2)));
}
//(molar values)
inline scalar pengRobinson::d2pdv2(const scalar rho,const scalar T) const
{
return 2*(2*this->a()*this->n()*this->Tcrit()*(this->b()-(this->W()/rho))*(this->n()+1)*
(5*pow(this->b(),4)-4*pow(this->b(),3)*(this->W()/rho)-4*pow(this->b(),2)*pow((this->W()/rho),2)
+3*pow((this->W()/rho),4))*pow(T/this->Tcrit(),0.5)
+this->Tcrit()*(this->RR*T*(pow(this->b(),6)-6*pow(this->b(),5)*(this->W()/rho)+9*pow(this->b(),4)*pow((this->W()/rho),2)
+4*pow(this->b(),3)*pow((this->W()/rho),3)-9*pow(this->b(),2)*pow((this->W()/rho),4)-6*this->b()*pow((this->W()/rho),5)
-pow((this->W()/rho),6))
-this->a()*pow((this->n()+1),2)*(5*pow(this->b(),5)-9*pow(this->b(),4)*(this->W()/rho)
+4*pow(this->b(),2)*pow((this->W()/rho),3)+3*this->b()*pow((this->W()/rho),4)-3*pow((this->W()/rho),5)))
-this->a()*pow(this->n(),2)*T*(5*pow(this->b(),5)-9*pow(this->b(),4)*(this->W()/rho)+4*pow(this->b(),2)*pow((this->W()/rho),3)
+3*this->b()*pow((this->W()/rho),4)-3*pow((this->W()/rho),5)))
/(this->Tcrit()*pow((pow(this->b(),2)-2*this->b()*(this->W()/rho)-pow((this->W()/rho),2)),3)*pow(((this->W()/rho)-this->b()),3));
}
//(molar values)
//using second order implicit differentiation
inline scalar pengRobinson::d2vdT2(const scalar rho, const scalar T) const
{
return -(pow(this->dpdT(rho,T),2)*this->d2pdv2(rho,T)+ pow(this->dpdv(rho,T),2) *this->d2pdT2(rho,T)- 2*this->dpdv(rho,T)*this->dpdT(rho,T)*this->d2pdvdT(rho,T))/( pow(this->dpdv(rho,T),3));
}
//(molar values)
inline scalar pengRobinson::d2pdvdT(const scalar rho, const scalar T) const
{
return -2*this->a()*this->n()*(this->b()+(this->W()/rho))*(this->n()+1)*pow(T/this->Tcrit(),0.5)
/(T*pow((pow(this->b(),2)-2*this->b()*(this->W()/rho)-pow((this->W()/rho),2)),2))+(2*this->a()*pow(this->n(),2)*(this->b()+(this->W()/rho)))/(this->Tcrit()*pow(pow(this->b(),2)-2*this->b()*(this->W()/rho)-pow((this->W()/rho),2),2))-this->RR/(pow(this->b()-(this->W()/rho),2));
}
// the result of this intergal is needed for the nasa based cp polynomial
//(molar values)
inline scalar pengRobinson::integral_d2pdT2_dv(const scalar rho,const scalar T) const
{
return pow(2,0.5)*this->a()*this->n()*(this->n()+1)*pow(T/this->Tcrit(),0.5)
*log(this->b()*(pow(2,0.5)+1)+(this->W()/rho))/(8*this->b()*pow(T,2))
-pow(2,0.5)*this->a()*this->n()*(this->n()+1)*pow(T/this->Tcrit(),0.5)
*log(this->b()*(1-pow(2,0.5))+(this->W()/rho))/(8*this->b()*pow(T,2));
}
//* * * * * * * * * * * * * thermodynamic properties * * * * * * * * * * * //
//Isobar expansion Coefficent beta = 1/v (dv/dt) at constant p
//(molar values)
inline scalar pengRobinson::isobarExpCoef(const scalar rho,const scalar T) const
{
return this->dvdT(rho, T)*rho/this->W();
}
//isothemal compressiblity kappa
//(molar values)
inline scalar pengRobinson::isothermalCompressiblity(const scalar rho,const scalar T) const
{
return this->isobarExpCoef(rho, T)/this->dpdT(rho, T);
//also possible : return -this->dvdp(rho,T)*rho/this->W();
}
// Construct from components
inline pengRobinson::pengRobinson
(
const specie& sp,
scalar pcrit,
scalar Tcrit,
scalar azentricFactor
)
:
specie(sp),
pcrit_(pcrit),
Tcrit_(Tcrit),
azentricFactor_(azentricFactor)
{
rhostd_=this->rho(Pstd,Tstd,Pstd*this->W()/(Tstd*this->R())); // Starting GUESS for the density by ideal gas law
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
// Construct as named copy
inline pengRobinson::pengRobinson(const word& name, pengRobinson& pg)
:
specie(name, pg),
pcrit_(pg.pcrit_),
Tcrit_(pg.Tcrit_),
azentricFactor_(pg.azentricFactor_)
{
pg.rhostd_=this->rho(Pstd,Tstd, (Pstd*this->W()/(Tstd*this->R()))); // Starting GUESS for the density by ideal gas law
}
// Construct and return a clone
inline autoPtr<pengRobinson> pengRobinson::clone() const
{
return autoPtr<pengRobinson>(new pengRobinson(*this));
}
// Selector from Istream
inline autoPtr<pengRobinson> pengRobinson::New(Istream& is)
{
return autoPtr<pengRobinson>(new pengRobinson(is));
}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
//- Return density [kg/m^3]
// TO DO Include a max Iteration number loop and abort function
inline scalar pengRobinson::rho(const scalar p,const scalar T,const scalar rho0) const
{
scalar molarVolumePrevIteration;
scalar molarVolume;
int iter=0;
int i;
int maxIter_=400;
scalar tol_=1e-8;
scalar rho1=rhoMax_, rho2=rhoMin_,rho3, f1,f2,f3;
molarVolume=this->W()/rho0;
do
{
molarVolumePrevIteration= molarVolume;
i=0;
do
{
molarVolume=molarVolumePrevIteration-((this->pReturn((this->W()/molarVolumePrevIteration),T)-p)/(this->dpdv((this->W()/
molarVolumePrevIteration),T)))/(pow(2,i));
i++;
if(i>8)
{
//using bisection methode as backup, solution must be between rho=0.001 to rho=1500;
for(i=0;i<200;i++)
{
f1= (this->pReturn(rho1,T)-p);
f2= (this->pReturn(rho2,T)-p);
rho3=(rho1+rho2)/2;
f3=(this->pReturn(rho3,T)-p);
if ((f2<0 && f3>0)||(f2>0 &&f3<0))
{
rho1=rho3;
}
else if ((f1<0 && f3>0)||(f1>0 &&f3<0))
{
rho2=rho3;
}
else
{
rho2=(rho2+rho3)/2;
}
if(mag(f3)<p*tol_)
{
molarVolume=this->W()/rho3;
molarVolumePrevIteration=this->W()/rho3;
break;
}
else
{
molarVolumePrevIteration=this->W()/rho3;
}
}
}
}
while(mag(this->pReturn((this->W()/molarVolume),T)-p)>mag(this->pReturn((this->W()/molarVolumePrevIteration),T)-p));
if (iter++ > maxIter_)
{
FatalErrorIn
(
"inline scalar pengRobinson::rho(const scalar p,const scalar T,const scalar rho0) const "
) << "Maximum number of iterations exceeded"
<< abort(FatalError);
}
}
while(mag(molarVolumePrevIteration-molarVolume)>tol_*(this->W()/rho0));
return this->W()/molarVolume;
}
//- Return density [kg/m^3]on
inline scalar pengRobinson::rho(const scalar p,const scalar T) const
{
scalar rho0=p/(this->R()*T); //using perfect gas equation as starting point
return rho(p,T,rho0);
}
//- Return compressibility drho/dp [s^2/m^2]
inline scalar pengRobinson::psi(const scalar rho, const scalar T) const
{
return -this->dvdp(rho,T)*pow(rho,2)/this->W();
}
//- Return compression factor []
inline scalar pengRobinson::Z( const scalar p, const scalar T,const scalar rho0) const
{
return (p*this->rho(p,T,rho0))/(this->R()*T);
}
// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
inline void pengRobinson::operator+=(const pengRobinson& pg)
{
specie::operator+=(pg);
}
inline void pengRobinson::operator-=(const pengRobinson& pg)
{
specie::operator-=(pg);
}
inline void pengRobinson::operator*=(const scalar s)
{
specie::operator*=(s);
}
// * * * * * * * * * * * * * * * Friend Operators * * * * * * * * * * * * * //
//****************not working**************//
/*
inline pengRobinson operator+
(
const pengRobinson& pg1,
const pengRobinson& pg2
)
{
return pengRobinson
(
static_cast<const specie&>(pg1)
+ static_cast<const specie&>(pg2)
);
}
inline pengRobinson operator-
(
const pengRobinson& pg1,
const pengRobinson& pg2
)
{
return pengRobinson
(
static_cast<const specie&>(pg1)
- static_cast<const specie&>(pg2)
);
}
inline pengRobinson operator*
(
const scalar s,
const pengRobinson& pg
)
{
return pengRobinson(s*static_cast<const specie&>(pg));
}
inline pengRobinson operator==
(
const pengRobinson& pg1,
const pengRobinson& pg2
)
{
return pg2 - pg1;
}
*/
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// ************************************************************************* //

View file

@ -0,0 +1,77 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd |
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 2 of the License, or (at your
option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM; if not, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Description
Redlich Kwong equation of state.
Author
Christian Lucas
Institut für Thermodynamik
Technische Universität Braunschweig
Germany
\*---------------------------------------------------------------------------*/
#include "redlichKwong.H"
#include "IOstreams.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
redlichKwong::redlichKwong(Istream& is)
:
specie(is),
pcrit_(readScalar(is)),
Tcrit_(readScalar(is)),
azentricFactor_(readScalar(is))
{
is.check("redlichKwong::redlichKwong(Istream& is)");
rhostd_=this->rho(Pstd,Tstd,Pstd*this->W()/(Tstd*this->R()));
rhoMax_=1500;
rhoMin_=0.001;
}
// * * * * * * * * * * * * * * * Ostream Operator * * * * * * * * * * * * * //
Ostream& operator<<(Ostream& os, const redlichKwong& pg)
{
os << static_cast<const specie&>(pg)<< tab
<< pg.pcrit_ << tab<< pg.Tcrit_<< tab << pg.azentricFactor_;
os.check("Ostream& operator<<(Ostream& os, const redlichKwong& st)");
return os;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// ************************************************************************* //

View file

@ -0,0 +1,191 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd |
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 2 of the License, or (at your
option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM; if not, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Class
Foam::redlichKwong
Description
Redlich Kwong equation of state.
SourceFiles
redlichKwongI.H
redlichKwong.C
Author
Christian Lucas
Institut für Thermodynamik
Technische Universität Braunschweig
Germany
\*---------------------------------------------------------------------------*/
#ifndef redlichKwong_H
#define redlichKwong_H
#include "specie.H"
#include "autoPtr.H"
#include "word.H"
#include "scalar.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
/*---------------------------------------------------------------------------*\
Class perfectGas Declaration
\*---------------------------------------------------------------------------*/
class redlichKwong
:
public specie
{
public:
// Constructors
//- Construct from components
inline redlichKwong(
const specie& sp,
scalar pcrit,
scalar Tcrit,
scalar azentricFactor
);
//- Construct from Istream
redlichKwong(Istream&);
//- Construct as named copy
inline redlichKwong(const word& name, redlichKwong&);
//- Construct and return a clone
inline autoPtr<redlichKwong> clone() const;
// Selector from Istream
inline static autoPtr<redlichKwong> New(Istream& is);
//Member Variabels
scalar pcrit_;
scalar Tcrit_;
scalar rhostd_;
scalar azentricFactor_;
scalar rhoMax_; //should be read from the fvSolution file where rhoMax and rhoMin values must be define ( for rhoSimpleFoam)
scalar rhoMin_;
// Member functions
inline scalar pcrit() const;
inline scalar Tcrit() const;
inline scalar rhostd()const;
inline scalar azentricFactor() const;
inline scalar pReturn(const scalar rho, const scalar T) const;
//-Redlich Kwong factors
inline scalar a() const;
inline scalar b() const;
//derivatives
inline scalar dpdv(const scalar rho,const scalar T) const;
inline scalar dpdT(const scalar rho, const scalar T) const;
inline scalar dvdT(const scalar rho,const scalar T) const;
inline scalar dvdp(const scalar rho, const scalar T) const;
inline scalar isobarExpCoef(const scalar rho,const scalar T) const;
inline scalar isothermalCompressiblity(const scalar rho,const scalar T) const;
inline scalar integral_d2pdT2_dv(const scalar rho,const scalar T) const ; // Used for cv
inline scalar d2pdv2(const scalar rho,const scalar T) const; // not Used At The Moment
inline scalar d2pdT2(const scalar rho,const scalar T) const; // not Used At The Moment
inline scalar d2pdvdT(const scalar rho,const scalar T) const; // not Used At The Moment
inline scalar d2vdT2(const scalar rho,const scalar T) const; // not Used At The Moment
inline scalar integral_p_dv(const scalar rho,const scalar T) const; //Used for internal Energy
inline scalar integral_dpdT_dv(const scalar rho,const scalar T) const; //Used for Entropy
//- Return density [kg/m^3] // rho0 is the starting point of the newton solver used to calculate rho
inline scalar rho(const scalar p,const scalar T,const scalar rho0) const;
inline scalar rho(const scalar p,const scalar T) const;
//- Return compressibility drho/dp [s^2/m^2]
inline scalar psi(const scalar rho, const scalar T) const;
//- Return compression factor []
inline scalar Z(const scalar p,const scalar T,const scalar rho0) const;
// Member operators
inline void operator+=(const redlichKwong&);
inline void operator-=(const redlichKwong&);
inline void operator*=(const scalar);
/* // Friend operators
inline friend redlichKwong operator+
(
const redlichKwong&,
const redlichKwong&
);
inline friend redlichKwong operator-
(
const redlichKwong&,
const redlichKwong&
);
inline friend redlichKwong operator*
(
const scalar s,
const redlichKwong&
);
inline friend redlichKwong operator==
(
const redlichKwong&,
const redlichKwong&
);
*/
// Ostream Operator
friend Ostream& operator<<(Ostream&, const redlichKwong&);
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#include "redlichKwongI.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View file

@ -0,0 +1,476 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd |
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 2 of the License, or (at your
option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM; if not, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Author
Christian Lucas
Institut für Thermodynamik
Technische Universität Braunschweig
Germany
\*---------------------------------------------------------------------------*/
#include "redlichKwong.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
inline scalar redlichKwong::pcrit()const
{
return pcrit_;
}
inline scalar redlichKwong::Tcrit()const
{
return Tcrit_;
}
// Returns the Azentric Factor (Acentric Factor)
inline scalar redlichKwong::azentricFactor() const
{
return azentricFactor_;
}
inline scalar redlichKwong::rhostd()const
{
return rhostd_;
}
//returns the pressure for a given density and temperature
inline scalar redlichKwong::pReturn(const scalar rho,const scalar T) const
{
return (this->RR *T/((this->W()/rho)-this->b()) - (this->a()/(sqrt(T)*(this->W()/rho)*((this->W()/rho)+this->b()))));
}
// Faktor a of the redlich Kwong equation of state
//(molar values)
inline scalar redlichKwong::a() const
{
return 0.42748*pow(this->RR,2)*pow(this->Tcrit(),2.5)/(this->pcrit());
}
// Faktor b of the redlich Kwong equation of state
//(molar values)
inline scalar redlichKwong::b() const
{
return 0.08664*this->RR*this->Tcrit()/this->pcrit();
}
//* * * * * * * * * * * * * Derivatives * * * * * * * * * * * //
//Real deviative dp/dv at constant temperature
//(molar values)
inline scalar redlichKwong::dpdv(const scalar rho, const scalar T) const
{
return (this->a()*(pow(this->b(),3)-3*this->b()*pow((this->W()/rho),2)+2*pow((this->W()/rho),3))-this->RR*pow(T,1.5)*pow((this->W()/rho),2) *(pow(this->b(),2)+2*this->b()*(this->W()/rho)+pow((this->W()/rho),2))) / ( sqrt(T) * pow((this->W()/rho),2) * pow((this->b()+(this->W()/rho)),2) *pow( (this->b()-(this->W()/rho)),2) );
}
//Real deviative dp/dT at constant molar volume
//(molar values)
inline scalar redlichKwong::dpdT(const scalar rho, const scalar T) const
{
return 0.5*this->a()/(pow(T,1.5)*(this->W()/rho)*(this->b()+(this->W()/rho)))-this->RR/(this->b()-(this->W()/rho));
}
//Real deviative dv/dT at constant pressure
//using implicit differentiation
//(molar values)
inline scalar redlichKwong::dvdT(const scalar rho,const scalar T) const
{
return (-1)*this->dpdT(rho,T)/this->dpdv(rho,T);
}
//Real deviative dv/dp at constant temperature
//(molar values)
inline scalar redlichKwong::dvdp(const scalar rho,const scalar T) const
{
return 1/this->dpdv(rho,T);
}
//needed to calculate the internal energy
//(molar values)
inline scalar redlichKwong::integral_p_dv(const scalar rho,const scalar T) const
{
return this->RR*T*log((this->W()/rho)-this->b())+(this->a()*log(this->b()+(this->W()/rho)))/(this->b()*sqrt(T))-(this->a()*log(this->W()/rho))/(this->b()*sqrt(T));
}
//needed to calculate the entropy
//(molar values)
inline scalar redlichKwong::integral_dpdT_dv(const scalar rho,const scalar T) const
{
return this->RR*log((this->W()/rho)-this->b())
-(this->a()*log(this->b()+(this->W()/rho)))/(2*this->b()* pow(T,1.5) )
+(this->a()*log(this->W()/rho))/(2*this->b()* pow(T,1.5));
}
//* * * * * * * * * * * * * second order Derivative based functions * * * * * * * * * * * //
//(molar values)
inline scalar redlichKwong::d2pdT2(const scalar rho,const scalar T) const
{
return -0.75*this->a()/( pow(T,2.5)*(this->W()/rho)*(this->b()+(this->W()/rho)));
}
//(molar values)
inline scalar redlichKwong::d2pdv2(const scalar rho,const scalar T) const
{
return
(
2*(this->a()*(pow(this->b(),5)-3*pow(this->b(),3)*pow((this->W()/rho),2)-pow(this->b(),2)*pow((this->W()/rho),3)+6*this->b()*pow((this->W()/rho),4)-3*pow((this->W()/rho),5))+this->RR*pow(T,1.5)*pow((this->W()/rho),3)
*(pow(this->b(),3)+3*pow(this->b(),2)*(this->W()/rho)+3*this->b()*pow((this->W()/rho),2)+pow((this->W()/rho),3)))/( sqrt(T)* pow((this->W()/rho),3) *pow( (this->b()+(this->W()/rho)) ,3)* pow((this->W()/rho)-this->b(),3)));
}
//(molar values)
//using second Order implicit differentiation
inline scalar redlichKwong::d2vdT2(const scalar rho, const scalar T) const
{
return -(pow(this->dpdT(rho,T),2)*this->d2pdv2(rho,T)+ pow(this->dpdv(rho,T),2) *this->d2pdT2(rho,T)- 2*this->dpdv(rho,T)*this->dpdT(rho,T)*this->d2pdvdT(rho,T))/( pow(this->dpdv(rho,T),3));
}
//(molar values)
inline scalar redlichKwong::d2pdvdT(const scalar rho, const scalar T) const
{
return -(0.5*(this->a()*( pow(this->b(),3)-3*this->b()* pow((this->W()/rho),2) +2* pow((this->W()/rho),3) )+2*this->RR*pow(T,1.5)* pow((this->W()/rho),2)*( pow(this->b(),2) + 2*this->b()*(this->W()/rho)+ pow((this->W()/rho),2) )))/( pow(T,1.5)* pow((this->W()/rho),2)*pow(this->b()+(this->W()/rho),2)*pow(this->b()-(this->W()/rho),2));
}
// the result of this intergal is needed for the nasa based cp polynomial
//(molar values)
inline scalar redlichKwong::integral_d2pdT2_dv(const scalar rho,const scalar T) const
{
return 0.75*this->a()*log(this->b() + (this->W()/rho))/(pow(T,2.5)*this->b()) - 0.75*this->a()*log((this->W()/rho))/(pow(T,2.5)*this->b());
}
//* * * * * * * * * * * * * thermodynamic properties * * * * * * * * * * * //
//Isobar expansion Coefficent beta = 1/v (dv/dt) at constant p
//(molar values)
inline scalar redlichKwong::isobarExpCoef(const scalar rho,const scalar T) const
{
return this->dvdT(rho, T)*rho/this->W();
}
//isothemal compressiblity kappa
//(molar values)
inline scalar redlichKwong::isothermalCompressiblity(const scalar rho,const scalar T) const
{
return this->isobarExpCoef(rho, T)/this->dpdT(rho, T);
//also possible : return -this->dvdp(rho,T)*rho/this->W();
}
// Construct from components
inline redlichKwong::redlichKwong
(
const specie& sp,
scalar pcrit,
scalar Tcrit,
scalar azentricFactor
)
:
specie(sp),
pcrit_(pcrit),
Tcrit_(Tcrit),
azentricFactor_(azentricFactor)
{
rhostd_=this->rho(Pstd,Tstd,Pstd*this->W()/(Tstd*this->R())); // Starting GUESS for the density by ideal gas law
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
// Construct as named copy
// Starting GUESS for the density by ideal gas law
inline redlichKwong::redlichKwong(const word& name, redlichKwong& pg)
:
specie(name, pg),
pcrit_(pg.pcrit_),
Tcrit_(pg.Tcrit_),
azentricFactor_(pg.azentricFactor_)
{
pg.rhostd_=this->rho(Pstd,Tstd, (Pstd*this->W()/(Tstd*this->R()))); // Starting GUESS for the density by ideal gas law
}
// Construct and return a clone
inline autoPtr<redlichKwong> redlichKwong::clone() const
{
return autoPtr<redlichKwong>(new redlichKwong(*this));
}
// Selector from Istream
inline autoPtr<redlichKwong> redlichKwong::New(Istream& is)
{
return autoPtr<redlichKwong>(new redlichKwong(is));
}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
//- Return density [kg/m^3]on
inline scalar redlichKwong::rho(const scalar p,const scalar T,const scalar rho0) const
{
scalar molarVolumePrevIteration;
scalar molarVolume;
int iter=0;
int maxIter_=400;
scalar tol_=1e-8;
int i;
scalar rho1=rhoMax_, rho2=rhoMin_,rho3, f1,f2,f3;
molarVolume=this->W()/rho0;
do
{
molarVolumePrevIteration= molarVolume;
i=0;
do
{
molarVolume=molarVolumePrevIteration-((this->pReturn((this->W()/molarVolumePrevIteration),T)-p)/(this->dpdv((this->W()/
molarVolumePrevIteration),T)))/(pow(2,i));
i++;
if(i>8)
{
//using bisection methode as backup, solution must be between rho=0.001 to rho=1500;
for(i=0;i<200;i++)
{
f1= (this->pReturn(rho1,T)-p);
f2= (this->pReturn(rho2,T)-p);
rho3=(rho1+rho2)/2;
f3=(this->pReturn(rho3,T)-p);
if ((f2<0 && f3>0)||(f2>0 &&f3<0))
{
rho1=rho3;
}
else if ((f1<0 && f3>0)||(f1>0 &&f3<0))
{
rho2=rho3;
}
else
{
rho2=(rho2+rho3)/2;
}
if(mag(f3)<p*tol_)
{
molarVolume=this->W()/rho3;
molarVolumePrevIteration=this->W()/rho3;
break;
}
else
{
molarVolumePrevIteration=this->W()/rho3;
}
}
}
}
while(mag(this->pReturn((this->W()/molarVolume),T)-p)>mag(this->pReturn((this->W()/molarVolumePrevIteration),T)-p));
if (iter++ > maxIter_)
{
FatalErrorIn
(
"inline scalar redlichKwong::rho(const scalar p,const scalar T,const scalar rho0) const "
) << "Maximum number of iterations exceeded"
<< abort(FatalError);
}
}
while(mag(molarVolumePrevIteration-molarVolume)>tol_*(this->W()/rho0));
return this->W()/molarVolume;
}
//- Return density [kg/m^3]on
inline scalar redlichKwong::rho(const scalar p,const scalar T) const
{
scalar rho0=p/(this->R()*T); //using perfect gas equation as starting point
return rho(p,T,rho0);
}
//- Return compressibility drho/dp [s^2/m^2]
inline scalar redlichKwong::psi(const scalar rho, const scalar T) const
{
return -this->dvdp(rho,T)*pow(rho,2)/this->W();
}
//- Return compression factor []
inline scalar redlichKwong::Z( const scalar p, const scalar T,const scalar rho0) const
{
return (p*this->rho(p,T,rho0))/(this->R()*T);
}
// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
inline void redlichKwong::operator+=(const redlichKwong& pg)
{
specie::operator+=(pg);
}
inline void redlichKwong::operator-=(const redlichKwong& pg)
{
specie::operator-=(pg);
}
inline void redlichKwong::operator*=(const scalar s)
{
specie::operator*=(s);
}
// * * * * * * * * * * * * * * * Friend Operators * * * * * * * * * * * * * //
//****************not working**************////
/*
inline redlichKwong operator+
(
const redlichKwong& pg1,
const redlichKwong& pg2
)
{
return redlichKwong
(
static_cast<const specie&>(pg1)
+ static_cast<const specie&>(pg2)
);
}
inline redlichKwong operator-
(
const redlichKwong& pg1,
const redlichKwong& pg2
)
{
return redlichKwong
(
static_cast<const specie&>(pg1)
- static_cast<const specie&>(pg2)
);
}
inline redlichKwong operator*
(
const scalar s,
const redlichKwong& pg
)
{
return redlichKwong(s*static_cast<const specie&>(pg));
}
inline redlichKwong operator==
(
const redlichKwong& pg1,
const redlichKwong& pg2
)
{
return pg2 - pg1;
}
*/
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// ************************************************************************* //

View file

@ -0,0 +1,76 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd |
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 2 of the License, or (at your
option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM; if not, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Description
Soave Redlich Kwong equation of state.
Author
Christian Lucas
Institut für Thermodynamik
Technische Universität Braunschweig
Germany
\*---------------------------------------------------------------------------*/
#include "soaveRedlichKwong.H"
#include "IOstreams.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
soaveRedlichKwong::soaveRedlichKwong(Istream& is)
:
specie(is),
pcrit_(readScalar(is)),
Tcrit_(readScalar(is)),
azentricFactor_(readScalar(is))
{
is.check("soaveRedlichKwong::soaveRedlichKwong(Istream& is)");
rhostd_=this->rho(Pstd,Tstd,Pstd*this->W()/(Tstd*this->R()));
rhoMax_=1500;
rhoMin_=0.001;
}
// * * * * * * * * * * * * * * * Ostream Operator * * * * * * * * * * * * * //
Ostream& operator<<(Ostream& os, const soaveRedlichKwong& pg)
{
os << static_cast<const specie&>(pg)<< tab
<< pg.pcrit_ << tab<< pg.Tcrit_<<tab<<pg.azentricFactor_;
os.check("Ostream& operator<<(Ostream& os, const soaveRedlichKwong& st)");
return os;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// ************************************************************************* //

View file

@ -0,0 +1,191 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 2 of the License, or (at your
option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM; if not, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Class
Foam::soaveRedlichKwong
Description
Soave Redlich Kwong equation of state.
SourceFiles
soaveRedlichKwongI.H
soaveRedlichKwong.C
Author
Christian Lucas
Institut für Thermodynamik
Technische Universität Braunschweig
Germany
\*---------------------------------------------------------------------------*/
#ifndef soaveRedlichKwong_H
#define soaveRedlichKwong_H
#include "specie.H"
#include "autoPtr.H"
#include "word.H"
#include "scalar.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
/*---------------------------------------------------------------------------*\
Class perfectGas Declaration
\*---------------------------------------------------------------------------*/
class soaveRedlichKwong
:
public specie
{
public:
// Constructors
//- Construct from components
inline soaveRedlichKwong(
const specie& sp,
scalar pcrit,
scalar Tcrit,
scalar azentricFactor
);
//- Construct from Istream
soaveRedlichKwong(Istream&);
//- Construct as named copy
inline soaveRedlichKwong(const word& name, soaveRedlichKwong&);
//- Construct and return a clone
inline autoPtr<soaveRedlichKwong> clone() const;
// Selector from Istream
inline static autoPtr<soaveRedlichKwong> New(Istream& is);
//Member Variabels
scalar pcrit_;
scalar Tcrit_;
scalar rhostd_;
scalar azentricFactor_;
scalar rhoMax_; //should be read from the fvSolution file where rhoMax and rhoMin values must be define ( for rhoSimpleFoam)
scalar rhoMin_;
// Member functions
inline scalar pcrit() const;
inline scalar Tcrit() const;
inline scalar azentricFactor() const;
inline scalar rhostd()const;
inline scalar pReturn(const scalar rho, const scalar T) const;
//-Redlich Kwong factors
inline scalar a() const;
inline scalar b() const;
inline scalar n() const;
//derivatives
inline scalar dpdv(const scalar rho,const scalar T) const;
inline scalar dpdT(const scalar rho, const scalar T) const;
inline scalar dvdT(const scalar rho,const scalar T) const;
inline scalar dvdp(const scalar rho, const scalar T) const;
inline scalar isobarExpCoef(const scalar rho,const scalar T) const;
inline scalar isothermalCompressiblity(const scalar rho,const scalar T) const;
inline scalar integral_d2pdT2_dv(const scalar rho,const scalar T) const ; // Used for cv
inline scalar d2pdv2(const scalar rho,const scalar T) const; // not Used At The Moment
inline scalar d2pdT2(const scalar rho,const scalar T) const; // not Used At The Moment
inline scalar d2pdvdT(const scalar rho,const scalar T) const; // not Used At The Moment
inline scalar d2vdT2(const scalar rho,const scalar T) const; // not Used At The Moment
inline scalar integral_p_dv(const scalar rho,const scalar T) const; //Used for internal Energy
inline scalar integral_dpdT_dv(const scalar rho,const scalar T) const; //Used for Entropy
//- Return density [kg/m^3] // rho0 is the starting point of the newton solver used to calculate rho
inline scalar rho(const scalar p,const scalar T,const scalar rho0) const;
inline scalar rho(const scalar p,const scalar T) const;
//- Return compressibility rho/p [s^2/m^2]
inline scalar psi(const scalar rho, const scalar T) const;
//- Return compression factor []
inline scalar Z(const scalar p,const scalar T,const scalar rho0) const;
// Member operators
inline void operator+=(const soaveRedlichKwong&);
inline void operator-=(const soaveRedlichKwong&);
inline void operator*=(const scalar);
/* // Friend operators
inline friend soaveRedlichKwong operator+
(
const soaveRedlichKwong&,
const soaveRedlichKwong&
);
inline friend soaveRedlichKwong operator-
(
const soaveRedlichKwong&,
const soaveRedlichKwong&
);
inline friend soaveRedlichKwong operator*
(
const scalar s,
const soaveRedlichKwong&
);
inline friend soaveRedlichKwong operator==
(
const soaveRedlichKwong&,
const soaveRedlichKwong&
);
*/
// Ostream Operator
friend Ostream& operator<<(Ostream&, const soaveRedlichKwong&);
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#include "soaveRedlichKwongI.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View file

@ -0,0 +1,488 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd |
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 2 of the License, or (at your
option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM; if not, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Author
Christian Lucas
Institut für Thermodynamik
Technische Universität Braunschweig
Germany
\*---------------------------------------------------------------------------*/
#include "soaveRedlichKwong.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
inline scalar soaveRedlichKwong::pcrit()const
{
return pcrit_;
}
inline scalar soaveRedlichKwong::Tcrit()const
{
return Tcrit_;
}
inline scalar soaveRedlichKwong::rhostd()const
{
return rhostd_;
}
// Returns the Azentric Factor (Acentric Factor)
inline scalar soaveRedlichKwong::azentricFactor() const
{
return azentricFactor_;
}
//returns the pressure for a given density and temperature
inline scalar soaveRedlichKwong::pReturn(const scalar rho,const scalar T) const
{
return (this->RR*T/((this->W()/rho)-this->b())-this->a()*pow((1+this->n()*(1-pow((T/this->Tcrit()),0.5))),2)/((this->W()/rho)*((this->W()/rho)+this->b())));
}
// Faktor a of the soave redlich Kwong equation of state
//(molar values)
inline scalar soaveRedlichKwong::a() const
{
return 0.42747*pow(this->RR,2)*pow(this->Tcrit(),2)/(this->pcrit());
}
// Faktor b of the soave redlich Kwong equation of state
//(molar values)
inline scalar soaveRedlichKwong::b() const
{
return 0.08664*this->RR*this->Tcrit()/this->pcrit();
}
// Faktor n of the soave redlich Kwong equation of state
//(molar values)
inline scalar soaveRedlichKwong::n() const
{
return 0.48508+1.55171*this->azentricFactor()-0.15613*pow(this->azentricFactor(),2);
}
//* * * * * * * * * * * * * Derivatives * * * * * * * * * * * //
//Real deviative dp/dv at constant temperature
//(molar values)
inline scalar soaveRedlichKwong::dpdv(const scalar rho, const scalar T) const
{
return -(2*this->a()*this->n()*this->Tcrit()*(this->b()-(this->W()/rho))*(pow(this->b(),2)+this->b()*(this->W()/rho)-2*pow((this->W()/rho),2))*(this->n()+1)*pow((T/this->Tcrit()),0.5)+this->Tcrit()*(this->RR*T*pow((this->W()/rho),2)*(pow(this->b(),2)+2*this->b()*(this->W()/rho)+pow((this->W()/rho),2))-this->a()*(pow(this->b(),3)-3*this->b()*pow((this->W()/rho),2)+2*pow((this->W()/rho),3))*pow((this->n()+1),2))-this->a()*pow(this->n(),2)*T*(pow(this->b(),3)-3*this->b()*pow((this->W()/rho),2)+2*pow((this->W()/rho),3)))/(pow((this->W()/rho),2)*this->Tcrit()*pow((this->b()+(this->W()/rho)),2)*pow((this->b()-(this->W()/rho)),2));
}
//Real deviative dp/dT at constant molar volume
//(molar values)
inline scalar soaveRedlichKwong::dpdT(const scalar rho, const scalar T) const
{
return this->a()*this->n()*(this->n()+1)*pow((T/this->Tcrit()),0.5)/(T*(this->W()/rho)*(this->b()+(this->W()/rho)))-this->a()*pow(this->n(),2)/((this->W()/rho)*this->Tcrit()*(this->b()+(this->W()/rho)))-this->RR/(this->b()-(this->W()/rho));
}
//Real deviative dv/dT at constant pressure
//using implicit differentiation
// (molar values)
inline scalar soaveRedlichKwong::dvdT(const scalar rho,const scalar T) const
{
return (-1)*this->dpdT(rho,T)/this->dpdv(rho,T);
}
//Real deviative dv/dp at constant temperature
//(molar values)
inline scalar soaveRedlichKwong::dvdp(const scalar rho,const scalar T) const
{
return 1/this->dpdv(rho,T);
}
//needed to calculate the internal energy
//(molar values)
inline scalar soaveRedlichKwong::integral_p_dv(const scalar rho,const scalar T) const
{
return this->RR*T*log((this->W()/rho)-this->b())
-(this->a()*(2*this->n()*this->Tcrit()*(this->n()+1)*pow(T/this->Tcrit(),0.5)-this->Tcrit()*(pow(this->n(),2)+2*this->n()+1)-pow(this->n(),2)*T)*log(this->b()+(this->W()/rho)))/(this->b()*this->Tcrit())
+this->a()*(2*this->n()*this->Tcrit()*(this->n()+1)*pow(T/this->Tcrit(),0.5)-this->Tcrit()*(pow(this->n(),2)+2*this->n()+1)-pow(this->n(),2)*T)*log((this->W()/rho))/(this->b()*this->Tcrit());
}
//needed to calculate the entropy
//(molar values)
inline scalar soaveRedlichKwong::integral_dpdT_dv(const scalar rho,const scalar T) const
{
return this->RR*log((this->W()/rho)-this->b())+(pow(this->n(),2)*this->a()/(this->b()*this->Tcrit())-this->a()*this->n()*(this->n()+1)*pow((T/this->Tcrit()),0.5)/(this->b()*T))*log(this->b()+(this->W()/rho))+(this->a()*this->n()*(this->n()+1)*pow((T/this->Tcrit()),0.5)/(this->b()*T)-this->a()*pow(this->n(),2)/(this->b()*this->Tcrit()))*log((this->W()/rho));
}
//* * * * * * * * * * * * * second order Derivative based functions * * * * * * * * * * * //
//(molar values)
inline scalar soaveRedlichKwong::d2pdT2(const scalar rho,const scalar T) const
{
return -this->a()*this->n()*(this->n()+1)*pow(T/this->Tcrit(),0.5)/(2*pow(T,2)*(this->W()/rho)*(this->b()+(this->W()/rho)));
}
//(molar values)
inline scalar soaveRedlichKwong::d2pdv2(const scalar rho,const scalar T) const
{
return 2*(2*this->a()*this->n()*this->Tcrit()*(this->b()-(this->W()/rho))
*(pow(this->b(),4)+pow(this->b(),3)*(this->W()/rho)-2*pow(this->b(),2)*pow((this->W()/rho),2)
-3*this->b()*pow((this->W()/rho),3)+3*pow((this->W()/rho),4))*(this->n()+1)*pow(T/this->Tcrit(),0.5)
-this->Tcrit()*(this->a()*(pow(this->b(),5)-3*pow(this->b(),3)*pow((this->W()/rho),2)-pow(this->b(),2)*pow((this->W()/rho),3)
+6*this->b()*pow((this->W()/rho),4)-3*pow((this->W()/rho),5))*pow((this->n()+1),2)
+this->RR*T*pow((this->W()/rho),3)*(pow(this->b(),3)+3*pow(this->b(),2)*(this->W()/rho)+3*this->b()*pow((this->W()/rho),2)+pow((this->W()/rho),3)))
-this->a()*pow(this->n(),2)*T*(pow(this->b(),5)-3*pow(this->b(),3)*pow((this->W()/rho),2)-pow(this->b(),2)*pow((this->W()/rho),3)
+6*this->b()*pow((this->W()/rho),4)-3*pow((this->W()/rho),5)))
/(pow((this->W()/rho),3)*this->Tcrit()*pow(((this->W()/rho)+this->b()),3)*pow((this->b()-(this->W()/rho)),3));
}
//(molar values)
// using second Order implicit differentiation
inline scalar soaveRedlichKwong::d2vdT2(const scalar rho, const scalar T) const
{
return -(pow(this->dpdT(rho,T),2)*this->d2pdv2(rho,T)+ pow(this->dpdv(rho,T),2) *this->d2pdT2(rho,T)- 2*this->dpdv(rho,T)*this->dpdT(rho,T)*this->d2pdvdT(rho,T))/( pow(this->dpdv(rho,T),3));
}
//(molar values)
inline scalar soaveRedlichKwong::d2pdvdT(const scalar rho, const scalar T) const
{
return -this->a()*this->n()*(this->b()+2*(this->W()/rho))*(this->n()+1)*pow(T/this->Tcrit(),0.5)
/(T*pow((this->W()/rho),2)*pow((this->b()+(this->W()/rho)),2))
-(this->RR*pow((this->W()/rho),2)*this->Tcrit()*(pow(this->b(),2)+2*this->b()*(this->W()/rho)+pow((this->W()/rho),2))
-this->a()*pow(this->n(),2)*(pow(this->b(),3)-3*this->b()*pow((this->W()/rho),2)+2*pow((this->W()/rho),3)))
/(pow((this->W()/rho),2)*this->Tcrit()*pow((this->b()+(this->W()/rho)),2)*pow((this->b()-(this->W()/rho)),2));
}
// the result of this intergal is needed for the nasa based cp polynomial
//(molar values)
inline scalar soaveRedlichKwong::integral_d2pdT2_dv(const scalar rho,const scalar T) const
{
return this->a()*this->n()*(this->n()+1)*pow(T/this->Tcrit(),0.5)*log(this->b()+(this->W()/rho))
/(2*this->b()*pow(T,2))
-this->a()*this->n()*(this->n()+1)*pow(T/this->Tcrit(),0.5)*log((this->W()/rho))/(2*this->b()*pow(T,2));
}
//* * * * * * * * * * * * * thermodynamic properties * * * * * * * * * * * //
//Isobar expansion Coefficent beta = 1/v (dv/dt) at constant p
//(molar values)
inline scalar soaveRedlichKwong::isobarExpCoef(const scalar rho,const scalar T) const
{
return this->dvdT(rho, T)*rho/this->W();
}
//isothemal compressiblity kappa
//(molar values)
inline scalar soaveRedlichKwong::isothermalCompressiblity(const scalar rho,const scalar T) const
{
return this->isobarExpCoef(rho, T)/this->dpdT(rho, T);
}
// Construct from components
inline soaveRedlichKwong::soaveRedlichKwong
(
const specie& sp,
scalar pcrit,
scalar Tcrit,
scalar azentricFactor
)
:
specie(sp),
pcrit_(pcrit),
Tcrit_(Tcrit),
azentricFactor_(azentricFactor)
{
rhostd_=this->rho(Pstd,Tstd,Pstd*this->W()/(Tstd*this->R()));
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
// Construct as named copy
inline soaveRedlichKwong::soaveRedlichKwong(const word& name, soaveRedlichKwong& pg)
:
specie(name, pg),
pcrit_(pg.pcrit_),
Tcrit_(pg.Tcrit_),
azentricFactor_(pg.azentricFactor_)
{
pg.rhostd_=this->rho(Pstd,Tstd, (Pstd*this->W()/(Tstd*this->R())));
}
// Construct and return a clone
inline autoPtr<soaveRedlichKwong> soaveRedlichKwong::clone() const
{
return autoPtr<soaveRedlichKwong>(new soaveRedlichKwong(*this));
}
// Selector from Istream
inline autoPtr<soaveRedlichKwong> soaveRedlichKwong::New(Istream& is)
{
return autoPtr<soaveRedlichKwong>(new soaveRedlichKwong(is));
}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
//- Return density [kg/m^3]on
inline scalar soaveRedlichKwong::rho(const scalar p,const scalar T,const scalar rho0) const
{
scalar molarVolumePrevIteration;
scalar molarVolume;
int iter=0;
int maxIter_=400;
scalar tol_=1e-8;
int i;
scalar rho1=rhoMax_, rho2=rhoMin_,rho3, f1,f2,f3;
molarVolume=this->W()/rho0;
do
{
molarVolumePrevIteration= molarVolume;
i=0;
do
{
molarVolume=molarVolumePrevIteration-((this->pReturn((this->W()/molarVolumePrevIteration),T)-p)/(this->dpdv((this->W()/
molarVolumePrevIteration),T)))/(pow(2,i));
i++;
if(i>8)
{
//using bisection methode as backup, solution must be between rho=0.001 to rho=1500;
for(i=0;i<200;i++)
{
f1= (this->pReturn(rho1,T)-p);
f2= (this->pReturn(rho2,T)-p);
rho3=(rho1+rho2)/2;
f3=(this->pReturn(rho3,T)-p);
if ((f2<0 && f3>0)||(f2>0 &&f3<0))
{
rho1=rho3;
}
else if ((f1<0 && f3>0)||(f1>0 &&f3<0))
{
rho2=rho3;
}
else
{
rho2=(rho2+rho3)/2;
}
if(mag(f3)<p*tol_)
{
molarVolume=this->W()/rho3;
molarVolumePrevIteration=this->W()/rho3;
break;
}
else
{
molarVolumePrevIteration=this->W()/rho3;
}
}
}
}
while(mag(this->pReturn((this->W()/molarVolume),T)-p)>mag(this->pReturn((this->W()/molarVolumePrevIteration),T)-p));
if (iter++ > maxIter_)
{
FatalErrorIn
(
"inline scalar soaveRedlichKwong::rho(const scalar p,const scalar T,const scalar rho0) const "
) << "Maximum number of iterations exceeded"
<< abort(FatalError);
}
}
while(mag(molarVolumePrevIteration-molarVolume)>tol_*(this->W()/rho0));
return this->W()/molarVolume;
}
//- Return density [kg/m^3]on
inline scalar soaveRedlichKwong::rho(const scalar p,const scalar T) const
{
scalar rho0=p/(this->R()*T); //using perfect gas equation as starting point
return rho(p,T,rho0);
}
//- Return compressibility drho/dp [s^2/m^2]
inline scalar soaveRedlichKwong::psi(const scalar rho, const scalar T) const
{
return -this->dvdp(rho,T)*pow(rho,2)/this->W();
}
//- Return compression factor []
inline scalar soaveRedlichKwong::Z( const scalar p, const scalar T,const scalar rho0) const
{
return (p*this->rho(p,T,rho0))/(this->R()*T);
}
// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
inline void soaveRedlichKwong::operator+=(const soaveRedlichKwong& pg)
{
specie::operator+=(pg);
}
inline void soaveRedlichKwong::operator-=(const soaveRedlichKwong& pg)
{
specie::operator-=(pg);
}
inline void soaveRedlichKwong::operator*=(const scalar s)
{
specie::operator*=(s);
}
// * * * * * * * * * * * * * * * Friend Operators * * * * * * * * * * * * * //
//**************** not working**************//
/*
inline soaveRedlichKwong operator+
(
const soaveRedlichKwong& pg1,
const soaveRedlichKwong& pg2
)
{
return soaveRedlichKwong
(
static_cast<const specie&>(pg1)
+ static_cast<const specie&>(pg2)
);
}
inline soaveRedlichKwong operator-
(
const soaveRedlichKwong& pg1,
const soaveRedlichKwong& pg2
)
{
return soaveRedlichKwong
(
static_cast<const specie&>(pg1)
- static_cast<const specie&>(pg2)
);
}
inline soaveRedlichKwong operator*
(
const scalar s,
const soaveRedlichKwong& pg
)
{
return soaveRedlichKwong(s*static_cast<const specie&>(pg));
}
inline soaveRedlichKwong operator==
(
const soaveRedlichKwong& pg1,
const soaveRedlichKwong& pg2
)
{
return pg2 - pg1;
}
*/
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// ************************************************************************* //

View file

@ -0,0 +1,73 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd |
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 2 of the License, or (at your
option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM; if not, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Author
Christian Lucas
Institut für Thermodynamik
Technische Universität Braunschweig
Germany
\*---------------------------------------------------------------------------*/
#include "nasaHeatCapacityPolynomial.H"
#include "IOstreams.H"
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
template<class equationOfState>
Foam::nasaHeatCapacityPolynomial<equationOfState>::nasaHeatCapacityPolynomial(Istream& is)
:
equationOfState(is),
a1_(readScalar(is)),
a2_(readScalar(is)),
a3_(readScalar(is)),
a4_(readScalar(is)),
a5_(readScalar(is)),
a6_(readScalar(is)),
a7_(readScalar(is))
{
is.check("nasaHeatCapacityPolynomial::nasaHeatCapacityPolynomial(Istream& is)");
cp_std=this->cp_nonLimited(this->rhostd_,this->Tstd); // cp @ STD (needed to limit cp for stability
}
// * * * * * * * * * * * * * * * Ostream Operator * * * * * * * * * * * * * //
template<class equationOfState>
Foam::Ostream& Foam::operator<<
(
Ostream& os,
const nasaHeatCapacityPolynomial<equationOfState>& ct
)
{
os << static_cast<const equationOfState&>(ct) << tab
<< ct.a1_ << tab<< ct.a2_ << tab << ct.a3_ << tab << ct.a4_ << tab << ct.a5_ << tab << ct.a6_ << tab << ct.a7_ ;
cout<<"nasa polynomal start"<<nl<<endl;
os.check("Ostream& operator<<(Ostream& os, const nasaHeatCapacityPolynomial& ct)");
return os;
}
// ************************************************************************* //

View file

@ -0,0 +1,259 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd |
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 2 of the License, or (at your
option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM; if not, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Class
Foam::nasaHeatCapacityPolynomial
Description
Nasa Heat Capacity Polynomial for perfect Gas (7.order polynominal) --> freely available for many fluids
--> paper title: NASA Glenn Coefficients for Calculating Thermodynamic Properties of Individual Species
templated into the equationOfState
-> uses the equation of state to calculate all real Gas properties like Enthalpy, Entropy ...
-> can not be used with the perfectGas equation of state
Equations for the real gas correction: Have a look at thermodnamics books e.g. Thermodynamics: An Engineering Approch, 5 Edition, Chapter 12
SourceFiles
nasaHeatCapacityPolynomialI.H
nasaHeatCapacityPolynomial.C
Author
Christian Lucas
Institut für Thermodynamik
Technische Universität Braunschweig
Germany
\*---------------------------------------------------------------------------*/
#ifndef nasaHeatCapacityPolynomial_H
#define nasaHeatCapacityPolynomial_H
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// Forward declaration of friend functions and operators
template<class equationOfState> class nasaHeatCapacityPolynomial;
template<class equationOfState>
inline nasaHeatCapacityPolynomial<equationOfState> operator+
(
const nasaHeatCapacityPolynomial<equationOfState>&,
const nasaHeatCapacityPolynomial<equationOfState>&
);
template<class equationOfState>
inline nasaHeatCapacityPolynomial<equationOfState> operator-
(
const nasaHeatCapacityPolynomial<equationOfState>&,
const nasaHeatCapacityPolynomial<equationOfState>&
);
template<class equationOfState>
inline nasaHeatCapacityPolynomial<equationOfState> operator*
(
const scalar,
const nasaHeatCapacityPolynomial<equationOfState>&
);
template<class equationOfState>
inline nasaHeatCapacityPolynomial<equationOfState> operator==
(
const nasaHeatCapacityPolynomial<equationOfState>&,
const nasaHeatCapacityPolynomial<equationOfState>&
);
template<class equationOfState>
Ostream& operator<<
(
Ostream&,
const nasaHeatCapacityPolynomial<equationOfState>&
);
/*---------------------------------------------------------------------------*\
Class nasaHeatCapacityPolynomial Thermo Declaration
\*---------------------------------------------------------------------------*/
template<class equationOfState>
class nasaHeatCapacityPolynomial
:
public equationOfState
{
// Private data
scalar a1_;
scalar a2_;
scalar a3_;
scalar a4_;
scalar a5_;
scalar a6_;
scalar a7_;
scalar cp_std;
// Private member functions
//- Construct from components
inline nasaHeatCapacityPolynomial
(
const equationOfState& st,
const scalar a1,
const scalar a2,
const scalar a3,
const scalar a4,
const scalar a5,
const scalar a6,
const scalar a7
);
public:
//Variable
// Constructors
//- Construct from Istream
nasaHeatCapacityPolynomial(Istream&);
//- Construct as named copy
inline nasaHeatCapacityPolynomial(const word&, const nasaHeatCapacityPolynomial&);
//- Construct and return a clone
inline autoPtr<nasaHeatCapacityPolynomial> clone() const;
//- Selector from Istream
inline static autoPtr<nasaHeatCapacityPolynomial> New(Istream& is);
// Member Functions
//useful functions
//used to calculate the internal energy
//ideal Gas Enthalpy
inline scalar h0(const scalar T) const;
// used to calculate the entropy
//ideal Gas Entropy
inline scalar s0(const scalar T) const;
//used to calculate the internal energy
//ideal Gas Enthalpy
inline scalar e0(const scalar T) const;
// Fundamental properties
//- ideal gas Heat capacity at constant pressure [J/(kmol K)]
inline scalar cv0(const scalar T) const;
//- ideal gas Heat capacity at constant pressure [J/(kmol K)]
inline scalar cp0(const scalar T) const;
//- Heat capacity at constant pressure [J/(kmol K)]
inline scalar cp(const scalar rho, const scalar T) const;
//- Heat capacity at constant pressure [J/(kmol K)]
inline scalar cp_nonLimited(const scalar rho, const scalar T) const;
//- Heat capacity at constant pressure [J/(kmol K)]
inline scalar cv(const scalar rho, const scalar T) const;
//- Enthalpy [J/kmol]
inline scalar h(const scalar rho, const scalar T) const;
//- Entropy [J/(kmol K)]
inline scalar s(const scalar rho,const scalar T) const;
//- Internal Energy [J/kmol]
inline scalar e(const scalar rho, const scalar T) const;
// Member operators
inline void operator+=(const nasaHeatCapacityPolynomial&);
inline void operator-=(const nasaHeatCapacityPolynomial&);
// Friend operators
friend nasaHeatCapacityPolynomial operator+ <equationOfState>
(
const nasaHeatCapacityPolynomial&,
const nasaHeatCapacityPolynomial&
);
friend nasaHeatCapacityPolynomial operator- <equationOfState>
(
const nasaHeatCapacityPolynomial&,
const nasaHeatCapacityPolynomial&
);
friend nasaHeatCapacityPolynomial operator* <equationOfState>
(
const scalar,
const nasaHeatCapacityPolynomial&
);
friend nasaHeatCapacityPolynomial operator== <equationOfState>
(
const nasaHeatCapacityPolynomial&,
const nasaHeatCapacityPolynomial&
);
// IOstream Operators
friend Ostream& operator<< <equationOfState>
(
Ostream&,
const nasaHeatCapacityPolynomial&
);
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#include "nasaHeatCapacityPolynomialI.H"
#ifdef NoRepository
# include "nasaHeatCapacityPolynomial.C"
#endif
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View file

@ -0,0 +1,419 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd |
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 2 of the License, or (at your
option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM; if not, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Author
Christian Lucas
Institut für Thermodynamik
Technische Universität Braunschweig
Germany
\*---------------------------------------------------------------------------*/
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
template<class equationOfState>
inline Foam::nasaHeatCapacityPolynomial<equationOfState>::nasaHeatCapacityPolynomial
(
const equationOfState& st,
const scalar a1,
const scalar a2,
const scalar a3,
const scalar a4,
const scalar a5,
const scalar a6,
const scalar a7
)
:
equationOfState(st),
a1_(a1),
a2_(a2),
a3_(a3),
a4_(a4),
a5_(a5),
a6_(a6),
a7_(a7)
{
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
template<class equationOfState>
inline Foam::nasaHeatCapacityPolynomial<equationOfState>::nasaHeatCapacityPolynomial
(
const word& name,
const nasaHeatCapacityPolynomial& ct
)
:
equationOfState(name, ct),
a1_(ct.a1_),
a2_(ct.a2_),
a3_(ct.a3_),
a4_(ct.a4_),
a5_(ct.a5_),
a6_(ct.a6_),
a7_(ct.a7_)
{
}
template<class equationOfState>
inline Foam::autoPtr<Foam::nasaHeatCapacityPolynomial<equationOfState> >
Foam::nasaHeatCapacityPolynomial<equationOfState>::clone() const
{
return autoPtr<nasaHeatCapacityPolynomial<equationOfState> >
(
new nasaHeatCapacityPolynomial<equationOfState>(*this)
);
}
template<class equationOfState>
inline Foam::autoPtr<Foam::nasaHeatCapacityPolynomial<equationOfState> >
Foam::nasaHeatCapacityPolynomial<equationOfState>::New(Istream& is)
{
return autoPtr<nasaHeatCapacityPolynomial<equationOfState> >
(
new nasaHeatCapacityPolynomial<equationOfState>(is)
);
}
// * * * * * * * * * * * * * * *useful functions* * * * * * * * * * * * * //
//used to calculate the internal energy
//perfect gas enthalpy
template<class equationOfState>
inline Foam::scalar Foam::nasaHeatCapacityPolynomial<equationOfState>::h0
(
const scalar T
) const
{
return this->RR*T*(-this->a1_*pow(T,-2)+this->a2_*log(T)/T+this->a3_+0.5*this->a4_*T+(this->a5_*pow(T,2))/3+(this->a6_*pow(T,3))/4+(this->a7_*pow(T,4))/5);
}
//used to calculate the internal energy
//perfect gas internal energy
template<class equationOfState>
inline Foam::scalar Foam::nasaHeatCapacityPolynomial<equationOfState>::e0
(
const scalar T
) const
{
return this->h0(T) - this->RR*T;
}
// used to calculate the entropy
// perfect gas entropy
template<class equationOfState>
inline Foam::scalar Foam::nasaHeatCapacityPolynomial<equationOfState>::s0
(
const scalar T
) const
{
return this->RR*( this->a1_*(-1)/(2*pow(T,2))-this->a2_/T+this->a3_*log(T)+this->a4_*T+(this->a5_*pow(T,2))/2+(this->a6_*pow(T,3))/3+(this->a7_*pow(T,4))/4);
}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
//perfect gas cp
template<class equationOfState>
inline Foam::scalar Foam::nasaHeatCapacityPolynomial<equationOfState>::cp0
(
const scalar T
) const
{
return this->RR*(this->a1_*1/pow(T,2)+this->a2_*1/T+this->a3_+this->a4_*T+this->a5_*pow(T,2)+this->a6_*pow(T,3)+this->a7_*pow(T,4));
}
//perfect gas cv
template<class equationOfState>
inline Foam::scalar Foam::nasaHeatCapacityPolynomial<equationOfState>::cv0
(
const scalar T
) const
{
return this->cp0(T)-this->RR;
}
//function to calculate real gas cp
//using cp=cv+(dp/dT)^2/(dp/dv)
template<class equationOfState>
inline Foam::scalar Foam::nasaHeatCapacityPolynomial<equationOfState>::cp
(
const scalar rho,
const scalar T
) const
{
// Problem --> dpdv(rho,T) is =0 at some points within the vapour dome. To increase stability, (dp/dv) has to be limited
// cp can be negative within the vapor dome. To avoid this nonphysical result, the absolute value is used.
// within the vapourdome and at the critical point, cp increases to very high values --> infinity,
// this would decrease the stability, so cp will be limited to 20 time the cp @ STD
return min(cp_std*20,fabs(this->cv(rho,T)-T*pow((this->dpdT(rho, T)),2)/min(this->dpdv(rho, T),-1)));
}
// this function is needed to get cp @ STD (without the limit imposed in the function above), which in turn is needed to limit the cp in the function above
template<class equationOfState>
inline Foam::scalar Foam::nasaHeatCapacityPolynomial<equationOfState>::cp_nonLimited
(
const scalar rho,
const scalar T
) const
{
return fabs(this->cv(rho,T)-T*pow((this->dpdT(rho, T)),2)/min(this->dpdv(rho, T),-1));
}
//function to calculate real gas cv
//cv=cv0+T*integral d2p/dT2 dv
template<class equationOfState>
inline Foam::scalar Foam::nasaHeatCapacityPolynomial<equationOfState>::cv
(
const scalar rho,
const scalar T
) const
{
return this->cv0(T)+T*this->integral_d2pdT2_dv(rho, T);
}
//function to calculate real gas enthalpy
template<class equationOfState>
inline Foam::scalar Foam::nasaHeatCapacityPolynomial<equationOfState>::h
(
const scalar rho,
const scalar T
) const
{
return this->e(rho,T)+this->pReturn(rho,T)/rho*this->W()-this->Pstd/this->rhostd()*this->W();
}
// function to calculate real gas internal energy
// important assumption used is that the internal Energie is 0 at STD conditions.
// equation: du= cv0 dT +[T*dp/dT -p]dv
template<class equationOfState>
inline Foam::scalar Foam::nasaHeatCapacityPolynomial<equationOfState>::e
(
const scalar rho,
const scalar T
) const
{
return ( -this->Tstd*this->integral_dpdT_dv(this->rhostd(),this->Tstd)
+this->integral_p_dv(this->rhostd(),this->Tstd)
+this->e0(T)-this->e0(this->Tstd)
+T*this->integral_dpdT_dv(rho,T)
-this->integral_p_dv(rho,T)
);
}
//function to calculate real gas entropy
// important assumption used is that the Entropy is 0 at STD conditions.
// equation: ds= cv0/T * dT + dp/dT *dv
// --> integral cv0/T dT = s0(T) -s0(Tstd) - R*ln(T/Tstd) --> due to s0(T)-s0(Tstd)=integral cp0/T dT
template<class equationOfState>
inline Foam::scalar Foam::nasaHeatCapacityPolynomial<equationOfState>::s
(
const scalar rho,
const scalar T
) const
{
return -this->integral_dpdT_dv(this->rhostd(),this->Tstd)+(this->s0(T)-this->s0(this->Tstd))-this->RR*log(T/this->Tstd)+ this->integral_dpdT_dv(rho,T);
}
// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
template<class equationOfState>
inline void Foam::nasaHeatCapacityPolynomial<equationOfState>::operator+=
(
const nasaHeatCapacityPolynomial<equationOfState>& ct
)
{
scalar molr1 = this->nMoles();
equationOfState::operator+=(ct);
molr1 /= this->nMoles();
scalar molr2 = ct.nMoles()/this->nMoles();
a1_ = molr1*a1_ + molr2*ct.a1_;
a2_ = molr1*a2_ + molr2*ct.a2_;
a3_ = molr1*a3_ + molr2*ct.a3_;
a4_ = molr1*a4_ + molr2*ct.a4_;
a5_ = molr1*a5_ + molr2*ct.a5_;
a6_ = molr1*a6_ + molr2*ct.a6_;
a7_ = molr1*a7_ + molr2*ct.a7_;
}
template<class equationOfState>
inline void Foam::nasaHeatCapacityPolynomial<equationOfState>::operator-=
(
const nasaHeatCapacityPolynomial<equationOfState>& ct
)
{
scalar molr1 = this->nMoles();
nasaHeatCapacityPolynomial::operator-=(ct);
molr1 /= this->nMoles();
scalar molr2 = ct.nMoles()/this->nMoles();
a1_ = molr1*a1_ - molr2*ct.a1_;
a2_ = molr1*a2_ - molr2*ct.a2_;
a3_ = molr1*a3_ - molr2*ct.a3_;
a4_ = molr1*a4_ - molr2*ct.a4_;
a5_ = molr1*a5_ - molr2*ct.a5_;
a6_ = molr1*a6_ - molr2*ct.a6_;
a7_ = molr1*a7_ - molr2*ct.a7_;
}
// * * * * * * * * * * * * * * * Friend Operators * * * * * * * * * * * * * //
template<class equationOfState>
inline Foam::nasaHeatCapacityPolynomial<equationOfState> Foam::operator+
(
const nasaHeatCapacityPolynomial<equationOfState>& ct1,
const nasaHeatCapacityPolynomial<equationOfState>& ct2
)
{
equationOfState eofs
(
static_cast<const equationOfState&>(ct1)
+ static_cast<const equationOfState&>(ct2)
);
return nasaHeatCapacityPolynomial<equationOfState>
(
eofs,
ct1.nMoles()/eofs.nMoles()*ct1.a1_
+ ct2.nMoles()/eofs.nMoles()*ct2.a1_,
ct1.nMoles()/eofs.nMoles()*ct1.a2_
+ ct2.nMoles()/eofs.nMoles()*ct2.a2_,
ct1.nMoles()/eofs.nMoles()*ct1.a3_
+ ct2.nMoles()/eofs.nMoles()*ct2.a3_,
ct1.nMoles()/eofs.nMoles()*ct1.a4_
+ ct2.nMoles()/eofs.nMoles()*ct2.a4_,
ct1.nMoles()/eofs.nMoles()*ct1.a5_
+ ct2.nMoles()/eofs.nMoles()*ct2.a5_,
ct1.nMoles()/eofs.nMoles()*ct1.a6_
+ ct2.nMoles()/eofs.nMoles()*ct2.a6_,
ct1.nMoles()/eofs.nMoles()*ct1.a7_
+ ct2.nMoles()/eofs.nMoles()*ct2.a7_
);
}
template<class equationOfState>
inline Foam::nasaHeatCapacityPolynomial<equationOfState> Foam::operator-
(
const nasaHeatCapacityPolynomial<equationOfState>& ct1,
const nasaHeatCapacityPolynomial<equationOfState>& ct2
)
{
equationOfState eofs
(
static_cast<const equationOfState&>(ct1)
- static_cast<const equationOfState&>(ct2)
);
return nasaHeatCapacityPolynomial<equationOfState>
(
eofs,
ct1.nMoles()/eofs.nMoles()*ct1.a1_
- ct2.nMoles()/eofs.nMoles()*ct2.a1_,
ct1.nMoles()/eofs.nMoles()*ct1.a2_
- ct2.nMoles()/eofs.nMoles()*ct2.a2_,
ct1.nMoles()/eofs.nMoles()*ct1.a3_
- ct2.nMoles()/eofs.nMoles()*ct2.a3_,
ct1.nMoles()/eofs.nMoles()*ct1.a4_
- ct2.nMoles()/eofs.nMoles()*ct2.a4_,
ct1.nMoles()/eofs.nMoles()*ct1.a5_
- ct2.nMoles()/eofs.nMoles()*ct2.a5_,
ct1.nMoles()/eofs.nMoles()*ct1.a6_
- ct2.nMoles()/eofs.nMoles()*ct2.a6_,
ct1.nMoles()/eofs.nMoles()*ct1.a7_
- ct2.nMoles()/eofs.nMoles()*ct2.a7_
);
}
template<class equationOfState>
inline Foam::nasaHeatCapacityPolynomial<equationOfState> Foam::operator*
(
const scalar s,
const nasaHeatCapacityPolynomial<equationOfState>& ct
)
{
return nasaHeatCapacityPolynomial<equationOfState>
(
s*static_cast<const equationOfState&>(ct),
ct.a1_,
ct.a2_,
ct.a3_,
ct.a4_,
ct.a5_,
ct.a6_,
ct.a7_
);
}
template<class equationOfState>
inline Foam::nasaHeatCapacityPolynomial<equationOfState> Foam::operator==
(
const nasaHeatCapacityPolynomial<equationOfState>& ct1,
const nasaHeatCapacityPolynomial<equationOfState>& ct2
)
{
return ct2 - ct1;
}
// ************************************************************************* //

View file

@ -0,0 +1,72 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd |
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 2 of the License, or (at your
option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM; if not, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Author
Christian Lucas
Institut für Thermodynamik
Technische Universität Braunschweig
Germany
\*---------------------------------------------------------------------------*/
#include "realGasSpecieThermo.H"
#include "IOstreams.H"
/* * * * * * * * * * * * * * * private static data * * * * * * * * * * * * * */
template<class thermo>
const Foam::scalar Foam::realGasSpecieThermo<thermo>::tol_ = 1.0e-9;
template<class thermo>
const int Foam::realGasSpecieThermo<thermo>::maxIter_ = 500;
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
template<class thermo>
Foam::realGasSpecieThermo<thermo>::realGasSpecieThermo(Istream& is)
:
thermo(is)
{
is.check("realGasSpecieThermo::realGasSpecieThermo(Istream& is)");
}
// * * * * * * * * * * * * * * * Ostream Operator * * * * * * * * * * * * * //
template<class thermo>
Foam::Ostream& Foam::operator<<(Ostream& os, const realGasSpecieThermo<thermo>& st)
{
os << static_cast<const thermo&>(st);
os.check("Ostream& operator<<(Ostream& os, const realGasSpecieThermo& st)");
return os;
}
// ************************************************************************* //

View file

@ -0,0 +1,305 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd |
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 2 of the License, or (at your
option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM; if not, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Class
Foam::realGasSpecieThermo
Description
This is an subversion of the specieThermo function. While the "orginal" specieThermo function
is only valid for perfect Gases, this function is valid for real gases.
Basic thermodynamics type based on the use of fitting functions for
cp, h, s obtained from the template argument type thermo. All other
properties are derived from these primitive functions.
Some function copied from the "orginal" specieThermo!
SourceFiles
realGasSpecieThermoI.H
realGasSpecieThermo.C
Author
Christian Lucas
Institut für Thermodynamik
Technische Universität Braunschweig
Germany
\*---------------------------------------------------------------------------*/
#ifndef realGasSpecieThermo_H
#define realGasSpecieThermo_H
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// Forward declaration of friend functions and operators
template<class thermo> class realGasSpecieThermo;
template<class thermo>
inline realGasSpecieThermo<thermo> operator+
(
const realGasSpecieThermo<thermo>&,
const realGasSpecieThermo<thermo>&
);
template<class thermo>
inline realGasSpecieThermo<thermo> operator-
(
const realGasSpecieThermo<thermo>&,
const realGasSpecieThermo<thermo>&
);
template<class thermo>
inline realGasSpecieThermo<thermo> operator*
(
const scalar,
const realGasSpecieThermo<thermo>&
);
template<class thermo>
inline realGasSpecieThermo<thermo> operator==
(
const realGasSpecieThermo<thermo>&,
const realGasSpecieThermo<thermo>&
);
template<class thermo>
Ostream& operator<<
(
Ostream&,
const realGasSpecieThermo<thermo>&
);
/*---------------------------------------------------------------------------*\
Class specieThermo Declaration
\*---------------------------------------------------------------------------*/
template<class thermo>
class realGasSpecieThermo
:
public thermo
{
// Private data
//- Convergence tolerance of energy -> temperature inversion functions
static const scalar tol_;
//- Max number of iterations in energy->temperature inversion functions
static const int maxIter_;
// Private member functions
// return the temperature corresponding to the value of the
// thermodynamic property f, given the function f = F(T) and dF(T)/dT
inline void T
(
scalar f,
scalar &T0,
scalar p,
scalar &rho0,
scalar (realGasSpecieThermo::*F)(const scalar,const scalar) const,
scalar (realGasSpecieThermo::*dFdT)(const scalar,const scalar) const
) const;
public:
// Constructors
//- construct from components
inline realGasSpecieThermo(const thermo& sp);
//- Construct from Istream
realGasSpecieThermo(Istream&);
//- Construct as named copy
inline realGasSpecieThermo(const word& name, const realGasSpecieThermo&);
// Member Functions
// Fundamaental properties
// (These functions must be provided in derived types)
// Heat capacity at constant pressure [J/(kmol K)]
//scalar cp(const scalar) const;
// Enthalpy [J/kmol]
//scalar h(const scalar) const;
// Sensible enthalpy [J/kmol]
//virtual scalar hs(const scalar) const;
// Chemical enthalpy [J/kmol]
//virtual scalar hc(const scalar) const;
// Entropy [J/(kmol K)]
//virtual scalar s(const scalar) const;
// Calculate and return derived properties
// (These functions need not provided in derived types)
// Mole specific properties
//- Heat capacity at constant volume [J/(kmol K)]
//inline scalar cv(const scalar T, const scalar rho) const;
//- gamma = cp/cv []
//inline scalar gamma(const scalar T, const scalar rho) const;
// Internal energy [J/kmol]
// inline scalar e(const scalar rho, const scalar T) const;
//- Sensible internal energy [J/kmol]
// inline scalar es(const scalar p, const scalar rho) const;
//- Gibbs free energy [J/kmol]
inline scalar g(const scalar rho, const scalar T ) const;
//- Helmholtz free energy [J/kmol]
inline scalar a(const scalar rho, const scalar T ) const;
// Mass specific properties
//- Heat capacity at constant pressure [J/(kg K)]
inline scalar Cp(const scalar rho, const scalar T) const;
//- Heat capacity at constant volume [J/(kg K)]
inline scalar Cv(const scalar rho, const scalar T) const;
//- Enthalpy [J/kg]
inline scalar H(const scalar rho, const scalar T) const;
//- Sensible enthalpy [J/kg]
// inline scalar Hs(const scalar T) const;
//- Chemical enthalpy [J/kg]
// inline scalar Hc() const;
//- Entropy [J/(kg K)]
inline scalar S(const scalar rho, const scalar T) const;
//- Internal energy [J/kg]
inline scalar E(const scalar rho, const scalar T) const;
//- Gibbs free energy [J/kg]
inline scalar G(const scalar rho, const scalar T) const;
//- Helmholtz free energy [J/kg]
inline scalar A(const scalar rho, const scalar T) const;
// Energy->temperature inversion functions
//- Temperature from Enthalpy given an initial temperature T0
inline void TH(const scalar H, scalar &T0,const scalar p, scalar &psi0) const;
//- Temperature from internal energy given an initial temperature T0
inline void TE(const scalar E, scalar &T0,const scalar p, scalar &psi0) const;
// Member operators
inline void operator+=(const realGasSpecieThermo&);
inline void operator-=(const realGasSpecieThermo&);
inline void operator*=(const scalar);
// Friend operators
friend realGasSpecieThermo operator+ <thermo>
(
const realGasSpecieThermo&,
const realGasSpecieThermo&
);
friend realGasSpecieThermo operator- <thermo>
(
const realGasSpecieThermo&,
const realGasSpecieThermo&
);
friend realGasSpecieThermo operator* <thermo>
(
const scalar s,
const realGasSpecieThermo&
);
friend realGasSpecieThermo operator== <thermo>
(
const realGasSpecieThermo&,
const realGasSpecieThermo&
);
// Ostream Operator
friend Ostream& operator<< <thermo>
(
Ostream&,
const realGasSpecieThermo&
);
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#include "realGasSpecieThermoI.H"
#ifdef NoRepository
# include "realGasSpecieThermo.C"
#endif
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View file

@ -0,0 +1,298 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd |
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 2 of the License, or (at your
option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM; if not, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Author
Christian Lucas
Institut für Thermodynamik
Technische Universität Braunschweig
Germany
\*---------------------------------------------------------------------------*/
#include "realGasSpecieThermo.H"
template<class thermo>
inline Foam::realGasSpecieThermo<thermo>::realGasSpecieThermo
(
const thermo& sp
)
:
thermo(sp)
{}
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
// using a stabilizing newton solver
template<class thermo>
inline void Foam::realGasSpecieThermo<thermo>::T
(
scalar f,
scalar &T0,
scalar p,
scalar &rho0,
scalar (realGasSpecieThermo<thermo>::*F)(const scalar,const scalar) const,
scalar (realGasSpecieThermo<thermo>::*dFdT)(const scalar,const scalar) const
) const
{
scalar Test = T0;
scalar Tnew = T0;
scalar rho=rho0;
scalar Ttol = T0*tol_;
int iter = 0;
int i;
do
{
Test = Tnew;
rho=this->rho(p,Test,rho);
i=0;
;
do
{
Tnew = Test - ((this->*F)(rho,Test) - f)/(this->*dFdT)(rho,Test)/(pow(2,i));
i++; // if the solve is diverging, the time step is reduced until the solver converges
}while((i<20)&&((mag((this->*F)(rho,Tnew) - f) > mag((this->*F)(rho,Test) - f))));
if (iter++ > maxIter_)
{
FatalErrorIn
(
"realGasSpecieThermo<thermo>::T(scalar f, scalar T0, "
"scalar (realGasSpecieThermo<thermo>::*F)(const scalar) const, "
"scalar (realGasSpecieThermo<thermo>::*dFdT)(const scalar) const"
") const"
) << "Maximum number of iterations exceeded"
<< abort(FatalError);
}
} while (mag(mag(Tnew) - mag(Test)) > Ttol);
rho0=rho;
T0=Tnew;
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
template<class thermo>
inline Foam::realGasSpecieThermo<thermo>::realGasSpecieThermo
(
const word& name,
const realGasSpecieThermo& st
)
:
thermo(name, st)
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class thermo>
inline Foam::scalar Foam::realGasSpecieThermo<thermo>::g(const scalar rho, const scalar T ) const
{
return this->h(rho, this->pReturn(rho,T)) - T*this->s(rho, this->pReturn(rho,T));
}
template<class thermo>
inline Foam::scalar Foam::realGasSpecieThermo<thermo>::a(const scalar rho, const scalar T ) const
{
return this->e(rho,this->pReturn(rho,T)) - T*this->s(rho,this->pReturn(rho,T));
}
template<class thermo>
inline Foam::scalar Foam::realGasSpecieThermo<thermo>::Cp( const scalar rho, const scalar T) const
{
return this->cp(rho, T)/this->W();
}
template<class thermo>
inline Foam::scalar Foam::realGasSpecieThermo<thermo>::Cv( const scalar rho, const scalar T) const
{
return this->cv(rho, T)/this->W();
}
template<class thermo>
inline Foam::scalar Foam::realGasSpecieThermo<thermo>::H(const scalar rho, const scalar T) const
{
return this->h(rho, T)/this->W();
}
template<class thermo>
inline Foam::scalar Foam::realGasSpecieThermo<thermo>::S(const scalar rho, const scalar T) const
{
return this->s(rho, T)/this->W();
}
template<class thermo>
inline Foam::scalar Foam::realGasSpecieThermo<thermo>::E(const scalar rho, const scalar T) const
{
return this->e(rho, T)/this->W();
}
template<class thermo>
inline Foam::scalar Foam::realGasSpecieThermo<thermo>::G(const scalar rho, const scalar T) const
{
return this->g(rho, T)/this->W();
}
template<class thermo>
inline Foam::scalar Foam::realGasSpecieThermo<thermo>::A(const scalar rho, const scalar T) const
{
return this->a(rho, T)/this->W();
}
template<class thermo>
inline void Foam::realGasSpecieThermo<thermo>::TH
(
const scalar h,
scalar &T0,
const scalar p,
scalar &rho0
) const
{
T(h, T0, p,rho0, &realGasSpecieThermo<thermo>::H, &realGasSpecieThermo<thermo>::Cp);
}
template<class thermo>
inline void Foam::realGasSpecieThermo<thermo>::TE
(
const scalar e,
scalar &T0,
const scalar p,
scalar &rho0
) const
{
T(e, T0, p,rho0, &realGasSpecieThermo<thermo>::E, &realGasSpecieThermo<thermo>::Cv);
}
// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
template<class thermo>
inline void Foam::realGasSpecieThermo<thermo>::operator+=
(
const realGasSpecieThermo<thermo>& st
)
{
thermo::operator+=(st);
}
template<class thermo>
inline void Foam::realGasSpecieThermo<thermo>::operator-=
(
const realGasSpecieThermo<thermo>& st
)
{
thermo::operator-=(st);
}
template<class thermo>
inline void Foam::realGasSpecieThermo<thermo>::operator*=(const scalar s)
{
thermo::operator*=(s);
}
// * * * * * * * * * * * * * * * Friend Operators * * * * * * * * * * * * * //
template<class thermo>
inline Foam::realGasSpecieThermo<thermo> Foam::operator+
(
const realGasSpecieThermo<thermo>& st1,
const realGasSpecieThermo<thermo>& st2
)
{
return realGasSpecieThermo<thermo>
(
static_cast<const thermo&>(st1) + static_cast<const thermo&>(st2)
);
}
template<class thermo>
inline Foam::realGasSpecieThermo<thermo> Foam::operator-
(
const realGasSpecieThermo<thermo>& st1,
const realGasSpecieThermo<thermo>& st2
)
{
return realGasSpecieThermo<thermo>
(
static_cast<const thermo&>(st1) - static_cast<const thermo&>(st2)
);
}
template<class thermo>
inline Foam::realGasSpecieThermo<thermo> Foam::operator*
(
const scalar s,
const realGasSpecieThermo<thermo>& st
)
{
return realGasSpecieThermo<thermo>
(
s*static_cast<const thermo&>(st)
);
}
template<class thermo>
inline Foam::realGasSpecieThermo<thermo> Foam::operator==
(
const realGasSpecieThermo<thermo>& st1,
const realGasSpecieThermo<thermo>& st2
)
{
return st2 - st1;
}
// ************************************************************************* //

View file

@ -0,0 +1,79 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright held by original author
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 2 of the License, or (at your
option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM; if not, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Description
Modified version of constTransport, modified to be used with realGases
Constant properties Transport package. Templated ito a given
thermodynamics package (needed for thermal conductivity).
Modified by
Christian Lucas
Institut für Thermodynamik
Technische Universität Braunschweig
Germany
\*---------------------------------------------------------------------------*/
#include "realGasConstTransport.H"
#include "IOstreams.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
template<class thermo>
realGasConstTransport<thermo>::realGasConstTransport(Istream& is)
:
thermo(is),
Mu(readScalar(is)),
rPr(1.0/readScalar(is))
{
is.check("realGasConstTransport::realGasConstTransport(Istream& is)");
}
// * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * //
template<class thermo>
Ostream& operator<<(Ostream& os, const realGasConstTransport<thermo>& ct)
{
operator<<(os, static_cast<const thermo&>(ct));
os << tab << ct.Mu << tab << 1.0/ct.rPr;
os.check("Ostream& operator<<(Ostream& os, const realGasConstTransport& ct)");
return os;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// ************************************************************************* //

View file

@ -0,0 +1,204 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright held by original author
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 2 of the License, or (at your
option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM; if not, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Class
Foam::realGasConstTransport
Description
Constant properties Transport package.
Templated into a given thermodynamics package (needed for thermal
conductivity).
SourceFiles
realGasConstTransportI.H
realGasConstTransport.C
Modified by
Christian Lucas
Institut für Thermodynamik
Technische Universität Braunschweig
Germany
\*---------------------------------------------------------------------------*/
#ifndef realGasConstTransport_H
#define realGasConstTransport_H
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// Forward declaration of friend functions and operators
template<class thermo> class realGasConstTransport;
template<class thermo>
inline realGasConstTransport<thermo> operator+
(
const realGasConstTransport<thermo>&,
const realGasConstTransport<thermo>&
);
template<class thermo>
inline realGasConstTransport<thermo> operator-
(
const realGasConstTransport<thermo>&,
const realGasConstTransport<thermo>&
);
template<class thermo>
inline realGasConstTransport<thermo> operator*
(
const scalar,
const realGasConstTransport<thermo>&
);
template<class thermo>
inline realGasConstTransport<thermo> operator==
(
const realGasConstTransport<thermo>&,
const realGasConstTransport<thermo>&
);
template<class thermo>
Ostream& operator<<
(
Ostream&,
const realGasConstTransport<thermo>&
);
/*---------------------------------------------------------------------------*\
Class realGasConstTransport Declaration
\*---------------------------------------------------------------------------*/
template<class thermo>
class realGasConstTransport
:
public thermo
{
// Private data
//- Constant viscosity and reciprocal Prandtl Number.
scalar Mu, rPr;
// Private member functions
//- Construct from components
inline realGasConstTransport
(
const thermo& t,
const scalar nu,
const scalar Pr
);
public:
// Constructors
//- Construct as named copy
inline realGasConstTransport(const word&, const realGasConstTransport&);
//- Construct from Istream
realGasConstTransport(Istream&);
// Member functions
//- Dynamic viscosity [kg/ms]
inline scalar mu(const scalar T) const;
//- Thermal conductivity [W/mK]
inline scalar kappa(const scalar rho,const scalar T) const;
//- Thermal diffusivity for enthalpy [kg/ms]
inline scalar alpha(const scalar rho,const scalar T) const;
// Member operators
inline realGasConstTransport& operator=
(
const realGasConstTransport&
);
// Friend operators
friend realGasConstTransport operator+ <thermo>
(
const realGasConstTransport&,
const realGasConstTransport&
);
friend realGasConstTransport operator- <thermo>
(
const realGasConstTransport&,
const realGasConstTransport&
);
friend realGasConstTransport operator* <thermo>
(
const scalar,
const realGasConstTransport&
);
friend realGasConstTransport operator== <thermo>
(
const realGasConstTransport&,
const realGasConstTransport&
);
// Ostream Operator
friend Ostream& operator<< <thermo>
(
Ostream&,
const realGasConstTransport&
);
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#include "realGasConstTransportI.H"
#ifdef NoRepository
# include "realGasConstTransport.C"
#endif
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View file

@ -0,0 +1,199 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright held by original author
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 2 of the License, or (at your
option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM; if not, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Modified by
Christian Lucas
Institut für Thermodynamik
Technische Universität Braunschweig
Germany
\*---------------------------------------------------------------------------*/
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
// Construct from components
template<class thermo>
inline realGasConstTransport<thermo>::realGasConstTransport
(
const thermo& t,
const scalar mu,
const scalar Pr
)
:
thermo(t),
Mu(mu),
rPr(1.0/Pr)
{}
// Construct as named copy
template<class thermo>
inline realGasConstTransport<thermo>::realGasConstTransport
(
const word& name,
const realGasConstTransport& ct
)
:
thermo(name, ct),
Mu(ct.Mu),
rPr(ct.rPr)
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
// Dynamic viscosity [kg/ms]
template<class thermo>
inline scalar realGasConstTransport<thermo>::mu(const scalar T) const
{
return Mu;
}
// Thermal conductivity [W/mK]
template<class thermo>
inline scalar realGasConstTransport<thermo>::kappa(const scalar rho,const scalar T) const
{
return this->Cp(rho,T)*mu(T)*rPr;
}
// Thermal diffusivity for enthalpy [kg/ms]
template<class thermo>
inline scalar realGasConstTransport<thermo>::alpha(const scalar rho,const scalar T) const
{
scalar Cp_ = this->Cp(rho,T);
scalar deltaT = T - specie::Tstd;
scalar CpBar =
(deltaT*(this->H(rho,T) - this->H(this->rhostd_,specie::Tstd)) + Cp_)/(sqr(deltaT) + 1);
return Cp_*mu(T)*rPr/CpBar;
}
// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
template<class thermo>
inline realGasConstTransport<thermo>& realGasConstTransport<thermo>::operator=
(
const realGasConstTransport<thermo>& ct
)
{
thermo::operator=(ct);
Mu = ct.Mu;
rPr = ct.rPr;
return *this;
}
// * * * * * * * * * * * * * * * Friend Operators * * * * * * * * * * * * * //
template<class thermo>
inline realGasConstTransport<thermo> operator+
(
const realGasConstTransport<thermo>& ct1,
const realGasConstTransport<thermo>& ct2
)
{
thermo t
(
static_cast<const thermo&>(ct1) + static_cast<const thermo&>(ct2)
);
scalar molr1 = ct1.nMoles()/t.nMoles();
scalar molr2 = ct2.nMoles()/t.nMoles();
return realGasConstTransport<thermo>
(
t,
molr1*ct1.Mu + molr2*ct2.Mu,
molr1*ct1.rPr + molr2*ct2.rPr
);
}
template<class thermo>
inline realGasConstTransport<thermo> operator-
(
const realGasConstTransport<thermo>& ct1,
const realGasConstTransport<thermo>& ct2
)
{
thermo t
(
static_cast<const thermo&>(ct1) - static_cast<const thermo&>(ct2)
);
scalar molr1 = ct1.nMoles()/t.nMoles();
scalar molr2 = ct2.nMoles()/t.nMoles();
return realGasConstTransport<thermo>
(
t,
molr1*ct1.Mu - molr2*ct2.Mu,
molr1*ct1.rPr - molr2*ct2.rPr
);
}
template<class thermo>
inline realGasConstTransport<thermo> operator*
(
const scalar s,
const realGasConstTransport<thermo>& ct
)
{
return realGasConstTransport<thermo>
(
s*static_cast<const thermo&>(ct),
ct.Mu,
ct.rPr
);
}
template<class thermo>
inline realGasConstTransport<thermo> operator==
(
const realGasConstTransport<thermo>& ct1,
const realGasConstTransport<thermo>& ct2
)
{
return ct2 - ct1;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// ************************************************************************* //

View file

@ -0,0 +1,74 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd |
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 2 of the License, or (at your
option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM; if not, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Modified by
Christian Lucas
Institut für Thermodynamik
Technische Universität Braunschweig
Germany
\*---------------------------------------------------------------------------*/
#include "realGasSutherlandTransport.H"
#include "IOstreams.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
template<class thermo>
realGasSutherlandTransport<thermo>::realGasSutherlandTransport(Istream& is)
:
thermo(is),
As(readScalar(is)),
Ts(readScalar(is))
{
is.check("realGasSutherlandTransport<thermo>::realGasSutherlandTransport(Istream&)");
}
// * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * //
template<class thermo>
Ostream& operator<<(Ostream& os, const realGasSutherlandTransport<thermo>& st)
{
os << static_cast<const thermo&>(st) << tab << st.As << tab << st.Ts;
cout<<"sutherland start"<<nl<<endl;
os.check
(
"Ostream& operator<<(Ostream&, const realGasSutherlandTransport<thermo>&)"
);
return os;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// ************************************************************************* //

View file

@ -0,0 +1,237 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd |
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 2 of the License, or (at your
option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM; if not, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Class
Foam::realGasSutherlandTransport
Description
Copy of the sutherlandTransport class, modified to be used with real gas properties
Transport package using Sutherland's formula.
Templated into a given thermodynamics package (needed for thermal
conductivity).
Dynamic viscosity [kg/m.s]
@f[
\mu = A_s \frac{\sqrt{T}}{1 + T_s / T}
@f]
SourceFiles
realGasSutherlandTransportI.H
realGasSutherlandTransport.C
Modified by
Christian Lucas
Institut für Thermodynamik
Technische Universität Braunschweig
Germany
\*---------------------------------------------------------------------------*/
#ifndef realGasSutherlandTransport_H
#define realGasSutherlandTransport_H
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// Forward declaration of friend functions and operators
template<class thermo> class realGasSutherlandTransport;
template<class thermo>
inline realGasSutherlandTransport<thermo> operator+
(
const realGasSutherlandTransport<thermo>&,
const realGasSutherlandTransport<thermo>&
);
template<class thermo>
inline realGasSutherlandTransport<thermo> operator-
(
const realGasSutherlandTransport<thermo>&,
const realGasSutherlandTransport<thermo>&
);
template<class thermo>
inline realGasSutherlandTransport<thermo> operator*
(
const scalar,
const realGasSutherlandTransport<thermo>&
);
template<class thermo>
inline realGasSutherlandTransport<thermo> operator==
(
const realGasSutherlandTransport<thermo>&,
const realGasSutherlandTransport<thermo>&
);
template<class thermo>
Ostream& operator<<
(
Ostream&,
const realGasSutherlandTransport<thermo>&
);
/*---------------------------------------------------------------------------*\
Class realGasSutherlandTransport Declaration
\*---------------------------------------------------------------------------*/
template<class thermo>
class realGasSutherlandTransport
:
public thermo
{
// Private data
// Sutherland's coefficients
scalar As, Ts;
// Private member functions
//- Calculate the Sutherland coefficients
// given two viscosities and temperatures
inline void calcCoeffs
(
const scalar mu1, const scalar T1,
const scalar mu2, const scalar T2
);
public:
// Constructors
//- Construct from components
inline realGasSutherlandTransport
(
const thermo& t,
const scalar as,
const scalar ts
);
//- Construct from two viscosities
inline realGasSutherlandTransport
(
const thermo& t,
const scalar mu1, const scalar T1,
const scalar mu2, const scalar T2
);
//- Construct as named copy
inline realGasSutherlandTransport(const word&, const realGasSutherlandTransport&);
//- Construct from Istream
realGasSutherlandTransport(Istream&);
//- Construct and return a clone
inline autoPtr<realGasSutherlandTransport> clone() const;
// Selector from Istream
inline static autoPtr<realGasSutherlandTransport> New(Istream& is);
// Member functions
//- Dynamic viscosity [kg/ms]
inline scalar mu(const scalar T) const;
//- Thermal conductivity [W/mK]
inline scalar kappa(const scalar rho,const scalar T) const;
//- Thermal diffusivity for enthalpy [kg/ms]
inline scalar alpha(const scalar rho,const scalar T) const;
// Member operators
inline realGasSutherlandTransport& operator=
(
const realGasSutherlandTransport&
);
// Friend operators
friend realGasSutherlandTransport operator+ <thermo>
(
const realGasSutherlandTransport&,
const realGasSutherlandTransport&
);
friend realGasSutherlandTransport operator- <thermo>
(
const realGasSutherlandTransport&,
const realGasSutherlandTransport&
);
friend realGasSutherlandTransport operator* <thermo>
(
const scalar,
const realGasSutherlandTransport&
);
friend realGasSutherlandTransport operator== <thermo>
(
const realGasSutherlandTransport&,
const realGasSutherlandTransport&
);
// Ostream Operator
friend Ostream& operator<< <thermo>
(
Ostream&,
const realGasSutherlandTransport&
);
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#include "realGasSutherlandTransportI.H"
#ifdef NoRepository
# include "realGasSutherlandTransport.C"
#endif
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View file

@ -0,0 +1,262 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd |
\\/ M anipulation |
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 2 of the License, or (at your
option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM; if not, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Modified by
Christian Lucas
Institut für Thermodynamik
Technische Universität Braunschweig
Germany
\*---------------------------------------------------------------------------*/
#include "specie.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
template<class thermo>
inline void realGasSutherlandTransport<thermo>::calcCoeffs
(
const scalar mu1, const scalar T1,
const scalar mu2, const scalar T2
)
{
scalar rootT1 = sqrt(T1);
scalar mu1rootT2 = mu1*sqrt(T2);
scalar mu2rootT1 = mu2*rootT1;
Ts = (mu2rootT1 - mu1rootT2)/(mu1rootT2/T1 - mu2rootT1/T2);
As = mu1*(1.0 + Ts/T1)/rootT1;
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
// Construct from components
template<class thermo>
inline realGasSutherlandTransport<thermo>::realGasSutherlandTransport
(
const thermo& t,
const scalar as,
const scalar ts
)
:
thermo(t),
As(as),
Ts(ts)
{}
// Construct from components
template<class thermo>
inline realGasSutherlandTransport<thermo>::realGasSutherlandTransport
(
const thermo& t,
const scalar mu1, const scalar T1,
const scalar mu2, const scalar T2
)
:
thermo(t)
{
calcCoeffs(mu1, T1, mu2, T2);
}
//- Construct as named copy
template<class thermo>
inline realGasSutherlandTransport<thermo>::realGasSutherlandTransport
(
const word& name,
const realGasSutherlandTransport& st
)
:
thermo(name, st),
As(st.As),
Ts(st.Ts)
{}
// Construct and return a clone
template<class thermo>
inline autoPtr<realGasSutherlandTransport<thermo> > realGasSutherlandTransport<thermo>::clone
() const
{
return autoPtr<realGasSutherlandTransport<thermo> >
(
new realGasSutherlandTransport<thermo>(*this)
);
}
// Selector from Istream
template<class thermo>
inline autoPtr<realGasSutherlandTransport<thermo> > realGasSutherlandTransport<thermo>::New
(
Istream& is
)
{
return autoPtr<realGasSutherlandTransport<thermo> >
(
new realGasSutherlandTransport<thermo>(is)
);
}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
// Dynamic viscosity [kg/ms]
template<class thermo>
inline scalar realGasSutherlandTransport<thermo>::mu(const scalar T) const
{
return As*::sqrt(T)/(1.0 + Ts/T);
}
// Thermal conductivity [W/mK]
template<class thermo>
inline scalar realGasSutherlandTransport<thermo>::kappa(const scalar rho, const scalar T) const
{
scalar Cv_ = this->Cv(rho,T);
return mu(T)*Cv_*(1.32 + 1.77*this->R()/Cv_);
}
// Thermal diffusivity for enthalpy [kg/ms]
template<class thermo>
inline scalar realGasSutherlandTransport<thermo>::alpha(const scalar rho, const scalar T) const
{
scalar Cv_ = this->Cv(rho,T);
scalar Cp_ = this->Cp(rho,T);
scalar deltaT = T - specie::Tstd;
scalar CpBar =
(deltaT*(this->H(rho, T) - this->H(this->rhostd(),specie::Tstd)) + Cp_)/(sqr(deltaT) + 1);
return mu(T)*Cv_*(1.32 + 1.77*this->R()/Cv_)/CpBar;
}
// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
template<class thermo>
inline realGasSutherlandTransport<thermo>& realGasSutherlandTransport<thermo>::operator=
(
const realGasSutherlandTransport<thermo>& st
)
{
thermo::operator=(st);
As = st.As;
Ts = st.Ts;
return *this;
}
// * * * * * * * * * * * * * * * Friend Operators * * * * * * * * * * * * * //
template<class thermo>
inline realGasSutherlandTransport<thermo> operator+
(
const realGasSutherlandTransport<thermo>& st1,
const realGasSutherlandTransport<thermo>& st2
)
{
thermo t
(
static_cast<const thermo&>(st1) + static_cast<const thermo&>(st2)
);
scalar molr1 = st1.nMoles()/t.nMoles();
scalar molr2 = st2.nMoles()/t.nMoles();
return realGasSutherlandTransport<thermo>
(
t,
molr1*st1.As + molr2*st2.As,
molr1*st1.Ts + molr2*st2.Ts
);
}
template<class thermo>
inline realGasSutherlandTransport<thermo> operator-
(
const realGasSutherlandTransport<thermo>& st1,
const realGasSutherlandTransport<thermo>& st2
)
{
thermo t
(
static_cast<const thermo&>(st1) - static_cast<const thermo&>(st2)
);
scalar molr1 = st1.nMoles()/t.nMoles();
scalar molr2 = st2.nMoles()/t.nMoles();
return realGasSutherlandTransport<thermo>
(
t,
molr1*st1.As - molr2*st2.As,
molr1*st1.Ts - molr2*st2.Ts
);
}
template<class thermo>
inline realGasSutherlandTransport<thermo> operator*
(
const scalar s,
const realGasSutherlandTransport<thermo>& st
)
{
return realGasSutherlandTransport<thermo>
(
s*static_cast<const thermo&>(st),
st.As,
st.Ts
);
}
template<class thermo>
inline realGasSutherlandTransport<thermo> operator==
(
const realGasSutherlandTransport<thermo>& st1,
const realGasSutherlandTransport<thermo>& st2
)
{
return st2 - st1;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// ************************************************************************* //

View file

@ -0,0 +1,49 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: 1.7.1 |
| \\ / A nd | Web: www.OpenFOAM.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class volScalarField;
location "0";
object T;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
dimensions [0 0 0 1 0 0 0];
internalField uniform 333.15;
boundaryField
{
INLET
{
type fixedValue;
value uniform 333.15;
}
OUTLET
{
type zeroGradient;
}
WALL_1
{
type zeroGradient;
}
WALL_2
{
type zeroGradient;
}
frontAndBackPlanes
{
type empty;
}
}
// ************************************************************************* //

View file

@ -0,0 +1,52 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: 1.7.1 |
| \\ / A nd | Web: www.OpenFOAM.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class volVectorField;
location "0";
object U;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
dimensions [0 1 -1 0 0 0 0];
internalField uniform (5 0 0);
boundaryField
{
INLET
{
type inletOutlet;
inletValue uniform (5 0 0);
value uniform (5 0 0);
}
OUTLET
{
type zeroGradient;
}
WALL_1
{
type fixedValue;
value uniform (0 0 0);
}
WALL_2
{
type fixedValue;
value uniform (0 0 0);
}
frontAndBackPlanes
{
type empty;
}
}
// ************************************************************************* //

View file

@ -0,0 +1,53 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM Extend Project: Open source CFD |
| \\ / O peration | Version: 1.6-ext |
| \\ / A nd | Web: www.extend-project.de |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class volScalarField;
location "0";
object alphat;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
dimensions [1 -1 -1 0 0 0 0];
internalField uniform 0;
boundaryField
{
WALL_1
{
type alphatWallFunction;
Prt 0.85;
value uniform 0;
}
WALL_2
{
type alphatWallFunction;
Prt 0.85;
value uniform 0;
}
INLET
{
type calculated;
value uniform 0;
}
OUTLET
{
type calculated;
value uniform 0;
}
frontAndBackPlanes
{
type empty;
}
}
// ************************************************************************* //

View file

@ -0,0 +1,58 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM Extend Project: Open source CFD |
| \\ / O peration | Version: 1.6-ext |
| \\ / A nd | Web: www.extend-project.de |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class volScalarField;
location "0";
object epsilon;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
dimensions [0 2 -3 0 0 0 0];
internalField uniform 1120;
boundaryField
{
WALL_1
{
type compressible::epsilonWallFunction;
Cmu 0.09;
kappa 0.41;
E 9.8;
value uniform 1120;
}
WALL_2
{
type compressible::epsilonWallFunction;
Cmu 0.09;
kappa 0.41;
E 9.8;
value uniform 1120;
}
INLET
{
type fixedValue;
value uniform 1120;
}
OUTLET
{
type inletOutlet;
inletValue uniform 1120;
value uniform 1120;
}
frontAndBackPlanes
{
type empty;
}
}
// ************************************************************************* //

View file

@ -0,0 +1,59 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM Extend Project: Open source CFD |
| \\ / O peration | Version: 1.6-ext |
| \\ / A nd | Web: www.extend-project.de |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class volScalarField;
location "0";
object epsilon;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
dimensions [0 2 -3 0 0 0 0];
internalField uniform 1120;
boundaryField
{
WALL_1
{
type compressible::epsilonWallFunction;
Cmu 0.09;
kappa 0.41;
E 9.8;
value uniform 1120;
}
INLET
{
type fixedValue;
value uniform 1120;
}
OUTLET
{
type inletOutlet;
inletValue uniform 1120;
value uniform 1120;
}
WALL_2
{
type compressible::epsilonWallFunction;
Cmu 0.09;
kappa 0.41;
E 9.8;
value uniform 1120;
}
frontAndBackPlanes
{
type empty;
}
}
// ************************************************************************* //

View file

@ -0,0 +1,51 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM Extend Project: Open source CFD |
| \\ / O peration | Version: 1.6-ext |
| \\ / A nd | Web: www.extend-project.de |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class volScalarField;
location "0";
object k;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
dimensions [0 2 -2 0 0 0 0];
internalField uniform 5;
boundaryField
{
WALL_1
{
type compressible::kqRWallFunction;
value uniform 5;
}
WALL_2
{
type compressible::kqRWallFunction;
value uniform 5;
}
INLET
{
type turbulentIntensityKineticEnergyInlet;
intensity 0.01;
value uniform 5;
}
OUTLET
{
type zeroGradient;
}
frontAndBackPlanes
{
type empty;
}
}
// ************************************************************************* //

View file

@ -0,0 +1,52 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM Extend Project: Open source CFD |
| \\ / O peration | Version: 1.6-ext |
| \\ / A nd | Web: www.extend-project.de |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class volScalarField;
location "0";
object k;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
dimensions [0 2 -2 0 0 0 0];
internalField uniform 5;
boundaryField
{
WALL_1
{
type compressible::kqRWallFunction;
value uniform 5;
}
INLET
{
type turbulentIntensityKineticEnergyInlet;
intensity 0.01;
value uniform 5;
}
OUTLET
{
type zeroGradient;
}
WALL_2
{
type compressible::kqRWallFunction;
value uniform 5;
}
frontAndBackPlanes
{
type empty;
}
}
// ************************************************************************* //

View file

@ -0,0 +1,57 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM Extend Project: Open source CFD |
| \\ / O peration | Version: 1.6-ext |
| \\ / A nd | Web: www.extend-project.de |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class volScalarField;
location "0";
object mut;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
dimensions [1 -1 -1 0 0 0 0];
internalField uniform 0;
boundaryField
{
WALL_1
{
type mutWallFunction;
Cmu 0.09;
kappa 0.41;
E 9.8;
value uniform 0;
}
WALL_2
{
type mutWallFunction;
Cmu 0.09;
kappa 0.41;
E 9.8;
value uniform 0;
}
INLET
{
type calculated;
value uniform 0;
}
OUTLET
{
type calculated;
value uniform 0;
}
frontAndBackPlanes
{
type empty;
}
}
// ************************************************************************* //

View file

@ -0,0 +1,49 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: 1.7.1 |
| \\ / A nd | Web: www.OpenFOAM.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class volScalarField;
location "0";
object p;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
dimensions [1 -1 -2 0 0 0 0];
internalField uniform 80e5;
boundaryField
{
INLET
{
type zeroGradient;
}
OUTLET
{
type fixedValue;
value uniform 8e+06;
}
WALL_1
{
type zeroGradient;
}
WALL_2
{
type zeroGradient;
}
frontAndBackPlanes
{
type empty;
}
}
// ************************************************************************* //

View file

@ -0,0 +1,25 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: 1.6 |
| \\ / A nd | Web: www.OpenFOAM.org |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
location "constant";
object RASProperties;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
RASModel kEpsilon;
turbulence on;
printCoeffs on;
// ************************************************************************* //

View file

@ -0,0 +1,52 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM Extend Project: Open source CFD |
| \\ / O peration | Version: 1.6-ext |
| \\ / A nd | Web: www.extend-project.de |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class polyBoundaryMesh;
location "constant/polyMesh";
object boundary;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
5
(
WALL_1
{
type wall;
nFaces 99;
startFace 3644;
}
WALL_2
{
type wall;
nFaces 99;
startFace 3743;
}
INLET
{
type patch;
nFaces 19;
startFace 3842;
}
OUTLET
{
type patch;
nFaces 19;
startFace 3861;
}
frontAndBackPlanes
{
type empty;
nFaces 3762;
startFace 3880;
}
)
// ************************************************************************* //

View file

@ -0,0 +1,21 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM Extend Project: Open source CFD |
| \\ / O peration | Version: 1.6-ext |
| \\ / A nd | Web: www.extend-project.de |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class regIOobject;
location "constant/polyMesh";
object cellZones;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
0
()
// ************************************************************************* //

View file

@ -0,0 +1,21 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM Extend Project: Open source CFD |
| \\ / O peration | Version: 1.6-ext |
| \\ / A nd | Web: www.extend-project.de |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class regIOobject;
location "constant/polyMesh";
object faceZones;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
0
()
// ************************************************************************* //

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,21 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM Extend Project: Open source CFD |
| \\ / O peration | Version: 1.6-ext |
| \\ / A nd | Web: www.extend-project.de |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class regIOobject;
location "constant/polyMesh";
object pointZones;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
0
()
// ************************************************************************* //

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,40 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM Extend Project: Open source CFD |
| \\ / O peration | Version: 1.6-ext |
| \\ / A nd | Web: www.extend-project.de |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class wordList;
location "constant/polyMesh";
object zoneToPatchName;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
16
(
unknown
unknown
unknown
unknown
unknown
unknown
unknown
unknown
unknown
unknown
unknown
int_SOLID
WALL_1
WALL_2
INLET
OUTLET
)
// ************************************************************************* //

View file

@ -0,0 +1,59 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: 1.6 |
| \\ / A nd | Web: www.OpenFOAM.org |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
location "constant";
object thermophysicalProperties;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
thermoType realGasHThermo<pureMixture<realGasSutherlandTransport<realGasSpecieThermo<nasaHeatCapacityPolynomial<aungierRedlichKwong>>>>>;
mixture CO2 1 44.01 73.773e5 304.13 0.22394 467.6 49436.5054 -626.411601 5.30172524 0.002503813816 -0.0000002127308728 -0.000000000768998878 2.849677801E-13 1.4792e-06 116;
//thermoType realGasHThermo<pureMixture<realGasSutherlandTransport<realGasSpecieThermo<nasaHeatCapacityPolynomial<redlichKwong>>>>>;
//mixture CO2 1 44.01 73.773e5 304.13 0.22394 49436.5054 -626.411601 5.30172524 0.002503813816 -0.0000002127308728 -0.000000000768998878 2.849677801e-13 1.4792e-06 116;
//thermoType realGasHThermo<pureMixture<realGasSutherlandTransport<realGasSpecieThermo<nasaHeatCapacityPolynomial<pengRobinson>>>>>;
//mixture CO2 1 44.01 73.773e5 304.13 0.22394 49436.5054 -626.411601 5.30172524 0.002503813816 -0.0000002127308728 -0.000000000768998878 2.849677801e-13 1.4792e-06 116;
//thermoType realGasHThermo<pureMixture<realGasSutherlandTransport<realGasSpecieThermo<nasaHeatCapacityPolynomial<soaveRedlichKwong>>>>>;
//mixture CO2 1 44.01 73.773e5 304.13 0.22394 49436.5054 -626.411601 5.30172524 0.002503813816 -0.0000002127308728 -0.000000000768998878 2.849677801e-13 1.4792e-06 116;
//thermoType realGasHThermo<pureMixture<realGasConstTransport<realGasSpecieThermo<nasaHeatCapacityPolynomial<aungierRedlichKwong>>>>>;
//mixture CO2 1 44.01 73.773e5 304.13 0.22394 467.6 49436.5054 -626.411601 5.30172524 0.002503813816 -0.0000002127308728 -0.000000000768998878 2.849677801E-13 1e-06 0.7;
//thermoType realGasHThermo<pureMixture<realGasConstTransport<realGasSpecieThermo<nasaHeatCapacityPolynomial<redlichKwong>>>>>;
//mixture CO2 1 44.01 73.773e5 304.13 0.22394 49436.5054 -626.411601 5.30172524 0.002503813816 -0.0000002127308728 -0.000000000768998878 2.849677801e-13 1e-06 0.7;
//thermoType realGasHThermo<pureMixture<realGasConstTransport<realGasSpecieThermo<nasaHeatCapacityPolynomial<pengRobinson>>>>>;
//mixture CO2 1 44.01 73.773e5 304.13 0.22394 49436.5054 -626.411601 5.30172524 0.002503813816 -0.0000002127308728 -0.000000000768998878 2.849677801e-13 1e-06 0.7;
//thermoType realGasHThermo<pureMixture<realGasConstTransport<realGasSpecieThermo<nasaHeatCapacityPolynomial<soaveRedlichKwong>>>>>;
//mixture CO2 1 44.01 73.773e5 304.13 0.22394 49436.5054 -626.411601 5.30172524 0.002503813816 -0.0000002127308728 -0.000000000768998878 2.849677801e-13 1e-06 0.7;
// *********************************************************************************************************************** //
// Coefficient
// CO2 --> Name
// 1
// 44.01 --> Molar Volume
// 77.773e5 --> critical pressure
// 304.13 --> critical temperatur
// 0.22394 --> acentric factor
// 467.6 --> critical density (only for aungier redlich kwong
// 49436.5054 --> 2.849677801e-13 --> 7 heat capacity polynomial coefficent's
// .... --> two coefficent's for sutherland model or for the constTransport model
// *********************************************************************************************************************** //
// ************************************************************************* //

View file

@ -0,0 +1,21 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: 1.6 |
| \\ / A nd | Web: www.OpenFOAM.org |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
location "constant";
object turbulenceProperties;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
simulationType RASModel;
// ************************************************************************* //

View file

@ -0,0 +1,55 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: 1.6 |
| \\ / A nd | Web: www.OpenFOAM.org |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
location "system";
object controlDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
application rhoPisoFoam;
startFrom latestTime;
//startTime 0;
stopAt endTime;
endTime 0.5;
deltaT 1e-5;
writeControl runTime;
writeInterval 1e-2;
purgeWrite 0;
writeFormat ascii;
writePrecision 6;
writeCompression uncompressed;
timeFormat general;
timePrecision 20;
adjustTimeStep yes;
maxCo 0.05;
maxDeltaT 1e-4;
runTimeModifiable yes;
// ************************************************************************* //

View file

@ -0,0 +1,76 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: 1.6 |
| \\ / A nd | Web: www.OpenFOAM.org |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
location "system";
object fvSchemes;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
ddtSchemes
{
default Euler;
}
gradSchemes
{
default cellMDLimited Gauss linear 0.333;
grad(p) cellMDLimited Gauss linear 0.333;
}
divSchemes
{
default none;
div(phi,U) Gauss limitedLinearV 0.5;
div(phid,p) Gauss limitedLinear 0.5;
div(phiU,p) Gauss limitedLinear 0.5;
div(phi,h) Gauss limitedLinear 0.5;
div(phi,k) Gauss limitedLinear 0.5;
div(phi,epsilon) Gauss limitedLinear 0.5;
div(phi,R) Gauss limitedLinear 0.5;
div(phi,omega) Gauss limitedLinear 0.5;;
div(U) Gauss limitedLinear 0.5;
div((muEff*dev2(grad(U).T()))) Gauss linear;
}
laplacianSchemes
{
default none;
laplacian(muEff,U) Gauss linear corrected;
laplacian(mut,U) Gauss linear corrected;
laplacian(DkEff,k) Gauss linear corrected;
laplacian(DepsilonEff,epsilon) Gauss linear corrected;
laplacian(DREff,R) Gauss linear corrected;
laplacian(DomegaEff,omega) Gauss linear corrected;
laplacian((rho*(1|A(U))),p) Gauss linear corrected;
laplacian(alphaEff,h) Gauss linear corrected;
}
interpolationSchemes
{
default linear;
}
snGradSchemes
{
default corrected;
}
fluxRequired
{
default no;
p ;
}
// ************************************************************************* //

View file

@ -0,0 +1,100 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | |
| \\ / A nd |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
location "system";
object fvSolution;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
solvers
{
p
{
solver GAMG;
tolerance 1e-14;
relTol 0.001;
smoother GaussSeidel;
minIter 4;
//maxIter 100;
cacheAgglomeration true;
nPreSweeps 1;
nPostSweeps 3;
nFinestSweeps 3;
nCellsInCoarsestLevel 20;
agglomerator faceAreaPair;
mergeLevels 1;
}
U
{
solver smoothSolver;
smoother GaussSeidel;
nSweeps 2;
tolerance 1e-14;
relTol 0.001;
}
rho
{
solver PCG;
preconditioner DIC;
tolerance 1e-10;
relTol 0;
}
htot
{
solver smoothSolver;
smoother GaussSeidel;
nSweeps 2;
tolerance 1e-14;
relTol 0.001;
}
h
{
solver smoothSolver;
smoother GaussSeidel;
nSweeps 2;
tolerance 1e-14;
relTol 0.001;
}
k
{
solver PBiCG;
preconditioner DILU;
tolerance 1e-10;
relTol 0;
}
epsilon
{
solver PBiCG;
preconditioner DILU;
tolerance 1e-10;
relTol 0;
}
}
PISO
{
nNonOrthogonalCorrectors 0;
nCorrectors 6;
momentumPredictor yes;
// transonic true;
}
// ************************************************************************* //

View file

@ -0,0 +1,44 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM Extend Project: Open Source CFD |
| \\ / O peration | Version: 1.6-ext |
| \\ / A nd | Web: www.extend-project.de |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
location "system";
object sampleDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
interpolationScheme cellPoint;
setFormat raw;
sets
(
leftPatch
{
type uniform;
axis y;
start (0.49 0 0.0);
end (0.49 0.01 0);
nPoints 100;
}
);
fields
(
U p T
);
surfaces
(
);
// ************************************************************************* //