I am stilling doing the same project as my previous question which is trying to simulate particle diffusion. My previous question does not relate to this, beyond still trying to simulate diffusion. I am at stage where I am trying to initiate different regions of diffusivity within the grid, so I have a function to produce a list of lists (coordinates) that can be checked against the coordinates of the particles at each move step to adjust the probability of movement, and as such the diffusivity.
I am using 2 classes; one to initiate the diffusion grid space, grid(), and another to move the particles, atom(). The class atom() does not inherit variables from the class grid(). A region of coordinates called t_space is created in grid() using initiate t_space and I want to access this variable t_space produced in initiate t_space in atom().
My code is very long so I have included what I hope are the relevant bits, and my current attempt at solving this.
The code I hoped would call the t_space variable from grid() in atom() was:
atom().tspace = grid().t_space
class grid():
def __init__(self, x, y):
self.grid = np.zeros((x,y))
self.list_of_atoms=[]
self.x = x
self.y = y
def initiate_t_space(self,t_space_x, t_space_y):
self.t_space = []
for i in range(0,self.t_space_x):
for j in range(0,self.t_space_y):
self.t_space.append([i,j])
class atom():
def __init__(self,x,y):
self.position=[x,y]
self.position_tracker=[]
self.dx=0
self.dy=0
# self.tspace = [[11, 42], [11, 43], [11, 44], [11, 45], [11, 46], [11, 47], [11, 48], [11, 49], [11, 50], [11, 51], [11, 52], [11, 53], [11, 54], [11, 55], [11, 56], [11, 57], [11, 58], [12, 38], [12, 39], [12, 40], [12, 41], [12, 42], [12, 43], [12, 44], [12, 45], [12, 46], [12, 47], [12, 48]]
# self.t_space = []
# for i in range(0,100):
# for j in range(0,200):
# self.t_space.append([i,j])
# print(self.t_space)
atom().tspace = grid().t_space
The commented out code in the atom() class is a previous attempt to initiate t_space in atom(), however it needs to be calculated in grid() as it uses variables from grid().
Any assistance would be greatly appreciated.