C/C++ Getting Started with C++ (for N-Body Simulations)

AI Thread Summary
To get started with C++ for N-body simulations, it's essential to build a solid foundation in C++ programming, especially focusing on parallel programming techniques. Resources like Open Source Physics provide useful libraries and ODE solvers for simulations, while Processing.org offers a Java environment with extensive graphics capabilities that can be adapted for N-body problems. For those familiar with Python, using Anaconda can simplify the installation of necessary libraries like NumPy and SciPy. Additionally, exploring libraries such as PixelFlow can enhance particle system simulations. Ultimately, patience and practice are crucial for mastering the complexities of N-body simulations in C++.
allazar
Messages
4
Reaction score
0
Hello all. I don't really know what to exactly ask from any of you other than how I should get started with C++ programming to hopefully create N-body simulations down the road. How to exactly start, I'm not entirely sure.

For a little about what I know, I know python extensively. I use it almost everyday for data analysis in my research and I can create programs that coincide with numerical computations. But that is just about it.

I have some knowledge on how C++ works, but not concretely (ie parallel programming??). Python can be simple in the case of just downloading and importing packages like numpy, scipy, or astropy to do data analysis, but for C++, i have no idea where to start on this (my apologies for reiterating this). In particular, I'm interested in devising N-body simulations and everything implemented with it (numerical solving and visualization). I have Hockney's "Computational Simulations using Particles" that goes over the theory, but all I have left is to just apply it.

How should I go about achieving my goals? What should I look into? What should I download.
 
Technology news on Phys.org
My first question is why have you chosen C/C++ as the language of choice?

There are many good references on N-body simulations that use Java and Python. Are you interested in "speed" of execution or is it because of some class requirement?

Assuming that language is not really the issue then I would suggest looking at Open Source Physics. Its a collection of java classes for writing complex simulations such as N-body simulations. It comes with several ODE solvers, and many 2D and 3D graphical plotting classes. THe authors have also written a book covering a lot of simulation material including and going beyond N-body.

www.compadre.org/osp

and the book

http://www.compadre.org/OSP/document/ServeFile.cfm?ID=7375&DocID=527

If instead you want ot use Python then the Anaconda version has numpy, and scipy included:

http://lectures.quantecon.org/

for directions on how to install and use it.

Alternatively you could consider using julia (see the above link) which is a MATLAB like clone as the programming language of choice

https://www.wired.com/2014/02/julia/

Lastly, you could look as Processing.org, a java language environment with extensive graphics libraries, examples and tutorials to get you up and running with Java. Some examples could be adapted to the N-body problem if they don't simulate it already.



Processing makes the power of OpenGL available to you via the java language so give it a try.

processing.org
 
  • Like
Likes QuantumQuest, Hesch and S.G. Janssens
To add to my previous post, Processing has a contributed library called PixelFlow which has some fantastic particle system examples which you should definitely checkout.

His github page has several videos to check out:

https://github.com/diwi/PixelFlow

The source code is here:

http://thomasdiewald.com/processing/libraries/pixelflow/

to run any examples:
- download processing,
- install it and
- from the Sektch>>Import Libraries...>>Add Library option,
- select this library to install it.
- then File>>Examples>>PixelFlow select an example.

One example, I've run recently is Softbody2D_ParticleSystems which interacts with the mouse and sloshes a bunch of variously sized particles around.
 
  • Like
Likes S.G. Janssens
You need to first make a trivial version where particle are a point class with
class particle
Vector3 speed
Vector3 position
double mass

then with two loop on the particle vector you can compute gravitationnal force and then integrate acceleration to move the particle.
For the visualisation OpenGl is well defined. After this you must use an Octree to accelerate the computation time. It's more complex but faster.
Octree can be parallelised on multiple CPU by using OpenMP or on multiple computer by an handcoded parralel computing system.
It need time, this is the only secret.
 
Thread 'Is this public key encryption?'
I've tried to intuit public key encryption but never quite managed. But this seems to wrap it up in a bow. This seems to be a very elegant way of transmitting a message publicly that only the sender and receiver can decipher. Is this how PKE works? No, it cant be. In the above case, the requester knows the target's "secret" key - because they have his ID, and therefore knows his birthdate.
I tried a web search "the loss of programming ", and found an article saying that all aspects of writing, developing, and testing software programs will one day all be handled through artificial intelligence. One must wonder then, who is responsible. WHO is responsible for any problems, bugs, deficiencies, or whatever malfunctions which the programs make their users endure? Things may work wrong however the "wrong" happens. AI needs to fix the problems for the users. Any way to...

Similar threads

Replies
19
Views
4K
Replies
1
Views
2K
Replies
15
Views
3K
Replies
9
Views
3K
Replies
4
Views
5K
Replies
2
Views
2K
Back
Top