예제 #1
0
    def __init__(
        self,
        plasma,
        particle_type="p",
        n_particles=1,
        scaling=1,
        dt=np.inf * u.s,
        nt=np.inf,
        integrator="explicit_boris",
    ):

        if np.isinf(dt) and np.isinf(nt):  # coverage: ignore
            raise ValueError("Both dt and nt are infinite.")

        self.q = atomic.integer_charge(particle_type) * constants.e.si
        self.m = atomic.particle_mass(particle_type)
        self.N = int(n_particles)
        self.scaling = scaling
        self.eff_q = self.q * scaling
        self.eff_m = self.m * scaling

        self.plasma = plasma

        self.dt = dt
        self.NT = int(nt)
        self.t = np.arange(nt) * dt

        self.x = np.zeros((n_particles, 3), dtype=float) * u.m
        self.v = np.zeros((n_particles, 3), dtype=float) * (u.m / u.s)
        self.name = particle_type

        self.position_history = np.zeros(
            (self.NT, *self.x.shape), dtype=float) * u.m
        self.velocity_history = np.zeros(
            (self.NT, *self.v.shape), dtype=float) * (u.m / u.s)
        # create intermediate array of dimension (nx,ny,nz,3) in order to allow
        # interpolation on non-equal spatial domain dimensions
        _B = np.moveaxis(self.plasma.magnetic_field.si.value, 0, -1)
        _E = np.moveaxis(self.plasma.electric_field.si.value, 0, -1)

        self.integrator = self._all_integrators[integrator]

        self._B_interpolator = interp.RegularGridInterpolator(
            (self.plasma.x.si.value, self.plasma.y.si.value,
             self.plasma.z.si.value),
            _B,
            method="linear",
            bounds_error=True,
        )

        self._E_interpolator = interp.RegularGridInterpolator(
            (self.plasma.x.si.value, self.plasma.y.si.value,
             self.plasma.z.si.value),
            _E,
            method="linear",
            bounds_error=True,
        )
예제 #2
0
 def setup_class(self):
     """set up some initial values for tests"""
     self.T_e = 1000 * u.eV
     self.n_e = 2e13 / u.cm**3
     self.ion = "D +1"
     self.m_i = particle_mass(self.ion)
     self.Z = integer_charge(self.ion)
     self.T_i = self.T_e
     self.n_i = self.n_e / self.Z
     self.B = 0.01 * u.T
     self.coulomb_log_val_ei = 17
     self.coulomb_log_val_ii = 17
     self.hall_e = None
     self.hall_i = None
     self.V_ei = None
     self.V_ii = None
     self.mu = m_e / self.m_i
     self.theta = self.T_e / self.T_i
     self.model = "Braginskii"
     self.field_orientation = "all"
     with pytest.warns(RelativityWarning):
         self.ct = ClassicalTransport(
             T_e=self.T_e,
             n_e=self.n_e,
             T_i=self.T_i,
             n_i=self.n_i,
             ion=self.ion,
             Z=self.Z,
             B=self.B,
             model=self.model,
             field_orientation=self.field_orientation,
             coulomb_log_ei=self.coulomb_log_val_ei,
             coulomb_log_ii=self.coulomb_log_val_ii,
             V_ei=self.V_ei,
             V_ii=self.V_ii,
             hall_e=self.hall_e,
             hall_i=self.hall_i,
             mu=self.mu,
             theta=self.theta,
         )
         self.ct_wrapper = ClassicalTransport(
             T_e=self.T_e,
             n_e=self.n_e,
             T_i=self.T_i,
             n_i=self.n_i,
             ion=self.ion,
             Z=self.Z,
             B=self.B,
             model=self.model,
             field_orientation=self.field_orientation,
             mu=self.mu,
             theta=self.theta,
         )
         self.all_variables = self.ct.all_variables
예제 #3
0
def test_integer_charge():
    with pytest.warns(PlasmaPyFutureWarning):
        assert integer_charge("Fe 20+") == 20