From 01efb2c85b74e7ad37ce230322444159f5e10aa5 Mon Sep 17 00:00:00 2001 From: Henry Weller Date: Tue, 19 Sep 2017 09:26:26 +0100 Subject: [PATCH] ENH: engineTime: Generalized to provide run-time selection of piston-motion Standard crank-connecting rod and the new free-piston kinematics motion options are provides, others can easily be added. Contributed by Francesco Contino and Nicolas Bourgeois, BURN Research Group. --- .../coldEngineFoam/coldEngineFoam.C | 4 +- .../coldEngineFoam/readEngineTimeControls.H | 3 + src/engine/Make/files | 6 +- .../crankConRod.C} | 95 ++++------ .../crankConRod.H} | 61 +++--- src/engine/engineTime/engineTime/engineTime.C | 126 +++++++++++++ src/engine/engineTime/engineTime/engineTime.H | 176 ++++++++++++++++++ .../engineTime/engineTime/engineTimeNew.C | 80 ++++++++ src/engine/engineTime/freePiston/freePiston.C | 91 +++++++++ src/engine/engineTime/freePiston/freePiston.H | 145 +++++++++++++++ src/engine/ignition/ignitionSiteIO.C | 6 +- src/engine/include/createEngineTime.H | 11 +- .../combustion/engineFoam/freePiston/0/T | 53 ++++++ .../combustion/engineFoam/freePiston/0/U | 53 ++++++ .../combustion/engineFoam/freePiston/0/air | 53 ++++++ .../combustion/engineFoam/freePiston/0/alphat | 38 ++++ .../engineFoam/freePiston/0/epsilon | 53 ++++++ .../freePiston/0/include/boundaryConditions | 70 +++++++ .../freePiston/0/include/caseSettings | 28 +++ .../combustion/engineFoam/freePiston/0/k | 53 ++++++ .../combustion/engineFoam/freePiston/0/nut | 38 ++++ .../combustion/engineFoam/freePiston/0/p | 53 ++++++ .../freePiston/constant/engineGeometry | 29 +++ .../engineFoam/freePiston/constant/g | 21 +++ .../freePiston/constant/include/reactions.air | 8 + .../freePiston/constant/include/thermo.air | 21 +++ .../constant/thermophysicalProperties | 38 ++++ .../freePiston/constant/turbulenceProperties | 29 +++ .../freePiston/system/blockMeshDict | 87 +++++++++ .../engineFoam/freePiston/system/controlDict | 51 +++++ .../engineFoam/freePiston/system/fvSchemes | 66 +++++++ .../engineFoam/freePiston/system/fvSolution | 62 ++++++ 32 files changed, 1599 insertions(+), 109 deletions(-) create mode 100644 applications/solvers/combustion/coldEngineFoam/readEngineTimeControls.H rename src/engine/engineTime/{engineTime.C => crankConRod/crankConRod.C} (66%) rename src/engine/engineTime/{engineTime.H => crankConRod/crankConRod.H} (82%) create mode 100644 src/engine/engineTime/engineTime/engineTime.C create mode 100644 src/engine/engineTime/engineTime/engineTime.H create mode 100644 src/engine/engineTime/engineTime/engineTimeNew.C create mode 100644 src/engine/engineTime/freePiston/freePiston.C create mode 100644 src/engine/engineTime/freePiston/freePiston.H create mode 100644 tutorials/combustion/engineFoam/freePiston/0/T create mode 100644 tutorials/combustion/engineFoam/freePiston/0/U create mode 100644 tutorials/combustion/engineFoam/freePiston/0/air create mode 100644 tutorials/combustion/engineFoam/freePiston/0/alphat create mode 100644 tutorials/combustion/engineFoam/freePiston/0/epsilon create mode 100644 tutorials/combustion/engineFoam/freePiston/0/include/boundaryConditions create mode 100644 tutorials/combustion/engineFoam/freePiston/0/include/caseSettings create mode 100644 tutorials/combustion/engineFoam/freePiston/0/k create mode 100644 tutorials/combustion/engineFoam/freePiston/0/nut create mode 100644 tutorials/combustion/engineFoam/freePiston/0/p create mode 100644 tutorials/combustion/engineFoam/freePiston/constant/engineGeometry create mode 100644 tutorials/combustion/engineFoam/freePiston/constant/g create mode 100644 tutorials/combustion/engineFoam/freePiston/constant/include/reactions.air create mode 100644 tutorials/combustion/engineFoam/freePiston/constant/include/thermo.air create mode 100644 tutorials/combustion/engineFoam/freePiston/constant/thermophysicalProperties create mode 100644 tutorials/combustion/engineFoam/freePiston/constant/turbulenceProperties create mode 100644 tutorials/combustion/engineFoam/freePiston/system/blockMeshDict create mode 100644 tutorials/combustion/engineFoam/freePiston/system/controlDict create mode 100644 tutorials/combustion/engineFoam/freePiston/system/fvSchemes create mode 100644 tutorials/combustion/engineFoam/freePiston/system/fvSolution diff --git a/applications/solvers/combustion/coldEngineFoam/coldEngineFoam.C b/applications/solvers/combustion/coldEngineFoam/coldEngineFoam.C index 7c442bafcb..799b2ee3fc 100644 --- a/applications/solvers/combustion/coldEngineFoam/coldEngineFoam.C +++ b/applications/solvers/combustion/coldEngineFoam/coldEngineFoam.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -77,7 +77,7 @@ int main(int argc, char *argv[]) runTime++; - Info<< "Crank angle = " << runTime.theta() << " CA-deg" + Info<< "Engine time = " << runTime.theta() << runTime.unit() << endl; mesh.move(); diff --git a/applications/solvers/combustion/coldEngineFoam/readEngineTimeControls.H b/applications/solvers/combustion/coldEngineFoam/readEngineTimeControls.H new file mode 100644 index 0000000000..cccee289dd --- /dev/null +++ b/applications/solvers/combustion/coldEngineFoam/readEngineTimeControls.H @@ -0,0 +1,3 @@ + #include "createTimeControls.H" + + maxDeltaT = runTime.userTimeToTime(maxDeltaT); diff --git a/src/engine/Make/files b/src/engine/Make/files index a11ecaf06f..a53bfe3ec6 100644 --- a/src/engine/Make/files +++ b/src/engine/Make/files @@ -1,4 +1,8 @@ -engineTime/engineTime.C +engineTime/engineTime/engineTime.C +engineTime/engineTime/engineTimeNew.C +engineTime/freePiston/freePiston.C +engineTime/crankConRod/crankConRod.C + ignition/ignition.C ignition/ignitionIO.C ignition/ignitionSite.C diff --git a/src/engine/engineTime/engineTime.C b/src/engine/engineTime/crankConRod/crankConRod.C similarity index 66% rename from src/engine/engineTime/engineTime.C rename to src/engine/engineTime/crankConRod/crankConRod.C index a70f6bba77..ca8bb64147 100644 --- a/src/engine/engineTime/engineTime.C +++ b/src/engine/engineTime/crankConRod/crankConRod.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2017 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -23,12 +23,22 @@ License \*---------------------------------------------------------------------------*/ -#include "engineTime.H" +#include "crankConRod.H" #include "unitConversion.H" +#include "addToRunTimeSelectionTable.H" + +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +namespace Foam +{ + defineTypeNameAndDebug(crankConRod, 0); + addToRunTimeSelectionTable(engineTime, crankConRod, dictionary); +} + // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // -void Foam::engineTime::timeAdjustment() +void Foam::crankConRod::timeAdjustment() { deltaT_ = degToTime(deltaT_); endTime_ = degToTime(endTime_); @@ -46,7 +56,7 @@ void Foam::engineTime::timeAdjustment() // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // -Foam::engineTime::engineTime +Foam::crankConRod::crankConRod ( const word& name, const fileName& rootPath, @@ -56,7 +66,7 @@ Foam::engineTime::engineTime const fileName& dictName ) : - Time + engineTime ( name, rootPath, @@ -64,18 +74,6 @@ Foam::engineTime::engineTime systemName, constantName ), - dict_ - ( - IOobject - ( - "engineGeometry", - constant(), - *this, - IOobject::MUST_READ_IF_MODIFIED, - IOobject::NO_WRITE, - false - ) - ), rpm_(dict_.lookup("rpm")), conRodLength_(dimensionedScalar("conRodLength", dimLength, 0)), bore_(dimensionedScalar("bore", dimLength, 0)), @@ -92,6 +90,7 @@ Foam::engineTime::engineTime startTime_ = degToTime(startTime_); value() = degToTime(value()); + deltaTSave_ = deltaT_; deltaT0_ = deltaT_; } @@ -99,16 +98,14 @@ Foam::engineTime::engineTime // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // -// Read the controlDict and set all the parameters -void Foam::engineTime::readDict() +void Foam::crankConRod::readDict() { Time::readDict(); timeAdjustment(); } -// Read the controlDict and set all the parameters -bool Foam::engineTime::read() +bool Foam::crankConRod::read() { if (Time::read()) { @@ -122,29 +119,33 @@ bool Foam::engineTime::read() } -Foam::scalar Foam::engineTime::degToTime(const scalar theta) const +Foam::scalar Foam::crankConRod::degToTime(const scalar theta) const { // 6 * rpm => deg/s return theta/(6.0*rpm_.value()); } -Foam::scalar Foam::engineTime::timeToDeg(const scalar t) const +Foam::scalar Foam::crankConRod::timeToDeg(const scalar t) const { // 6 * rpm => deg/s return t*(6.0*rpm_.value()); } -Foam::scalar Foam::engineTime::theta() const +Foam::scalar Foam::crankConRod::theta() const { return timeToDeg(value()); } -// Return current crank-angle translated to a single revolution -// (value between -180 and 180 with 0 = top dead centre) -Foam::scalar Foam::engineTime::thetaRevolution() const +Foam::word Foam::crankConRod::unit() const +{ + return " CAD"; +} + + +Foam::scalar Foam::crankConRod::thetaRevolution() const { scalar t = theta(); @@ -162,13 +163,13 @@ Foam::scalar Foam::engineTime::thetaRevolution() const } -Foam::scalar Foam::engineTime::deltaTheta() const +Foam::scalar Foam::crankConRod::deltaTheta() const { return timeToDeg(deltaTValue()); } -Foam::scalar Foam::engineTime::pistonPosition(const scalar theta) const +Foam::scalar Foam::crankConRod::pistonPosition(const scalar theta) const { return ( @@ -187,46 +188,14 @@ Foam::scalar Foam::engineTime::pistonPosition(const scalar theta) const } -Foam::dimensionedScalar Foam::engineTime::pistonPosition() const -{ - return dimensionedScalar - ( - "pistonPosition", - dimLength, - pistonPosition(theta()) - ); -} - -Foam::dimensionedScalar Foam::engineTime::pistonDisplacement() const -{ - return dimensionedScalar - ( - "pistonDisplacement", - dimLength, - pistonPosition(theta() - deltaTheta()) - pistonPosition().value() - ); -} - - -Foam::dimensionedScalar Foam::engineTime::pistonSpeed() const -{ - return dimensionedScalar - ( - "pistonSpeed", - dimVelocity, - pistonDisplacement().value()/(deltaTValue() + VSMALL) - ); -} - - -Foam::scalar Foam::engineTime::userTimeToTime(const scalar theta) const +Foam::scalar Foam::crankConRod::userTimeToTime(const scalar theta) const { return degToTime(theta); } -Foam::scalar Foam::engineTime::timeToUserTime(const scalar t) const +Foam::scalar Foam::crankConRod::timeToUserTime(const scalar t) const { return timeToDeg(t); } diff --git a/src/engine/engineTime/engineTime.H b/src/engine/engineTime/crankConRod/crankConRod.H similarity index 82% rename from src/engine/engineTime/engineTime.H rename to src/engine/engineTime/crankConRod/crankConRod.H index 2ccb142a12..358d16fb43 100644 --- a/src/engine/engineTime/engineTime.H +++ b/src/engine/engineTime/crankConRod/crankConRod.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2017 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -22,12 +22,12 @@ License along with OpenFOAM. If not, see . Class - Foam::engineTime + Foam::crankConRod Description Manage time in terms of engine RPM and crank-angle. - When engineTime is in effect, the userTime is reported in degrees + When crankConRod is in effect, the userTime is reported in degrees crank-angle instead of in seconds. The RPM to be used is specified in \c constant/engineGeometry. If only a time conversion is required, the geometric engine parameters can be dropped or set to zero. @@ -42,19 +42,16 @@ Description clearance clearance [0 1 0 0 0] 0.0; \endverbatim -Note - The engineTime can currently only be selected at compile-time. - SourceFiles - engineTime.C + crankConRod.C \*---------------------------------------------------------------------------*/ -#ifndef engineTime_H -#define engineTime_H +#ifndef crankConRod_H +#define crankConRod_H -#include "Time.H" -#include "IOdictionary.H" +#include "engineTime.H" +#include "dictionary.H" #include "dimensionedScalar.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -63,17 +60,15 @@ namespace Foam { /*---------------------------------------------------------------------------*\ - Class engineTime Declaration + Class crankConRod Declaration \*---------------------------------------------------------------------------*/ -class engineTime +class crankConRod : - public Time + public engineTime { // Private data - IOdictionary dict_; - //- RPM is required dimensionedScalar rpm_; @@ -87,20 +82,24 @@ class engineTime // Private Member Functions //- Disallow default bitwise copy construct - engineTime(const engineTime&); + crankConRod(const crankConRod&); //- Disallow default bitwise assignment - void operator=(const engineTime&); + void operator=(const crankConRod&); //- Adjust read time values void timeAdjustment(); public: + //- Runtime type information + TypeName("crankConRod"); + + // Constructors //- Construct from objectRegistry arguments - engineTime + crankConRod ( const word& name, const fileName& rootPath, @@ -111,7 +110,7 @@ public: ); //- Destructor - virtual ~engineTime() + virtual ~crankConRod() {} @@ -132,12 +131,6 @@ public: // Access - //- Return the engine geometry dictionary - const IOdictionary& engineDict() const - { - return dict_; - } - //- Return the engines current operating RPM const dimensionedScalar& rpm() const { @@ -170,23 +163,17 @@ public: //- Return current crank-angle - scalar theta() const; + virtual scalar theta() const; + + //- Return time unit + virtual word unit() const; //- Return current crank-angle translated to a single revolution // (value between -180 and 180 with 0 = top dead centre) scalar thetaRevolution() const; //- Return crank-angle increment - scalar deltaTheta() const; - - //- Return current piston position - dimensionedScalar pistonPosition() const; - - //- Return piston displacement for current time step - dimensionedScalar pistonDisplacement() const; - - //- Return piston speed for current time step - dimensionedScalar pistonSpeed() const; + virtual scalar deltaTheta() const; // Member functions overriding the virtual functions in time diff --git a/src/engine/engineTime/engineTime/engineTime.C b/src/engine/engineTime/engineTime/engineTime.C new file mode 100644 index 0000000000..0a571b238d --- /dev/null +++ b/src/engine/engineTime/engineTime/engineTime.C @@ -0,0 +1,126 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation + \\/ 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 3 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, see . + +\*---------------------------------------------------------------------------*/ + +#include "engineTime.H" + +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +namespace Foam +{ + defineTypeNameAndDebug(engineTime, 0); + defineRunTimeSelectionTable(engineTime, dictionary); +} + + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +Foam::engineTime::engineTime +( + const word& name, + const fileName& rootPath, + const fileName& caseName, + const fileName& systemName, + const fileName& constantName, + const fileName& dictName +) +: + Time + ( + name, + rootPath, + caseName, + systemName, + constantName + ), + dict_ + ( + IOobject + ( + "engineGeometry", + constant(), + *this, + IOobject::MUST_READ_IF_MODIFIED, + IOobject::NO_WRITE, + false + ) + ) +{} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +void Foam::engineTime::readDict() +{ + Time::readDict(); +} + + +bool Foam::engineTime::read() +{ + if (Time::read()) + { + return true; + } + else + { + return false; + } +} + + +Foam::dimensionedScalar Foam::engineTime::pistonPosition() const +{ + return dimensionedScalar + ( + "pistonPosition", + dimLength, + pistonPosition(theta()) + ); +} + + +Foam::dimensionedScalar Foam::engineTime::pistonDisplacement() const +{ + return dimensionedScalar + ( + "pistonDisplacement", + dimLength, + pistonPosition(theta() - deltaTheta()) - pistonPosition().value() + ); +} + + +Foam::dimensionedScalar Foam::engineTime::pistonSpeed() const +{ + return dimensionedScalar + ( + "pistonSpeed", + dimVelocity, + pistonDisplacement().value()/(deltaTValue() + VSMALL) + ); +} + + +// ************************************************************************* // diff --git a/src/engine/engineTime/engineTime/engineTime.H b/src/engine/engineTime/engineTime/engineTime.H new file mode 100644 index 0000000000..aa4e83af6b --- /dev/null +++ b/src/engine/engineTime/engineTime/engineTime.H @@ -0,0 +1,176 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation + \\/ 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 3 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, see . + +Class + Foam::engineTime + +Description + An abstract class for the time description of the piston motion + +SourceFiles + engineTime.C + +\*---------------------------------------------------------------------------*/ + +#ifndef engineTime_H +#define engineTime_H + +#include "Time.H" +#include "IOdictionary.H" +#include "dimensionedScalar.H" +#include "runTimeSelectionTables.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +/*---------------------------------------------------------------------------*\ + Class engineTime Declaration +\*---------------------------------------------------------------------------*/ + +class engineTime +: + public Time +{ + +protected: + + const IOdictionary dict_; + + +public: + + //- Runtime type information + TypeName("engineTime"); + + + //- Declare runtime constructor selection table + declareRunTimeSelectionTable + ( + autoPtr, + engineTime, + dictionary, + ( + const word& name, + const fileName& rootPath, + const fileName& caseName, + const fileName& systemName, + const fileName& constantName, + const fileName& dictName + ), + (name, rootPath, caseName, systemName, constantName, dictName) + ); + + + // Constructors + + //- Construct from objectRegistry arguments + engineTime + ( + const word& name, + const fileName& rootPath, + const fileName& caseName, + const fileName& systemName = "system", + const fileName& constantName = "constant", + const fileName& dictName = "engineGeometry" + ); + + + // Selector + + static autoPtr New + ( + const word& name, + const fileName& rootPath, + const fileName& caseName, + const fileName& systemName = "system", + const fileName& constantName = "constant", + const fileName& dictName = "engineGeometry" + ); + + + //- Destructor + virtual ~engineTime() + {} + + + // Member Functions + // Conversion + + //- Calculate the piston position from the engine geometry + // and given timr (CA or s) + virtual scalar pistonPosition(const scalar theta) const = 0; + + + // Access + + //- Return the engine geometry dictionary + inline const IOdictionary& engineDict() const + { + return dict_; + } + + //- Return current engine time + // (value might be expressed in CA or s depending on the model) + virtual scalar theta() const = 0; + + //- Return time unit + virtual word unit() const = 0; + + //- Return engine time increment + // (value might be expressed in CA or s depending on the model) + virtual scalar deltaTheta() const = 0; + + //- Return current piston position + dimensionedScalar pistonPosition() const; + + //- Return piston displacement for current time step + dimensionedScalar pistonDisplacement() const; + + //- Return piston speed for current time step + dimensionedScalar pistonSpeed() const; + + + // Member functions overriding the virtual functions in time + + //- Read the control dictionary and set the write controls etc. + virtual void readDict(); + + + // Edit + + //- Read the controlDict and set all the parameters + virtual bool read(); +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/engine/engineTime/engineTime/engineTimeNew.C b/src/engine/engineTime/engineTime/engineTimeNew.C new file mode 100644 index 0000000000..a196c2cada --- /dev/null +++ b/src/engine/engineTime/engineTime/engineTimeNew.C @@ -0,0 +1,80 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation + \\/ 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 3 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, see . + +\*---------------------------------------------------------------------------*/ + +#include "engineTime.H" +#include "IFstream.H" + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +Foam::autoPtr Foam::engineTime::New +( + const word& name, + const fileName& rootPath, + const fileName& caseName, + const fileName& systemName, + const fileName& constantName, + const fileName& dictName +) +{ + IFstream engineDictFile("."/constantName/dictName); + + dictionary engineDict(engineDictFile); + + const word engineType + ( + engineDict.lookupOrDefault("engineType", "crankConRod") + ); + + Info<< "Selecting engine type " << engineType << endl; + + dictionaryConstructorTable::iterator cstrIter = + dictionaryConstructorTablePtr_->find(engineType); + + if (cstrIter == dictionaryConstructorTablePtr_->end()) + { + FatalErrorInFunction + << "Unknown engine type " + << engineType << nl << nl + << "Valid engine types are :" << nl + << dictionaryConstructorTablePtr_->sortedToc() + << exit(FatalError); + } + + return autoPtr + ( + cstrIter() + ( + name, + rootPath, + caseName, + systemName, + constantName, + dictName + ) + ); +} + + +// ************************************************************************* // diff --git a/src/engine/engineTime/freePiston/freePiston.C b/src/engine/engineTime/freePiston/freePiston.C new file mode 100644 index 0000000000..09cfd6538f --- /dev/null +++ b/src/engine/engineTime/freePiston/freePiston.C @@ -0,0 +1,91 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2017 OpenFOAM Foundation + \\/ 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 3 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, see . + +\*---------------------------------------------------------------------------*/ + +#include "freePiston.H" +#include "addToRunTimeSelectionTable.H" + +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +namespace Foam +{ + defineTypeNameAndDebug(freePiston, 0); + addToRunTimeSelectionTable(engineTime, freePiston, dictionary); +} + + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +Foam::freePiston::freePiston +( + const word& name, + const fileName& rootPath, + const fileName& caseName, + const fileName& systemName, + const fileName& constantName, + const fileName& dictName +) +: + engineTime + ( + name, + rootPath, + caseName, + systemName, + constantName + ), + pistonPositionTime_ + ( + Function1::New("pistonPositionTime", dict_) + ) +{} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +Foam::scalar Foam::freePiston::theta() const +{ + return value(); +} + + +Foam::word Foam::freePiston::unit() const +{ + return " s"; +} + + +Foam::scalar Foam::freePiston::deltaTheta() const +{ + return deltaTValue(); +} + + +Foam::scalar Foam::freePiston::pistonPosition(const scalar theta) const +{ + return pistonPositionTime_->value(theta); +} + + +// ************************************************************************* // diff --git a/src/engine/engineTime/freePiston/freePiston.H b/src/engine/engineTime/freePiston/freePiston.H new file mode 100644 index 0000000000..47fff4348d --- /dev/null +++ b/src/engine/engineTime/freePiston/freePiston.H @@ -0,0 +1,145 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2017 OpenFOAM Foundation + \\/ 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 3 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, see . + +Class + Foam::freePiston + +Description + In case of free pistons, the piston position is determined by a user-defined + position according to time. + + The piston trajectory is specified in \c constant/engineGeometry using a + table or a separated file. The position is relative to the cylinder head, + i.e. decreasing when compressing. + + For example, + \verbatim + pistonPositionTime table ( (0 0.13) (0.020 0.03) ); + \endverbatim + + or with a tableFile + \verbatim + pistonPositionTime tableFile; + pistonPositionTimeCoeffs + { + fileName "data"; + outOfBounds clamp; + interpolationScheme linear; + } + \endverbatim + +SourceFiles + freePiston.C + +\*---------------------------------------------------------------------------*/ + +#ifndef freePiston_H +#define freePiston_H + +#include "engineTime.H" +#include "dictionary.H" +#include "dimensionedScalar.H" +#include "Function1.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +/*---------------------------------------------------------------------------*\ + Class freePiston Declaration +\*---------------------------------------------------------------------------*/ + +class freePiston +: + public engineTime +{ + // Private data + + autoPtr> pistonPositionTime_; + + + // Private Member Functions + + //- Disallow default bitwise copy construct + freePiston(const freePiston&); + + //- Disallow default bitwise assignment + void operator=(const freePiston&); + + +public: + + //- Runtime type information + TypeName("freePiston"); + + + // Constructors + + //- Construct from objectRegistry arguments + freePiston + ( + const word& name, + const fileName& rootPath, + const fileName& caseName, + const fileName& systemName = "system", + const fileName& constantName = "constant", + const fileName& dictName = "engineGeometry" + ); + + //- Destructor + virtual ~freePiston() + {} + + + // Member Functions + + // Conversion + + //- Calculate the piston position from the engine geometry + // and given crank angle. + scalar pistonPosition(const scalar theta) const; + + + // Access + + //- Return current engine time + virtual scalar theta() const; + + //- Return time unit + virtual word unit() const; + + //- Return engine time increment + virtual scalar deltaTheta() const; +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/engine/ignition/ignitionSiteIO.C b/src/engine/ignition/ignitionSiteIO.C index 588a03898b..9c068394c4 100644 --- a/src/engine/ignition/ignitionSiteIO.C +++ b/src/engine/ignition/ignitionSiteIO.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -80,14 +80,14 @@ Foam::ignitionSite::ignitionSite ( db_.userTimeToTime ( - edb.degToTime(readScalar(ignitionSiteDict_.lookup("start"))) + edb.userTimeToTime(readScalar(ignitionSiteDict_.lookup("start"))) ) ), duration_ ( db_.userTimeToTime ( - edb.degToTime(readScalar(ignitionSiteDict_.lookup("duration"))) + edb.userTimeToTime(readScalar(ignitionSiteDict_.lookup("duration"))) ) ), strength_(readScalar(ignitionSiteDict_.lookup("strength"))), diff --git a/src/engine/include/createEngineTime.H b/src/engine/include/createEngineTime.H index e8c9c754b1..54a5c1b0d1 100644 --- a/src/engine/include/createEngineTime.H +++ b/src/engine/include/createEngineTime.H @@ -1,8 +1,13 @@ - Info<< "Create engine time\n" << endl; +Info<< "Create engine time\n" << endl; - engineTime runTime +autoPtr runTimePtr +( + engineTime::New ( Time::controlDictName, args.rootPath(), args.caseName() - ); + ) +); + +engineTime& runTime = runTimePtr(); diff --git a/tutorials/combustion/engineFoam/freePiston/0/T b/tutorials/combustion/engineFoam/freePiston/0/T new file mode 100644 index 0000000000..097e61c6a7 --- /dev/null +++ b/tutorials/combustion/engineFoam/freePiston/0/T @@ -0,0 +1,53 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: dev | +| \\ / A nd | Web: www.OpenFOAM.org | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format binary; + class volScalarField; + location "0"; + object T; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#include "include/caseSettings" + +dimensions [0 0 0 1 0 0 0]; + +internalField uniform $:internalField.T; + +boundaryField +{ + back + { + type wedge; + } + + front + { + $back; + } + + liner + { + $:wall.T; + } + + cylinderHead + { + $liner; + } + + piston + { + $liner; + } +} + + +// ************************************************************************* // diff --git a/tutorials/combustion/engineFoam/freePiston/0/U b/tutorials/combustion/engineFoam/freePiston/0/U new file mode 100644 index 0000000000..81c314be05 --- /dev/null +++ b/tutorials/combustion/engineFoam/freePiston/0/U @@ -0,0 +1,53 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM:.Uhe Open Source CFD Toolbox | +| \\ / O peration | Version: dev | +| \\ / A nd | Web: www.OpenFOAM.org | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format binary; + class volVectorField; + location "0"; + object U; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#include "include/caseSettings" + +dimensions [0 1 -1 0 0 0 0]; + +internalField uniform $:internalField.U; + +boundaryField +{ + back + { + type wedge; + } + + front + { + $back; + } + + liner + { + $:wall.U; + } + + cylinderHead + { + $liner; + } + + piston + { + $:piston.U; + } +} + + +// ************************************************************************* // diff --git a/tutorials/combustion/engineFoam/freePiston/0/air b/tutorials/combustion/engineFoam/freePiston/0/air new file mode 100644 index 0000000000..61bd8112ae --- /dev/null +++ b/tutorials/combustion/engineFoam/freePiston/0/air @@ -0,0 +1,53 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: dev | +| \\ / A nd | Web: www.OpenFOAM.org | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class volScalarField; + location "0"; + object air; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#include "include/caseSettings" + +dimensions [0 0 0 0 0 0 0]; + +internalField uniform 1; + +boundaryField +{ + back + { + type wedge; + } + + front + { + $back; + } + + liner + { + $:wall.p; + } + + cylinderHead + { + $liner; + } + + piston + { + $liner; + } +} + + +// ************************************************************************* // diff --git a/tutorials/combustion/engineFoam/freePiston/0/alphat b/tutorials/combustion/engineFoam/freePiston/0/alphat new file mode 100644 index 0000000000..6d96c7f481 --- /dev/null +++ b/tutorials/combustion/engineFoam/freePiston/0/alphat @@ -0,0 +1,38 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: dev | +| \\ / A nd | Web: www.OpenFOAM.org | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format binary; + class volScalarField; + location "0"; + object alphat; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#include "include/caseSettings" + +dimensions [1 -1 -1 0 0 0 0]; + +internalField uniform 0; + +boundaryField +{ + back + { + type wedge; + } + front { $back; } + liner { $:wall.alphat; } + cylinderHead { $liner; } + piston { $liner; } +} +} + + +// ************************************************************************* // diff --git a/tutorials/combustion/engineFoam/freePiston/0/epsilon b/tutorials/combustion/engineFoam/freePiston/0/epsilon new file mode 100644 index 0000000000..c51e83baa5 --- /dev/null +++ b/tutorials/combustion/engineFoam/freePiston/0/epsilon @@ -0,0 +1,53 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: dev | +| \\ / A nd | Web: www.OpenFOAM.org | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format binary; + class volScalarField; + location "0"; + object epsilon; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#include "include/caseSettings" + +dimensions [0 2 -3 0 0 0 0]; + +internalField uniform $:internalField.epsilon; + +boundaryField +{ + back + { + type wedge; + } + + front + { + $back; + } + + liner + { + $:wall.epsilon; + } + + cylinderHead + { + $liner; + } + + piston + { + $liner; + } +} + + +// ************************************************************************* // diff --git a/tutorials/combustion/engineFoam/freePiston/0/include/boundaryConditions b/tutorials/combustion/engineFoam/freePiston/0/include/boundaryConditions new file mode 100644 index 0000000000..d49dedb7c8 --- /dev/null +++ b/tutorials/combustion/engineFoam/freePiston/0/include/boundaryConditions @@ -0,0 +1,70 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: dev | +| \\ / A nd | Web: www.OpenFOAM.org | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + object boundaryConditions; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +wall +{ + p + { + type zeroGradient; + } + + U + { + type fixedValue; + value uniform (0 0 0); + } + + T + { + type zeroGradient; + } + + k + { + type kqRWallFunction; + value uniform $:internalField.k; + } + + epsilon + { + type epsilonWallFunction; + value uniform $:internalField.epsilon; + } + + nut + { + type nutkWallFunction; + value uniform 0; + } + + alphat + { + type compressible::alphatWallFunction; + Prt 0.85; + value uniform 0; + } +} + +piston +{ + U + { + type movingWallVelocity; + value uniform (0 0 0); + } +} + +// ************************************************************************* // diff --git a/tutorials/combustion/engineFoam/freePiston/0/include/caseSettings b/tutorials/combustion/engineFoam/freePiston/0/include/caseSettings new file mode 100644 index 0000000000..fd4fc84c88 --- /dev/null +++ b/tutorials/combustion/engineFoam/freePiston/0/include/caseSettings @@ -0,0 +1,28 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: dev | +| \\ / A nd | Web: www.OpenFOAM.org | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + object caseSettings; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +internalField +{ + U (0 0 0); + epsilon 5.70e-5; + k 2.40e-5; + T 350; + p 1e5; +} + +#include "boundaryConditions" + +// ************************************************************************* // diff --git a/tutorials/combustion/engineFoam/freePiston/0/k b/tutorials/combustion/engineFoam/freePiston/0/k new file mode 100644 index 0000000000..b428f1080b --- /dev/null +++ b/tutorials/combustion/engineFoam/freePiston/0/k @@ -0,0 +1,53 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM:.khe Open Source CFD Toolbox | +| \\ / O peration | Version: dev | +| \\ / A nd | Web: www.OpenFOAM.org | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format binary; + class volScalarField; + location "0"; + object k; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#include "include/caseSettings" + +dimensions [0 2 -2 0 0 0 0]; + +internalField uniform $:internalField.k; + +boundaryField +{ + back + { + type wedge; + } + + front + { + $back; + } + + liner + { + $:wall.k; + } + + cylinderHead + { + $liner; + } + + piston + { + $liner; + } +} + + +// ************************************************************************* // diff --git a/tutorials/combustion/engineFoam/freePiston/0/nut b/tutorials/combustion/engineFoam/freePiston/0/nut new file mode 100644 index 0000000000..2d3213ce17 --- /dev/null +++ b/tutorials/combustion/engineFoam/freePiston/0/nut @@ -0,0 +1,38 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: dev | +| \\ / A nd | Web: www.OpenFOAM.org | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format binary; + class volScalarField; + location "0"; + object nut; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#include "include/caseSettings" + +dimensions [0 2 -1 0 0 0 0]; + +internalField uniform 0; + +boundaryField +{ + back + { + type wedge; + } + front { $back; } + liner { $:wall.nut; } + cylinderHead { $liner; } + piston { $liner; } +} +} + + +// ************************************************************************* // diff --git a/tutorials/combustion/engineFoam/freePiston/0/p b/tutorials/combustion/engineFoam/freePiston/0/p new file mode 100644 index 0000000000..6676f4e209 --- /dev/null +++ b/tutorials/combustion/engineFoam/freePiston/0/p @@ -0,0 +1,53 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM:.phe Open Source CFD Toolbox | +| \\ / O peration | Version: dev | +| \\ / A nd | Web: www.OpenFOAM.org | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format binary; + class volScalarField; + location "0"; + object p; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#include "include/caseSettings" + +dimensions [1 -1 -2 0 0 0 0]; + +internalField uniform $:internalField.p; + +boundaryField +{ + back + { + type wedge; + } + + front + { + $back; + } + + liner + { + $:wall.p; + } + + cylinderHead + { + $liner; + } + + piston + { + $liner; + } +} + + +// ************************************************************************* // diff --git a/tutorials/combustion/engineFoam/freePiston/constant/engineGeometry b/tutorials/combustion/engineFoam/freePiston/constant/engineGeometry new file mode 100644 index 0000000000..62371d9779 --- /dev/null +++ b/tutorials/combustion/engineFoam/freePiston/constant/engineGeometry @@ -0,0 +1,29 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: dev | +| \\ / A nd | Web: www.OpenFOAM.org | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + location "constant"; + object engineGeometry; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +engineMesh layered; + +engineType freePiston; + +pistonPositionTime table +( + (0 0.13) + (0.020 0.013) +); + + +// ************************************************************************* // diff --git a/tutorials/combustion/engineFoam/freePiston/constant/g b/tutorials/combustion/engineFoam/freePiston/constant/g new file mode 100644 index 0000000000..d182180d95 --- /dev/null +++ b/tutorials/combustion/engineFoam/freePiston/constant/g @@ -0,0 +1,21 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: dev | +| \\ / A nd | Web: www.OpenFOAM.org | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class uniformDimensionedVectorField; + location "constant"; + object g; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +dimensions [0 1 -2 0 0 0 0]; +value (0 0 0); + +// ************************************************************************* // diff --git a/tutorials/combustion/engineFoam/freePiston/constant/include/reactions.air b/tutorials/combustion/engineFoam/freePiston/constant/include/reactions.air new file mode 100644 index 0000000000..5bb714747f --- /dev/null +++ b/tutorials/combustion/engineFoam/freePiston/constant/include/reactions.air @@ -0,0 +1,8 @@ +species +( + air +); + +reactions +{ +} diff --git a/tutorials/combustion/engineFoam/freePiston/constant/include/thermo.air b/tutorials/combustion/engineFoam/freePiston/constant/include/thermo.air new file mode 100644 index 0000000000..f2dad8a6c0 --- /dev/null +++ b/tutorials/combustion/engineFoam/freePiston/constant/include/thermo.air @@ -0,0 +1,21 @@ +air +{ + specie + { + nMoles 1; + molWeight 28.9596; + } + thermodynamics + { + Tlow 200; + Thigh 3500; + Tcommon 1000; + highCpCoeffs ( 3.57304 -7.24383e-04 1.67022e-06 -1.26501e-10 -4.20580e-13 -1047.41 3.12431 ); + lowCpCoeffs ( 3.09589 1.22835e-03 -4.14267e-07 6.56910e-11 -3.87021e-15 -983.191 5.34161 ); + } + transport + { + As 1.67212e-06; + Ts 170.672; + } +} diff --git a/tutorials/combustion/engineFoam/freePiston/constant/thermophysicalProperties b/tutorials/combustion/engineFoam/freePiston/constant/thermophysicalProperties new file mode 100644 index 0000000000..15a3d8ab51 --- /dev/null +++ b/tutorials/combustion/engineFoam/freePiston/constant/thermophysicalProperties @@ -0,0 +1,38 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: dev | +| \\ / A nd | Web: www.OpenFOAM.org | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + location "constant"; + object thermophysicalProperties; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +thermoType +{ + type hePsiThermo; + mixture reactingMixture; + transport sutherland; + thermo janaf; + equationOfState perfectGas; + specie specie; + energy sensibleInternalEnergy; +} + +inertSpecie air; + +chemistryReader foamChemistryReader; + +foamChemistryFile "$FOAM_CASE/constant/include/reactions.air"; + +foamChemistryThermoFile "$FOAM_CASE/constant/include/thermo.air"; + + +// ************************************************************************* // diff --git a/tutorials/combustion/engineFoam/freePiston/constant/turbulenceProperties b/tutorials/combustion/engineFoam/freePiston/constant/turbulenceProperties new file mode 100644 index 0000000000..d587253c9a --- /dev/null +++ b/tutorials/combustion/engineFoam/freePiston/constant/turbulenceProperties @@ -0,0 +1,29 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: dev | +| \\ / A nd | Web: www.OpenFOAM.org | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + location "constant"; + object turbulenceProperties; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +simulationType RAS; + +RAS +{ + RASModel kEpsilon; + + turbulence on; + + printCoeffs on; +} + +// ************************************************************************* // diff --git a/tutorials/combustion/engineFoam/freePiston/system/blockMeshDict b/tutorials/combustion/engineFoam/freePiston/system/blockMeshDict new file mode 100644 index 0000000000..434e1c2f47 --- /dev/null +++ b/tutorials/combustion/engineFoam/freePiston/system/blockMeshDict @@ -0,0 +1,87 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: dev | +| \\ / A nd | Web: www.OpenFOAM.org | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + object blockMeshDict; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +convertToMeters 1; + +vertices +( + (0 0 0) + (0.05 -0.000872753 0) + (0.05 0.000872753 0) + (0 0 0.13) + (0.05 -0.000872753 0.13) + (0.05 0.000872753 0.13) +); + +blocks +( + hex (0 1 2 0 3 4 5 3) (50 1 130) simpleGrading (1 1 1) +); + +boundary +( + front + { + type wedge; + faces + ( + (0 1 4 3) + ); + } + back + { + type wedge; + faces + ( + (0 3 5 2) + ); + } + piston + { + type wall; + faces + ( + (0 2 1 0) + ); + } + cylinderHead + { + type wall; + faces + ( + (3 4 5 3) + ); + } + axis + { + type empty; + faces + ( + (0 3 3 0) + ); + } + liner + { + type wall; + faces + ( + (1 2 5 4) + ); + } +); + + +// ************************************************************************* // diff --git a/tutorials/combustion/engineFoam/freePiston/system/controlDict b/tutorials/combustion/engineFoam/freePiston/system/controlDict new file mode 100644 index 0000000000..08ccfa4cf3 --- /dev/null +++ b/tutorials/combustion/engineFoam/freePiston/system/controlDict @@ -0,0 +1,51 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: dev | +| \\ / A nd | Web: www.OpenFOAM.org | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + object controlDict; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +application coldEngineFoam; + +startFrom startTime; + +startTime 0; + +stopAt endTime; + +endTime 0.03; + +deltaT 5.0e-7; + +writeControl adjustableRunTime; + +writeInterval 0.001; + +purgeWrite 0; + +writeFormat binary; + +writePrecision 6; + +writeCompression off; + +timeFormat general; + +timePrecision 8; + +runTimeModifiable true; + +adjustTimeStep yes; + +maxCo 0.25; + +// ************************************************************************* // diff --git a/tutorials/combustion/engineFoam/freePiston/system/fvSchemes b/tutorials/combustion/engineFoam/freePiston/system/fvSchemes new file mode 100644 index 0000000000..a3bc2848d7 --- /dev/null +++ b/tutorials/combustion/engineFoam/freePiston/system/fvSchemes @@ -0,0 +1,66 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: dev | +| \\ / 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 Gauss linear; +} + +divSchemes +{ + default none; + + div(phi,U) Gauss linearUpwind grad(U); + div(phi,e) Gauss linearUpwind grad(e); + + div(phiv,p) Gauss linear; + div(phi,K) Gauss linear; + div(meshPhi,p) Gauss linear; + + div(phi,k) Gauss upwind; + div(phi,epsilon) Gauss upwind; + + div(((rho*nuEff)*dev2(T(grad(U))))) Gauss linear; +} + +laplacianSchemes +{ + default Gauss linear corrected; +} + +interpolationSchemes +{ + default linear; +} + +snGradSchemes +{ + default corrected; +} + +fluxRequired +{ + default no; + p; +} + +// ************************************************************************* // diff --git a/tutorials/combustion/engineFoam/freePiston/system/fvSolution b/tutorials/combustion/engineFoam/freePiston/system/fvSolution new file mode 100644 index 0000000000..a9e1486f35 --- /dev/null +++ b/tutorials/combustion/engineFoam/freePiston/system/fvSolution @@ -0,0 +1,62 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: dev | +| \\ / A nd | Web: www.OpenFOAM.org | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + location "system"; + object fvSolution; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +solvers +{ + "rho.*" + { + solver diagonal; + } + + p + { + solver PCG; + preconditioner DIC; + tolerance 1e-6; + relTol 0.1; + } + + pFinal + { + $p; + relTol 0; + } + + "(U|e|k|epsilon)" + { + solver PBiCGStab; + preconditioner DILU; + tolerance 1e-5; + relTol 0.1; + } + + "(U|e|k|epsilon)Final" + { + $U; + relTol 0; + } +} + +PIMPLE +{ + nCorrectors 2; + nNonOrthogonalCorrectors 1; + momentumPredictor yes; +} + + +// ************************************************************************* //