|
| 1 | +"""Tests for the methods in plasma_source.""" |
| 2 | + |
| 3 | +import pytest |
| 4 | + |
| 5 | +from parametric_plasma_source.plasma_source import PlasmaSource |
| 6 | + |
| 7 | +plasma_params = { |
| 8 | + "elongation": 1.557, |
| 9 | + "ion_density_origin": 1.09e20, |
| 10 | + "ion_density_peaking_factor": 1, |
| 11 | + "ion_density_pedistal": 1.09e20, |
| 12 | + "ion_density_seperatrix": 3e19, |
| 13 | + "ion_temperature_origin": 45.9, |
| 14 | + "ion_temperature_peaking_factor": 8.06, |
| 15 | + "ion_temperature_pedistal": 6.09, |
| 16 | + "ion_temperature_seperatrix": 0.1, |
| 17 | + "major_radius": 906.0, |
| 18 | + "minor_radius": 292.258, |
| 19 | + "pedistal_radius": 0.8 * 292.258, |
| 20 | + "plasma_id": 1, |
| 21 | + "shafranov_shift": 44.789, |
| 22 | + "triangularity": 0.270, |
| 23 | + "ion_temperature_beta": 6, |
| 24 | +} |
| 25 | + |
| 26 | + |
| 27 | +@pytest.fixture(scope="session") |
| 28 | +def plasma_source(): |
| 29 | + """Make a plasma source to use as a test fixture.""" |
| 30 | + return PlasmaSource(**plasma_params) |
| 31 | + |
| 32 | + |
| 33 | +class TestPlasmaSource: |
| 34 | + """A class to run tests against the plasma source.""" |
| 35 | + |
| 36 | + def test_ion_density_magnetic_origin(self, plasma_source): |
| 37 | + """Test the ion density at the magnetic origin.""" |
| 38 | + ion_density = plasma_source.ion_density(0.0) |
| 39 | + |
| 40 | + assert pytest.approx(ion_density, 1.09e20) |
| 41 | + |
| 42 | + def test_ion_density_inside_pedestal(self, plasma_source): |
| 43 | + """Test the ion density inside the pedestal.""" |
| 44 | + ion_density = plasma_source.ion_density(0.2) |
| 45 | + |
| 46 | + assert pytest.approx(ion_density, 1.09e20) |
| 47 | + |
| 48 | + def test_ion_density_outside_pedestal(self, plasma_source): |
| 49 | + """Test the ion density outside the pedestal.""" |
| 50 | + ion_density = plasma_source.ion_density(2.4) |
| 51 | + |
| 52 | + assert pytest.approx(ion_density, 1.00628584e20) |
| 53 | + |
| 54 | + def test_ion_density_boundary(self, plasma_source): |
| 55 | + """Test the ion density at the boundary.""" |
| 56 | + boundary = plasma_params["minor_radius"] / 100.0 |
| 57 | + ion_density = plasma_source.ion_density(boundary) |
| 58 | + |
| 59 | + assert pytest.approx( |
| 60 | + ion_density, plasma_params["ion_density_seperatrix"] |
| 61 | + ) |
| 62 | + |
| 63 | + def test_ion_temperature_magnetic_origin(self, plasma_source): |
| 64 | + """Test the ion temperature at the magnetic origin.""" |
| 65 | + ion_temperature = plasma_source.ion_temperature(0.0) |
| 66 | + |
| 67 | + assert pytest.approx( |
| 68 | + ion_temperature, plasma_params["ion_temperature_origin"] |
| 69 | + ) |
| 70 | + |
| 71 | + def test_ion_temperature_inside_pedestal(self, plasma_source): |
| 72 | + """Test the ion temperature inside the pedestal.""" |
| 73 | + ion_temperature = plasma_source.ion_temperature(0.2) |
| 74 | + |
| 75 | + assert pytest.approx(ion_temperature, 45.89987429) |
| 76 | + |
| 77 | + def test_ion_temperature_outside_pedestal(self, plasma_source): |
| 78 | + """Test the ion temperature outside the pedestal.""" |
| 79 | + ion_temperature = plasma_source.ion_temperature(2.4) |
| 80 | + |
| 81 | + assert pytest.approx(ion_temperature, 5.45525594) |
| 82 | + |
| 83 | + def test_ion_temperature_boundary(self, plasma_source): |
| 84 | + """Test the ion temperature at the boundary.""" |
| 85 | + boundary = plasma_params["minor_radius"] / 100.0 |
| 86 | + ion_temperature = plasma_source.ion_temperature(boundary) |
| 87 | + |
| 88 | + assert pytest.approx( |
| 89 | + ion_temperature, plasma_params["ion_temperature_seperatrix"] |
| 90 | + ) |
| 91 | + |
| 92 | + def test_dt_cross_section(self, plasma_source): |
| 93 | + """Test the dt cross section at a specific temperature.""" |
| 94 | + dt_cross_section = plasma_source.dt_xs(4.25e7) |
| 95 | + |
| 96 | + assert pytest.approx(dt_cross_section, 0.0) |
0 commit comments