Beispiel #1
0
def test_mu_Yaws():
    assert_close(mu_Yaws(300.0, -6.4406 - log10(1000), 1117.6, 0.0137,
                         -0.000015465),
                 0.00100666120816515,
                 rtol=1e-14)

    d = dmu_Yaws_dT(300.0, -9.4406, 1117.6, 0.0137, -0.000015465)
    d_num = derivative(
        lambda T: mu_Yaws(T, -9.4406, 1117.6, 0.0137, -0.000015465),
        300.0,
        dx=300.0 * 1e-7)
    assert_close(d, d_num)

    T, A, B, C, D = 300.0, -9.4406, 1117.6, 0.0137, -0.000015465
    der_num = [
        derivative(lambda A: mu_Yaws(T, A, B, C, D), A, dx=A * 1e-5),
        derivative(lambda B: mu_Yaws(T, A, B, C, D), B, dx=B * 1e-5),
        derivative(lambda C: mu_Yaws(T, A, B, C, D), C, dx=C * 1e-5),
        derivative(lambda D: mu_Yaws(T, A, B, C, D), D, dx=D * 1e-5)
    ]

    der_expect = [[
        0.0023179230916164487, 7.726410305388163e-06, 0.6953769274849346,
        208.61307824548038
    ]]
    der_analytical = mu_Yaws_fitting_jacobian([T], A, B, C, D)
    assert_close1d(der_expect, der_analytical, rtol=1e-13)
    assert_close1d(der_analytical, [der_num], rtol=1e-7)

    # Point where overflow would occur
    kwargs = {'T': 489.2, 'A': 1.0, 'B': 1.0, 'C': 1.0, 'D': 1.0}
    mu_Yaws(**kwargs)
def test_PPDS9():
    mu = PPDS9(400.0, 1.74793, 1.33728, 482.347, 41.78, 9.963e-05)
    assert_close(mu, 0.00035091137378230684, rtol=1e-13)

    coeffs = (1.74793, 1.33728, 482.347, 41.78, 9.963e-05)
    # normal region
    mu_expect = PPDS9(400.0, *coeffs)
    dmu, mu = dPPDS9_dT(400.0, *coeffs)
    assert_close(mu, mu_expect, rtol=1e-13)
    assert_close(dmu, -3.186540635882627e-06, rtol=1e-10)
    assert_close(derivative(PPDS9, 400.0, args=coeffs, dx=1e-4),
                 dmu,
                 rtol=1e-9)

    mu_expect = PPDS9(5.0, *coeffs)
    dmu, mu = dPPDS9_dT(5.0, *coeffs)
    assert_close(mu, mu_expect, rtol=1e-13)
    assert_close(dmu, 1126796480623.1184, rtol=1e-10)
    assert_close(derivative(PPDS9, 5.0, args=coeffs, dx=1e-5), dmu, rtol=1e-9)

    # Check can go super low T without overflow
    coeffs = [1.20479, 0.6058, 216.325, 2.278, 8.756e-05]
    assert PPDS9(3, *coeffs) > 1e10
    assert PPDS9(2, *coeffs) > 1e10
    assert PPDS9(1, *coeffs) > 1e10

    dPPDS9_dT(2, *coeffs)
    dPPDS9_dT(1, *coeffs)
    dPPDS9_dT(3, *coeffs)
Beispiel #3
0
def test_VaporPressure_bestfit_derivatives():
    obj = VaporPressure(poly_fit=(175.7, 512.49, [-1.446088049406911e-19, 4.565038519454878e-16, -6.278051259204248e-13, 4.935674274379539e-10,
                                                -2.443464113936029e-07, 7.893819658700523e-05, -0.016615779444332356, 2.1842496316772264, -134.19766175812708]))
    assert_close(obj.T_dependent_property(300), 18601.061401014867, rtol=1e-11)
    assert_close(obj.T_dependent_property_derivative(300), 954.1652489206775, rtol=1e-11)
    assert_close(obj.T_dependent_property_derivative(300, order=2), 41.8787546283273, rtol=1e-11)
    assert_close(derivative(obj.T_dependent_property, 300, dx=300*1e-7), obj.T_dependent_property_derivative(300))
    assert_close(derivative(obj.T_dependent_property_derivative, 300, dx=300*1e-7), obj.T_dependent_property_derivative(300, order=2))
Beispiel #4
0
def test_TRC_Antoine_extended():
    # Tetrafluoromethane, coefficients from [1]_, at 180 K:
    Psat = TRC_Antoine_extended(180.0, 227.51, -120., 8.95894, 510.595, -15.95,
                                2.41377, -93.74, 7425.9)
    assert_close(Psat, 706317.0898414153)

    # Test x is restricted to 0
    Psat = TRC_Antoine_extended(120.0, 227.51, -120., 8.95894, 510.595, -15.95,
                                2.41377, -93.74, 7425.9)
    assert_close(Psat, 11265.018958511126)

    # Confirm that at low x, reverts to the Antoine expression
    assert_close(TRC_Antoine_extended(T=100.0,
                                      Tc=227.51,
                                      to=-120.,
                                      A=8.95894,
                                      B=510.595,
                                      C=-15.95,
                                      n=2.41377,
                                      E=-93.74,
                                      F=7425.9),
                 Antoine(T=100.0, A=8.95894, B=510.595, C=-15.95),
                 rtol=1e-13)

    dPsat_dT_numerical = derivative(TRC_Antoine_extended,
                                    180.0,
                                    dx=1e-3,
                                    args=(227.51, -120., 8.95894, 510.595,
                                          -15.95, 2.41377, -93.74, 7425.9))
    dPsat_dT_analytical = dTRC_Antoine_extended_dT(180.0, 227.51, -120.,
                                                   8.95894, 510.595, -15.95,
                                                   2.41377, -93.74, 7425.9)
    assert_close(dPsat_dT_analytical, 31219.606126382252, rtol=1e-13)
    assert_close(dPsat_dT_numerical, dPsat_dT_analytical, rtol=1e-8)

    for T in (0.0, 1e-150, 1e-200, 1e-250, 1e-300, 1e-100, 1e-400, 1e-308,
              1e-307):
        assert dTRC_Antoine_extended_dT(T, 227.51, -120., 8.95894, 510.595,
                                        -15.95, 2.41377, -93.74, 7425.9) == 0.0

    d2Psat_dT2_numerical = derivative(dTRC_Antoine_extended_dT,
                                      180.0,
                                      dx=1e-3,
                                      args=(227.51, -120., 8.95894, 510.595,
                                            -15.95, 2.41377, -93.74, 7425.9))
    d2Psat_dT2_analytical = d2TRC_Antoine_extended_dT2(180.0, 227.51, -120.,
                                                       8.95894, 510.595,
                                                       -15.95, 2.41377, -93.74,
                                                       7425.9)
    assert_close(d2Psat_dT2_analytical, 1022.5503689444175, rtol=1e-13)
    assert_close(d2Psat_dT2_numerical, d2Psat_dT2_analytical, rtol=1e-8)

    for T in (0.0, 1e-150, 1e-200, 1e-250, 1e-300, 1e-100, 1e-400, 1e-308,
              1e-307):
        assert d2TRC_Antoine_extended_dT2(T, 227.51, -120., 8.95894, 510.595,
                                          -15.95, 2.41377, -93.74,
                                          7425.9) == 0.0
Beispiel #5
0
def test_Antoine_fit_extrapolate():
    T = 178.01
    A, B, C =  (24.0989474955895, 4346.793091137991, -18.96968471040141)
    Psat, dPsat_dT, d2Psat_dT2 = (0.03946094565666715, 0.006781441203850251, 0.0010801244983894853)
    
    assert_close(Psat, Antoine(T, A, B, C, base=e), rtol=1e-10)
    dPsat_dT_num = derivative(lambda T: Antoine(T, A, B, C, base=e), T, dx=T*1e-9)
    assert_close(dPsat_dT_num, dPsat_dT, rtol=1e-7)
    d2Psat_dT2_num = derivative(lambda T: Antoine(T, A, B, C, base=e), T, dx=T*1e-7, n=2, order=13)
    d2Psat_dT2_analytical = B*(B/(C + T) - 2)*exp(A - B/(C + T))/(C + T)**3
    assert_close(d2Psat_dT2_num, d2Psat_dT2, rtol=1e-4)
    assert_close(d2Psat_dT2_analytical, d2Psat_dT2, rtol=1e-10)
Beispiel #6
0
def test_Wagner_original():
    # Methane, coefficients from [2]_, at 100 K
    Psat = Wagner_original(100.0, 190.53, 4596420., -6.00435, 1.1885,
                           -0.834082, -1.22833)
    assert_close(Psat, 34520.44601450496)

    for T in (0.0, 1e-100, 1e-15, 1e-7, 1.0):
        assert 0 == Wagner_original(T,
                                    190.53,
                                    4596420.,
                                    a=-6.00435,
                                    b=1.1885,
                                    c=-0.834082,
                                    d=-1.22833)

    # First derivative
    dPsat_dT_numerical = derivative(Wagner_original,
                                    100.0,
                                    dx=1e-3,
                                    args=(190.53, 4596420., -6.00435, 1.1885,
                                          -0.834082, -1.22833))
    dPsat_dT_analytical = dWagner_original_dT(100, 190.53, 4596420., -6.00435,
                                              1.1885, -0.834082, -1.22833)
    assert_close(dPsat_dT_analytical, 3593.707832837502, rtol=1e-13)
    assert_close(dPsat_dT_numerical, dPsat_dT_analytical, rtol=1e-8)

    assert dWagner_original_dT(
        1.0, 190.53, 4596420., a=-6.00435, b=1.1885, c=-0.834082,
        d=-1.22833) < 1e-100

    for T in (0.0, 1e-150, 1e-200, 1e-250, 1e-300, 1e-100, 1e-400, 1e-308,
              1e-307):
        assert dWagner_original_dT(T, 190.53, 4596420., -6.00435, 1.1885,
                                   -0.834082, -1.22833) == 0.0

    # Second derivative
    d2Psat_dT2_numerical = derivative(dWagner_original_dT,
                                      100.0,
                                      dx=1e-3,
                                      args=(190.53, 4596420., -6.00435, 1.1885,
                                            -0.834082, -1.22833))
    d2Psat_dT2_analytical = d2Wagner_original_dT2(100, 190.53, 4596420.,
                                                  -6.00435, 1.1885, -0.834082,
                                                  -1.22833)
    assert_close(d2Psat_dT2_analytical, 296.87593368224003, rtol=1e-13)
    assert_close(d2Psat_dT2_numerical, d2Psat_dT2_analytical, rtol=1e-8)

    for T in (0.0, 1e-150, 1e-200, 1e-250, 1e-300, 1e-100, 1e-400, 1e-308,
              1e-307):
        assert d2Wagner_original_dT2(T, 190.53, 4596420., -6.00435, 1.1885,
                                     -0.834082, -1.22833) == 0.0
Beispiel #7
0
def test_lemmon2000_air_d3A0_dtau3():
    assert_close(lemmon2000_air_d3A0_dtau3(0.36842, .5),
                 102.9144884392338,
                 rtol=2e-12)
    assert_close(
        derivative(lambda tau: lemmon2000_air_d2A0_dtau2(tau, .5),
                   0.36842,
                   dx=1e-7), lemmon2000_air_d3A0_dtau3(0.36842, .5))

    for rat in (1000.0, 100.0, 10.0, 5.0, 3.0, 2.5, 2.0, 1.5, 1.0, .5, .2, .1,
                .01, .001):
        assert_close(
            derivative(lambda tau: lemmon2000_air_d2A0_dtau2(tau, .5),
                       rat,
                       dx=rat * 1e-5), lemmon2000_air_d3A0_dtau3(rat, .5))
Beispiel #8
0
def test_lemmon2000_air_d4A0_dtau4():
    assert_close(lemmon2000_air_d4A0_dtau4(126.192 / 200.0, 13000 / 11183.9),
                 -94.8155327278803,
                 rtol=1e-13)

    assert_close(
        derivative(lambda tau: lemmon2000_air_d3A0_dtau3(tau, .5),
                   0.36842,
                   dx=4e-7), lemmon2000_air_d4A0_dtau4(0.36842, .5))

    for rat in (1000.0, 100.0, 10.0, 5.0, 3.0, 2.5, 2.0, 1.5, 1.0, .5, .2, .1,
                .01, .001):
        assert_close(
            derivative(lambda tau: lemmon2000_air_d3A0_dtau3(tau, .5),
                       rat,
                       dx=rat * 1e-5), lemmon2000_air_d4A0_dtau4(rat, .5))
Beispiel #9
0
def test_Wagner_fitting_jacobian():
    T, Tc, Pc, a, b, c, d = 100.0, 475.03, 2980000.0, -8.32915, 2.37044, -3.75113, -4.6033
    der_num = [
        derivative(lambda a: Wagner(T, Tc, Pc, a, b, c, d), a, dx=a * 1e-5),
        derivative(lambda b: Wagner(T, Tc, Pc, a, b, c, d), b, dx=b * 1e-5),
        derivative(lambda c: Wagner(T, Tc, Pc, a, b, c, d), c, dx=c * 1e-5),
        derivative(lambda d: Wagner(T, Tc, Pc, a, b, c, d), d, dx=d * 1e-5)
    ]

    der_expect = [[
        5.1791400515036586e-11, 4.601825445175529e-11, 3.633081272138977e-11,
        2.0120443215711467e-11
    ]]
    der_analytical = Wagner_fitting_jacobian([T], Tc, Pc, a, b, c, d)
    assert_close1d(der_expect, der_analytical, rtol=1e-13)
    assert_close1d(der_analytical, [der_num], rtol=1e-7)
Beispiel #10
0
    def calculate_derivative_P(self, P, T, method, order=1):
        r'''Method to calculate a derivative of a temperature and pressure
        dependent property with respect to pressure at constant temperature,
        of a given order using a specified method. Uses SciPy's derivative
        function, with a delta of 0.01 Pa and a number of points equal to
        2*order + 1.

        This method can be overwritten by subclasses who may perfer to add
        analytical methods for some or all methods as this is much faster.

        If the calculation does not succeed, returns the actual error
        encountered.

        Parameters
        ----------
        P : float
            Pressure at which to calculate the derivative, [Pa]
        T : float
            Temperature at which to calculate the derivative, [K]
        method : str
            Method for which to find the derivative
        order : int
            Order of the derivative, >= 1

        Returns
        -------
        dprop_dP_T : float
            Calculated derivative property at constant temperature,
            [`units/Pa^order`]
        '''
        f = lambda P: self.calculate_P(T, P, method)
        return derivative(f, P, dx=1e-2, n=order, order=1 + order * 2)
Beispiel #11
0
def test_Antoine():
    # Methane, coefficients from [1]_, at 100 K:
    Psat = Antoine(100.0, 8.7687, 395.744, -6.469)
    assert_close(Psat, 34478.367349639906)

    # Tetrafluoromethane, coefficients from [1]_, at 180 K
    Psat = Antoine(180, A=8.95894, B=510.595, C=-15.95)
    assert_close(Psat, 702271.0518579542)

    # Oxygen at 94.91 K, with coefficients from [3]_ in units of °C, mmHg, log10,
    # showing the conversion of coefficients A (mmHg to Pa) and C (°C to K)
    Psat = Antoine(94.91, 6.83706 + 2.1249, 339.2095, 268.70 - 273.15)
    assert_close(Psat, 162978.88655572367)

    # Extremely low temperature checks
    Psat = Antoine(T=60, A=3.45604 + 5, B=1044.038, C=-53.893)
    assert Psat < 1e-100
    assert Psat > 0.0

    assert Antoine(T=53, A=3.45604 + 5, B=1044.038, C=-53.893) == 0.0
    assert Antoine(T=53.893, A=3.45604 + 5, B=1044.038, C=-53.893) == 0.0
    assert Antoine(T=50, A=3.45604 + 5, B=1044.038, C=-53.893) == 0.0

    dPsat_dT = dAntoine_dT(100.0, 8.7687, 395.744, -6.469)
    assert_close(dPsat_dT, 3591.4147747481156, rtol=1e-13)
    assert_close(dPsat_dT,
                 derivative(Antoine,
                            100.0,
                            dx=100 * 1e-7,
                            args=(8.7687, 395.744, -6.469)),
                 rtol=1e-9)

    # Extremely low temperature derivative check
    assert dAntoine_dT(5, 8.7687, 395.744, -6.469) == 0.0

    d2Psat_dT = d2Antoine_dT2(100, 8.7687, 395.744, -6.469)
    d2Psat_dT_num = derivative(dAntoine_dT,
                               100.0,
                               dx=.01,
                               args=(8.7687, 395.744, -6.469))
    assert_close(d2Psat_dT, 297.30093799054947, rtol=1e-13)
    assert_close(d2Psat_dT, d2Psat_dT_num, rtol=1e-7)

    # Low T values
    for T in (0, 1e-10, 1e-100, 10, 53, 53.893, 54):
        assert 0 == d2Antoine_dT2(T=T, A=3.45604 + 5, B=1044.038, C=-53.893)
Beispiel #12
0
def test_TEOS10_CAWW_derivatives():
    assert_close(TEOS10_CAWW_derivatives(200.0)[0], -0.349872634E-5, rtol=1e-9)
    assert_close(TEOS10_CAWW_derivatives(200.0)[1], 0.188025052E-6, rtol=2e-9)
    assert_close(TEOS10_CAWW_derivatives(200.0)[2], -0.124996856E-7, rtol=2e-9)
    assert_close(derivative(lambda T: TEOS10_CAWW_derivatives(T)[-2],
                            200.0,
                            dx=200 * 1e-7),
                 TEOS10_CAWW_derivatives(200)[-1],
                 rtol=1e-8)
Beispiel #13
0
def test_lemmon2000_air_d4Ar_ddelta3dtau():

    for rat in (1000.0, 100.0, 10.0, 5.0, 3.0, 2.5, 2.0, 1.5, 1.0, .5, .2, .1,
                .01, .001):
        assert_close(
            derivative(lambda tau: lemmon2000_air_d3Ar_ddelta3(tau, .5),
                       rat,
                       dx=rat * 1e-5),
            lemmon2000_air_d4Ar_ddelta3dtau(rat, .5))
Beispiel #14
0
def test_TEOS10_BAW_derivatives():
    assert_close(TEOS10_BAW_derivatives(200)[0], -0.784874278E-4)
    assert_close(TEOS10_BAW_derivatives(200)[1], 0.848076624E-6)
    assert_close(TEOS10_BAW_derivatives(200)[2], -0.122622146E-7)
    assert_close(derivative(lambda T: TEOS10_BAW_derivatives(T)[-2],
                            200.0,
                            dx=200 * 1e-7),
                 TEOS10_BAW_derivatives(200)[-1],
                 rtol=1e-8)
Beispiel #15
0
def test_lemmon2000_air_dA0_dtau():
    assert_close(derivative(
        lambda tau: lemmon2000_air_A0(tau, 13000 / 11183.9),
        126.192 / 200.0,
        dx=1e-7),
                 lemmon2000_air_dA0_dtau(126.192 / 200.0, 13000 / 11183.9),
                 rtol=1e-9)

    assert_close(lemmon2000_air_dA0_dtau(0.36842, 0.5),
                 6.764336610288353,
                 rtol=1e-14)

    for rat in (1000.0, 100.0, 10.0, 5.0, 3.0, 2.5, 2.0, 1.5, 1.0, .5, .2, .1,
                .01, .001):
        assert_close(
            derivative(lambda tau: lemmon2000_air_A0(tau, .5),
                       rat,
                       dx=rat * 1e-5), lemmon2000_air_dA0_dtau(rat, .5))
Beispiel #16
0
def test_lemmon2000_air_d2A0_dtau2():
    assert_close(lemmon2000_air_d2A0_dtau2(126.192 / 200.0, 13000 / 11183.9),
                 -6.260482844274295,
                 rtol=1e-13)

    for rat in (1000.0, 100.0, 10.0, 5.0, 3.0, 2.5, 2.0, 1.5, 1.0, .5, .2, .1,
                .01, .001):
        assert_close(
            derivative(lambda tau: lemmon2000_air_dA0_dtau(tau, .5),
                       rat,
                       dx=rat * 1e-5), lemmon2000_air_d2A0_dtau2(rat, .5))
Beispiel #17
0
def test_lemmon2000_air_dAr_dtau():
    assert_close(lemmon2000_air_dAr_dtau(0.36842, 0.15880050154579475),
                 -0.20189573196786642,
                 rtol=1e-13)

    for rat in (1000.0, 100.0, 10.0, 5.0, 3.0, 2.5, 2.0, 1.5, 1.0, .5, .2, .1,
                .01, .001):
        assert_close(
            derivative(lambda tau: lemmon2000_air_Ar(tau, .5),
                       rat,
                       dx=rat * 1e-5), lemmon2000_air_dAr_dtau(rat, .5))
Beispiel #18
0
def test_lemmon2000_air_d2Ar_ddeltadtau():
    assert_close(lemmon2000_air_d2Ar_ddeltadtau(0.36842, 0.15880050154579475),
                 -1.261887383081615,
                 rtol=1e-13)

    for rat in (1000.0, 100.0, 10.0, 5.0, 3.0, 2.5, 2.0, 1.5, 1.0, .5, .2, .1,
                .01, .001):
        assert_close(
            derivative(lambda tau: lemmon2000_air_dAr_ddelta(tau, .5),
                       rat,
                       dx=rat * 1e-5), lemmon2000_air_d2Ar_ddeltadtau(rat, .5))
Beispiel #19
0
def test_lemmon2000_air_d4Ar_ddelta4():
    assert_close(lemmon2000_air_d4Ar_ddelta4(0.36842, 0.15880050154579475),
                 1.0647113576834495,
                 rtol=1e-13)

    for rat in (1000.0, 100.0, 10.0, 5.0, 3.0, 2.5, 2.0, 1.5, 1.0, .5, .2, .1,
                .01, .001):
        assert_close(
            derivative(lambda delta: lemmon2000_air_d3Ar_ddelta3(.5, delta),
                       rat,
                       dx=rat * 1e-5), lemmon2000_air_d4Ar_ddelta4(.5, rat))
Beispiel #20
0
def test_lemmon2000_air_d2Ar_ddelta2():
    assert_close(lemmon2000_air_d2Ar_ddelta2(0.36842, 0.15880050154579475),
                 0.15165011962677075,
                 rtol=1e-13)

    for rat in (1000.0, 100.0, 10.0, 5.0, 3.0, 2.5, 2.0, 1.5, 1.0, .5, .2, .1,
                .01, .001):
        assert_close(
            derivative(lambda delta: lemmon2000_air_dAr_ddelta(.5, delta),
                       rat,
                       dx=rat * 1e-5), lemmon2000_air_d2Ar_ddelta2(.5, rat))
Beispiel #21
0
def test_lemmon2000_air_d4Ar_dtau4():
    assert_close(lemmon2000_air_d4Ar_dtau4(132.6312 / 200.0, 13000 / 10447.7),
                 -8.197368061417675,
                 rtol=1e-14)

    for rat in (1000.0, 100.0, 10.0, 5.0, 3.0, 2.5, 2.0, 1.5, 1.0, .5, .2, .1,
                .01, .001):
        assert_close(
            derivative(lambda tau: lemmon2000_air_d3Ar_dtau3(tau, .5),
                       rat,
                       dx=rat * 1e-5), lemmon2000_air_d4Ar_dtau4(rat, .5))
Beispiel #22
0
def test_lemmon2000_air_d3Ar_dtau3():
    assert_close(lemmon2000_air_d3Ar_dtau3(132.6312 / 200.0, 13000 / 10447.7),
                 0.27922007457420017,
                 rtol=1e-13)

    for rat in (1000.0, 100.0, 10.0, 5.0, 3.0, 2.5, 2.0, 1.5, 1.0, .5, .2, .1,
                .01, .001):
        assert_close(
            derivative(lambda tau: lemmon2000_air_d2Ar_dtau2(tau, .5),
                       rat,
                       dx=rat * 1e-5), lemmon2000_air_d3Ar_dtau3(rat, .5))
Beispiel #23
0
def test_lemmon2000_air_d2Ar_dtau2():
    assert_close(lemmon2000_air_d2Ar_dtau2(132.6312 / 200.0, 13000 / 10447.7),
                 -0.7632109061747537,
                 rtol=1e-14)

    for rat in (1000.0, 100.0, 10.0, 5.0, 3.0, 2.5, 2.0, 1.5, 1.0, .5, .2, .1,
                .01, .001):
        assert_close(
            derivative(lambda tau: lemmon2000_air_dAr_dtau(tau, .5),
                       rat,
                       dx=rat * 1e-5), lemmon2000_air_d2Ar_dtau2(rat, .5))
Beispiel #24
0
def test_lemmon2000_air_d3Ar_ddelta3():
    assert_close(lemmon2000_air_d3Ar_ddelta3(0.36842, 0.15880050154579475),
                 -0.09682239073996685,
                 rtol=1e-13)

    for rat in (1000.0, 100.0, 10.0, 5.0, 3.0, 2.5, 2.0, 1.5, 1.0, .5, .2, .1,
                .01, .001):
        assert_close(
            derivative(lambda delta: lemmon2000_air_d2Ar_ddelta2(.5, delta),
                       rat,
                       dx=rat * 1e-5), lemmon2000_air_d3Ar_ddelta3(.5, rat))
Beispiel #25
0
def test_lemmon2000_air_d3Ar_ddelta2dtau():
    assert_close(lemmon2000_air_d3Ar_ddelta2dtau(132.6312 / 200.0,
                                                 13000 / 10447.7),
                 0.014417881989408202,
                 rtol=1e-13)

    for rat in (1000.0, 100.0, 10.0, 5.0, 3.0, 2.5, 2.0, 1.5, 1.0, .5, .2, .1,
                .01, .001):
        assert_close(
            derivative(lambda tau: lemmon2000_air_d2Ar_ddelta2(tau, .5),
                       rat,
                       dx=rat * 1e-5),
            lemmon2000_air_d3Ar_ddelta2dtau(rat, .5))
Beispiel #26
0
def test_lemmon2000_air_d3Ar_ddeltadtau2():
    assert_close(lemmon2000_air_d3Ar_ddeltadtau2(132.6312 / 200.0,
                                                 13000 / 10447.7),
                 -0.19089212184849963,
                 rtol=1e-13)

    for rat in (1000.0, 100.0, 10.0, 5.0, 3.0, 2.5, 2.0, 1.5, 1.0, .5, .2, .1,
                .01, .001):
        assert_close(
            derivative(lambda tau: lemmon2000_air_d2Ar_ddeltadtau(tau, .5),
                       rat,
                       dx=rat * 1e-5),
            lemmon2000_air_d3Ar_ddeltadtau2(rat, .5))
Beispiel #27
0
def test_TEOS10_CAAW_derivatives():
    assert_close1d(TEOS10_CAAW_derivatives(200.0)[:3],
                   (1.05493575e-09, -1.525350000000001e-12, -1.13436375e-13),
                   rtol=1e-13)
    assert_close(derivative(lambda T: TEOS10_CAAW_derivatives(T)[-2],
                            200.0,
                            dx=200 * 1e-7),
                 TEOS10_CAAW_derivatives(200)[-1],
                 rtol=1e-8)
    assert_close1d(TEOS10_CAAW_derivatives(300.0),
                   (8.019777407407409e-10, -1.9610345679012353e-12,
                    1.700556378600824e-14, -1.0129827160493834e-16),
                   rtol=1e-13)
Beispiel #28
0
def test_lemmon2000_air_d3Ar_ddelta2dtau():
    assert_close(lemmon2000_air_d4Ar_ddelta2dtau2(132.6312 / 200.0,
                                                  13000 / 10447.7),
                 0.11968731127306076,
                 rtol=1e-13)

    for rat in (1000.0, 100.0, 10.0, 5.0, 3.0, 2.5, 2.0, 1.5, 1.0, .5, .2, .1,
                .01, .001):
        assert_close(
            derivative(lambda tau: lemmon2000_air_d3Ar_ddelta2dtau(tau, .5),
                       rat,
                       dx=rat * 1e-5),
            lemmon2000_air_d4Ar_ddelta2dtau2(rat, .5))
Beispiel #29
0
def test_lemmon2000_air_d4Ar_ddeltadtau3():
    assert_close(lemmon2000_air_d4Ar_ddeltadtau3(132.6312 / 200.0,
                                                 13000 / 10447.7),
                 2.077739387492131,
                 rtol=1e-13)

    for rat in (1000.0, 100.0, 10.0, 5.0, 3.0, 2.5, 2.0, 1.5, 1.0, .5, .2, .1,
                .01, .001):
        assert_close(
            derivative(lambda tau: lemmon2000_air_d3Ar_ddeltadtau2(tau, .5),
                       rat,
                       dx=rat * 1e-5),
            lemmon2000_air_d4Ar_ddeltadtau3(rat, .5))
Beispiel #30
0
def test_Antoine_AB_fit_extrapolate():
    T = 178.01
    Psat, dPsat_dT, d2Psat_dT2 = (0.03946094565666715, 0.006781441203850251, 0.0010801244983894853)
    
    A, B = (27.358925161569008, 5445.569591293226)
    C = 0.0
    assert_close(Psat, Antoine(T, A, B, C, base=e), rtol=1e-10)
    dPsat_dT_num = derivative(lambda T: Antoine(T, A, B, C, base=e), T, dx=T*1e-9)
    assert_close(dPsat_dT_num, dPsat_dT, rtol=1e-7)
    # d2Psat_dT2_num = derivative(lambda T: Antoine(T, A, B, C, base=e), T, dx=T*1e-7, n=2, order=13)
    
    d2Psat_dT2_analytical = B*(B/T - 2)*exp(A - B/T)/T**3
    
    # Second derivative does not match, but is similar - small jump
    assert_close(d2Psat_dT2, d2Psat_dT2_analytical, rtol=1e-2)