Trying to get cross sectional area of flow

Hello, I am making a plane system, how can I get the cross sectional area of flow?
https://web.mit.edu/16.00/www/aec/flight.html
I need this to follow the formula
image

The formula you just listed is mass flowrate in kg/s which is found by multiplying density in kg/m^3 by volume flow rate Q in m^3/s of the fluid.

Mass flowrate is conserved accross a streamline according to bernoulli’s equation.

For a pipe you can easily find the volumetric flowrate as we can measure the area of the fluid which is constricted in the pipe with it’s velocity.

For a plane… Yeah let’s not even get started with the assumptions being made here, using the bernoulli’s equation will not get you why the plane lifts by itself.

A good explanation is in the scientific american article, there are way too many factors on why planes stay in the air.

TL;DR simulating aerodynamics is not worth the effort unless you want a real simulator in which you need more than just that formula.

Also don’t trust youtube videos. They can get it wrong and use equal transit time theory.

Idk what you want though realism or playability. I suggest looking at other flight games and how the behavior movement of the plane changes with angle of attack and such instead of dynamically trying to calculate lift.

3 Likes

So, I shouldn’t use bernoulli’s equation to make a plane on Roblox?

I mean, I want something like flighline, only the physics “aerodinamic”
Nothing else, since I am creating a game that contains plane, not as principal haha.

2 Likes

Anywhere else really by itself, the article should explain why.

@BanTech any opinions as an aerospace engineering student?

1 Like

I have tried tho, before, by using as “Angle Of Attack”
Orientation.X
and doing some stuff, but it never ended well.
Never could be smart enough to make a proper plane system

this was my attempt lol.

local AOT =  -MainP.Orientation.X

local x = (Weight) * Speed.Velocity.Magnitude/(135 + AOT*3)
x=math.clamp(x,0,Weight + 10000)
		MainP.Rotate.CFrame = CFrame.new(MainP.Position,Mouse.Hit.p)
	MainP.Lift.Force = Vector3.new(0,x,0)
	local y=MainP.CFrame.LookVector * Csp 
	Speed.Velocity =Vector3.new(y.X,0,y.Z)

Csp is speed basically

1 Like

If you want the physics you can look at this really cool paper titled

Flight Models in Flight Games
How Ace Combat 4 and Sky Odyssey juggle playability
and realism

It explains a really simple model where a plane moves where it points

From this simple description, a simplistic flight model could be made, and it would be
similar to the flight models of most early simulators. Pressing “Right” or “Left” would
cause the airplane to roll at a certain rate. Pushing “Up” or “Down” would cause the
plane to pitch down or up, at a certain rate. Two keys would be assigned to the rudder
pedals, and would turn the airplane sideways like a car, at a certain rate. The throttle
control would adjust the thrust, making the plane go faster or slower – different throttle
settings correspond to different terminal speeds. The airplane always goes in the direction
its nose points.

However yeah the trick is when you want it to be realistic :flushed:

Edit: way too long tldr consider the scenario for when this takes place:

Such a control system would not take long to learn, and would not be a challenge in
itself. However, it would not be realistic.
This is because an airplane does not always fly in the direction it points.

Yeah I recommend reading the full paper. The first step is to make it unrealistic but working. Then you add the if statements for the

STALL WARNING

Scenario

1 Like

Absolutely. There are some very complex codes out there to determine lift/drag and even the 2D ones are pretty complex.

I’d like to preface the below by saying this stuff can become very complicated, however there are simplifications that can be made. I will go into how detailed I personally would do it if I were making a realistic plane system, but even then I am making simplifications here.

Nobody but yourself can decide how realistic or not you want to be - the most simple is to assume constant rates of change, a constant air density, and therefore hard code in a single curve of lift and a single curve of drag.


Okay, so firstly you’ll need some aerodynamics knowledge, which can be challenging. I’ll try to explain as best I can.

Aerofoil definition

Forces-acting-on-a-typical-aerofoil-section-of-axial-flow-fan-blade

Think of an aerofoil as a cross section of a piece of wing. It has an angle of attack relative to the air it’s travelling through, and generates lift and drag.

We’ll use these three physical definitions for the aerodynamics.

Lift

Lift is dependent on the angle of attack of your wing. A higher angle of attack (nose pointing closer to the sky) the greater the lift:

Notice the label lift coefficient, C_L, instead of a force. That’s because the curve is not dependent on the side of the aerofoil or the length of the wing - only the shape. When converting to lift, you then factor in the speed, surface area and air density.

Tools such as xfoil can do this for unit length 2D aerofoils, but I don’t recommend attempting to implement that in Roblox and certainly not generating the values at runtime. The closest thing to realism you’ll get is to generate angle-of-attack C_L curves for your wing at a set of Reynolds numbers giving you a matrix of Reynolds in one dimension, angle-of-attack in the other dimension and C_L as the output. At values between the curves you can interpolate by whichever method you wish to.

Reynolds number is a way of dimensionalising the non-dimensional C_L and C_D values for a given flow condition based on air density (decreases with altitude) and velocity relative to the air (airspeed). Here’s a great area for simplification, however if you include it with an air density calculation based on height above the baseplate, it will naturally provide a ceiling for your aircraft. Otherwise you’ll have to limit altitude some other way.

Drag

For drag, most models out there predict it poorly until you get into really high level turbulence models. If you did the same as we did for lift, for the best drag model you can get hold of, adding some estimate for the body too, then you’ll now have two matrices for the aero force coefficients.

To use C_D to create a drag force, the drag equation is very similar to the lift equation, just swap any L for D.

There are some really complicated aerodynamics that go into drag that won’t be in 2D analysis, such as tip vortices at the ends of the wing (this is why some planes have winglets). It’s not worth trying to simulate these, but it may be a case of increasing your C_D slightly by an appropriate factor. You’d need to research that.

Thrust

Don’t get me started on jet engines, it’s not worth it as those are an entire different kettle of fish. I’d just get some thrust curves from the internet for the closest engine possible to the one you’re interested in.

I think personally I’d make most of my simplifications here. You’ll still want to make it diminish with altitude, but it’s complex and nonlinear.


Next would be to actually implement these concepts. You’d use the speed and air density with the knowledge of your wingspan to calculate Reynolds number at a given condition, and use that with the current angle of attack to calculate specific drag and lift forces at a given condition in real-time from your curve matrices. If applying the forces globally you’ll just need to resolve the lift, drag, weight and thrust forces in x, y and z.

Stall warning

Stall occurs when your aerofoil can no longer generate lift due to flow separation. It’s the reason the C_L curves earlier drop off and stop altogether.

Many planes have rudimentary stall warnings, and you can research what goes into those. If you’d like to create an accurate warning based on the system you create, then a stall is easy to predict when you are close to reaching the end of your lift coefficient curve at the current Reynolds number. If the curve gradient is decreasing, it would suggest you’re past the maximum lift angle and about to stall. Where the graph stops entirely is a deep stall.

Flaps and control surfaces

If your plane system intends to use flaps, and you want to be really realistic, you’ll then need to generate matrices for lift and drag for each flap condition too, and pull from the correct set based on the current flap angle. Definitely limit the possible settings.

For control surfaces (ailerons, rudders, elevators) you can follow a similar approach, as these are essentially flaps on horizontal or vertical aerofoils, except now we’re talking about stability and you need to factor in the effect of horizontal and vertical stabilisers, and how their angle of attack relative to the airflow will provide restorative moments and additional drag. They are usually symmetrical aerofoils but you’ll still need all the matrices and following all of the above, except now your lift and drag are acting at an arm to the centre of mass and predominantly create significant moments and negligible vector forces.

You could create entire sets of matrices for the control surfaces and various deflections and interpolate between them.


This approach of turning everything into curves at given conditions and interpolating between the conditions is exactly the type of thing you’ll find in flight simulators, engine models at manufacturers and companies like Airbus and Boeing, and generally is a good way of having really complicated behaviour readily available in real time.

How realistic your system is will be fully determined by how many things you choose to properly model and get data for, vs. how many things you make assumptions and simplifications for. The NASA website on aerodynamics can be a deep rabbit hole if you do want to learn more, and with some googling you can find some tools and possibly some already-generated data for common aerofoil shapes.


I think it would be a challenge for anyone to properly implement such a system, but not impossible. As mentioned by @dthecoolest, it’s a question of realism vs playability. The more realistic you make it, the harder it is for a beginner to fly. Pilot school exists for a reason, and it takes time to appreciate how planes move and very rarely fly exactly in the direction they are pointing.

As mentioned at the start, this isn’t an exhaustive list of all things affecting aircraft motion. This is just a summary of how I would go about making a plane system with my simplifications and assumptions in there.

9 Likes

Hmm, for this piece of code, My only advice, for now, is to not use Orientation because this property of a base part is relative to the world XYZ axis with some Euler Angle Trait-Bryan thing that makes my brain explode :exploding_head:

And moreover, the angle of attack is not exactly relative to the world XYZ axis. It’s the angle of the wing relative to the direction of flight or what this diagram explains…

AngleOfAttack

dang thats a lot of angles…moreover this diagram doesn’t consider what the angle would be if the plane was rolling as well in the z-axis as the diagram is only 2 dimensional…

But I believe you should be able to find it as well there are two vectors to calculate an angle, one based on the velocity of the flight assuming it is = opposite to the velocity of airflow and another vector which is relative to the wing aerofoil which you can arbitrarily set relative to the plane, that should be possible to work with.

So yeah make sure you know what angle you are dealing with or else you might just start working with magic code which is definitely not a fun experience.

Personal case example:

In my case, it’s when I start combining all the CFrame operators in all the permutations and combinations and wondering why I’m not achieving the rotation and position I want for my inverse kinematics project when my angle I use to apply the rotation is wrong in the first place :sweat_smile:.

8 Likes