コード例 #1
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:
            part (dtype_u): the particles
            t (float): current time (not used here)
        Returns:
            dtype_f: Fields for the particles (internal and external)
        """

        N = self.params.nparts

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

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

        for n in range(N):
            f.elec.values[3 * n:3 * n + 3] += self.params.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.params.omega_B * np.array([0, 0, 1])

        return f
コード例 #2
0
    def restrict(self, F):
        """
        Dummy restriction routine

        Args:
            F: the fine level data
        """

        if isinstance(F, particles):
            G = particles(F)
        elif isinstance(F, fields):
            G = fields(F)
        else:
            raise TransferError("Unknown type of fine data, got %s" % type(F))
        return G
コード例 #3
0
    def prolong(self, G):
        """
        Dummy prolongation routine

        Args:
            G: the coarse level data
        """

        if isinstance(G, particles):
            F = particles(G)
        elif isinstance(G, fields):
            F = fields(G)
        else:
            raise TransferError("Unknown type of coarse data, got %s" %
                                type(G))
        return F
コード例 #4
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((3, self.nparts))

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

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

        return f