1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
7 -------------------------------------------------------------------------------
9 This file is part of OpenFOAM.
11 OpenFOAM is free software: you can redistribute it and/or modify it
12 under the terms of the GNU General Public License as published by
13 the Free Software Foundation, either version 3 of the License, or
14 (at your option) any later version.
16 OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21 You should have received a copy of the GNU General Public License
22 along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
28 Manage time in terms of engine RPM and crank-angle.
30 When engineTime is in effect, the userTime is reported in degrees
31 crank-angle instead of in seconds. The RPM to be used is specified in
32 \c constant/engineGeometry. If only a time conversion is required,
33 the geometric engine parameters can be dropped or set to zero.
37 rpm rpm [0 0 -1 0 0] 2000;
39 conRodLength conRodLength [0 1 0 0 0] 0.0;
40 bore bore [0 1 0 0 0] 0.0;
41 stroke stroke [0 1 0 0 0] 0.0;
42 clearance clearance [0 1 0 0 0] 0.0;
46 The engineTime can currently only be selected at compile-time.
51 \*---------------------------------------------------------------------------*/
57 #include "dictionary.H"
58 #include "dimensionedScalar.H"
60 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
65 /*---------------------------------------------------------------------------*\
66 Class engineTime Declaration
67 \*---------------------------------------------------------------------------*/
78 dimensionedScalar rpm_;
80 //- Optional engine geometry parameters
81 dimensionedScalar conRodLength_;
82 dimensionedScalar bore_;
83 dimensionedScalar stroke_;
84 dimensionedScalar clearance_;
87 // Private Member Functions
89 //- Disallow default bitwise copy construct
90 engineTime(const engineTime&);
92 //- Disallow default bitwise assignment
93 void operator=(const engineTime&);
95 //- adjust read time values
96 void timeAdjustment();
102 //- Construct from objectRegistry arguments
106 const fileName& rootPath,
107 const fileName& caseName,
108 const fileName& systemName = "system",
109 const fileName& constantName = "constant",
110 const fileName& dictName = "engineGeometry"
114 virtual ~engineTime()
122 //- Convert degrees to seconds (for given engine speed in RPM)
123 scalar degToTime(const scalar theta) const;
125 //- Convert seconds to degrees (for given engine speed in RPM)
126 scalar timeToDeg(const scalar t) const;
128 //- Calculate the piston position from the engine geometry
129 // and given crank angle.
130 scalar pistonPosition(const scalar theta) const;
135 //- Return the engine geometry dictionary
136 const dictionary& engineDict() const
141 //- Return the engines current operating RPM
142 const dimensionedScalar& rpm() const
147 //- Return the engines connecting-rod length
148 const dimensionedScalar& conRodLength() const
150 return conRodLength_;
153 //- Return the engines bore
154 const dimensionedScalar& bore() const
159 //- Return the engines stroke
160 const dimensionedScalar& stroke() const
165 //- Return the engines clearance-gap
166 const dimensionedScalar& clearance() const
172 //- Return current crank-angle
173 scalar theta() const;
175 //- Return current crank-angle translated to a single revolution
176 // (value between -180 and 180 with 0 = top dead centre)
177 scalar thetaRevolution() const;
179 //- Return crank-angle increment
180 scalar deltaTheta() const;
182 //- Return current piston position
183 dimensionedScalar pistonPosition() const;
185 //- Return piston displacement for current time step
186 dimensionedScalar pistonDisplacement() const;
188 //- Return piston speed for current time step
189 dimensionedScalar pistonSpeed() const;
192 // Member functions overriding the virtual functions in time
194 //- Convert the user-time (CA deg) to real-time (s).
195 virtual scalar userTimeToTime(const scalar theta) const;
197 //- Convert the real-time (s) into user-time (CA deg)
198 virtual scalar timeToUserTime(const scalar t) const;
200 //- Read the control dictionary and set the write controls etc.
201 virtual void readDict();
206 //- Read the controlDict and set all the parameters
211 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
213 } // End namespace Foam
215 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
219 // ************************************************************************* //