• Advertisement
Sign in to follow this  

Simple aircraft physics question

This topic is 3304 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I am working on a basic aircraft simulation but have hit a problem. I can calculate the forces on the plane at a time (lift, weight, thrust, drag) which when added together give me an acceleration vector of the plane. Now what's the best way to use that acceleration vector to compute a velocity? I started using an accumulated vector for the velocity but that isn't working out very well. Basically every frame I was calculating the acceleration, adding to velocity vector and then adding the velocity to the position.
vector3 acceleration = CalculateAccelVector();
velocity += acceleration;
position += velocity;
This was causing a few issues. For example if the aircraft was moving along the z-axis and made a quick turn to the x-axis, it would maintain its velocity along the z-axis because there was no force to cancel it out. I've tried dividing the velocity vector every frame by some amount so that eventually the extra force would be cancelled out and fudging the velocity direction toward the thrust direction but haven't found good values for this yet. The aircraft would either act like a very powerful rocket with no drag (not losing any speed in turns) or the heading would take too long to match the thrust direction (flying forward and sideways). I think I am missing something simple here but don't know what, any ideas? Not sure if it matters but the flight model I am trying to implement is not a full blown simulator. Much simpler inputs to the physics simulation. Thanks

Share this post


Link to post
Share on other sites
Advertisement
The basic physics equation that should be burned into your memory is Newton's second law. Commonly, this is written as:

F = m * a

where F is the net force on the object, m is the object's mass, and a is the resulting acceleration of the object. The more accurate form - and the one you will want to use for modeling - is:

F = d/dt (m*v) = m * dv/dt

where d/dt is the time rate-of-change of the quantity in parentheses, and v is the velocity of the object. For small, discrete steps in time, and for error calculations, dv/dt in the final term can be translated as, "the difference in velocity divided by the difference in time".

At a given moment (frame or cycle) in your simulator, you know F (the sum of the forces). In all likelihood, you know m (the mass of the object). You want to know the difference in velocity, dv, so the only thing left for you to calculate is dt, the change in time since you last updated the forces and velocity. (I am assuming you are checking forces and updating velocity in the same frame; things can be a bit more tricky if you are not.) If you have a framerate subroutine already running, you already have dt available somewhere in your program. If not, see the next paragraph.

To calculate time elapsed since the last frame, you need to start a clock. The quantity dt will be the difference in this clock's value between the current and previous frame. There are many, many ways to keep track of time. For a simple simulator, I would recommend the ubiquitous 'ctime.h' library - standardized, well-documented, very simple to use. For more sophisticated simulations where small variations in your timestep can make your DE unstable, a more accurate approach may be needed.

Once you have dt, solving the equation for dv gives you:

dv = F * dt / m

To update your velocity, simply add dv to your previous velocity. Note that this works just as well in three dimensions (with vector equations), since v and F are vectors while m and dt are scalars. Simply do the above calculation for each axis.

On a nearly-irrelevant tangent, I'd be very interested to see your equations of flight. In particular, how are you simulating lift and drag?

Good luck!

Share this post


Link to post
Share on other sites
HI . I think your problem lies in that you are missing the air-resistance alltogether.

first thing ,you must know the RELATIVE AIRSPEED of the airplane .

hkVector4 RelAirSpeed

RelAirSpeed.z=hkRigidBody->GetLinearVelocity().Dot3( AirplanelocalVector( 2 ))
RelAirSpeed.y=hkRigidBody->GetLinearVelocity().Dot3( AirplanelocalVector( 1 ))
RelAirSpeed.x=hkRigidBody->GetLinearVelocity().Dot3( AirplanelocalVector( 0 ))

=please note that RelAirSpeed.z is the INDICATED airspeed that you should use for all your lift equations / dashboard airspeed readout , etc )


WITH the RELAVITE airspeed to the aircraft ,you should have a matrix (or at least a 3-dimensional value /vectors ect ) expressing how "resistant" to the air speed is the aircraft in each of the axis .

very obviously this would be something like hkVector4 AirResstance( 10.0, 900.0 , 2.0f ) , 0 ) , meaning that an aircraft generates 2 (whatever units of force ) to the wind coming in Z-axis (i.e. fliying normally ) but generatoes 900 when the same airspeed is caming trhought the Y-Axis . etc..etc...

this way .. even that you aircraft changes attitude while still moving mainly in the Y axis , It will definintely slow down and start moving in tthe desired direction .

Cheers
Javier

Share this post


Link to post
Share on other sites
Quote:
Original post by swiftcoder
It sounds like you are missing friction completely - are you sure your drag calculations are correct?
I did find a problem in there. Should have been taking the absolute value of something that I wasn't. Not the main issue but it would have been down the line.

Quote:
Original post by TythosEternal
The basic physics equation that should be burned into your memory is Newton's second law. Commonly, this is written as:

F = m * a
...
That was the issue, my implementation of it was wrong. It is looking much better now, not perfect but much better. Probably have to play with my force calculations a bit.

Quote:
Original post by TythosEternal
On a nearly-irrelevant tangent, I'd be very interested to see your equations of flight. In particular, how are you simulating lift and drag?
My implementations of those are very basic.

The drag calculation is split into drag due to speed and drag due to aoa.

To calculate drag due to speed, I take the current speed over the maximum speed (constant). At maximum speed this factor would be 1.0 to counteract the thrust.

To calculate drag due to aoa, I take the current aoa over a max drag aoa (constant). At higher aoa's (absolute value) more drag will be generated.

The final drag factor is then those two added together and multiplied with the max thrust. At max velocity the drag factor should counteract the thrust force and the velocity shouldn't increase due to thrust.

Lift is a bit more complex, my implementation might be wrong (lots of hard coded constants currently) but it is producing the desired results at the moment.

Like drag I split the lift calculation into lift due to speed and lift due to aoa.

To calculate lift due to speed, I take the current speed over a minimum speed (stall speed) and clamp it to a max value (constant). This will hopefully allow me to simulate takeoffs/landings in the future. The value needs to be clamped otherwise too much lift gets generated at high speeds.

Almost the same for the lift due to aoa, I take the current aoa over a maximum lift aoa (less lift is generated if the aoa gets too high) and clamp the value to a min and max (more constants).

Those two factors are then combined, clampled to a min and max (even more constants) and then multiplied by the aircrafts mass and gravity.

Quote:
Original post by jcarrion
HI . I think your problem lies in that you are missing the air-resistance alltogether.

...
Why is the air resistance a 3 component vector, shouldn't it just be a scalar constant?

What's the best way of implementing this? Taking the difference between the direction of the aircrafts nose and direction of velocity and adding an air resistance drag force to the total acceleration?

Thanks

Share this post


Link to post
Share on other sites
>>Why is the air resistance a 3 component vector, shouldn't it just be a scalar >>constant?

because the aircraft is not spherical. It is much more aerodynamic in his longitudinal (z) axis than any other axis . Correct values are -around-

x = 9
y= (100 .. 900 )
z = 2

multiply with the constant of choice to get meaningfull values.

Indeed , you soon realize that the aerodynamics of an aircraft are best defined by a 3x3 matrix . but that's probbably too much for the time being .


cheers
j



Share this post


Link to post
Share on other sites
For the lifting surfaces
------------------------
Lift: L = (CL)(1/2)(rho)(V^2)(S) or L = (CL)(q)(S)
Drag: D = (CD)(1/2)(rho)(V^2)(S) or D = (CD)(q)(S)

Where:
CL = coefficient of lift (varies with angle of attack)
CD = coefficient of drag (varies with angle of attack)
rho = density of fluid (air)
V = velocity of free-stream air
S = wing planform area
q = expressed as "dynamic pressure", is equal to (1/2)(rho)(V^2)

If air density and planform area are assumed constant, lift and drag of an airfoil varies with the angle of attack and by the square of the TRUE airspeed (not indicated airspeed).

By the way, in this case CD should be used to express total drag (that is induced + parasite drag).

Lift acts perpendicular to the relative wind (velocity vector) and drag acts parallel and opposite to velocity. Lift and drag are components of a single resultant force.

This should give you enough information to get your google on, or maybe to start a chain reaction of wikipedia searches. If you implement your flight model based on even a simple shred of authenticity, you will get much better results than trying to fudge it like you are and others here have suggested you do.

Also... you should not be using an Euler integrator. Use "Improved Euler" or RK4 for better stability.

Share this post


Link to post
Share on other sites
I'd imagine because you need to represent a complete 3 dimensional friction model. Wind resistance is approximated from the cross section of the aircraft in the direction of the wind. You could use a matrix to transform the wind vector into a resistance vector, based on the world space version of your 3x3 resistance transformation.

Share this post


Link to post
Share on other sites
Quote:
Original post by bzroom
I'd imagine because you need to represent a complete 3 dimensional friction model. Wind resistance is approximated from the cross section of the aircraft in the direction of the wind. You could use a matrix to transform the wind vector into a resistance vector, based on the world space version of your 3x3 resistance transformation.


Oh sorry for the confusion, I wasn't disputing the fact that the matrix would work as a hack, only because the OP says "the flight model I am trying to implement is not a full blown simulator. Much simpler inputs to the physics simulation" (it would not work for a realistic flight simulator)... I was disputing the statement "aerodynamics of an aircraft are best defined by a 3x3 matrix" which is absolute nonsense.

One could always do some reading

Share this post


Link to post
Share on other sites


the relative airspeed to an airplane goes also in 3d ,-genius-. is not an scalar/angle or "up/down" as the simpler equations tend to suggest.


the airfoil/wing model should cope with relative airspeed in 3D , i.e (not perpendicular to the wing ). Airplanes skid sideways , slip , etc.. most of the time. The relative airspeed can be in any axis .

how do your simple equations cope with non-perpendicular to the wing length airspeed ?


Therefore to define the lift/drag behaviour of a airfoil/wing when the relative air direction can come in ANY DIRECTION you need something much more complicated that the 2 equations you just wrote (and assume everyone knew).

For a wing whose area is defined by lenght , mayor chord , and minor chord (a ticpical trapezoidal wing ) you need serious math to compute the lift/drag if the Airspeed is not perpendicular to the length.

how would you do with your "angle of attack" ? ;)

Fortunately there are good approximations , all of them involving a 3x3 Matrix


-having said that , I agree that for a "simplistic flight model" , as for the original thread , your approach will do.

Cheers
J

Share this post


Link to post
Share on other sites
oi oi .. I just realized that I forgot to explain why a Matrix is better than a Vector .

For a non lift-generating body (i.e. a bycicle) the aerodynamics can be defined with a Vector (expressing the equivalent drag-areas/coefficient) in any of the axis.

however, my friend , when we are interested also in the lift (as in a wing ) we need to express :

->the drag of that wing in any of the axis (as the with the previous bicycle example )

->the LIFT of that wing , for EACH axis , and this for EACH direction of relative airspeed .

i.e. (the lift of the wing on the Z axis when airspeed come in the Z Axis -this is your Lift Coeficient)

but also ... the lift on the wing in the X axis when airspeed come in the Y Axis ... and so-on

An airpliane moving sideways (x axis ) Also generates some sort of lift (and definitely lots of drag and rot-moment ). How your 1-dimension approach cope with this ?


but real planes (in 3 dimensions) move relative to the air in -also- 3 and hence have ccoefficients in 3 d.

Drag.x Momment.x Lift.x
Drag.y Momment.y Lift.y
Drag.z Momment.z Lift.z

whereas Drag.z is your "Drag Coefficient when air comes in z. direciton )
but Drag.x is the drag coefficient when air comes in the x direction (left-to right )



I am sure you start to see the need for the Matrix. Whereas you put those 9 coefficient values in a Matrix or in a sandwitch is up to the implementer. A matrix is handy as you multiply the relative airspeed ( as a VECTOR , not as a scalar ! ) to the matrix , etc..etc.. and you probabbly figure out the rest.




Cheeers
Javier

[Edited by - jcarrion on January 29, 2009 4:04:12 PM]

Share this post


Link to post
Share on other sites
well, J... it is obvious from your last post that you have a lot of homework to do and probably should not be arguing this point as if you know what you're talking about, no offense. I hate to be argumentative, but I don't like it when bad information is spread. So, I'll humor you.

The L, D and V in "my" equations (you said MY equations? do you actually think I came up with those?) are vector quantities, not scalar. The "sideslip" angle you are referring to is typically called beta, and a more complicated model would use that component. Yes, a 3d flight model uses those equations, don't believe me??
What exactly do you think you're simulating here, a Harrier? a helicopter? maybe the JSF? When exactly was the last time you saw a conventional airplane flying backwards or sideways?

Perhaps you want to discuss the finer details with me (a commercial pilot with single and multiengine land instrument ratings, certified flight instructor, CFI instrument and multi-engine instructor with 1000+ hours and 5 years experience teaching aerodynamics to students, not to mention a BS in Aeronautical Science including several engineering courses) through another means, so as not to spam these boards with arguments.

BTW I was offering my help to OP because I have already created both a 2d and 3d flight simulator, and the only 3x3 matrix used in the flight model is the inertia tensor. Everything else is vector and quaternion based. If I didn't know what I was talking about, I would not have posted.

Share this post


Link to post
Share on other sites
hi there


>>The L, D and V in "my" equations (you said MY equations? do you actually think >>I came up with those?) are vector quantities, not scalar. The "sideslip" angle >>you are referring to is typically called beta, and a more complicated model >>would use that component. Yes, a 3d flight model uses those equations, don't >>believe me??
>>What exactly do you think you're simulating here, a Harrier? a helicopter? >>maybe the JSF? When exactly was the last time you saw a conventional airplane >>flying backwards or sideways?

I ll try again...

your L , D , and V are computed for airspeed normal to X=0. I assume you understand what a plane , a normal to a plane is .

you have not mentioned yet what happens with the airspeed in the plane z =0. If you are a pilot you should know better than anyone that airplanes skid , slip . either by leaning, or using the rudder , asymetric thrust , etc.. -I do believe you are a pilot so I assume you know what I mean- Airplanes experience lateral airspeed . Not much , but certainly not negligible . and has tremendous consecuences in drag , and rotation torque.

yet "your simplified model" doesnt take this into acconut at all.

My point is that you should have another set of equations (with its lift , drag and Torque ) for the airspeed moving in X=0. Airplanes have drag , and lift , and torque also when applied lateral airspeed .

That this airspeed = 0? fantastic ! we are fliying straight or turning coordinately ., call it a day . But It may not be . If you are doing a flight simulator you SHOULD cope with the aircraft moving backwards , forward , or whichever position/ attitude/relative airspeed ( aerobatics ?.)

I don't say that 1 plane model is wrong . For most simple flight simulators is ok .It is just too simplistic.

(I am diying you see your 2D (???????) flight simulator! )

On a absolutely unrelated front :

do you have any idea where can I find data for turboshafts ? Mainly Rotational mass , diameter , total mass , specific fuel consumtion etc ? I am really lost , and can't find anything .We are indeed reverse-engineering values from Microsoft FS ! which is dodgy as hell . Any idea where can we find manufacturer's data ?

oi oi
Jc

Share this post


Link to post
Share on other sites
I really don't want us to hijack this thread, but I guess we're the only ones keeping it alive now so it's ok.

Quote:
yet "your simplified model" doesnt take this into acconut at all.


but I did not present the entire model... only a small piece of the puzzle. I never stated that the lift and drag equations represent the entire flight model.

Secondly, it is not my model. My name is not Bernoulli and it is certainly not Newton.

Quote:
If you are doing a flight simulator you SHOULD cope with the aircraft moving backwards , forward , or whichever position/ attitude/relative airspeed ( aerobatics ?.)


You are absolutely right. For directions of travel outside of the normal flight envelope, with high alpha beyond your CL and CD curve/table range you can extrapolate for a while, beyond that use a simple linear model for CL and CD. Weathervaning tendency will give negative static stability to a conventional airplane in sideways or backward flight anyway, and that direction of travel cannot be maintained for long - that is, moments generated by the flight surfaces will tend to realign the longitudinal axis with the direction of travel, and back within the normal flight envelope.

You are taking a series of operations to determine the drag forces acting upon an aircraft and over-simplifying it based on the premise that a vector-matrix multiplication yields another vector.

Quote:
Not much , but certainly not negligible . and has tremendous consecuences in drag , and rotation torque.

Right, and the model does not negate it, it is all incorporated.

Quote:
I don't say that 1 plane model is wrong . For most simple flight simulators is ok .It is just too simplistic.

Why do I have to explain this again? Those are vector quantities. That means 3 dimensions dude! The equations give you the magnitude of the vector. I've already stated the direction in a previous post. It's not more simplistic.

Quote:
(I am diying you see your 2D (???????) flight simulator! )

It is actually called a vertical plane simulator because it simulates exactly that, the vertical plane. It is based on a VPS used in a Flight Technique Analysis class that I took. I will get it posted and provide a link so you may download it. It's been about 9 years since I looked at it, and is in no way a finished product, my crude proof-of-concept before delving into the full 3d model, just integrates linear motion and not rotational motion. It is meant to be an analysis tool more than a typical flight sim, so control inputs involve setting the pitch and thrust explicitly, and seeing how that impacts your angle of attack, airspeed, etc. and watching the forces on the airplane eventually settle back into equilibrium.

Quote:
do you have any idea where can I find data for turboshafts ? Mainly Rotational mass , diameter , total mass , specific fuel consumtion etc ? I am really lost , and can't find anything .We are indeed reverse-engineering values from Microsoft FS ! which is dodgy as hell . Any idea where can we find manufacturer's data ?

Turboshafts? for rotercraft? I'm a fixed-wing guy myself and don't know where free data may be found on the internet. I image you should get it from the manufacturer. You could also pull some useful data out of flight or maintenance manuals from specific models. I wouldn't necessarily say pulling values from MSFS is dodgy, they probably got their data from the manufacturer.

[Edited by - y2kiah on January 30, 2009 7:36:30 AM]

Share this post


Link to post
Share on other sites
Quote:
Original post by y2kiah
For the lifting surfaces
------------------------
Lift: L = (CL)(1/2)(rho)(V^2)(S) or L = (CL)(q)(S)
Drag: D = (CD)(1/2)(rho)(V^2)(S) or D = (CD)(q)(S)

Where:
CL = coefficient of lift (varies with angle of attack)
CD = coefficient of drag (varies with angle of attack)
rho = density of fluid (air)
V = velocity of free-stream air
S = wing planform area
q = expressed as "dynamic pressure", is equal to (1/2)(rho)(V^2)

Thanks, I'll give that a try.

Do you know of any good resources where I could find the coefficients for lift and drag for current aircraft (I'm trying to simulate a few military fighters)? Or is there a good way to generate them?

Share this post


Link to post
Share on other sites
you can go here to find out which wing type your airplane of interest uses

then start searching for good locations of coefficient data. I found a good source here for the NACA families of airfoils, and many other sources more detailed but not quite as convenient

Share this post


Link to post
Share on other sites
Quote:
Original post by y2kiah
you can go here to find out which wing type your airplane of interest uses

then start searching for good locations of coefficient data. I found a good source here for the NACA families of airfoils, and many other sources more detailed but not quite as convenient
Thanks for the links.

How would I convert the values on the NACA profiles to lift and drag coefficients? For example I am looking at the F-15 (which has a 'NACA 64A006.6' wing), so this would be the matching profile, not sure how to get the coefficients from the data (google hasn't turned up any good results yet).

Share this post


Link to post
Share on other sites
Sorry for the bad link, I guess it only has profile data available. You could check out NACA report 824 here to pull out any useful information. The lift, drag and moment coefficients you are looking for are on page 177 of the report.

Share this post


Link to post
Share on other sites
Quote:
Original post by y2kiah
Sorry for the bad link, I guess it only has profile data available. You could check out NACA report 824 here to pull out any useful information. The lift, drag and moment coefficients you are looking for are on page 177 of the report.
Thanks for the link but I am not a hundred percent sure how to read those graphs...

Looking at page 177 of the document (178 of the pdf).

From what I've found 'R' is reynolds number which is essentially a modifier for the coefficients for a certain altitude range? From those graphs which one of the R lines listed should I be using? I've been looking at the ones with R at 6.0 (left facing triangle data points).

On the top graph is the drag coefficient expressed in terms of the lift coefficient? For example at 0 aoa the lift coefficient is 1.2, the drag coefficient doesn't doesn't have a data point for that (max at 0.4), will I need to extrapolate?

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement