You are Here: Home >< Physics

# 2D Fluid Dynamics flow simulator - also AMA about the subject itself watch

1. I'm a 3rd year student of theoretical physics. I notice a lot of people on here talk about particle physics, relativity, quantum mechanics and the likes, and they probably assume that's the pinnacle of what physics is about. In fact, these areas are only a small part of what's really taught on a physics degree, and students can branch out into a lot of different specialisms.

I'm currently interested in fluid dynamics. For anyone interested in this rather curious topic that isn't covered at all in the A-level syllabus (unless things have changed at some point recently?), I've made a basic simulator that demonstrates a few simple flows. It also gives equations in their most suitable form, for anyone who wants to have a go at understanding new co-ordinate systems and vector calculus.

The content is all taken from a fluid dynamics course I did in 2nd year. I've done more advanced stuff now and can say things get rather more complex, but the flows in the simulator are good examples of the fundamentals in fluid dynamics. I particularly like the rotating cylinder which demonstrates how plane wings (and ship sails!) can take a rotating cylindrical shape for generating a force for lift or motion.

2. out of interest where do you study?
3. (Original post by Darth_Narwhale)
out of interest where do you study?
Leeds
4. That's pretty nifty!

For a programmer who does Physics, which language do you use? o.o
5. (Original post by Callicious)
That's pretty nifty!

For a programmer who does Physics, which language do you use? o.o
Cheers!

That program was done in C++.

On my degree I did basic C++ in 1st year, and slightly more advanced Python in 2nd year. None of it handled moving graphics or anything though. To make the 2D fluid flow simulator I had to self teach a fair amount.

I think in physics the more commonly used code is Python, because it's a little bit easier and has a lot of pre-made functionality for dealing with numerical data (i.e. large data sets from physics experiments etc).
6. (Original post by Pessimisterious)
Cheers!

That program was done in C++.

On my degree I did basic C++ in 1st year, and slightly more advanced Python in 2nd year. None of it handled moving graphics or anything though. To make the 2D fluid flow simulator I had to self teach a fair amount.

I think in physics the more commonly used code is Python, because it's a little bit easier and has a lot of pre-made functionality for dealing with numerical data (i.e. large data sets from physics experiments etc).
That's interesting o.o

I suppose my teachers horror stories of learning FORTRAN during her degree are unfounded, then?
7. (Original post by Callicious)
That's interesting o.o

I suppose my teachers horror stories of learning FORTRAN during her degree are unfounded, then?
I keep hearing about Fortran but I haven't a clue about it. As far as I'm aware, physics courses pretty much only use Python or C++.

I've never done anything with Fortran ever - I wouldn't even know what to use to write and test the code! A quick google tells me Fortran is used in computational fluid dynamics, which should rather concern me as this is an area I'd like to into, hah.
8. (Original post by Pessimisterious)
I keep hearing about Fortran but I haven't a clue about it. As far as I'm aware, physics courses pretty much only use Python or C++.

I've never done anything with Fortran ever - I wouldn't even know what to use to write and test the code! A quick google tells me Fortran is used in computational fluid dynamics, which should rather concern me as this is an area I'd like to into, hah.
At Edinburgh we used Java actually. We simulated molecules in a gas and the solar system. Java is a pain in the ass tbh though
9. (Original post by Pessimisterious)
I'm a 3rd year student of theoretical physics. I notice a lot of people on here talk about particle physics, relativity, quantum mechanics and the likes, and they probably assume that's the pinnacle of what physics is about. In fact, these areas are only a small part of what's really taught on a physics degree, and students can branch out into a lot of different specialisms.

I'm currently interested in fluid dynamics. For anyone interested in this rather curious topic that isn't covered at all in the A-level syllabus (unless things have changed at some point recently?), I've made a basic simulator that demonstrates a few simple flows. It also gives equations in their most suitable form, for anyone who wants to have a go at understanding new co-ordinate systems and vector calculus.

The content is all taken from a fluid dynamics course I did in 2nd year. I've done more advanced stuff now and can say things get rather more complex, but the flows in the simulator are good examples of the fundamentals in fluid dynamics. I particularly like the rotating cylinder which demonstrates how plane wings (and ship sails!) can take a rotating cylindrical shape for generating a force for lift or motion.

Truly beautiful simulation, well done! I had the choice of doing fluid dynamics this year, but I opted to specialise in Astrophysics.

It seems very interesting (and would have helped when learning about galaxy formations)
10. (Original post by langlitz)
At Edinburgh we used Java actually. We simulated molecules in a gas and the solar system. Java is a pain in the ass tbh though

I transferred to a different uni after 1st year. In the first uni I did C++ then the other I did Python. From that and general online info I sort of wildly assumed most unis must cover one of those two languages. For example, physicsforums members mostly discuss those languages.

I was under the impression Java and the likes were more for the web developing side of things? Either way, I sort of envy that you used it because it's definitely more widely applicable, as far as the employment world is concerned.
11. (Original post by GalaxyDestroyer)
Truly beautiful simulation, well done! I had the choice of doing fluid dynamics this year, but I opted to specialise in Astrophysics.

It seems very interesting (and would have helped when learning about galaxy formations)
Cheers

My fluid dynamics lecturers often say that it can apply to astrophysics. In fact it applies everywhere. As with most things in physics, it's one of those things that has vast global applications, but you're never really aware until you learn the content!

I aim to do other simulators when I have more free time. I take it you've done advanced mechanics? Or are soon to do it? I want to create simulators for the sorts of complex systems we learn to model with Lagrangian or Hamiltonian methods. It shouldn't be too hard as the only thing that changes in the coding is the equations for positions x and y. Or Ex, Ey, or whatever really (Hamiltonian formalism is great like that, heh).
12. (Original post by Pessimisterious)

I transferred to a different uni after 1st year. In the first uni I did C++ then the other I did Python. From that and general online info I sort of wildly assumed most unis must cover one of those two languages. For example, physicsforums members mostly discuss those languages.

I was under the impression Java and the likes were more for the web developing side of things? Either way, I sort of envy that you used it because it's definitely more widely applicable, as far as the employment world is concerned.
Java is used for literally everything haha! I've use Python quite a bit too and it's much more intuitive and useful for physics/engineering applications. But that's what made the projects quite challenging, in Python it would have been rather easy but in Java it was a complete nightmare...
13. (Original post by langlitz)
Java is used for literally everything haha! I've use Python quite a bit too and it's much more intuitive and useful for physics/engineering applications. But that's what made the projects quite challenging, in Python it would have been rather easy but in Java it was a complete nightmare...
Yeah I agree Python certainly did the job, almost too easily in fact. Given that I just had to collect some data and tell Python: "Here's a ton of data, now process it and show me what it looks like" (with some nuance), it's rather telling of that fact.

I like C++ because it's the only one that really forces you to deal with memory management from the start. It really annoys me when seemingly light apps and programs run like slugs, presumably because the person who made them has just written a load of logical "do this, do that" code and left the memory to fill up and weigh the system down. Phone apps seem to do this chronically.

Having said all that, I'll certain try to join the ranks of the Java coders in due time, solely because I'd like to be employable in the general computer programming world.

TSR Support Team

We have a brilliant team of more than 60 Support Team members looking after discussions on The Student Room, helping to make it a fun, safe and useful place to hang out.

This forum is supported by:
Updated: February 4, 2017
Today on TSR

### Congratulations to Harry and Meghan!

But did you bother to watch?

### Why are girls so attracted to tall guys?

Poll

The Student Room, Get Revising and Marked by Teachers are trading names of The Student Room Group Ltd.

Register Number: 04666380 (England and Wales), VAT No. 806 8067 22 Registered Office: International House, Queens Road, Brighton, BN1 3XE