Skip to content

Commit

Permalink
Add setUp to the TestCases containing Plasma to ensure that Plasma st…
Browse files Browse the repository at this point in the history
…ate is unchanged between the tests.
  • Loading branch information
vsnever committed Jul 19, 2024
1 parent d033dd1 commit dc8e00c
Show file tree
Hide file tree
Showing 4 changed files with 80 additions and 56 deletions.
58 changes: 32 additions & 26 deletions cherab/core/tests/test_beam.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,32 +55,38 @@ def beam_stopping_rate(self, beam_ion, plasma_ion, charge):

class TestBeam(unittest.TestCase):

atomic_data = MockAtomicData()

world = World()

plasma_density = 1.e19
plasma_temperature = 1.e3
plasma_species = [(deuterium, 1, plasma_density, plasma_temperature, Vector3D(0, 0, 0))]
plasma = build_constant_slab_plasma(length=1, width=1, height=1, electron_density=plasma_density,
electron_temperature=plasma_temperature,
plasma_species=plasma_species)
plasma.atomic_data = atomic_data
plasma.parent = world

beam = Beam(transform=translate(0.5, 0, 0))
beam.atomic_data = atomic_data
beam.plasma = plasma
beam.attenuator = SingleRayAttenuator(clamp_to_zero=True)
beam.energy = 50000
beam.power = 1e6
beam.temperature = 10
beam.element = deuterium
beam.parent = world
beam.sigma = 0.2
beam.divergence_x = 1.
beam.divergence_y = 2.
beam.length = 10.
def setUp(self):

self.atomic_data = MockAtomicData()

self.world = World()

self.plasma_density = 1.e19
self.plasma_temperature = 1.e3
plasma_species = [(deuterium, 1, self.plasma_density, self.plasma_temperature, Vector3D(0, 0, 0))]
plasma = build_constant_slab_plasma(length=1, width=1, height=1,
electron_density=self.plasma_density,
electron_temperature=self.plasma_temperature,
plasma_species=plasma_species)
plasma.atomic_data = self.atomic_data
plasma.parent = self.world

beam = Beam(transform=translate(0.5, 0, 0))
beam.atomic_data = self.atomic_data
beam.plasma = plasma
beam.attenuator = SingleRayAttenuator(clamp_to_zero=True)
beam.energy = 50000
beam.power = 1e6
beam.temperature = 10
beam.element = deuterium
beam.parent = self.world
beam.sigma = 0.2
beam.divergence_x = 1.
beam.divergence_y = 2.
beam.length = 10.

self.plasma = plasma
self.beam = beam

def test_beam_density(self):

Expand Down
46 changes: 27 additions & 19 deletions cherab/core/tests/test_beamcxline.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,25 +76,33 @@ def wavelength(self, ion, charge, transition):

class TestBeamCXLine(unittest.TestCase):

world = World()

atomic_data = MockAtomicData()

plasma_species = [(deuterium, 1, 1.e19, 200., Vector3D(0, 0, 0))]
plasma = build_constant_slab_plasma(length=1, width=1, height=1, electron_density=1e19, electron_temperature=200.,
plasma_species=plasma_species, b_field=Vector3D(0, 10., 0))
plasma.atomic_data = atomic_data
plasma.parent = world

beam = Beam(transform=translate(0.5, 0, 0))
beam.atomic_data = atomic_data
beam.plasma = plasma
beam.attenuator = SingleRayAttenuator(clamp_to_zero=True)
beam.energy = 50000
beam.power = 1e6
beam.temperature = 10
beam.element = deuterium
beam.parent = world
def setUp(self):

self.world = World()

self.atomic_data = MockAtomicData()

plasma_species = [(deuterium, 1, 1.e19, 200., Vector3D(0, 0, 0))]
plasma = build_constant_slab_plasma(length=1, width=1, height=1,
electron_density=1e19,
electron_temperature=200.,
plasma_species=plasma_species,
b_field=Vector3D(0, 10., 0))
plasma.atomic_data = self.atomic_data
plasma.parent = self.world

beam = Beam(transform=translate(0.5, 0, 0))
beam.atomic_data = self.atomic_data
beam.plasma = plasma
beam.attenuator = SingleRayAttenuator(clamp_to_zero=True)
beam.energy = 50000
beam.power = 1e6
beam.temperature = 10
beam.element = deuterium
beam.parent = self.world

self.plasma = plasma
self.beam = beam

def test_default_lineshape(self):
# setting up the model
Expand Down
19 changes: 12 additions & 7 deletions cherab/core/tests/test_bremsstrahlung.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,18 @@

class TestBremsstrahlung(unittest.TestCase):

world = World()

plasma_species = [(deuterium, 1, 1.e19, 2000., Vector3D(0, 0, 0)), (nitrogen, 7, 1.e18, 2000., Vector3D(0, 0, 0))]
plasma = build_constant_slab_plasma(length=1, width=1, height=1, electron_density=1e19, electron_temperature=2000.,
plasma_species=plasma_species)
plasma.parent = world
plasma.atomic_data = AtomicData()
def setUp(self):

self.world = World()

plasma_species = [(deuterium, 1, 1.e19, 2000., Vector3D(0, 0, 0)),
(nitrogen, 7, 1.e18, 2000., Vector3D(0, 0, 0))]
self.plasma = build_constant_slab_plasma(length=1, width=1, height=1,
electron_density=1e19,
electron_temperature=2000.,
plasma_species=plasma_species)
self.plasma.parent = self.world
self.plasma.atomic_data = AtomicData()

def test_bremsstrahlung_model(self):
# setting up the model
Expand Down
13 changes: 9 additions & 4 deletions cherab/core/tests/test_lineshapes.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,15 @@

class TestLineShapes(unittest.TestCase):

plasma_species = [(deuterium, 0, 1.e18, 5., Vector3D(2.e4, 0, 0)),
(nitrogen, 1, 1.e17, 10., Vector3D(1.e4, 5.e4, 0))]
plasma = build_constant_slab_plasma(length=1, width=1, height=1, electron_density=1e19, electron_temperature=20.,
plasma_species=plasma_species, b_field=Vector3D(0, 5., 0))
def setUp(self):

plasma_species = [(deuterium, 0, 1.e18, 5., Vector3D(2.e4, 0, 0)),
(nitrogen, 1, 1.e17, 10., Vector3D(1.e4, 5.e4, 0))]
self.plasma = build_constant_slab_plasma(length=1, width=1, height=1,
electron_density=1e19,
electron_temperature=20.,
plasma_species=plasma_species,
b_field=Vector3D(0, 5., 0))

def test_gaussian_line(self):
# setting up a line shape model
Expand Down

0 comments on commit dc8e00c

Please sign in to comment.