Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tests: Move Plasma and Beam set up into the setUp() method #449

Merged
merged 1 commit into from
Jul 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading