Example #1
0
    def test_linearInterpolation(self):
        y = utils.linearInterpolation(1.0, 2.0, 3.0, 4.0, targetX=20.0)
        x = utils.linearInterpolation(1.0, 2.0, 3.0, 4.0, targetY=y)

        x2 = utils.linearInterpolation(1.0, 1.0, 2.0, 2.0, targetY=50)

        self.assertEqual(x, 20.0)
        self.assertEqual(x2, 50.0)
Example #2
0
    def test_linearInterpolation(self):
        y = utils.linearInterpolation(1.0, 2.0, 3.0, 4.0, targetX=20.0)
        x = utils.linearInterpolation(1.0, 2.0, 3.0, 4.0, targetY=y)

        x2 = utils.linearInterpolation(1.0, 1.0, 2.0, 2.0, targetY=50)

        self.assertEqual(x, 20.0)
        self.assertEqual(x2, 50.0)

        with self.assertRaises(ZeroDivisionError):
            error = utils.linearInterpolation(1.0, 1.0, 1.0, 2.0)
Example #3
0
    def volumetricExpansion(self, Tk=None, Tc=None):
        r"""P. Espeau, R. Ceolin "density of molten sulfur in the 334-508K range"
        This is just a two-point interpolation."""
        Tk = getTk(Tc, Tk)

        self.checkTempRange(334, 430, Tk, "volumetric expansion")
        return utils.linearInterpolation(
            x0=334, y0=5.28e-4, x1=430, y1=5.56e-4, targetX=Tk
        )