]> git.mxchange.org Git - flightgear.git/blob - src/FDM/JSBSim.cxx
- removed unused reference to bfi.hxx
[flightgear.git] / src / FDM / JSBSim.cxx
1 // JSBsim.cxx -- interface to the JSBsim flight model
2 //
3 // Written by Curtis Olson, started February 1999.
4 //
5 // Copyright (C) 1999  Curtis L. Olson  - curt@flightgear.org
6 //
7 // This program is free software; you can redistribute it and/or
8 // modify it under the terms of the GNU General Public License as
9 // published by the Free Software Foundation; either version 2 of the
10 // License, or (at your option) any later version.
11 //
12 // This program is distributed in the hope that it will be useful, but
13 // WITHOUT ANY WARRANTY; without even the implied warranty of
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15 // General Public License for more details.
16 //
17 // You should have received a copy of the GNU General Public License
18 // along with this program; if not, write to the Free Software
19 // Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 //
21 // $Id$
22
23
24 #include <simgear/compiler.h>
25
26 #ifdef SG_MATH_EXCEPTION_CLASH
27 #  include <math.h>
28 #endif
29
30 #include STL_STRING
31
32 #include <simgear/constants.h>
33 #include <simgear/debug/logstream.hxx>
34 #include <simgear/math/sg_geodesy.hxx>
35 #include <simgear/misc/sg_path.hxx>
36
37 #include <Scenery/scenery.hxx>
38
39 #include <Aircraft/aircraft.hxx>
40 #include <Controls/controls.hxx>
41 #include <Main/globals.hxx>
42 #include <Main/fg_props.hxx>
43
44 #include <FDM/JSBSim/FGFDMExec.h>
45 #include <FDM/JSBSim/FGAircraft.h>
46 #include <FDM/JSBSim/FGFCS.h>
47 #include <FDM/JSBSim/FGPosition.h>
48 #include <FDM/JSBSim/FGRotation.h>
49 #include <FDM/JSBSim/FGState.h>
50 #include <FDM/JSBSim/FGTranslation.h>
51 #include <FDM/JSBSim/FGAuxiliary.h>
52 #include <FDM/JSBSim/FGDefs.h>
53 #include <FDM/JSBSim/FGInitialCondition.h>
54 #include <FDM/JSBSim/FGTrim.h>
55 #include <FDM/JSBSim/FGAtmosphere.h>
56 #include <FDM/JSBSim/FGMassBalance.h>
57 #include <FDM/JSBSim/FGAerodynamics.h>
58 #include "JSBSim.hxx"
59
60 /******************************************************************************/
61
62 FGJSBsim::FGJSBsim( double dt ) 
63   : FGInterface(dt)
64 {
65     bool result;
66    
67     fdmex=new FGFDMExec;
68     
69     State        = fdmex->GetState();
70     Atmosphere   = fdmex->GetAtmosphere();
71     FCS          = fdmex->GetFCS();
72     MassBalance  = fdmex->GetMassBalance();
73     Propulsion   = fdmex->GetPropulsion();
74     Aircraft     = fdmex->GetAircraft();
75     Translation  = fdmex->GetTranslation();
76     Rotation     = fdmex->GetRotation();
77     Position     = fdmex->GetPosition();
78     Auxiliary    = fdmex->GetAuxiliary();
79     Aerodynamics = fdmex->GetAerodynamics();
80
81     fgic=new FGInitialCondition(fdmex);
82     needTrim=true;
83   
84     SGPath aircraft_path( globals->get_fg_root() );
85     aircraft_path.append( "Aircraft" );
86
87     SGPath engine_path( globals->get_fg_root() );
88     engine_path.append( "Engine" );
89     set_delta_t( dt );
90     State->Setdt( dt );
91
92     result = fdmex->LoadModel( aircraft_path.str(),
93                                engine_path.str(),
94                                fgGetString("/sim/aircraft") );
95     
96     int Neng = Propulsion->GetNumEngines();
97     SG_LOG(SG_FLIGHT,SG_INFO, "Neng: " << Neng );
98     
99     for(int i=0;i<Neng;i++) {
100         add_engine( FGEngInterface() );
101     }  
102     
103     fgSetDouble("/fdm/trim/pitch-trim", FCS->GetPitchTrimCmd());
104     fgSetDouble("/fdm/trim/throttle",   FCS->GetThrottleCmd(0));
105     fgSetDouble("/fdm/trim/aileron",    FCS->GetDaCmd());
106     fgSetDouble("/fdm/trim/rudder",     FCS->GetDrCmd());
107
108     trimmed = fgGetValue("/fdm/trim/trimmed",true);
109     trimmed->setBoolValue(false);
110
111 }
112
113 /******************************************************************************/
114 FGJSBsim::~FGJSBsim(void) {
115     if(fdmex != NULL) {
116         delete fdmex;
117         delete fgic;
118     }  
119 }
120
121 /******************************************************************************/
122
123 // Initialize the JSBsim flight model, dt is the time increment for
124 // each subsequent iteration through the EOM
125
126 void FGJSBsim::init() {
127                 // Explicitly call the superclass's
128                 // init method first.
129     FGInterface::init();
130
131     bool result;
132
133     SG_LOG( SG_FLIGHT, SG_INFO, "Starting and initializing JSBsim" );
134
135     Atmosphere->UseInternal();
136
137     SG_LOG( SG_FLIGHT, SG_INFO, "  Initializing JSBSim with:" );
138
139     switch(fgic->GetSpeedSet()) {
140     case setned:
141         SG_LOG(SG_FLIGHT,SG_INFO, "  Vn,Ve,Vd= "
142                << Position->GetVn() << ", "
143                << Position->GetVe() << ", "
144                << Position->GetVd() << " ft/s");
145     break;
146     case setuvw:
147         SG_LOG(SG_FLIGHT,SG_INFO, "  U,V,W= "
148                << Translation->GetUVW(1) << ", "
149                << Translation->GetUVW(2) << ", "
150                << Translation->GetUVW(3) << " ft/s");
151     break;
152     case setmach:
153         SG_LOG(SG_FLIGHT,SG_INFO, "  Mach: "
154                << Translation->GetMach() );
155     break;
156     case setvc:
157     default:
158         SG_LOG(SG_FLIGHT,SG_INFO, "  Indicated Airspeed: "
159                << Auxiliary->GetVcalibratedKTS() << " knots" );
160     break;
161     }
162
163     SG_LOG( SG_FLIGHT, SG_INFO, "  Bank Angle: "
164             <<  Rotation->Getphi()*RADTODEG << " deg");
165     SG_LOG( SG_FLIGHT, SG_INFO, "  Pitch Angle: "
166             << Rotation->Gettht()*RADTODEG << " deg"  );
167     SG_LOG( SG_FLIGHT, SG_INFO, "  True Heading: "
168             << Rotation->Getpsi()*RADTODEG << " deg"  );
169     SG_LOG( SG_FLIGHT, SG_INFO, "  Latitude: "
170             <<  Position->GetLatitude() << " deg" );
171     SG_LOG( SG_FLIGHT, SG_INFO, "  Longitude: "
172             <<  Position->GetLongitude() << " deg"  );
173
174     SG_LOG( SG_FLIGHT, SG_INFO, "  loaded initial conditions" );
175
176     SG_LOG( SG_FLIGHT, SG_INFO, "  set dt" );
177
178     SG_LOG( SG_FLIGHT, SG_INFO, "Finished initializing JSBSim" );
179 }
180
181 /******************************************************************************/
182
183 // Run an iteration of the EOM (equations of motion)
184
185 bool FGJSBsim::update( int multiloop ) {
186
187     int i;
188
189     double save_alt = 0.0;
190
191     copy_to_JSBsim();
192
193     trimmed->setBoolValue(false);
194
195     if (needTrim && fgGetBool("/sim/startup/trim")) {
196
197       //fgic->SetSeaLevelRadiusFtIC( get_Sea_level_radius() );
198       //fgic->SetTerrainAltitudeFtIC( scenery.cur_elev * SG_METER_TO_FEET );
199
200     FGTrim *fgtrim;
201     if(fgic->GetVcalibratedKtsIC() < 10 ) {
202         fgic->SetVcalibratedKtsIC(0.0);
203         fgtrim=new FGTrim(fdmex,fgic,tGround);
204     } else {
205         fgtrim=new FGTrim(fdmex,fgic,tLongitudinal);
206     }
207     if(!fgtrim->DoTrim()) {
208         fgtrim->Report();
209         fgtrim->TrimStats();
210     } else {
211         trimmed->setBoolValue(true);
212     }
213     fgtrim->ReportState();
214     delete fgtrim;
215
216     needTrim=false;
217
218     fgSetDouble("/fdm/trim/pitch-trim", FCS->GetPitchTrimCmd());
219     fgSetDouble("/fdm/trim/throttle",   FCS->GetThrottleCmd(0));
220     fgSetDouble("/fdm/trim/aileron",    FCS->GetDaCmd());
221     fgSetDouble("/fdm/trim/rudder",     FCS->GetDrCmd());
222
223     controls.set_elevator_trim(FCS->GetPitchTrimCmd());
224     controls.set_elevator(FCS->GetDeCmd());
225     controls.set_throttle(FGControls::ALL_ENGINES,
226                           FCS->GetThrottleCmd(0));
227
228     controls.set_aileron(FCS->GetDaCmd());
229     controls.set_rudder( FCS->GetDrCmd());
230     
231     SG_LOG( SG_FLIGHT, SG_INFO, "  Trim complete" );
232     }  
233   
234     for( i=0; i<get_num_engines(); i++ ) {
235       get_engine(i)->set_RPM( Propulsion->GetThruster(i)->GetRPM() );
236       get_engine(i)->set_Throttle( controls.get_throttle(i) );
237     }
238
239     for ( i=0; i < multiloop; i++ ) {
240         fdmex->Run();
241     }
242
243     // printf("%d FG_Altitude = %.2f\n", i, FG_Altitude * 0.3048);
244     // printf("%d Altitude = %.2f\n", i, Altitude * 0.3048);
245
246     // translate JSBsim back to FG structure so that the
247     // autopilot (and the rest of the sim can use the updated values
248
249     copy_from_JSBsim();
250     return true;
251 }
252
253 /******************************************************************************/
254
255 // Convert from the FGInterface struct to the JSBsim generic_ struct
256
257 bool FGJSBsim::copy_to_JSBsim() {
258     // copy control positions into the JSBsim structure
259
260     FCS->SetDaCmd( controls.get_aileron());
261     FCS->SetDeCmd( controls.get_elevator());
262     FCS->SetPitchTrimCmd(controls.get_elevator_trim());
263     FCS->SetDrCmd( -controls.get_rudder());
264     FCS->SetDfCmd(  controls.get_flaps() );
265     FCS->SetDsbCmd( 0.0 ); //speedbrakes
266     FCS->SetDspCmd( 0.0 ); //spoilers
267     FCS->SetThrottleCmd( FGControls::ALL_ENGINES,
268                          controls.get_throttle( 0 ));
269     FCS->SetLBrake( controls.get_brake( 0 ) );
270     FCS->SetRBrake( controls.get_brake( 1 ) );
271     FCS->SetCBrake( controls.get_brake( 2 ) );
272
273     Position->SetSeaLevelRadius( get_Sea_level_radius() );
274     Position->SetRunwayRadius( scenery.cur_elev*SG_METER_TO_FEET
275                                + get_Sea_level_radius() );
276
277     Atmosphere->SetExTemperature(get_Static_temperature());
278     Atmosphere->SetExPressure(get_Static_pressure());
279     Atmosphere->SetExDensity(get_Density());
280     Atmosphere->SetWindNED(get_V_north_airmass(),
281                            get_V_east_airmass(),
282                            get_V_down_airmass());
283 //    SG_LOG(SG_FLIGHT,SG_INFO, "Wind NED: "
284 //                  << get_V_north_airmass() << ", "
285 //                  << get_V_east_airmass()  << ", "
286 //                  << get_V_down_airmass() );
287
288     return true;
289 }
290
291 /******************************************************************************/
292
293 // Convert from the JSBsim generic_ struct to the FGInterface struct
294
295 bool FGJSBsim::copy_from_JSBsim() {
296     unsigned int i, j;
297
298     _set_Inertias( MassBalance->GetMass(),
299                    MassBalance->GetIxx(),
300                    MassBalance->GetIyy(),
301                    MassBalance->GetIzz(),
302                    MassBalance->GetIxz() );
303
304     _set_CG_Position( MassBalance->GetXYZcg(1),
305                       MassBalance->GetXYZcg(2),
306                       MassBalance->GetXYZcg(3) );
307
308     _set_Accels_Body( Translation->GetUVWdot(1),
309                       Translation->GetUVWdot(2),
310                       Translation->GetUVWdot(3) );
311
312     _set_Accels_CG_Body( Translation->GetUVWdot(1),
313                          Translation->GetUVWdot(2),
314                          Translation->GetUVWdot(3) );
315
316     //_set_Accels_CG_Body_N ( Translation->GetNcg(1),
317     //                       Translation->GetNcg(2),
318     //                       Translation->GetNcg(3) );
319     //
320     _set_Accels_Pilot_Body( Auxiliary->GetPilotAccel(1),
321                             Auxiliary->GetPilotAccel(2),
322                             Auxiliary->GetPilotAccel(3) );
323
324     //_set_Accels_Pilot_Body_N( Auxiliary->GetNpilot(1),
325     //                         Auxiliary->GetNpilot(2),
326     //                         Auxiliary->GetNpilot(3) );
327
328     _set_Nlf( Aerodynamics->GetNlf() );
329
330     // Velocities
331
332     _set_Velocities_Local( Position->GetVn(),
333                            Position->GetVe(),
334                            Position->GetVd() );
335
336     _set_Velocities_Wind_Body( Translation->GetUVW(1),
337                                Translation->GetUVW(2),
338                                Translation->GetUVW(3) );
339
340     _set_V_rel_wind( Translation->GetVt() );
341
342     _set_V_equiv_kts( Auxiliary->GetVequivalentKTS() );
343
344     // _set_V_calibrated( Auxiliary->GetVcalibratedFPS() );
345
346     _set_V_calibrated_kts( Auxiliary->GetVcalibratedKTS() );
347
348     _set_V_ground_speed( Position->GetVground() );
349
350     _set_Omega_Body( Rotation->GetPQR(1),
351                      Rotation->GetPQR(2),
352                      Rotation->GetPQR(3) );
353
354     _set_Euler_Rates( Rotation->GetEulerRates(1),
355                       Rotation->GetEulerRates(2),
356                       Rotation->GetEulerRates(3) );
357
358     _set_Geocentric_Rates(Position->GetLatitudeDot(),
359                           Position->GetLongitudeDot(),
360                           Position->Gethdot() );
361
362     _set_Mach_number( Translation->GetMach() );
363
364     // Positions
365     _updatePosition( Position->GetLatitude(),
366                      Position->GetLongitude(),
367                      Position->Geth() );
368
369     _set_Euler_Angles( Rotation->Getphi(),
370                        Rotation->Gettht(),
371                        Rotation->Getpsi() );
372
373     _set_Alpha( Translation->Getalpha() );
374     _set_Beta( Translation->Getbeta() );
375
376
377     _set_Gamma_vert_rad( Position->GetGamma() );
378     // set_Gamma_horiz_rad( Gamma_horiz_rad );
379
380     _set_Earth_position_angle( Auxiliary->GetEarthPositionAngle() );
381
382     _set_Climb_Rate( Position->Gethdot() );
383
384
385     for ( i = 1; i <= 3; i++ ) {
386         for ( j = 1; j <= 3; j++ ) {
387             _set_T_Local_to_Body( i, j, State->GetTl2b(i,j) );
388         }
389     }
390     return true;
391 }
392
393 void FGJSBsim::snap_shot(void) {
394     fgic->SetLatitudeRadIC(get_Lat_geocentric() );
395     fgic->SetLongitudeRadIC( get_Longitude() );
396     fgic->SetAltitudeFtIC( get_Altitude() );
397     fgic->SetTerrainAltitudeFtIC( get_Runway_altitude() );
398     fgic->SetVtrueFpsIC( get_V_rel_wind() );
399     fgic->SetPitchAngleRadIC( get_Theta() );
400     fgic->SetRollAngleRadIC( get_Phi() );
401     fgic->SetTrueHeadingRadIC( get_Psi() );
402     fgic->SetClimbRateFpsIC( get_Climb_Rate() );
403 }
404
405
406 bool FGJSBsim::ToggleDataLogging(void) {
407     return fdmex->GetOutput()->Toggle();
408 }
409
410
411 bool FGJSBsim::ToggleDataLogging(bool state) {
412     if (state) {
413       fdmex->GetOutput()->Enable();
414       return true;
415     } else {
416       fdmex->GetOutput()->Disable();
417       return false;
418     }
419 }
420
421
422 //Positions
423 void FGJSBsim::set_Latitude(double lat) {
424     double sea_level_radius_meters,lat_geoc;
425
426     SG_LOG(SG_FLIGHT,SG_INFO,"FGJSBsim::set_Latitude: " << lat );
427
428     snap_shot();
429     sgGeodToGeoc( lat, get_Altitude() , &sea_level_radius_meters, &lat_geoc);
430     _set_Sea_level_radius( sea_level_radius_meters * SG_METER_TO_FEET  );
431     fgic->SetSeaLevelRadiusFtIC( sea_level_radius_meters * SG_METER_TO_FEET  );
432     fgic->SetLatitudeRadIC( lat_geoc );
433     fdmex->RunIC(fgic); //loop JSBSim once
434     copy_from_JSBsim(); //update the bus
435     needTrim=true;
436 }
437
438 void FGJSBsim::set_Longitude(double lon) {
439
440     SG_LOG(SG_FLIGHT,SG_INFO,"FGJSBsim::set_Longitude: " << lon );
441
442     snap_shot();
443     fgic->SetLongitudeRadIC(lon);
444     fdmex->RunIC(fgic); //loop JSBSim once
445     copy_from_JSBsim(); //update the bus
446     needTrim=true;
447 }
448
449 void FGJSBsim::set_Altitude(double alt) {
450     double sea_level_radius_meters,lat_geoc;
451
452     SG_LOG(SG_FLIGHT,SG_INFO, "FGJSBsim::set_Altitude: " << alt );
453
454     snap_shot();
455     sgGeodToGeoc( get_Latitude(), alt , &sea_level_radius_meters, &lat_geoc);
456     _set_Sea_level_radius( sea_level_radius_meters * SG_METER_TO_FEET  );
457     fgic->SetSeaLevelRadiusFtIC( sea_level_radius_meters * SG_METER_TO_FEET );
458     fgic->SetLatitudeRadIC( lat_geoc );
459     fgic->SetAltitudeFtIC(alt);
460     fdmex->RunIC(fgic); //loop JSBSim once
461     copy_from_JSBsim(); //update the bus
462     needTrim=true;
463 }
464
465 void FGJSBsim::set_V_calibrated_kts(double vc) {
466     SG_LOG(SG_FLIGHT,SG_INFO, "FGJSBsim::set_V_calibrated_kts: " <<  vc );
467
468     snap_shot();
469     fgic->SetVcalibratedKtsIC(vc);
470     fdmex->RunIC(fgic); //loop JSBSim once
471     copy_from_JSBsim(); //update the bus
472     needTrim=true;
473 }
474
475 void FGJSBsim::set_Mach_number(double mach) {
476     SG_LOG(SG_FLIGHT,SG_INFO, "FGJSBsim::set_Mach_number: " <<  mach );
477
478     snap_shot();
479     fgic->SetMachIC(mach);
480     fdmex->RunIC(fgic); //loop JSBSim once
481     copy_from_JSBsim(); //update the bus
482     needTrim=true;
483 }
484
485 void FGJSBsim::set_Velocities_Local( double north, double east, double down ){
486     SG_LOG(SG_FLIGHT,SG_INFO, "FGJSBsim::set_Velocities_Local: "
487        << north << ", " <<  east << ", " << down );
488
489     snap_shot();
490     fgic->SetVnorthFpsIC(north);
491     fgic->SetVeastFpsIC(east);
492     fgic->SetVdownFpsIC(down);
493     fdmex->RunIC(fgic); //loop JSBSim once
494     copy_from_JSBsim(); //update the bus
495     needTrim=true;
496 }
497
498 void FGJSBsim::set_Velocities_Wind_Body( double u, double v, double w){
499     SG_LOG(SG_FLIGHT,SG_INFO, "FGJSBsim::set_Velocities_Wind_Body: "
500        << u << ", " <<  v << ", " <<  w );
501
502     snap_shot();
503     fgic->SetUBodyFpsIC(u);
504     fgic->SetVBodyFpsIC(v);
505     fgic->SetWBodyFpsIC(w);
506     fdmex->RunIC(fgic); //loop JSBSim once
507     copy_from_JSBsim(); //update the bus
508     needTrim=true;
509 }
510
511 //Euler angles
512 void FGJSBsim::set_Euler_Angles( double phi, double theta, double psi ) {
513     SG_LOG(SG_FLIGHT,SG_INFO, "FGJSBsim::set_Euler_Angles: "
514        << phi << ", " << theta << ", " << psi );
515
516     snap_shot();
517     fgic->SetPitchAngleRadIC(theta);
518     fgic->SetRollAngleRadIC(phi);
519     fgic->SetTrueHeadingRadIC(psi);
520     fdmex->RunIC(fgic); //loop JSBSim once
521     copy_from_JSBsim(); //update the bus
522     needTrim=true;
523 }
524
525 //Flight Path
526 void FGJSBsim::set_Climb_Rate( double roc) {
527     SG_LOG(SG_FLIGHT,SG_INFO, "FGJSBsim::set_Climb_Rate: " << roc );
528
529     snap_shot();
530     fgic->SetClimbRateFpsIC(roc);
531     fdmex->RunIC(fgic); //loop JSBSim once
532     copy_from_JSBsim(); //update the bus
533     needTrim=true;
534 }
535
536 void FGJSBsim::set_Gamma_vert_rad( double gamma) {
537     SG_LOG(SG_FLIGHT,SG_INFO, "FGJSBsim::set_Gamma_vert_rad: " << gamma );
538
539     snap_shot();
540     fgic->SetFlightPathAngleRadIC(gamma);
541     fdmex->RunIC(fgic); //loop JSBSim once
542     copy_from_JSBsim(); //update the bus
543     needTrim=true;
544 }
545
546 //Earth
547 void FGJSBsim::set_Sea_level_radius(double slr) {
548     SG_LOG(SG_FLIGHT,SG_INFO, "FGJSBsim::set_Sea_level_radius: " << slr );
549
550     snap_shot();
551     fgic->SetSeaLevelRadiusFtIC(slr);
552     fdmex->RunIC(fgic); //loop JSBSim once
553     copy_from_JSBsim(); //update the bus
554     needTrim=true;
555 }
556
557 void FGJSBsim::set_Runway_altitude(double ralt) {
558     SG_LOG(SG_FLIGHT,SG_INFO, "FGJSBsim::set_Runway_altitude: " << ralt );
559
560     snap_shot();
561     _set_Runway_altitude( ralt );
562     fgic->SetTerrainAltitudeFtIC( ralt );
563     fdmex->RunIC(fgic); //loop JSBSim once
564     copy_from_JSBsim(); //update the bus
565     needTrim=true;
566 }
567
568 void FGJSBsim::set_Static_pressure(double p) {
569     SG_LOG(SG_FLIGHT,SG_INFO, "FGJSBsim::set_Static_pressure: " << p );
570
571     snap_shot();
572     Atmosphere->SetExPressure(p);
573     if(Atmosphere->External() == true)
574     needTrim=true;
575 }
576
577 void FGJSBsim::set_Static_temperature(double T) {
578     SG_LOG(SG_FLIGHT,SG_INFO, "FGJSBsim::set_Static_temperature: " << T );
579     
580     snap_shot();
581     Atmosphere->SetExTemperature(T);
582     if(Atmosphere->External() == true)
583     needTrim=true;
584 }
585  
586
587 void FGJSBsim::set_Density(double rho) {
588     SG_LOG(SG_FLIGHT,SG_INFO, "FGJSBsim::set_Density: " << rho );
589     
590     snap_shot();
591     Atmosphere->SetExDensity(rho);
592     if(Atmosphere->External() == true)
593     needTrim=true;
594 }
595   
596
597 void FGJSBsim::set_Velocities_Local_Airmass (double wnorth, 
598                          double weast, 
599                          double wdown ) {
600     SG_LOG(SG_FLIGHT,SG_INFO, "FGJSBsim::set_Velocities_Local_Airmass: " 
601        << wnorth << ", " << weast << ", " << wdown );
602     
603     _set_Velocities_Local_Airmass( wnorth, weast, wdown );
604     snap_shot();
605     Atmosphere->SetWindNED(wnorth, weast, wdown );
606     if(Atmosphere->External() == true)
607         needTrim=true;
608 }     
609