r/AerospaceEngineering • • Feb 15 '23

Uni / College Python code

Post image

So my assignment problem is coding a program to find the mach number and total enthalpy using python/matlab. I prefer python coz of the vast possiblities in AI and Automation. Can someone please help me with this🫡

0 Upvotes

22 comments sorted by

12

u/[deleted] Feb 15 '23

Assuming you know the brayton cycle it should be pretty straightforward to put it in code, i recommend using coolprop for thermo calcs.

-23

u/[deleted] Feb 15 '23

I have next to 0 knowledge in coding

42

u/[deleted] Feb 15 '23

and you will remain that way if somebody posts an entire code for you on reddit. If that's what you're after try chatGPT :) If you ask some more specific questions people may be able to help, what is the problem you're having? Have you tried learning basic syntax and writing some straightforward calculation scripts yet?

-16

u/[deleted] Feb 15 '23

I have a minimal bg in coding i had bio as my major in 12th grade💀. But yeah i do wanna learn pythons i just wanted to know the process,heard aerospace has serperate libraries in python and matlab from cs friends

9

u/[deleted] Feb 15 '23

As a short aside, you should take everything your CS friends say about coding with a massive grain of salt, you and they exist in different universes, they know essentially nothing about the types of codes you will be writing as an engineer. As an engineer, the code you will be writing will by syntactically incredibly simple, and conceptually very complex. 90% of your codes will be completely done on paper before you write a single line, and then it becomes a formality. It is unlikely you will need to optimize the shit out of your codes, work with insanely large datasets, or write frameworks, interfaces, or applications. Likewise, most of them will not need to (or be able to) solve differential equations, thermo problems, discretized PDEs (the backbone of CFD), etc. Source: I lived with a 4.0 CS major for 4 years, at no point did he understand wtf was going on in my codes, and at no point did I understand wtf was going on in his.

-11

u/[deleted] Feb 15 '23

😭😭😭😭😭😭 i love how aerospace breaks my soul and my aim to break down boeing

5

u/[deleted] Feb 15 '23

Here's where you should start, do you understand the Brayton cycle? can you solve this problem on paper without python? If you do not know how to solve the problem on paper, you will not be able to write a code to solve it, you have to tell the computer exactly what to do at every single step. If the answer to both of those questions is yes, you should move on to learning basic python. Start with basic syntax, how to make functions and solve equations. Then move on to libraries, if you are just starting your engineering schooling you should primarily get to know numpy and matplotlib.pyplot as those are going to be your best friends. There is an insane amount of resources online for learning the fundamentals of python. For AERO you will likely benefit greatly from a thermo library like coolprop. You may need pandas or scipy eventually but outside of this you should be good for most all AERO applications.

As an exercise you should work through the entire problem and break it down into the most basic steps you can imagine, and try to only use variables and minimize real numbers (generally called hard-coding). Then when you code that, you will be able to solve any Brayton cycle instead of just this problem.

1

u/[deleted] Feb 15 '23

Thankkkk youuuuuu!!!!!!!!!!

19

u/8for8m8 Feb 15 '23

You don’t need libraries to do this…you need like 100 lines of matlab at most.

I’d strongly suggest you enroll in some basic coding class. Can’t get through an aero degree without this knowledge. My school had a 1 credit matlab for engineers class. Or you could do comp sci 101 for a bit more. If you need to teach yourself, time to visit youtube. codingbat is a good practice website.

Edit: It’s also comical to me that you are talking about AI and automation when you are struggling with this.

5

u/NukeRocketScientist Feb 15 '23

This is super easy, you don't even need MATLAB or Python. You can either solve for M1 using a numerical solver or just guess and check with a few iterations.

-4

u/[deleted] Feb 15 '23

According to the professor i have to write a code.😭🫡

5

u/NukeRocketScientist Feb 15 '23

Okayyyyy, so just set up the equation to solve for M1 in MATLAB or Python. If you don't have the programming knowledge to at the minimum set up a single equation variable solver you're going to have a very hard time. This should honestly take you less than 10 minutes in MATLAB.

36

u/Bobyyyyyyyghyh Feb 15 '23

How do you prefer python if you don't know python? If you know MATLAB you're more than knowledgeable enough to do this. MATLAB was born for problem solving like this, use the symbolic toolbox if you need

5

u/Jaky_ Feb 15 '23

If you know matlab, python Is not that difficult

2

u/[deleted] Feb 15 '23

I learned, Python -> MATLAB -> C.

8

u/Jaky_ Feb 15 '23

I learned C -> Matlab -> python

5

u/imagatorsfan Feb 16 '23

I learned Matlab -> … ahh I’ll learn python later!

1

u/wiggle-le-air Feb 16 '23

Matlab is the GOAT

1

u/13D00 Feb 16 '23

I know matlab quite well, nothing too crazy but am comfortable doing maths and simple data analysis. My company just doesn’t feel like getting me a license and forces me into python.

I’ve never used python though, so I guess I’ll have to learn it in some way or another. :)

1

u/imagatorsfan Feb 16 '23

That seems to be the consensus once you get out of academia. I definitely want to learn python for that reason and the fact that I’ve heard nothing but good things about it.

I enjoyed learning coding through Matlab, but I definitely have encountered many headaches when doing more advanced stuff that I just feel like shouldn’t be an issue. Trying to make an app was a nightmare…

1

u/1percentof2 Feb 19 '23

Ask chatGPT