Code for aircraft performance, stability and design modifications

182 views
Skip to first unread message

Rahmathulla P

unread,
Jun 15, 2023, 2:31:07 AM6/15/23
to MachUp Forum
Hi Cory,

MachupX is a great lifting line algorithm implemented in python which gives me script-ability to extend its capability further to whatever I want.

I'm interested to carry out performance and stability analysis of my UAV for design modifications to meet the requirements in loop with MachupX. One option is to write my own python code for these analyses. I'm wondering if there are any existing tools for performance and stability analysis that I can simply uses and connect to MachupX for iterative design.

Please let me know if you know any other open source code written in python that work well with MachupX.

Regards,
Rahmat

Cory Goates

unread,
Jun 16, 2023, 12:16:32 PM6/16/23
to MachUp Forum
Hi Rahmat

What kinds of performance and stability analysis are you looking for? MachUpX has the ability to calculate all aerodynamic derivatives built-in (stability, damping, control). With these, you can directly determine static stability.

The only open-source code I know of that pairs with MachUpX is our flight simulation package, Pylot (https://github.com/usuaero/Pylot). MachUpX can be used as the aerodynamics engine for Pylot, which allows for testing performance.

Thanks

Cory

Rahmathulla P

unread,
Jun 17, 2023, 3:43:16 PM6/17/23
to MachUp Forum
Hi Cory,

Pylot looks very interesting and I will explore it more. Thanks for sharing this.

I can see now that with all aerodynamics derivatives, stability calculations can be carried out. stability_derivatives() output static margin directly. I'll also explore dynamic stability later.

Regarding performance analysis, following are the kind of questions I am looking at
  • For a given aircraft and a given mission profile (take-off, climb, cruise etc), how can I calculate thrust required and power required to select an engine?
  • For a given range and endurance, what is the optimum mission profile and what is the battery capacity required?
  • For a given aircraft, engine and battery, what can be achieved in terms of flight performance (eg rate of climb), range and endurance?
  • Can I get flight envelope (v-n diagram) for the structural analysis down the line?

It may be that the above questions are very user specific and can be coded outside linking with MachupX. Your comments will be much appreciated.

Regards,
Rahmat

Cory Goates

unread,
Jun 20, 2023, 11:51:00 AM6/20/23
to MachUp Forum
Hi Rahmat

Happy to help. 

To calculate thrust and power required, those are a simple function of your drag , airspeed, and climb angle. Chapter 3 in "Mechanics of Flight" by W F Phillips goes over these.

As far as an optimum mission profile goes, I don't know of any existing codes. I tackled something similar, and you can check out my code (https://github.com/corygoates/TrajectoryOptimization).

For calculating range and endurance, you may be able to use our tool PyProp. The optimization side of it is pretty limited, but the analysis side is there.

To create a v-n diagram, I'd again recommend looking at "Mechanics of Flight" by W F Phillips.

Hope that helps!

Thanks

Cory

Rahmathulla P

unread,
Jun 24, 2023, 7:13:12 AM6/24/23
to MachUp Forum
Awesome. I've downloaded PyProp and I will go through them in detail. I can easily find a workflow connecting MachupX with PyProp to meet my objectives.

From MachupX, I can get aircraft characteristics using which I can calculate thrust required and power required based on "Mechanics of Flight"
Using PyProp, I can iterate to find an appropriate prop, motor, ESC and battery and calculate range and endurance
I can iterate through the above two steps to finalize the aircraft and an engine unit to meet my requirements
I am also excited to explore the database you created for prop, motor, esc and battery.

Excellent! thank you very much for sharing this. Should I use this forum if I have any questions on PyProp?

Regards,
Rahmat

Cory Goates

unread,
Jun 26, 2023, 1:40:03 PM6/26/23
to MachUp Forum
Great! Yep, this forum is probably the best place for questions on PyProp.

Rahmathulla P

unread,
Oct 10, 2023, 4:17:40 AM10/10/23
to MachUp Forum
Hi Cory,

As you recommended previously, I'm referring to Chapter 3 in "Mechanics of Flight" by W F Phillips to calculate the thrust and power required.

To calculate the thrust required for a level flight at a particular angle of attack, I'd need L/D ratio of the aircraft (refer equation 3.2.4). If so, what would be the easiest way to get L/D? Should I use the method, "solve_forces" to get "Fx" and "Fz", transform them to get L and D and then calculate L/D ratio?

I'd like to plot L/D vs Airspeed as shown below.
Lift to Drag Ratio - an overview | ScienceDirect Topics
Is the following could be the steps to achieve the above?
  1. Set the aircraft velocity using "set_aircraft_state"
  2. Get "pitch_trim" to get the required angle of attack to fly at the above velocity
  3. Extract "Fx" and "Fz" from "solve_forces"
  4. Derive L and D from "Fx" and "Fz" and calculate L/D ratio.
  5. Repeat steps 1 to 4 for different aircraft velocities.
Please let me know your comments.

Cory Goates

unread,
Oct 16, 2023, 3:41:11 PM10/16/23
to MachUp Forum
Hi Rahmat

Sorry for the delayed response. That's definitely a good way to do it. A more direct way would be to use "FL" and "FD" from "solve_forces", but you should get the same results from both.

Cory

Rahmathulla P

unread,
Oct 16, 2023, 5:24:26 PM10/16/23
to MachUp Forum
Hi Cory,

No problem. Thanks. Yes, using "FL" and "FD" from "solve_forces" is easier.

I'm exploring ways to get some performance parameters of the aircraft. I'd like to calculate the minimum airspeed (stall onset) but I'm not finding an easy way. It is a function of aircraft mass, wing area and max lift coefficient. Is there a way to get these parameters once the scene class is defined?

I also would like to know if there is a way to get the current aircraft state. I can see "set_aircraft_state" method but not finding a "get_aircraft_state" method? After some methods like "pitch_trim", I'd like to check the state like velocity and alpha. Is there a means to get it?

Regards,
Rahmat

Cory Goates

unread,
Oct 17, 2023, 3:02:27 PM10/17/23
to MachUp Forum
Hi Rahmat

The aircraft mass will be whatever you input. The wing area is calculated based on the main wing geometry and can be gotten from "get_aircraft_reference_geometry". Max CL you can find by just sweeping angle of attack and finding where the lift coefficient peaks.

When you call "pitch_trim", it will return a dictionary that gives you the angle of attack and the pitch control surface deflection. "pitch_trim" won't change any other variables in the aircraft state, so you can just use what you put in.

Thanks

Cory

Rahmathulla P

unread,
Oct 18, 2023, 5:22:09 PM10/18/23
to MachUp Forum
Hi Cory,

Very useful to proceed but have a couple of related questions.

On the question of finding Max CL, you said " Max CL you can find by just sweeping angle of attack and finding where the lift coefficient peaks". How can I find CL by giving angle of attack? In other words, what is the method which has input parameter, alpha and returns CL?

On "pitch_trim", documentation says it "Returns the required angle of attack and pitch control deflection for trim at the current state". It also states "This alters the body-fixed aircraft velocity in order to achieve trim". In my understanding, state is defined by velocity, alpha and beta. If velocity and alpha are defined by the state, "pitch_trim" should alter only one of them, keeping the other fixed at the current state. If it changes alpha to achieve the trim, then velocity should be kept at the same state velocity, right? Then why it says "This alters the body-fixed aircraft velocity in order to achieve trim"? Also, see the documentation on the parameter "set_trim_state".
set_trim_state (bool) – If set to True, once trim is determined, the state of the aircraft will be set to this trim state. Note this will only affect the velocity of the aircraft; its orientation will remain unchanged.
Why it says "this will only affect the velocity of the aircraft"? I'm bit confused what is fixed and what is to be changed.

I would like to find the velocity for a fixed angle of attack. Is there a way to get it?

Could you please clarify the above?

Regards,
Rahmat

Cory Goates

unread,
Oct 20, 2023, 2:12:45 PM10/20/23
to MachUp Forum
Hi Rahmat

If you just specify the angle of attack and velocity and call "solve_forces", then that will give you CL. Or are you wanting the maximum trimmed CL? That will be a little trickier. You'll have to slowly increase the desired CL in "pitch_trim" until the pitch trim solver can't converge anymore. I'm not sure of any other way you'd tackle that.

To achieve trim, MachUpX will alter the direction of the velocity but not its magnitude. So what it's really doing is just changing the angle of attack. It's phrased that way in the documentation because MachUpX stores velocity direction and aircraft orientation. The latter is not often used, but really one could change the aircraft orientation to change the angle of attack. However, that has significantly more computational overhead than just changing the angle of attack via the velocity vector, so that's what MachUpX does within "pitch_trim" for the sake of speed.

What do you mean by velocity for a fixed angle of attack?

Thanks

Cory

Reply all
Reply to author
Forward
0 new messages