def setup_class(self):
     """set up some initial values for tests"""
     u.set_enabled_equivalencies(u.temperature_energy())
     self.T_e = 1000 * u.eV
     self.n_e = 2e13 / u.cm**3
     self.ion_particle = 'D +1'
     self.m_i = particle_mass(self.ion_particle)
     self.Z = integer_charge(self.ion_particle)
     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_particle=self.ion_particle,
             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_particle=self.ion_particle,
             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()
Exemple #2
0
    def __init__(self,
                 plasma,
                 particle_type='p',
                 n_particles=1,
                 scaling=1,
                 dt=np.inf * u.s,
                 nt=np.inf):

        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._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)