crankConRod.H
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration | Website: https://openfoam.org
5  \\ / A nd | Copyright (C) 2017-2020 OpenFOAM Foundation
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
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.
15 
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
19  for more details.
20 
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/>.
23 
24 Class
25  Foam::crankConRod
26 
27 Description
28  Manage time in terms of engine RPM and crank-angle.
29 
30  When crankConRod 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.
34 
35  For example,
36  \verbatim
37  rpm rpm [0 0 -1 0 0] 2000;
38 
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;
43  \endverbatim
44 
45 SourceFiles
46  crankConRod.C
47 
48 \*---------------------------------------------------------------------------*/
49 
50 #ifndef crankConRod_H
51 #define crankConRod_H
52 
53 #include "engineTime.H"
54 #include "dictionary.H"
55 #include "dimensionedScalar.H"
56 
57 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
58 
59 namespace Foam
60 {
61 
62 /*---------------------------------------------------------------------------*\
63  Class crankConRod Declaration
64 \*---------------------------------------------------------------------------*/
65 
66 class crankConRod
67 :
68  public engineTime
69 {
70  // Private Data
71 
72  //- RPM is required
73  dimensionedScalar rpm_;
74 
75  //- Optional engine geometry parameters
76  dimensionedScalar conRodLength_;
77  dimensionedScalar bore_;
78  dimensionedScalar stroke_;
79  dimensionedScalar clearance_;
80 
81 
82  // Private Member Functions
83 
84  //- Adjust read time values
85  void timeAdjustment();
86 
87 
88 public:
89 
90  //- Runtime type information
91  TypeName("crankConRod");
92 
93 
94  // Constructors
95 
96  //- Construct from objectRegistry arguments
98  (
99  const word& name,
100  const fileName& rootPath,
101  const fileName& caseName,
102  const fileName& systemName = "system",
103  const fileName& constantName = "constant",
104  const fileName& dictName = "engineGeometry"
105  );
106 
107  //- Disallow default bitwise copy construction
108  crankConRod(const crankConRod&) = delete;
109 
110 
111  //- Destructor
112  virtual ~crankConRod()
113  {}
114 
115 
116  // Member Functions
117 
118  // Conversion
119 
120  //- Convert degrees to seconds (for given engine speed in RPM)
121  scalar degToTime(const scalar theta) const;
122 
123  //- Convert seconds to degrees (for given engine speed in RPM)
124  scalar timeToDeg(const scalar t) const;
125 
126  //- Calculate the piston position from the engine geometry
127  // and given crank angle.
128  scalar pistonPosition(const scalar theta) const;
129 
130 
131  // Access
132 
133  //- Return the engines current operating RPM
134  const dimensionedScalar& rpm() const
135  {
136  return rpm_;
137  }
138 
139  //- Return the engines connecting-rod length
140  const dimensionedScalar& conRodLength() const
141  {
142  return conRodLength_;
143  }
144 
145  //- Return the engines bore
146  const dimensionedScalar& bore() const
147  {
148  return bore_;
149  }
150 
151  //- Return the engines stroke
152  const dimensionedScalar& stroke() const
153  {
154  return stroke_;
155  }
156 
157  //- Return the engines clearance-gap
158  const dimensionedScalar& clearance() const
159  {
160  return clearance_;
161  }
162 
163 
164  //- Return current crank-angle
165  virtual scalar theta() const;
166 
167  //- Return time unit
168  virtual word unit() const;
169 
170  //- Return current crank-angle translated to a single revolution
171  // (value between -180 and 180 with 0 = top dead centre)
172  scalar thetaRevolution() const;
173 
174  //- Return crank-angle increment
175  virtual scalar deltaTheta() const;
176 
177 
178  // Member Functions overriding the virtual functions in time
179 
180  //- Convert the user-time (CA deg) to real-time (s).
181  virtual scalar userTimeToTime(const scalar theta) const;
182 
183  //- Convert the real-time (s) into user-time (CA deg)
184  virtual scalar timeToUserTime(const scalar t) const;
185 
186  //- Ratio between real-time and user-time
187  virtual scalar timeToUserTimeRatio() const;
188 
189  //- Read the control dictionary and set the write controls etc.
190  virtual void readDict();
191 
192 
193  // Edit
194 
195  //- Read the controlDict and set all the parameters
196  virtual bool read();
197 
198 
199  // Member Operators
200 
201  //- Disallow default bitwise assignment
202  void operator=(const crankConRod&) = delete;
203 };
204 
205 
206 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
207 
208 } // End namespace Foam
209 
210 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
211 
212 #endif
213 
214 // ************************************************************************* //
virtual void readDict()
Read the control dictionary and set the write controls etc.
Definition: crankConRod.C:101
A class for handling file names.
Definition: fileName.H:79
TypeName("crankConRod")
Runtime type information.
virtual scalar theta() const
Return current crank-angle.
Definition: crankConRod.C:136
void operator=(const crankConRod &)=delete
Disallow default bitwise assignment.
const dimensionedScalar & conRodLength() const
Return the engines connecting-rod length.
Definition: crankConRod.H:139
dimensionedScalar pistonPosition() const
Return current piston position.
Definition: engineTime.C:93
An abstract class for the time description of the piston motion.
Definition: engineTime.H:51
crankConRod(const word &name, const fileName &rootPath, const fileName &caseName, const fileName &systemName="system", const fileName &constantName="constant", const fileName &dictName="engineGeometry")
Construct from objectRegistry arguments.
Definition: crankConRod.C:60
scalar timeToDeg(const scalar t) const
Convert seconds to degrees (for given engine speed in RPM)
Definition: crankConRod.C:129
const dimensionedScalar & stroke() const
Return the engines stroke.
Definition: crankConRod.H:151
virtual scalar deltaTheta() const
Return crank-angle increment.
Definition: crankConRod.C:166
virtual bool read()
Read the controlDict and set all the parameters.
Definition: crankConRod.C:108
const dimensionedScalar & clearance() const
Return the engines clearance-gap.
Definition: crankConRod.H:157
Manage time in terms of engine RPM and crank-angle.
Definition: crankConRod.H:65
A class for handling words, derived from string.
Definition: word.H:59
const dimensionedScalar & bore() const
Return the engines bore.
Definition: crankConRod.H:145
const fileName & caseName() const
Return case name.
Definition: TimePaths.H:107
const fileName & rootPath() const
Return root path.
Definition: TimePaths.H:95
const dimensionedScalar & rpm() const
Return the engines current operating RPM.
Definition: crankConRod.H:133
virtual scalar timeToUserTime(const scalar t) const
Convert the real-time (s) into user-time (CA deg)
Definition: crankConRod.C:198
scalar degToTime(const scalar theta) const
Convert degrees to seconds (for given engine speed in RPM)
Definition: crankConRod.C:122
virtual scalar userTimeToTime(const scalar theta) const
Convert the user-time (CA deg) to real-time (s).
Definition: crankConRod.C:192
const word & name() const
Return const reference to name.
virtual scalar timeToUserTimeRatio() const
Ratio between real-time and user-time.
Definition: crankConRod.C:204
virtual ~crankConRod()
Destructor.
Definition: crankConRod.H:111
virtual word unit() const
Return time unit.
Definition: crankConRod.C:142
scalar thetaRevolution() const
Return current crank-angle translated to a single revolution.
Definition: crankConRod.C:148
const word dictName("noiseDict")
Namespace for OpenFOAM.