def build_f(self, f, part, t): """ Helper function to assemble the correct right-hand side out of B and E field Args: f: the field values part: the current particles data t: the current time Returns: correct RHS of type acceleration """ assert isinstance(part, particles) N = self.nparts rhs = acceleration(self.nparts) for n in range(N): rhs.values[3 * n:3 * n + 3] = part.q[n] / part.m[n] * ( f.elec.values[3 * n:3 * n + 3] + np.cross(part.vel.values[3 * n:3 * n + 3], f.magn.values[3 * n:3 * n + 3])) return rhs
def build_f(self,f,part,t): """ Helper function to assemble the correct right-hand side out of B and E field Args: f: wannabe right-hand side, actually the E field part: particle data t: current time Returns: correct RHS of type acceleration """ assert isinstance(part,particles) rhs = acceleration(self.nparts) rhs.values[:] = part.q[:]/part.m[:]*(f.elec.values + np.cross(part.vel.values,f.magn.values)) return rhs
def build_f(self, f, part, t): """ Helper function to assemble the correct right-hand side out of B and E field Args: f: wannabe right-hand side, actually the E field part: particle data t: current time Returns: correct RHS of type acceleration """ assert isinstance(part, particles) rhs = acceleration(self.nparts) rhs.values[:] = part.q[:] / part.m[:] * ( f.elec.values + np.cross(part.vel.values, f.magn.values)) return rhs
def build_f(self,f,part,t): """ Helper function to assemble the correct right-hand side out of B and E field Args: f: the field values part: the current particles data t: the current time Returns: correct RHS of type acceleration """ assert isinstance(part,particles) N = self.nparts rhs = acceleration(self.nparts) for n in range(N): rhs.values[3*n:3*n+3] = part.q[n]/part.m[n]*(f.elec.values[3*n:3*n+3] + np.cross(part.vel.values[3*n:3*n+3], f.magn.values[3*n:3*n+3])) return rhs
def check_datatypes_particles(init): from pySDC.datatype_classes.particles import particles from pySDC.datatype_classes.particles import acceleration p1 = particles(init) p2 = particles(p1) p5 = particles(init) p1.pos.values[:] = 1.0 p2.pos.values[:] = 2.0 p1.vel.values[:] = 10.0 p2.vel.values[:] = 20.0 p3 = p1 + p2 p4 = p1 - p2 p5.pos = 0.1*p1.vel p6 = p1 p7 = abs(p1) a1 = acceleration(init) a2 = acceleration(a1) p8 = particles(p1) a1.values[:] = 100.0 a2.values[:] = 200.0 a3 = a1 + a2 p8.vel = 0.1*a1 p8.pos = 0.1*(0.1*a1) assert isinstance(p3,type(p1)) assert isinstance(p4,type(p1)) assert isinstance(p5.pos,type(p1.pos)) assert isinstance(p6,type(p1)) assert isinstance(p7,float) assert isinstance(a2,type(a1)) assert isinstance(p8.pos,type(p1.pos)) assert isinstance(p8.vel,type(p1.vel)) assert isinstance(0.1*0.1*a1,type(p1.vel)) assert p2 is not p1 assert p3 is not p1 assert p4 is not p1 assert p5 is not p1 assert p6 is p1 assert a2 is not a1 assert a3 is not a1 assert np.shape(p3.pos.values) == np.shape(p1.pos.values) assert np.shape(p4.pos.values) == np.shape(p1.pos.values) assert np.shape(p3.vel.values) == np.shape(p1.vel.values) assert np.shape(p4.vel.values) == np.shape(p1.vel.values) assert np.shape(a2.values) == np.shape(a1.values) assert np.all(p3.pos.values==3.0) assert np.all(p4.pos.values==-1.0) assert np.all(p3.vel.values==30.0) assert np.all(p4.vel.values==-10.0) assert np.all(p5.pos.values==1.0) assert p7 >= 0 assert np.all(p8.pos.values==1.0) assert np.all(p8.vel.values==10.0) assert np.all(a3.values==300.0)