What is the best way to build a physics simulation

In summary: If you're looking for a software that's very versatile and can do a lot of things, it's probably worth looking into. OpenCL is good for performance, but it can be difficult to understand the code.
  • #1
RaamGeneral
50
1
Hello.

I know a bit of programming, python, C and I tried once the processing language.
I'd like to make, sometimes, some simulation on mechanics, with gravity, collisions, springs, ecc...

But I have not very much time to spend in creating these things (supposing I could), so I would like to know if there some tool, software or library to quickly set up a simulation (I'm on Windows).

Thank you.
 
Technology news on Phys.org
  • #3
If you can afford them, MATLAB and Simulink are widely used for simulations in Engineering. There is a forum here for those types of programs (see "Math and Science Software" under "Computing and Technology") MATLAB is a script language and Simulink is a diagramming tool to make signal-flow diagrams and run them in time simulations. Both have extensive libraries to support areas of application.
 
  • #5
Depends on your level of fidelity. If you want something somewhat accurate, you can try gaming physics engines. They run off of the same basic physics principles and they're often quick. The problem is that games only have to look and feel right, not be physically correct.

Matlab and Simulink are good options as well, but they're not too fast and it's harder to do something freeform. Plus, if you're doing any kind of involved programming, you'll hate Matlab's language. It's a good script language, but not for libraries or any hard development.

A good finite element analysis package will get all the forces and things right, but it's very expensive and time-consuming. As well, you'd probably find it hard to create an accurate model (although the solver is really good about getting the solution to the model).
 
  • #6
I am paying attention to this thread, its something I've been wondering too. The sagemath/scipy/numpy suit has a lot built in, but for custom stuff its so slow when you can't use the wrapped C libraries. What I have done with Open CL is fantastic in speed, but limited. I've actually seen some good stuff in webgl:
http://nullprogram.com/webgl-particles/
But again, its really written for graphics. Writing for parallel execution is just hard for some things, but I don't have an nvidia card and I've heard really good things about their scientific computing library in Cuda.
I've been messing with it for a long time though, and I seriously think the best advice I could give is to really delve what MATLAB and Wolfram's software have to offer, save up and buy what you need. Its just not there yet in the open source community: The good programmers didn't major in physics and the good physicists didn't major in programming.
 
  • #7
I like OpenCL's capabilities. I've been waiting for ArrayFire to catch up with what Accelereyes developed for Matlab's Parallel Computing Toolbox. I guess Mathworks bought all the "nice code" and now the community is going to have to rebuild it.

It's true that there's not a great open-source community for scientific computing, but most of the time it's about money. There are very few people that study these hard subjects that have enough spare time and energy to want to develop cool libraries and NOT get paid for it.
 
  • Like
Likes Fooality
  • #8
Yeah, good point. The other thing is its multi-disciplinary in a way other FOSS projects are not. If you have the programming skills, and you find something wrong in Firefox, you fix it, because you know how a browser should act. But I have found clear errors in Sagemath and watched them sit there for years, because its unclear if what appears to be a fix is truly mathematically correct, or if they integrate into the "Symbolic Ring" in the right way... I just don't have the math chops to know for sure. I'm sure its the same for physics software. Of course in a company you just ask the physicist/mathematician down the hall and work it out.

Thanks for letting me know about ArrayFire, I hadn't seen that.
 

Related to What is the best way to build a physics simulation

1. What is the purpose of building a physics simulation?

The purpose of building a physics simulation is to recreate real-world physical phenomena in a virtual environment. This allows scientists and engineers to understand and predict the behavior of objects and systems without the need for costly and time-consuming experiments.

2. What factors should be considered when building a physics simulation?

Some of the key factors to consider when building a physics simulation include the accuracy and complexity of the simulation, the computational resources available, the level of detail needed for the simulation, and the specific goals of the simulation.

3. What methods are commonly used to build physics simulations?

The most commonly used methods for building physics simulations include numerical integration techniques, finite element analysis, and computational fluid dynamics. These methods involve solving equations and algorithms to simulate the behavior of physical systems.

4. How can one ensure the accuracy of a physics simulation?

To ensure the accuracy of a physics simulation, it is important to use appropriate numerical methods and algorithms, validate the simulation results against real-world data, and continuously refine and improve the simulation as needed. Collaborating with other experts in the field can also help to identify potential errors and improve the accuracy of the simulation.

5. What are the limitations of physics simulations?

Despite advancements in technology, physics simulations still have limitations. These include the need for simplified assumptions and models, the reliance on accurate input data, and the inability to account for all variables and complexities in a real-world system. Additionally, simulations can be computationally expensive and time-consuming to run, making them impractical for certain applications.

Similar threads

  • Programming and Computer Science
Replies
6
Views
998
  • Programming and Computer Science
Replies
1
Views
1K
  • Programming and Computer Science
Replies
10
Views
3K
  • Programming and Computer Science
Replies
4
Views
1K
  • Programming and Computer Science
Replies
1
Views
1K
  • STEM Academic Advising
Replies
3
Views
838
  • Programming and Computer Science
Replies
1
Views
1K
Replies
4
Views
873
  • Programming and Computer Science
Replies
3
Views
4K
  • Programming and Computer Science
Replies
7
Views
643
Back
Top