コード例 #1
0
ファイル: test_Species.py プロジェクト: nasryn/PlasmaPy
def test_particle_nonuniform_grid():
    '''
        Test the particle stepper when the spatial domain dimensions
        are unequal
    '''
    x = np.linspace(0, 1, 10) * u.m
    y = np.linspace(0, 1, 20) * u.m
    z = np.linspace(0, 1, 30) * u.m

    plasma = Plasma(x, y, z)

    Species(plasma, 'e', dt=1e-14 * u.s, nt=5).run()
コード例 #2
0
ファイル: particle_stepper.py プロジェクト: hzxusx/PlasmaPy
An example of PlasmaPy's particle stepper class, currently in need of a rewrite
for speed. Currently disabled from running.
"""


import numpy as np
from astropy import units as u
from plasmapy.classes import Plasma, Species

############################################################
# Initialize a plasma. This will be a source of electric and magnetic
# fields for our particles to move in.

plasma = Plasma(domain_x=np.linspace(-1, 1, 10) * u.m,
                domain_y=np.linspace(-1, 1, 10) * u.m,
                domain_z=np.linspace(-1, 1, 10) * u.m)

############################################################
# Initialize the fields. We'll take $\vec{B}$ in the $\hat{x}$ direction
# and $E$ in the $\hat{y}$ direction, which gets us an $E \times B$ drift
# in $\hat{z}$.

B0 = 4 * u.T
plasma.magnetic_field[0, :, :, :] = np.ones((10, 10, 10)) * B0

E0 = 2 * u.V / u.m
plasma.electric_field[1, :, :, :] = np.ones((10, 10, 10)) * E0

############################################################
# Initialize the particle. We'll take one proton `p` with a timestep of
コード例 #3
0
An example of PlasmaPy's particle stepper class, currently in need of a rewrite
for speed.
"""

import numpy as np
from astropy import units as u
from plasmapy.classes import Plasma
from plasmapy.simulation import ParticleTracker
from plasmapy.formulary import gyrofrequency

############################################################
# Initialize a plasma. This will be a source of electric and magnetic
# fields for our particles to move in.

plasma = Plasma(domain_x=np.linspace(-1, 1, 10) * u.m,
                domain_y=np.linspace(-1, 1, 10) * u.m,
                domain_z=np.linspace(-1, 1, 10) * u.m)

############################################################
# Initialize the fields. We'll take B in the x direction
# and E in the y direction, which gets us an E cross B drift
# in the z direction.

B0 = 4 * u.T
plasma.magnetic_field[0, :, :, :] = np.ones((10, 10, 10)) * B0

E0 = 2 * u.V / u.m
plasma.electric_field[1, :, :, :] = np.ones((10, 10, 10)) * E0

############################################################
# Calculate the timestep. We'll take one proton `p`, take its gyrofrequency, invert that
コード例 #4
0
ファイル: test_Species.py プロジェクト: nasryn/PlasmaPy
def uniform_magnetic_field(N=3, max_x=1):
    x = np.linspace(-max_x, max_x, N) * u.m
    test_plasma = Plasma(x, x, x)
    magfieldstr = 1 * u.T
    test_plasma.magnetic_field[2] = magfieldstr
    return test_plasma
コード例 #5
0
ファイル: test_Species.py プロジェクト: hzxusx/PlasmaPy
def uniform_magnetic_field(N=3, max_x=1):
    x = np.linspace(-max_x, max_x, N) * u.m
    test_plasma = Plasma(x, x, x)
    magfieldstr = 1 * u.T
    test_plasma.magnetic_field[2] = magfieldstr
    return test_plasma