0

I a beginner in python and I want to know how I can make the following

((x_0_p1,y_0_p1), (x_0_p2,y_0_p2),...,) # P_1 = planet 1, x_0 or y_0 = position 1
((x_1_p1,y_1_p1), (x_1_p2,y_1_p2),...,)

Maybe easier to understand if I say that I want to plot the position of 8 planets orbiting around a star. I am only given start position (x0,y0) of all the planets, star velocity(vx0,vy0) of all the planets. I want to iterate over all the arrays over time with Euler to plot position and time. I want to store all these positions and velocities per dt in arrays.

Hope you guys understand

Already tried:

import numpy as np
N = 1000 # Number of iterations
r = np.zeros((N,3))# 3darray
v = np.zeros((N,3)) # 3darray

for i in range(N-1):
    F = ... # Forces between planet and sun
    for j in range(3):
        ... #Euler solver
Ertya98
  • 11
  • 4
  • 1
    possible duplicate of http://stackoverflow.com/questions/6667201/how-to-define-two-dimensional-array-in-python – Jacob Morris Oct 25 '16 at 17:23
  • If I understand correctly, there is 8 planets times 4 values (x, y, vx, vy) times 1000 iterations. Right? – zvone Oct 25 '16 at 17:25
  • Or I want (x,y) and(vx,vy) else correct – Ertya98 Oct 25 '16 at 17:28
  • But I kinda want an array inside the matrix – Ertya98 Oct 25 '16 at 17:37
  • 1
    `from numpy *` should be `from numpy import *` -- though it is seldom good design to import namespaces unreservedly like that. This is the reason that a lot of numpy code begins with the line `import numpy as np`. It is so idiomatic that using `np.whatever()` rather than `whatever()` serves to self-document the code a bit. – John Coleman Oct 25 '16 at 17:40

0 Answers0