Exemplo n.º 1
0
    def eval_f(self,part,t):
        """
        Routine to compute the electric and magnetic fields

        Args:
            t: current time
            part: the current particle
        Returns:
            E and B field for the particle (external only)
        """

        f = fields(self.nparts)

        # f.elec.values[0] = 0
        # f.elec.values[1] = self.delta*self.a0*np.sin(t-part.pos.values[0])
        # f.elec.values[2] = -(1-self.delta**2)**(1/2)*self.a0*np.cos(t-part.pos.values[0])
        #
        # f.magn.values[0] = 0
        # f.magn.values[1] = (1-self.delta**2)**(1/2)*self.a0*np.cos(t-part.pos.values[0])
        # f.magn.values[2] = self.delta*self.a0*np.sin(t-part.pos.values[0])

        R = np.linalg.norm(part.pos.values,2)
        f.elec.values[0] = 0.02/(R**3)*part.pos.values[0]
        f.elec.values[1] = 0.02/(R**3)*part.pos.values[1]
        f.elec.values[2] = 0

        f.magn.values[0] = 0
        f.magn.values[1] = 0
        f.magn.values[2] = R


        # print(f.elec.values,f.magn.values)

        return f
Exemplo n.º 2
0
    def eval_f(self,part,t):
        """
        Routine to compute the E and B fields (named f for consistency with the original PEPC version)

        Args:
            t: current time (not used here)
            part: the particles
        Returns:
            Fields for the particles (internal and external)
        """

        N = self.nparts

        Emat = np.diag([1,1,-2])
        f = fields(self.nparts)

        f.elec.values = self.get_interactions(part)


        for n in range(N):
            f.elec.values[3*n:3*n+3] += self.omega_E**2 / (part.q[n]/part.m[n]) * np.dot(Emat,part.pos.values[
                                                                                              3*n:3*n+3])
            f.magn.values[3*n:3*n+3] = self.omega_B * np.array([0,0,1])

        return f
Exemplo n.º 3
0
    def prolong_space(self,G):
        """
        Dummy prolongation routine

        Args:
            G: the coarse level data (easier to access than via the coarse attribute)
        """

        if isinstance(G,particles):
            F = particles(G)
        elif isinstance(G,fields):
            F = fields(G)
        else:
            print('Transfer error')
            exit()
        return F
Exemplo n.º 4
0
    def restrict_space(self,F):
        """
        Dummy restriction routine

        Args:
            F: the fine level data (easier to access than via the fine attribute)

        """

        if isinstance(F,particles):
            G = particles(F)
        elif isinstance(F,fields):
            G = fields(F)
        else:
            print('Transfer error')
            exit()
        return G