Hey there! Sign in to join this conversationNew here? Join for free

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

    • Thread Starter
    Offline

    12
    ReputationRep:
    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.

    If anyone has any questions about this or physics undergrad content in general, feel free to ask.

    Download here: https://github.com/Stuart88/Flow-sim...Flow%20Sim.rar


    Offline

    3
    ReputationRep:
    out of interest where do you study?
    • Thread Starter
    Offline

    12
    ReputationRep:
    (Original post by Darth_Narwhale)
    out of interest where do you study?
    Leeds
    Offline

    14
    ReputationRep:
    That's pretty nifty!

    For a programmer who does Physics, which language do you use? o.o
    • Thread Starter
    Offline

    12
    ReputationRep:
    (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).
    Offline

    14
    ReputationRep:
    (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?
    • Thread Starter
    Offline

    12
    ReputationRep:
    (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.
    Offline

    17
    ReputationRep:
    (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
    Offline

    0
    ReputationRep:
    (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.

    If anyone has any questions about this or physics undergrad content in general, feel free to ask.

    Download here: https://github.com/Stuart88/Flow-sim...Flow%20Sim.rar



    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)
    • Thread Starter
    Offline

    12
    ReputationRep:
    (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
    Ah, my bad.

    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.
    • Thread Starter
    Offline

    12
    ReputationRep:
    (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).
    Offline

    17
    ReputationRep:
    (Original post by Pessimisterious)
    Ah, my bad.

    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...
    • Thread Starter
    Offline

    12
    ReputationRep:
    (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.
 
 
 
Today on TSR

Ask the experts

Advice on your uni application, apprenticeships, getting a job, dropping out of uni and more...

  • See more of what you like on The Student Room

    You can personalise what you see on TSR. Tell us a little about yourself to get started.

  • Poll
    Did TEF Bronze Award affect your UCAS choices?
  • See more of what you like on The Student Room

    You can personalise what you see on TSR. Tell us a little about yourself to get started.

  • 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

    Quick reply
    Reputation gems: You get these gems as you gain rep from other members for making good contributions and giving helpful advice.