JSBSim Flight Dynamics Model  1.0 (02 March 2017)
An Open Source Flight Dynamics and Control Software Library in C++
FGWinds.h
1 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2 
3  Header: FGWinds.h
4  Author: Jon Berndt, Andreas Gaeb, David Culp
5  Date started: 5/2011
6 
7  ------------- Copyright (C) 2011 Jon S. Berndt (jon@jsbsim.org) -------------
8 
9  This program is free software; you can redistribute it and/or modify it under
10  the terms of the GNU Lesser General Public License as published by the Free Software
11  Foundation; either version 2 of the License, or (at your option) any later
12  version.
13 
14  This program is distributed in the hope that it will be useful, but WITHOUT
15  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
16  FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
17  details.
18 
19  You should have received a copy of the GNU Lesser General Public License along with
20  this program; if not, write to the Free Software Foundation, Inc., 59 Temple
21  Place - Suite 330, Boston, MA 02111-1307, USA.
22 
23  Further information about the GNU Lesser General Public License can also be found on
24  the world wide web at http://www.gnu.org.
25 
26 HISTORY
27 --------------------------------------------------------------------------------
28 5/2011 JSB Created
29 
30 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
31 SENTRY
32 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
33 
34 #ifndef FGWINDS_H
35 #define FGWINDS_H
36 
37 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
38 INCLUDES
39 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
40 
41 #include "models/FGModel.h"
42 #include "math/FGColumnVector3.h"
43 #include "math/FGMatrix33.h"
44 #include "math/FGTable.h"
45 
46 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
47 DEFINITIONS
48 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
49 
50 #define ID_WINDS "$Id: FGWinds.h,v 1.11 2015/02/27 20:36:47 bcoconni Exp $"
51 
52 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
53 FORWARD DECLARATIONS
54 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
55 
56 namespace JSBSim {
57 
58 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
59 CLASS DOCUMENTATION
60 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
61 
115 /*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
116 CLASS DECLARATION
117 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%*/
118 
119 class FGWinds : public FGModel {
120 public:
121 
123  FGWinds(FGFDMExec*);
125  ~FGWinds();
133  bool Run(bool Holding);
134  bool InitModel(void);
135  enum tType {ttNone, ttStandard, ttCulp, ttMilspec, ttTustin} turbType;
136 
137  // TOTAL WIND access functions (wind + gust + turbulence)
138 
140  virtual const FGColumnVector3& GetTotalWindNED(void) const { return vTotalWindNED; }
141 
143  virtual double GetTotalWindNED(int idx) const {return vTotalWindNED(idx);}
144 
145  // WIND access functions
146 
148  virtual void SetWindNED(double wN, double wE, double wD) { vWindNED(1)=wN; vWindNED(2)=wE; vWindNED(3)=wD;}
149 
151  virtual void SetWindNED(int idx, double wind) { vWindNED(idx)=wind;}
152 
154  virtual void SetWindNED(const FGColumnVector3& wind) { vWindNED=wind; }
155 
157  virtual const FGColumnVector3& GetWindNED(void) const { return vWindNED; }
158 
160  virtual double GetWindNED(int idx) const {return vWindNED(idx);}
161 
165  virtual double GetWindPsi(void) const { return psiw; }
166 
173  virtual void SetWindPsi(double dir);
174 
175  virtual void SetWindspeed(double speed);
176 
177  virtual double GetWindspeed(void) const;
178 
179  // GUST access functions
180 
182  virtual void SetGustNED(int idx, double gust) { vGustNED(idx)=gust;}
183 
185  virtual void SetTurbNED(int idx, double turb) { vTurbulenceNED(idx)=turb;}
186 
188  virtual void SetGustNED(double gN, double gE, double gD) { vGustNED(eNorth)=gN; vGustNED(eEast)=gE; vGustNED(eDown)=gD;}
189 
191  virtual double GetGustNED(int idx) const {return vGustNED(idx);}
192 
194  virtual double GetTurbNED(int idx) const {return vTurbulenceNED(idx);}
195 
197  virtual const FGColumnVector3& GetGustNED(void) const {return vGustNED;}
198 
200  virtual void SetTurbType(tType tt) {turbType = tt;}
201  virtual tType GetTurbType() const {return turbType;}
202 
203  virtual void SetTurbGain(double tg) {TurbGain = tg;}
204  virtual double GetTurbGain() const {return TurbGain;}
205 
206  virtual void SetTurbRate(double tr) {TurbRate = tr;}
207  virtual double GetTurbRate() const {return TurbRate;}
208 
209  virtual void SetRhythmicity(double r) {Rhythmicity=r;}
210  virtual double GetRhythmicity() const {return Rhythmicity;}
211 
212  virtual double GetTurbPQR(int idx) const {return vTurbPQR(idx);}
213  virtual double GetTurbMagnitude(void) const {return vTurbulenceNED.Magnitude();}
214  virtual double GetTurbDirection(void) const {return TurbDirection;}
215  virtual const FGColumnVector3& GetTurbPQR(void) const {return vTurbPQR;}
216 
217  virtual void SetWindspeed20ft(double ws) { windspeed_at_20ft = ws;}
218  virtual double GetWindspeed20ft() const { return windspeed_at_20ft;}
219 
221  virtual void SetProbabilityOfExceedence( int idx) {probability_of_exceedence_index = idx;}
222  virtual int GetProbabilityOfExceedence() const { return probability_of_exceedence_index;}
223 
224  // Stores data defining a 1 - cosine gust profile that builds up, holds steady
225  // and fades out over specified durations.
227  bool Running;
228  double elapsedTime;
230  double steadyDuration;
231  double endDuration;
233  {
234  elapsedTime = 0.0;
235  Running = false;
236  startupDuration = 2;
237  steadyDuration = 4;
238  endDuration = 2;
239  }
240  };
241 
242  enum eGustFrame {gfNone=0, gfBody, gfWind, gfLocal};
243 
248  double magnitude;
249  eGustFrame gustFrame;
250  struct OneMinusCosineProfile gustProfile;
252  {
253  vWind.InitMatrix(0.0);
254  gustFrame = gfLocal;
255  magnitude = 1.0;
256  };
257  };
258 
260  struct UpDownBurst {
261  double ringLatitude;
262  double ringLongitude;
263  double ringAltitude;
264  double ringRadius;
265  double ringCoreRadius;
266  double circulation;
267  struct OneMinusCosineProfile oneMCosineProfile;
269  ringLatitude = ringLongitude = 0.0;
270  ringAltitude = 1000.0;
271  ringRadius = 2000.0;
272  ringCoreRadius = 100.0;
273  circulation = 100000.0;
274  }
275  };
276 
277  // 1 - Cosine gust setters
279  virtual void StartGust(bool running) {oneMinusCosineGust.gustProfile.Running = running;}
281  virtual void StartupGustDuration(double dur) {oneMinusCosineGust.gustProfile.startupDuration = dur;}
283  virtual void SteadyGustDuration(double dur) {oneMinusCosineGust.gustProfile.steadyDuration = dur;}
285  virtual void EndGustDuration(double dur) {oneMinusCosineGust.gustProfile.endDuration = dur;}
287  virtual void GustMagnitude(double mag) {oneMinusCosineGust.magnitude = mag;}
295  virtual void GustFrame(eGustFrame gFrame) {oneMinusCosineGust.gustFrame = gFrame;}
297  virtual void GustXComponent(double x) {oneMinusCosineGust.vWind(eX) = x;}
299  virtual void GustYComponent(double y) {oneMinusCosineGust.vWind(eY) = y;}
301  virtual void GustZComponent(double z) {oneMinusCosineGust.vWind(eZ) = z;}
302 
303  // Up- Down-burst functions
304  void NumberOfUpDownburstCells(int num);
305 
306  struct Inputs {
307  double V;
308  double wingspan;
309  double DistanceAGL;
310  double AltitudeASL;
311  double longitude;
312  double latitude;
313  double planetRadius;
314  FGMatrix33 Tl2b;
315  FGMatrix33 Tw2b;
316  double totalDeltaT;
317  } in;
318 
319 private:
320 
321  double MagnitudedAccelDt, MagnitudeAccel, Magnitude, TurbDirection;
322  //double h;
323  double TurbGain;
324  double TurbRate;
325  double Rhythmicity;
326  double wind_from_clockwise;
327  double spike, target_time, strength;
328  FGColumnVector3 vTurbulenceGrad;
329  FGColumnVector3 vBodyTurbGrad;
330  FGColumnVector3 vTurbPQR;
331 
332  struct OneMinusCosineGust oneMinusCosineGust;
333  std::vector <struct UpDownBurst*> UpDownBurstCells;
334 
335  // Dryden turbulence model
336  double windspeed_at_20ft;
337  int probability_of_exceedence_index;
338  FGTable *POE_Table;
339 
340  double psiw;
341  FGColumnVector3 vTotalWindNED;
342  FGColumnVector3 vWindNED;
343  FGColumnVector3 vGustNED;
344  FGColumnVector3 vCosineGust;
345  FGColumnVector3 vBurstGust;
346  FGColumnVector3 vTurbulenceNED;
347 
348  void Turbulence(double h);
349  void UpDownBurst();
350 
351  void CosineGust();
352  double CosineGustProfile( double startDuration, double steadyDuration,
353  double endDuration, double elapsedTime);
354  double DistanceFromRingCenter(double lat, double lon);
355 
356  virtual void bind(void);
357  void Debug(int from);
358 };
359 
360 } // namespace JSBSim
361 
362 //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
363 #endif
364 
FGWinds(FGFDMExec *)
Constructor.
Definition: FGWinds.cpp:77
virtual void SteadyGustDuration(double dur)
Specifies the length of time that the gust is at a steady, full strength.
Definition: FGWinds.h:283
virtual void SetWindPsi(double dir)
Sets the direction that the wind is coming from.
Definition: FGWinds.cpp:187
virtual void StartGust(bool running)
Initiates the execution of the gust.
Definition: FGWinds.h:279
virtual void SetGustNED(int idx, double gust)
Sets a gust component in NED frame.
Definition: FGWinds.h:182
virtual void StartupGustDuration(double dur)
Specifies the duration of the startup portion of the gust.
Definition: FGWinds.h:281
virtual const FGColumnVector3 & GetTotalWindNED(void) const
Retrieves the total wind components in NED frame.
Definition: FGWinds.h:140
virtual double GetTotalWindNED(int idx) const
Retrieves a total wind component in NED frame.
Definition: FGWinds.h:143
virtual void SetWindNED(double wN, double wE, double wD)
Sets the wind components in NED frame.
Definition: FGWinds.h:148
virtual void SetTurbNED(int idx, double turb)
Sets a turbulence component in NED frame.
Definition: FGWinds.h:185
virtual void EndGustDuration(double dur)
Specifies the length of time it takes for the gust to return to zero velocity.
Definition: FGWinds.h:285
virtual void SetWindNED(int idx, double wind)
Sets a wind component in NED frame.
Definition: FGWinds.h:151
virtual void GustYComponent(double y)
Specifies the Y component of velocity in the specified gust frame (ft/sec).
Definition: FGWinds.h:299
FGColumnVector3 vWindTransformed
Definition: FGWinds.h:247
virtual double GetGustNED(int idx) const
Retrieves a gust component in NED frame.
Definition: FGWinds.h:191
Models atmospheric disturbances: winds, gusts, turbulence, downbursts, etc.
Definition: FGWinds.h:119
virtual void SetGustNED(double gN, double gE, double gD)
Sets the gust components in NED frame.
Definition: FGWinds.h:188
virtual const FGColumnVector3 & GetGustNED(void) const
Retrieves the gust components in NED frame.
Definition: FGWinds.h:197
Stores information about a specified Up- or Down-burst.
Definition: FGWinds.h:260
Stores the information about a single one minus cosine gust instance.
Definition: FGWinds.h:245
virtual double GetTurbNED(int idx) const
Retrieves a turbulence component in NED frame.
Definition: FGWinds.h:194
virtual double GetWindPsi(void) const
Retrieves the direction that the wind is coming from.
Definition: FGWinds.h:165
Base class for all scheduled JSBSim models.
Definition: FGModel.h:74
virtual void GustMagnitude(double mag)
Specifies the magnitude of the gust in feet/second.
Definition: FGWinds.h:287
virtual void SetTurbType(tType tt)
Turbulence models available: ttNone, ttStandard, ttBerndt, ttCulp, ttMilspec, ttTustin.
Definition: FGWinds.h:200
virtual void SetWindNED(const FGColumnVector3 &wind)
Sets the wind components in NED frame.
Definition: FGWinds.h:154
This class implements a 3 element column vector.
virtual const FGColumnVector3 & GetWindNED(void) const
Retrieves the wind components in NED frame.
Definition: FGWinds.h:157
virtual void GustFrame(eGustFrame gFrame)
Specifies the frame that the gust direction vector components are specified in.
Definition: FGWinds.h:295
virtual void GustXComponent(double x)
Specifies the X component of velocity in the specified gust frame (ft/sec).
Definition: FGWinds.h:297
virtual void GustZComponent(double z)
Specifies the Z component of velocity in the specified gust frame (ft/sec).
Definition: FGWinds.h:301
virtual void SetProbabilityOfExceedence(int idx)
allowable range: 0-7, 3=light, 4=moderate, 6=severe turbulence
Definition: FGWinds.h:221
Handles matrix math operations.
Definition: FGMatrix33.h:92
double Magnitude(void) const
Length of the vector.
~FGWinds()
Destructor.
Definition: FGWinds.cpp:116
virtual double GetWindNED(int idx) const
Retrieves a wind component in NED frame.
Definition: FGWinds.h:160
Encapsulates the JSBSim simulation executive.
Definition: FGFDMExec.h:189
Lookup table class.
Definition: FGTable.h:243
bool Run(bool Holding)
Runs the winds model; called by the Executive Can pass in a value indicating if the executive is dire...
Definition: FGWinds.cpp:142