I wrote a program in C that uses structs to model the motion of planets going around the Sun. I want to write that same program in Python. The planets and Sun are treated as particles.
In C I wrote a struct for the data of any particle. In the 2D arrays, the rows are the x,y,z components and the columns are the old,current,new iterations. The acceleration of each particle doesn't change so it is an array of x,y,z components.
struct type_particle {
double mass;
double acceleration[3];
double position[3][3];
double velocity[3][3];
};
I used this struct variable to access data about specific particles. Each element in the array is a specific particle where N=9. For example, particle[0] is the Sun.
static struct type_particle particle[N];
I define the initial x-position of the Sun by
particle[0].position[0][0] = -0.002893107099833329;
I want to do the same thing in Python using classes. I am just using the Sun and one planet so N=2. So far I have this.
class type_particle:
particle = [N]
def __init__(self, position):
self.position = [],[]
I am not sure if I can define the class variable "particle" as a list. Is this on the right track to creating something that gives the same results as the struct and struct variable I used earlier? I read that classes can be used like structs but I do not understand how. My goal is to use a class to access data for a particular particle. Any help is appreciated.