So, I am in the world of plasma modeling. Now, although I know that top-level simulations are written in fortran and have efficient ultra-memory routines and specialized code, I hope to just run some low-level simulations.
My problem is that when simulating a large number of particles in a time-varying environment (well, with step-by-step time) tracking all of this data is a trick. I used multidimensional arrays before - using the column number for the particle and the row number for the attribute, however this seems pretty awkward. However, it is faster.
I recently tried to define my own class, but as a Python newbie, I probably did it very inefficiently. For each particle in three dimensions, I needed to save the position, speed and strength of the particle (with the possibility of adding additional variables after the code becomes more complex). Using what I knew about classes, I defined an object particle(I think) that makes my code much easier to read and follow:
class particle():
def __init__(self, index=0, pos=np.array([0, 0, 0]), vel=np.array([0,0,0]),
F=np.array([0, 0, 0])):
self.index = index
self.pos = pos
self.vel = vel
self.F = F
, , , . , , . , - , , .
, , : "" ? / . (.. particle[i].pos = [1,2,3] particle[2].vx[1] = 3), , . , Python, , , .