|
|
|
engineTime.HGo to the documentation of this file.00001 /*---------------------------------------------------------------------------*\ 00002 ========= | 00003 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox 00004 \\ / O peration | 00005 \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd. 00006 \\/ M anipulation | 00007 ------------------------------------------------------------------------------- 00008 License 00009 This file is part of OpenFOAM. 00010 00011 OpenFOAM is free software; you can redistribute it and/or modify it 00012 under the terms of the GNU General Public License as published by the 00013 Free Software Foundation; either version 2 of the License, or (at your 00014 option) any later version. 00015 00016 OpenFOAM is distributed in the hope that it will be useful, but WITHOUT 00017 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 00018 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 00019 for more details. 00020 00021 You should have received a copy of the GNU General Public License 00022 along with OpenFOAM; if not, write to the Free Software Foundation, 00023 Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 00024 00025 Class 00026 Foam::engineTime 00027 00028 Description 00029 Manage time in terms of engine RPM and crank-angle. 00030 00031 When engineTime is in effect, the userTime is reported in degrees 00032 crank-angle instead of in seconds. The RPM to be used is specified in 00033 @c constant/engineGeometry. If only a time conversion is required, 00034 the geometric engine parameters can be dropped or set to zero. 00035 00036 For example, 00037 @verbatim 00038 rpm rpm [0 0 -1 0 0] 2000; 00039 00040 conRodLength conRodLength [0 1 0 0 0] 0.0; 00041 bore bore [0 1 0 0 0] 0.0; 00042 stroke stroke [0 1 0 0 0] 0.0; 00043 clearance clearance [0 1 0 0 0] 0.0; 00044 @endverbatim 00045 00046 Note 00047 The engineTime can currently only be selected at compile-time. 00048 00049 SourceFiles 00050 engineTime.C 00051 00052 \*---------------------------------------------------------------------------*/ 00053 00054 #ifndef engineTime_H 00055 #define engineTime_H 00056 00057 #include "Time.H" 00058 #include "dictionary.H" 00059 #include "dimensionedScalar.H" 00060 00061 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 00062 00063 namespace Foam 00064 { 00065 00066 /*---------------------------------------------------------------------------*\ 00067 Class engineTime Declaration 00068 \*---------------------------------------------------------------------------*/ 00069 00070 class engineTime 00071 : 00072 public Time 00073 { 00074 // Private data 00075 00076 IOdictionary dict_; 00077 00078 //- RPM is required 00079 dimensionedScalar rpm_; 00080 00081 //- Optional engine geometry parameters 00082 dimensionedScalar conRodLength_; 00083 dimensionedScalar bore_; 00084 dimensionedScalar stroke_; 00085 dimensionedScalar clearance_; 00086 00087 00088 // Private Member Functions 00089 00090 //- Disallow default bitwise copy construct 00091 engineTime(const engineTime&); 00092 00093 //- Disallow default bitwise assignment 00094 void operator=(const engineTime&); 00095 00096 //- adjust read time values 00097 void timeAdjustment(); 00098 00099 public: 00100 00101 // Constructors 00102 00103 //- Construct from objectRegistry arguments 00104 engineTime 00105 ( 00106 const word& name, 00107 const fileName& rootPath, 00108 const fileName& caseName, 00109 const fileName& systemName = "system", 00110 const fileName& constantName = "constant", 00111 const fileName& dictName = "engineGeometry" 00112 ); 00113 00114 // Destructor 00115 00116 virtual ~engineTime() 00117 {} 00118 00119 00120 // Member Functions 00121 00122 // Conversion 00123 00124 //- Convert degrees to radians 00125 scalar degToRad(const scalar rad) const; 00126 00127 //- Convert degrees to seconds (for given engine speed in RPM) 00128 scalar degToTime(const scalar theta) const; 00129 00130 //- Convert seconds to degrees (for given engine speed in RPM) 00131 scalar timeToDeg(const scalar t) const; 00132 00133 //- Calculate the piston position from the engine geometry 00134 // and given crank angle. 00135 scalar pistonPosition(const scalar theta) const; 00136 00137 00138 // Access 00139 00140 //- Return the engine geometry dictionary 00141 const dictionary& engineDict() const 00142 { 00143 return dict_; 00144 } 00145 00146 //- Return the engines current operating RPM 00147 const dimensionedScalar& rpm() const 00148 { 00149 return rpm_; 00150 } 00151 00152 //- Return the engines connecting-rod length 00153 const dimensionedScalar& conRodLength() const 00154 { 00155 return conRodLength_; 00156 } 00157 00158 //- Return the engines bore 00159 const dimensionedScalar& bore() const 00160 { 00161 return bore_; 00162 } 00163 00164 //- Return the engines stroke 00165 const dimensionedScalar& stroke() const 00166 { 00167 return stroke_; 00168 } 00169 00170 //- Return the engines clearance-gap 00171 const dimensionedScalar& clearance() const 00172 { 00173 return clearance_; 00174 } 00175 00176 00177 //- Return current crank-angle 00178 scalar theta() const; 00179 00180 //- Return current crank-angle translated to a single revolution 00181 // (value between -180 and 180 with 0 = top dead centre) 00182 scalar thetaRevolution() const; 00183 00184 //- Return crank-angle increment 00185 scalar deltaTheta() const; 00186 00187 //- Return current piston position 00188 dimensionedScalar pistonPosition() const; 00189 00190 //- Return piston displacement for current time step 00191 dimensionedScalar pistonDisplacement() const; 00192 00193 //- Return piston speed for current time step 00194 dimensionedScalar pistonSpeed() const; 00195 00196 00197 // Member functions overriding the virtual functions in time 00198 00199 //- Convert the user-time (CA deg) to real-time (s). 00200 virtual scalar userTimeToTime(const scalar theta) const; 00201 00202 //- Convert the real-time (s) into user-time (CA deg) 00203 virtual scalar timeToUserTime(const scalar t) const; 00204 00205 //- Read the control dictionary and set the write controls etc. 00206 virtual void readDict(); 00207 00208 00209 // Edit 00210 00211 //- Read the controlDict and set all the parameters 00212 virtual bool read(); 00213 }; 00214 00215 00216 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 00217 00218 } // End namespace Foam 00219 00220 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 00221 00222 #endif 00223 00224 // ************************************************************************* // |