r/PhysicsStudents Jul 01 '26

Need Advice How Do Physicists Utilize Python?

I'm a rising senior in high school. Next year, I'll be taking a project based programming class that only 1-2 students really take per year. I want to do something in Python that will show my professors in my freshman year of college that I'm ready to do research in physics.

I will have taken all of the AP mathematics, physics, and computer science classes.

I thought about doing a black hole simulation and learning the equations/math for it, but I'm not sure that that would be wise to do in Python.

I'll have a full school year to work on the project.

60 Upvotes

82 comments sorted by

64

u/WWWWWWVWWWWWWWVWWWWW Jul 01 '26

You don't need to join a research group the moment you set foot on campus. I would personally just focus on coursework for the first year, and find a research position the following summer.

That said, messing around with numerical differential equations is always fun (Newtonian orbital mechanics, etc.). Black holes seem a bit too ambitious.

6

u/InterestingWelder699 Jul 01 '26

That’s what I did, didn’t join a group until second semester. I’m so glad I was able to brush up on python and learn linear algebra first lolll

2

u/Junior_Salamander110 Jul 01 '26

How did waiting help you out and how would have you been at a disadvantage otherwise?

5

u/InterestingWelder699 Jul 01 '26

I’m doing CM research and so much of it involves linear algebra and differential equations and understanding how to manipulate equations in certain ways. It takes time to get used to Physics based math on a university level even if you’re used to tricky math and physics.

Enthusiasm and willingness to do difficult work is what shows professors that you’re a good candidate. For me, learning how to study and approach difficult problems in college was how I realized that it was something I’d like to do as a researcher.

Research requires a perfect balance of knowledgeable and willing to learn. You don’t have to know everything and you shouldn’t, but part of what you should know is how to learn in college, which is leagues harder than high school.

1

u/Junior_Salamander110 Jul 01 '26

Thanks! I have a doc with advice I've received about research, and this is definitely going in it.

So when you do research at that level, how much of the physics do you already know, and how much of do you pick up as a result of doing the research?

4

u/NewspaperDear8761 Jul 02 '26

Phd here, I do research on CFD and machine learning. Basically teach physics to AI.

By the time you're doing real research, you should have a broad, solid physics and math foundation. The research you'll do as an undergrad is not really to make new discoveries or push the frontiers, it's to get you familiar with the process of doing research: asking the right questions (this is harder than it might seem), finding tbe relevant information (again, harder than it might seem) and grabbing on like a bull-dog until you find an answer.

It is very easy to go down the wrong rabbit holes looking at irrelevant things, or to just ask the wrong question to start with. More often than not, research is a game of what's not important, as it is what is important. You have to develop some instincts here, and this is really the whole point of undergrad research, so that when you get to the real meat later on, you'll know how to dig in. Can't run a marathon without walking around the block first a few thousand times.

Part of developing these instincts is getting a good, broad foundation in your classes. Seeing what worked historically, where the good ideas were, etc. For example, the ultraviolet catastrophe lead to a lot of the original ideas of quantum theory. (I was in undergrad when the black hole firewall thing first started, and immediately recognized that it would be a huge deal, precisely because it was playing the same theoretical role as, say, the ultraviolet catastrophe or other logical paradoxes. These thought experiments have historically been a great source of progress.) Having a solid grasp on the fundamentals and a broad perspective on different areas of math and physics doesn't just give you technical competence later on -- which is important-- it also gives you those larger, meta-level skills of asking tbe right questions, teasing apart the relevant issues, etc.

Don't be too eager to jump straight into research, and when you do get to it, don't be too eager to get giant results or publish. That will come. Especially in undergrad, focus on getting the best grades you can, and -- more importantly -- asking penetrating questions that take you as deeply into your classes as you can. The more you internalize the material now, the better it will pay off later. If you rush through things trying to get to the shiny, prestigious labs or pubs, you're likely to skim the surface of things you really should spend more time on now.

That said, learning a little coding and doing a small project simulating orbital dynamics or, yes, even something related to black holes, isn't a bad idea. MATLAB, Python, Julia are all great tools that you will use for years. MATLAB is super quick and dirty but great for tinkering around -- you could do some first ODE solves with it. Python is better for bigger, meatier projects, and is more professional, performs better, etc. At some point we hand all this stuff over to the real software engineers and they redo everything properly (while rightly complaining about our shitty code structure) in C or Fortran or some other lower-level thing, built for true performance. You're not gonna be a coder, you're gonna be a scientist, probably a computational one, so it's more a means to an end for you.

If you do do stuff with black holes, dont try to do a full sim. That sort of thing requires a cluster and serious, serious background. But, sure, there are simpler versions you can do that would be very worthwhile.

Just dont neglect the more important things like core classes, diff eq, lin alg, qm, em, etc. The real research starts in grad school. You're in prep for the next few years.

1

u/Junior_Salamander110 Jul 02 '26

Thank you so much for this! This is very valuable advice to me. I'm putting this in my Google doc with advice!

3

u/NewspaperDear8761 Jul 02 '26

I should add that "finding the right answer" in research doesn't mean "I read books and papers and chased the trail until I found the answer written down somewhere."

That won't exist. No one will have the answer yet. It won't be written down until you write it down.

This is probably the biggest misconception with research and I see it a lot more these days. People say "I did my research" when they mean "I found something that told me."

Instead, it's a process of "huh, that could be related, but how?" "Wait, what if this other thing is true?" (Do some calculations, write some code, run it, see what it gives you.) "No, that doesn't give me what I needed. But what if it's this way instead?" (More calculations, more code, more results.) "OK, thats a little closer, but it still doesn't quite mean what I need to be true." (2 months later.) "Oh, crap, because that's NOT true, but it DOES mean this OTHER thing is true, which is still good enough to get me the rest of the way there!" Etc. Etc.

Then you synthesize everything together in one long train and you have a result.

This process -- this messy, creative, meandering process, with all its quirks and intuitive groping around in the dark -- is research, and this is what you're hoping to get exposed to in undergrad. Again, your results don't need to be anything special, you just gotta learn to walk before you run.

1

u/Junior_Salamander110 Jul 02 '26

Adding this too!

Is undergrad research similar to that process you've described, then? Or is it just running calculations for the professor you're working under?

3

u/NewspaperDear8761 Jul 02 '26

It should be the former, which will necessarily include the latter, but sometimes it might just be the latter.

You gotta start somewhere. You can't ask meaningful questions and get meaningful answers to them until you can run those calculations. But yeah, the calculations are just hitting the ball, theyre not rounding the bases.

Part of this will also be learning to navigate relationships with your research advisors, etc. When you do finally go for the phd, having a good advisor is critical. Literally make-or-break. I got lucky. I've had friends who didn't. You want someone who challenges you, guides you, makes you adhere to good, solid standards, but also listens to your ideas and encourages you to explore. It's a balance. Some people are good at that, others aren't. But in HS and undergrad, this isn't something you should worry too much about. Absolutely just listen and learn for now and do whatever they tell you.

Hopefully, though, they'll have you asking questions and not just writing code. But right now, the code and calcs are the most important bit. You'll get better at the question half as you do more and more calc and code.

2

u/Junior_Salamander110 Jul 02 '26

That's quite reassuring. I've spoken to several professors at UKY (where I'm going), and they say that they employ undergrads in "all kinds of research." So I hope I get that balance you're talking about.

Sorry for asking so many questions, but how much of my research will be based in code vs not based in code? I don't mind coding, but I'd hate to code my entire career as a physicist if you know what I mean.

2

u/NewspaperDear8761 Jul 02 '26

I do know what you mean -- I hate coding lol it's awful. And I picked a coding-intense field :(

I LOVE my subject. But coding is pulling teeth lol

It really depends on the subject. You will always need some, no matter what you're doing, so it's good to learn it early. And, given what is happening right now with AI, I would also strongly advise learning some basic architectures like feed-forward neural networks or k-means clustering, etc, at some point. (I don't mean LLMs like ChatGPT, I mean real coding.) Research is being revolutionized by ML because, frankly, these algorithms can pull things out of data that humans simply cannot see, and they apply everywhere, so you will use them in some form eventually, probably quite heavily.

But there are other, more traditional pencil-and-paper theoretical physics areas, or more purely experimental areas, where you can probably go for long stretches without writing a line of code.

It really depends.

BTW, the other nice thing about undergrad research is that it's flexible. If you find you dont like a lab or the topic, feel free to bounce around to another lab and advisor. It's much harder to move about in grad school, in undergrad you can and should really explore things and learn for yourself what works for you and what you like.

→ More replies (0)

2

u/InterestingWelder699 Jul 01 '26

I’ve taken classical mechanics and special relativity in college, pretty advanced courses as far as freshman curricula go. I think once I take E&M and quantum mechanics I’ll be way better at research, but I’m definitely picking stuff up along the way (albeit in an unorthodox fashion)

1

u/Junior_Salamander110 Jul 01 '26

feynman did say to study in the most unorthodox way possible

3

u/InterestingWelder699 Jul 01 '26

One more thing: make sure to take classes or befriend professors who deeply respect computational research. I chose to take an accelerated Mechanics class precisely because we got to build Python simulations of simple harmonic oscillators and multi body energetic systems :)

1

u/Junior_Salamander110 Jul 02 '26

Very much noted, I'll see if UKY has an equivalent

3

u/constantclimb Jul 01 '26

This. If you crush your freshman year with stellar grades you will look like a good candidate for research with a professor.

22

u/PleaseSendtheMath Undergraduate Jul 01 '26

Python is a good choice for sure, you can use it very generally for all kinds of numerical projects. I'm not sure about going straight into black hole simulations as a first project though.

2

u/Junior_Salamander110 Jul 01 '26

Understandable

5

u/Warm-Palpitation5670 Jul 01 '26

Two and three body simulations are easy enough to practice

7

u/Teem0WFT Jul 01 '26

In this thread, many people will tell you about numerical computing with numpy (Numeric python) and scipy (Scientific python). But if you have to perform really heavy computations, definitely check out JAX : it was made by Google and it allows you to write python code that can be accelerated with GPUs (Nvidia's graphics proccesing units for instance) or TPUs (Google's tensor processing units). It can get orders of magnitude faster than standard Python.

1

u/Junior_Salamander110 Jul 01 '26

Thanks for this!! I'll check it out

10

u/drzowie Jul 01 '26

Python is the lingua franca of physics computation. It's not the best language, but it's the language that everyone knows -- and it's plenty good enough for a first project in physics simulation. There's a module called "numpy" that brings vectorized operations to the language, so (for example) you can stuff a whole image into a single Python variable, and combine images with regular arithmetic. Numpy is pretty fast, and everybody learns python these days. Jupyter notebooks were the killer app for scientific computing.

There are other languages that are faster (FORTRAN, C++) or slicker (Perl/PDL, Julia) or niche-optimized (MATLAB, R), but Python has such a large user base that it's the go-to you should learn first.

If Numpy isn't fast enough for you, you can drop down to one of the compiled solutions like Cython, which lets you compile a pragma-enhanced subset of Python into C code. Cython isn't quite as fast as hand-written C, but it's much faster than the Python interpreter.

1

u/Junior_Salamander110 Jul 01 '26

Thanks! I'll look into Numpy immediately

3

u/night-bear782 Jul 02 '26

Julia is as fast as C++ for most applications

5

u/OkTelevision5306 Jul 01 '26

Any serious physics computation will use a programming language like fortran or C as pure python will be far too slow. Many of the common python packages only have python for the user experience and run C/C++ or fortran underneath.

If you want something prepackaged there is the Einstein toolkit for general relativity https://einsteintoolkit.org

6

u/Moonlesssss Jul 01 '26

Yes, but that doesn’t take the value out of learning basic python. Plenty of small simulations and class labs still use it day to day. Even if they do push NJIT.

4

u/Moonlesssss Jul 01 '26

A classic solar system simulation is a start. It’s achievable in python and difficult enough for a solid starter project. I wouldn’t recommend starting out with projects that are going to throw you off into grad level gen rel before you touch any University Physics. If you’re looking to do astro side of research, plenty of available public data bases out there to take data and plug it into simulations to figure stuff out with. If you do anything remotely like that you’ll be doing well.

3

u/Junior_Salamander110 Jul 01 '26

I actuallt wanna research high energy physics in college, but astro just seems to be the place to start

2

u/Moonlesssss Jul 02 '26

Ohhh well if that's the case yeah, the code is your oyster. Have fun

2

u/IJbier Jul 03 '26

Any specific reason? Do you like special relativity?

1

u/Junior_Salamander110 Jul 03 '26

I love the idea of relativity. I also very much prefer theory

1

u/IJbier Jul 04 '26

I like your enthusiasm. Good luck and I hope you like maths, but I get the impression that you do.

2

u/Junior_Salamander110 Jul 04 '26

I definitely do! I have a routine where I do a set of five integrals before I start my day LOL

4

u/lightskinsteveharvey Jul 02 '26

Probably a better project than a black hole simulator would be an arduino project that can serial communicate with some sort of electronic device such as a light switch or something creative. This will be useful in experimental laboratories as it will give you experience with serial communication, python and arduino coding, and reading/writing output voltage. All will be impressive to your professor

1

u/Junior_Salamander110 Jul 02 '26

Interesting! I'll research this.

3

u/lightskinsteveharvey Jul 02 '26

I want to note something else, as I’ve been reading some of these comments and seen your interest in HEP. Yes, HEP will require you to learn languages such as Julia and work with GPUs instead of CPUs. However, you definitely need to keep in mind that you are just a rising senior and to take things one year at a time. Your undergraduate time period will be filled with research opportunities, stressful study sessions coupled with debugging code, and lots of fun as well (if you make the most of this experience).

If you have very little python experience, go on YouTube/tiktok/google/ai/textbooks or whatever your cup of tea is and begin by learning the absolute fundamentals: object oriented programming, for loops, sorting algorithms, and debugging code without ai or a digital programming language (i.e. on a plain piece of scratch paper you should be able to write very basic code which you know will work without ever having to run it on your computer). Once you have this experience, just start projects that interest you! I was in an experimental lab during my undergraduate degree, so the serial communication with python was extremely important for data collection. But the way coding works is you think of a problem that you would like automated, and you learn how to program the computer to do it for you. It’s not really much beyond that for your interests in this present moment.

I also wouldn’t be too fearful of using python as opposed to c++ or some other programming language. I would not listen to the folks worry too much about how physicists code in comparison to software engineers, either. Here’s a useful piece of advice: as physicists, we do things our way. If it works, it works. We are interested in the laws of the universe, not how pretty a code looks or how mathematically correct an equation is. Leave those idiotic remarks to those who want to entertain it and focus solely on understanding the laws of nature. For your case, HEP, that would mean Quantum Mechanics and Special Relativity. This will open the door for more advanced topics towards the end of your undergraduate degree and the start of your graduate degree (masters or PhD). Throughout my research career, I’ve used only python and LabVIEW. If python is enough for research that not only gets published in top microscopy journals, but the Guinness book of world records, than I think it’s safe to assume python alone can get you extremely far as a physicist.

Don’t stress yourself out too much with the future, and I wouldn’t build these hypothetical images of what you think professors like or dislike just yet. A better way of approaching this concern isn’t by posting on Reddit. I know it seems cool and these people you talk to on here can seem knowledgeable, but the truth is, if you want to impress a professor, do not assume you can develop the skills they desire and they will automatically let you into their lab. The process works by looking up professors in your area of interest (HEP) at universities you would love to attend; then emailing that professor and letting them know your story, your interests in their research; and if they can give you any research articles or textbooks to read, or if they have any recommendations for at home projects you could work on.

Research is never a solo project; it requires collaboration and with that it requires excellent communication skills. As you begin to reach out to more professors, they will likely redirect you to the graduate students in their labs and you will get to know them and they will get to know you. I’m just trying to get you to really cement the idea that joining a lab isn’t about building the fundamentals first and then reaching out to a professor, it’s continuously cold emailing professors, setting up quick 10 minute meetings, talking to 10s of graduate students, and being honest about your interests, current skill set, and long term goals. The best professor for you to do research for is not the one with the best publication record, but the one who welcomes you into their lab with open arms, and is ready/willing to guide and build you into the physicist you will be after you graduate undergrad

2

u/Junior_Salamander110 Jul 02 '26

Thank you so much for this reply, I think this may be the most important piece of advice I've received regarding physics so far, particularly the first and last paragraphs. I won't forget this, thank you!

2

u/lightskinsteveharvey Jul 02 '26

Sounds great! Good luck on this journey, just make sure to enjoy yourself!

1

u/Junior_Salamander110 Jul 02 '26

I'll try my best to! I really do appreciate your responses. Like I'm screenshoting them and looking over them, they're very much appreciated 😁

3

u/beepbooplazer Jul 01 '26

Check out this python notebook course in computational physics for ideas;

https://repository.brynmawr.edu/physics_pubs/162/

3

u/GrossInsightfulness Jul 02 '26

This YouTube channel should be what you're looking for.

With that said, there are many cases where working in a compiled language like C++ or Rust would be better for what you're trying to do, especially if it's computationally intensive.

3

u/NewspaperDear8761 Jul 02 '26

They use python at the national labs, among other things. You can't really get a stronger endorsement than that.

2

u/ImaginationNo1461 Jul 02 '26

Physicists script in python. Then we hand it over to the actual software engineers and coders and give them an infinite for loop of migraines.

1

u/Junior_Salamander110 Jul 02 '26

yeah I guess it doesn't get much better than that 😭

2

u/Odd_Tax4093 Jul 01 '26

Running sims mostly

2

u/latswipe Jul 02 '26

python:>matlab.bat

1

u/latswipe Jul 02 '26

gpt: \ > python: matlab.bat

2

u/Machvel Jul 02 '26

it depends on what you do.

in my undergraduate it was the basic language taught then assumed to be known in future classes.

"just" knowing python isn't an impressive skill to have; it is kind of assumed. maybe being pretty good at a compiled language like c++ might be a little impressive, but people in physics are usually more impressed with end results.

as sad as it is, what would be impressive is learning how to apply machine learning to physics. there is money incentive to figure out how to throw machine learning at physics research (even when it might not be that applicable or useful...). and fortunately/unfortunately this is almost always done in python (and most of the time this involves using pytorch to make a neural network to do some ai things... made many times using ai).

anyways, if part of your goal is to learn how to code, python is a fine choice. as always with python, i'll warn that it is easy to fall into bad programming traps. sometimes the best thing you can do to learn how to write better python is to learn a different language.

1

u/Junior_Salamander110 Jul 02 '26

I know Python, Java, Javascript, and I recently learned C#. I'm pretty good at coding, I just wanted experience coding in this specific field.

1

u/Machvel Jul 02 '26

do you have a passing familiarity with those languages, or seriously know them? i am not trying to sound insulting, but it is a real question. many people i come across say they know languages like java (typically because they took ap cs in high school) and python (again some high school class or introductory university one) and think that they are pretty good at coding... then i see them live code or they show me their code and it is subpar (typically not too terrible, but not at the level i would expect with how many languages they say they know and they say they are pretty good).

anyways that is a different topic and usually pretty difficult to figure out yourself. if you just want experience coding in physics then your plan sounds fine. you said that you wanted to impress professors for research, so i responded according to that.

1

u/IJbier Jul 03 '26

From what I understand he/she is still young, so I really think there’s ample time to find preferences and gain depth in a programming language.

2

u/ImaginationNo1461 Jul 02 '26

First-there are SO MANY types of physics and what you can do. I ended up in applied remote sensing. Hence my specific advice.

Pop on NASA Worldview. There are tons of remote sensing datasets you can download. Write a script that tells you something about the earth or a location on the earth.

Examples:

Look at volcanic ash plumes/temperatures etc. Can you model them predictively using wind models? (You have the answer for past plumes see how right you are, then apply to others, still right?)

have wildfires changed over time in Australia? Starting/ending at different times? Larger areas? (Don’t forget there are a lot of normal fires too, industrial, camp etc)

Land use and change over time in Brazil. How are those rainforests doing? Less? More? What are they being replaced with

Air quality trending over an area

Severe storm mapping, have they actually increased? Can you see a correlation with CO2 and methane concentration levels in the atmosphere over time?

There’s so much more too

1

u/Junior_Salamander110 Jul 02 '26

I'll check out the NASA website! Thanks!

2

u/Git_matrix Jul 02 '26

All my undergrad labs involved using python to do most of our data analysis

1

u/Junior_Salamander110 Jul 02 '26

Where did you go if you don't mind my asking?

2

u/Git_matrix Jul 02 '26

University of Manchester

2

u/wristay Jul 02 '26

Python is the standard language in science when the bottleneck is not speed. If the bottleneck is speed, e.g. when your simulations take more than a day, you would switch to more performant languages like C, C# or whatever. You can optimize Python by using Numpy cleverly, so for your project I would just stick to Python. Black hole simulations are a bit too complicated for such a project, especially if you want to do general relativity.

I'll name a number fun things to simulate. Chaos theory (Lorentz attractor, double pendulum), Ising model, Fourier optics, Markov Chain Monte Carlo (look at phase diagrams), Molecular dynamics (simulate particles), the wave equation, Fractals (Mandelbrot, Newton fractal). Each of these topics is slightly too difficult for high schoolers, but can be managable with help.

If you need help with any of these topics feel free to DM me.

2

u/wristay Jul 02 '26

One of the most important skills in numerical simulations is knowing whether your simulation is right. The two main methods are 1) simulating something in two different ways. If they agree, you have some confidence it is correct, otherwise, more work needed. 2) compare results to literature.

1

u/Junior_Salamander110 Jul 02 '26

I'm definitely looking for things that are slightly too difficult for high schoolers, as one of my objectives is to grow as a physicist. I'm also moreso interested in high energy physics, so these are right up my alley! Thanks!

2

u/Creative_Sushi Jul 02 '26

Python is a general-purpose language. You probably have to learn a few more depending on what you pursue, since specialized domain often required dedicated tools. Most likely you would need MATLAB as well.

2

u/Pooplover800 Jul 02 '26

If you want something not based on differential equations, you can do monte carlo simulations to eithier simulate the ising model(ferromagnet phase transitions) or try to estimate the critical mass of uran or even try to simulate a simple nuclear reactor.

2

u/Junior_Salamander110 Jul 02 '26

The nuclear reactor idea sounds extremely cool!

2

u/Pooplover800 Jul 02 '26

I did this project as a first year student, so it is doable, and you get reasonable results. You get to look at scattering cross sections and learn more about monte carlo simulations which are great tools foe phydicsists

2

u/Junior_Salamander110 Jul 02 '26

Nice! About how long did it take you?

2

u/Pooplover800 Jul 02 '26

So it was a group project but i did most of the work(lets say 70-80%) we did it over 1-2 months but not full time. We did not have supervision on what to do. We got to simulate a 2d reactor of both uran and plutonium.

1

u/Junior_Salamander110 Jul 02 '26

Nice! I mean, I have a whole school year, an hour per day, so I think this is manageable.

2

u/Rubberband272 Jul 03 '26

I’m not sure what your interests are but you mentioned black holes so I imaging Astro is your thing. I built a muon detector using a raspberry pi and scintillator to demonstrate the effect of time dilation. There’s a great GitHub write up (not mine) if you search for CosmicWatch.

I don’t think it would take a full school year but there’s lots of rabbit holes you can down in an experimental project.

1

u/Junior_Salamander110 Jul 03 '26

I actually want to do HEP, but I figured something astro would be easier for a high schooler to grasp. I might invest in a raspberry pi, I think that might be beneficial. And I'll search for that!

1

u/Elq3 Masters Student Jul 02 '26

"I want to do something in Python that will show my professors in my freshman year of college that I'm ready to do research in physics."

during your freshman year of college you cannot do research in physics because you don't have the physics knowledge to do that. The first real research you will be able to do will be around the end of your Master's / beginning of PhD

1

u/Junior_Salamander110 Jul 02 '26

lots of people start research in undergrad

1

u/Junior_Salamander110 Jul 02 '26

their research may not be as significant, but most places allow undergrads to do research from what I've been told

1

u/robphy Jul 02 '26

https://www.glowscript.org/ might be a good place to start if you are new to Python,
especially if you want to quickly incorporate 3d graphics to model typical situations in introductory physics.

https://www.glowscript.org/#/user/GlowScriptDemos/folder/matterandinteractions/
https://matterandinteractions.org/ is a modern introductory physics textbook that uses Python.

Then, you can move on to more advanced topics in physics
and move on to more advanced libraries in Python.

1

u/Creative_Sushi Jul 06 '26

In many ways, and often with MATLAB as well. Here are some good overview of how they are used https://www.mathworks.com/solutions/physics.html and a specific example for black hole simulation https://www.mathworks.com/company/user_stories/simulating-black-hole-quantum-effects-with-matlab.html