Presentation is loading. Please wait.

Presentation is loading. Please wait.

N B ODY G RAVITATIONAL P ROBLEM Seminar By Srinivasan Manoharan.

Similar presentations


Presentation on theme: "N B ODY G RAVITATIONAL P ROBLEM Seminar By Srinivasan Manoharan."— Presentation transcript:

1 N B ODY G RAVITATIONAL P ROBLEM Seminar By Srinivasan Manoharan

2 P ROBLEM To compute the position of N bodies over a set of Iterations by using the forces that exists between the other bodies. A big mathematical conundrum I chose this problem because of the huge amount of computation involved in this problem. Mathematical Problem:- Consider n point masses in three dimensional space Assumption :- Force experienced between them is Newtonian. Then, if the initial positions in space and initial velocities are specified for every particle at some present instant t 0, determine the position of each particle at every future (or past) moment of time

3 P ROBLEM (C ONTD..) The All Pairs Approach is a brute force technique which evaluates the interactions between all the pairs of the N bodies. The problem with this approach is that the worst case computational complexity is O(N 2 ). The all pair approach is used for evaluating bodies that are interacting very closely. So the all pairs method is combined with a more efficient method,far field approximation of long range forces(Barnes Hut method). This far field method is only valid when the two bodies are well separated. The all pairs method requires substantial time to compute and an area where acceleration can be used.

4 C ALCULATION Force Between two bodies with a distance r is The total Force on the Body i is the summation of the all the forces other than i. i.e where j is 1 to N and not equal to j. Due to approximation, softening factor is included and Force = mass * Acceleration. Acceleration of the body,a i F ij =G*(m i* m j )/r ij 2 F i =∑F ij F i =G*m i *∑((m j r ij )/r ij 3 ) F i =G*m i *∑((m j r ij )/(r ij 2 +ε 2 ) 3/2 ). a i =G*∑((m j r ij )/(r ij 2 +ε 2 ) 3/2 ).

5 C ALCULATION ( CONTD..) With acceleration calculated, we can get the velocity v and the distance x for the body to move. We can calculate all F ij in a grid of size N * N. F11F12F13F14F15F16F1jF1n F21F22F23F24F25F26F2jF2n F31F32F33F34F35F36F3jF3n F41F42F43F44F45F46F4jF4n Fi1Fi2Fi3Fi4Fi5Fi6FijFin Fn1Fn2Fn3Fn4Fn5Fn6FnjFnn

6 S TRATEGY First we randomly position the bodies in the 3 dimensional space. Then we calculate the force exerted in all the axis using the formula. We calculate the acceleration by dividing the force by mass We calculate the velocity by multiplying the acceleration with delta time. Then finally we calculate the new position by multiplying the velocity with delta time.

7 S TRATEGY Each entry in the Grid can be calculated independently, therefore there is N 2 parallelism. But Since the memory is limited, we cannot use N 2 threads each computing the force in the grid. So we can calculate the forces in a row to be calculated in sequential order. And parallelize the columns as each thread can calculate the Force and acceleration of the body.

8 A NALYSIS We need to obtain the performance by By varying the number of bodies N interacting By Varying the number of iterations. By varying the number of threads per block. By varying the number of processors. The number of threads per block can also be varied,but the performance was better when I used p= 256 i.e 256 threads per block. Number of Blocks = Number of Bodies / Number of threads

9 T ABLE (N & N UMBER OF I TERATIONS )-S EQUENTIAL

10 T ABLE (N & N UMBER OF I TERATIONS )-P ARALLEL N - Number of BodiesTime for 2 Iteration in Milli sec16 Iteration128 iterations

11 P ERFORMANCE (T IME V S N)

12 P ERFORMANCE (T IME V S P ROCESSORS ) As the number of Nodes increases, the performance is better.

13 A NALYSIS & I NFERENCE The number of calculations involved is and computed in 11.4 milli seconds. Each calculation involves 14 operations. When the number of computation is less the processors are underutilized. But when the calculations increase the performance is far better than the sequential code. When the number of bodies is 32 the performance is better in parallel.i.e calculations.

14 QUESTIONS Thank You


Download ppt "N B ODY G RAVITATIONAL P ROBLEM Seminar By Srinivasan Manoharan."

Similar presentations


Ads by Google