]> git.mxchange.org Git - flightgear.git/blob - src/FDM/YASim/Rotor.hpp
Maik: add a downwashfactor tunable
[flightgear.git] / src / FDM / YASim / Rotor.hpp
1 #ifndef _ROTOR_HPP
2 #define _ROTOR_HPP
3
4 #include "Vector.hpp"
5 #include "Rotorpart.hpp"
6 #include "Integrator.hpp"
7 #include "RigidBody.hpp"
8 #include "BodyEnvironment.hpp"
9
10 namespace yasim {
11
12 class Surface;
13 class Rotorpart;
14 class Ground;
15 const float rho_null=1.184f; //25DegC, 101325Pa
16
17 class Rotor {
18     friend std::ostream &  operator<<(std::ostream & out, /*const*/ Rotor& r);
19 private:
20     float _torque;
21     float _omega,_omegan,_omegarel,_ddt_omega,_omegarelneu;
22     float _phi_null;
23     float _chord;
24     float _taper;
25     float _airfoil_incidence_no_lift;
26     float _collective;
27     float _airfoil_lift_coefficient;
28     float _airfoil_drag_coefficient0;
29     float _airfoil_drag_coefficient1;
30     int _ccw;
31     int _number_of_blades;
32     int _number_of_segments;
33     int _number_of_parts;
34     float _balance1;
35     float _balance2;
36     float _tilt_yaw;
37     float _tilt_roll;
38     float _tilt_pitch;
39     float _old_tilt_roll;
40     float _old_tilt_pitch;
41     float _old_tilt_yaw;
42     float _downwash_factor;
43
44 public:
45     Rotor();
46     ~Rotor();
47
48     // Rotor geometry:
49     void setNormal(float* normal);
50     //the normal vector (direction of rotormast, pointing up)
51
52     void setForward(float* forward);
53     //the normal vector pointing forward (for ele and ail)
54     void setForceAtPitchA(float force);
55     void setPowerAtPitch0(float value);
56     void setPowerAtPitchB(float value);
57     void setNotorque(int value);
58     void setPitchA(float value);
59     void setPitchB(float value);
60     void setMinCyclicail(float value);
61     void setMinCyclicele(float value);
62     void setMaxCyclicail(float value);
63     void setMaxCyclicele(float value);
64     void setMaxCollective(float value);
65     void setMinCollective(float value);
66     void setMinTiltYaw(float value);
67     void setMinTiltPitch(float value);
68     void setMinTiltRoll(float value);
69     void setMaxTiltYaw(float value);
70     void setMaxTiltPitch(float value);
71     void setMaxTiltRoll(float value);
72     void setTiltCenterX(float value);
73     void setTiltCenterY(float value);
74     void setTiltCenterZ(float value);
75     void setTiltYaw(float lval);
76     void setTiltPitch(float lval);
77     void setTiltRoll(float lval);
78     void setDiameter(float value);
79     void setWeightPerBlade(float value);
80     void setNumberOfBlades(float value);
81     void setRelBladeCenter(float value);
82     void setDelta3(float value);
83     void setDelta(float value);
84     void setDynamic(float value);
85     void setTranslift(float value);
86     void setC2(float value);
87     void setStepspersecond(float steps);
88     void setRPM(float value);
89     void setPhiNull(float value);
90     void setRelLenHinge(float value);
91     void setBase(float* base);        // in local coordinates
92     void getPosition(float* out);
93     void setCyclicail(float lval,float rval);
94     void setCyclicele(float lval,float rval);
95     void setCollective(float lval);
96     void setAlphaoutput(int i, const char *text);
97     void setCcw(int ccw);
98     int getCcw() {return _ccw;};
99     void setParameter(char *parametername, float value);
100     void setGlobalGround(double* global_ground, float* global_vel);
101     float getTorqueOfInertia();
102     int getValueforFGSet(int j,char *b,float *f);
103     void setName(const char *text);
104     void inititeration(float dt,float omegarel,float ddt_omegarel,float *rot);
105     void compile();
106     void updateDirectionsAndPositions(float *rot);
107     void getTip(float* tip);
108     void calcLiftFactor(float* v, float rho, State *s);
109     void getDownWash(float *pos, float * v_heli, float *downwash);
110     int getNumberOfBlades(){return _number_of_blades;}
111     void setDownwashFactor(float value);
112
113     // Query the list of Rotorpart objects
114     int numRotorparts();
115     Rotorpart* getRotorpart(int n);
116     void setAlpha0(float f);
117     void setAlphamin(float f);
118     void setAlphamax(float f);
119     void setTeeterdamp(float f);
120     void setMaxteeterdamp(float f);
121     void setRelLenTeeterHinge(float value);
122     void setAlpha0factor(float f);
123     void setTorque(float f);
124     void addTorque(float f);
125     float getTorque() {return _torque;}
126     float getLiftFactor();
127     float getLiftCoef(float incidence,float speed);
128     float getDragCoef(float incidence,float speed);
129     float getOmegaRel() {return _omegarel;}
130     float getOmegaRelNeu() {return _omegarelneu;}
131     void setOmegaRelNeu(float orn) {_omegarelneu=orn;}
132     float getOmegan() {return _omegan;}
133     float getTaper() { return _taper;}
134     float getChord() { return _chord;}
135     int getNumberOfParts() { return _number_of_parts;}
136     float getOverallStall() 
137         {if (_stall_v2sum !=0 ) return _stall_sum/_stall_v2sum; else return 0;}
138     float getAirfoilIncidenceNoLift() {return _airfoil_incidence_no_lift;}
139     Vector _rotorparts;
140     void findGroundEffectAltitude(Ground * ground_cb,State *s);
141     float *getGravDirection() {return _grav_direction;}
142     void writeInfo();
143     void setSharedFlapHinge(bool s);
144     void setBalance(float b);
145     float getBalance(){ return (_balance1>0)?_balance1*_balance2:_balance1;}
146
147 private:
148     void testForRotorGroundContact (Ground * ground_cb,State *s);
149     void strncpy(char *dest,const char *src,int maxlen);
150     void interp(float* v1, float* v2, float frac, float* out);
151     float calcStall(float incidence,float speed);
152     float findGroundEffectAltitude(Ground * ground_cb,State *s,
153         float *pos0,float *pos1,float *pos2,float *pos3,
154         int iteration=0,float a0=-1,float a1=-1,float a2=-1,float a3=-1);
155     static void euler2orient(float roll, float pitch, float hdg,
156                              float* out);
157     Rotorpart* newRotorpart(/*float* pos, float *posforceattac, float *normal,
158         float* speed,float *dirzentforce, */float zentforce,float maxpitchforce,
159         float delta3,float mass,float translift,float rellenhinge,float len);
160     float _base[3];
161     float _groundeffectpos[4][3];
162     float _ground_contact_pos[16][3];
163     int _num_ground_contact_pos;
164     float _ground_effect_altitude;
165     //some postions, where to calcualte the ground effect
166     float _normal[3];//the normal vector (direction of rotormast, pointing up)
167     float _normal_with_yaw_roll[3];//the normal vector (perpendicular to rotordisc)
168     float _forward[3];
169     float _diameter;
170     float _weight_per_blade;
171     float _rel_blade_center;
172     float _tilt_center[3];
173     float _min_tilt_yaw;
174     float _min_tilt_pitch;
175     float _min_tilt_roll;
176     float _max_tilt_yaw;
177     float _max_tilt_pitch;
178     float _max_tilt_roll;
179     float _min_pitch;
180     float _max_pitch;
181     float _force_at_pitch_a;
182     float _pitch_a;
183     float _power_at_pitch_0;
184     float _power_at_pitch_b;
185     int _no_torque;
186     int _sim_blades;
187     float _pitch_b;
188     float _rotor_rpm;
189     float _rel_len_hinge;
190     float _maxcyclicail;
191     float _maxcyclicele;
192     float _mincyclicail;
193     float _mincyclicele;
194     float _delta3;
195     float _delta;
196     float _dynamic;
197     float _translift;
198     float _c2;
199     float _stepspersecond;
200     char _alphaoutput[8][256];
201     char _name[256];
202     int _engineon;
203     float _alphamin,_alphamax,_alpha0,_alpha0factor;
204     float _teeterdamp,_maxteeterdamp;
205     float _rellenteeterhinge;
206     float _translift_ve;
207     float _translift_maxfactor;
208     float _ground_effect_constant;
209     float _vortex_state_lift_factor;
210     float _vortex_state_c1;
211     float _vortex_state_c2;
212     float _vortex_state_c3;
213     float _vortex_state_e1;
214     float _vortex_state_e2;
215     float _vortex_state_e3;
216     float _lift_factor,_f_ge,_f_vs,_f_tl;
217     float _vortex_state;
218     double _global_ground[4];
219     float _liftcoef;
220     float _dragcoef0;
221     float _dragcoef1;
222     float _twist; //outer incidence = inner inner incidence + _twist
223     float _rel_len_where_incidence_is_measured;
224     float _torque_of_inertia;
225     float _rel_len_blade_start;
226     float _incidence_stall_zero_speed;
227     float _incidence_stall_half_sonic_speed;
228     float _lift_factor_stall;
229     float _stall_change_over;
230     float _drag_factor_stall;
231     float _stall_sum;
232     float _stall_v2sum;
233     float _yaw;
234     float _roll;
235     float _cyclicail;
236     float _cyclicele;
237     float _cyclic_factor;
238     float _rotor_correction_factor;
239     float _phi;
240     bool _shared_flap_hinge;
241     float _grav_direction[3];
242     int _properties_tied;
243     bool _directions_and_postions_dirty;
244 };
245 std::ostream &  operator<<(std::ostream & out, /*const*/ Rotor& r);
246
247 class Rotorgear {
248 private:
249     int _in_use;
250     int _engineon;
251     float _max_power_engine;
252     float _engine_prop_factor;
253     float _yasimdragfactor;
254     float _yasimliftfactor;
255     float _rotorbrake;
256     float _max_power_rotor_brake;
257     float _rotorgear_friction;
258     float _ddt_omegarel;
259     float _engine_accel_limit;
260     float _total_torque_on_engine;
261     Vector _rotors;
262     float _target_rel_rpm;
263     float _max_rel_torque;
264
265 public:
266     Rotorgear();
267     ~Rotorgear();
268     int isInUse() {return _in_use;}
269     void setInUse() {_in_use = 1;}
270     void compile();
271     void addRotor(Rotor* rotor);
272     int getNumRotors() {return _rotors.size();}
273     Rotor* getRotor(int i) {return (Rotor*)_rotors.get(i);}
274     void calcForces(float* torqueOut);
275     void setParameter(char *parametername, float value);
276     void setEngineOn(int value);
277     int getEngineon();
278     void setRotorBrake(float lval);
279     void setRotorEngineMaxRelTorque(float lval);
280     void setRotorRelTarget(float lval);
281     float getYasimDragFactor() { return _yasimdragfactor;}
282     float getYasimLiftFactor() { return _yasimliftfactor;}
283     float getMaxPowerEngine() { return _max_power_engine;}
284     float getMaxPowerRotorBrake() { return _max_power_rotor_brake;}
285     float getRotorBrake() { return _rotorbrake;}
286     float getEnginePropFactor() {return _engine_prop_factor;}
287     Vector* getRotors() { return &_rotors;}
288     void initRotorIteration(float *lrot,float dt);
289     void getDownWash(float *pos, float * v_heli, float *downwash);
290     int getValueforFGSet(int j,char *b,float *f);
291 };
292
293 }; // namespace yasim
294 #endif // _ROTOR_HPP