예제 #1
0
    def test_z_mean_override(self, kwargs, expected):
        """Test overriding behavior of kw 'z_mean'."""
        ws = two_fluid_dispersion_solution(**kwargs)
        ws_expected = two_fluid_dispersion_solution(**expected)

        for mode in ws:
            assert np.isclose(ws[mode], ws_expected[mode], atol=0, rtol=1.7e-4)
예제 #2
0
    def test_on_bellan2012_vals(self, kwargs, expected):
        """
        Test calculated values based on Figure 1 of Bellan 2012
        (DOI: https://agupubs.onlinelibrary.wiley.com/doi/10.1029/2012JA017856).
        """
        # theta and k values need to be single valued for this test to function
        # correctly

        cs = pfp.cs_(kwargs["T_e"], kwargs["T_i"], kwargs["ion"])
        va = pfp.va_(kwargs["B"], kwargs["n_i"], ion=kwargs["ion"])
        wci = pfp.wc_(kwargs["B"], kwargs["ion"])

        beta = (cs / va).value ** 2
        if not np.isclose(beta, 0.4, atol=1e-4):
            pytest.fail(
                f"The Bellan 2012 paper requires a 'beta' value of 0.4 and the test "
                f"parameters yielded {beta:.6f}."
            )

        Lambda = (kwargs["k"] * va / wci).value ** 2
        if not np.isclose(Lambda, 0.4, atol=1e-4):
            pytest.fail(
                f"The Bellan 2012 paper requires a 'Lambda' value of 0.4 and the test "
                f"parameters yielded {Lambda:.6f}."
            )

        ws = two_fluid_dispersion_solution(**kwargs)
        for mode, val in ws.items():
            norm = (np.absolute(val) / (kwargs["k"] * va)).value ** 2
            assert np.isclose(norm, expected[mode])
예제 #3
0
    def test_return_structure(self, kwargs, expected):
        """Test the structure of the returned values."""
        ws = two_fluid_dispersion_solution(**kwargs)

        assert isinstance(ws, dict)
        assert len({"acoustic_mode", "alfven_mode", "fast_mode"} - set(ws.keys())) == 0

        for mode, val in ws.items():
            assert isinstance(val, u.Quantity)
            assert val.unit == u.rad / u.s
            assert val.shape == expected["shape"]
예제 #4
0
 def test_warns(self, kwargs, _warning):
     """Test scenarios the issue a `Warning`."""
     with pytest.warns(_warning):
         two_fluid_dispersion_solution(**kwargs)
예제 #5
0
 def test_raises(self, kwargs, _error):
     """Test scenarios that raise an `Exception`."""
     with pytest.raises(_error):
         two_fluid_dispersion_solution(**kwargs)