Ejemplo n.º 1
0
def test_global_quadratic_nnp_grand_potential_mu():
    # E(N) = -9.0 + (-25.0)*N + N^2, N0=15
    _, deriv, grand = make_symbolic_quadratic_model(1.0, -25.0, -9.0)
    # build global tool
    model = QuadraticGlobalTool({15: -159.0, 16: -153.0, 14: -163.0})
    # check mu to N conversion
    assert_almost_equal(model.convert_mu_to_n(5.0), 15., decimal=6)
    assert_almost_equal(model.convert_mu_to_n(5.004), 15.002, decimal=6)
    assert_almost_equal(model.convert_mu_to_n(3.472), 14.236, decimal=6)
    assert_almost_equal(model.convert_mu_to_n(8.962), 16.981, decimal=6)
    # check grand potential (as a function of mu)
    assert_almost_equal(model.grand_potential_mu(deriv(15)),
                        grand(15),
                        decimal=6)
    assert_almost_equal(model.grand_potential_mu(deriv(14)),
                        grand(14),
                        decimal=6)
    assert_almost_equal(model.grand_potential_mu(deriv(16)),
                        grand(16),
                        decimal=6)
    assert_almost_equal(model.grand_potential_mu(deriv(13.7)),
                        grand(13.7),
                        decimal=6)
    assert_almost_equal(model.grand_potential_mu(deriv(14.8)),
                        grand(14.8),
                        decimal=6)
    assert_almost_equal(model.grand_potential_mu(deriv(12.3)),
                        grand(12.3),
                        decimal=6)
    assert_almost_equal(model.grand_potential_mu(deriv(11.4)),
                        grand(11.4),
                        decimal=6)
    assert_almost_equal(model.grand_potential_mu(deriv(15.05)),
                        grand(15.05),
                        decimal=6)
    # check grand potential derivative (as a function of mu)
    assert_almost_equal(model.grand_potential_mu_derivative(deriv(15.05), 1),
                        -15.05,
                        decimal=6)
    assert_almost_equal(model.grand_potential_mu_derivative(deriv(16.34), 1),
                        -16.34,
                        decimal=6)
    assert_almost_equal(model.grand_potential_mu_derivative(deriv(15.61), 2),
                        -0.5,
                        decimal=6)
    assert_almost_equal(model.grand_potential_mu_derivative(deriv(16.67), 2),
                        -0.5,
                        decimal=6)
    assert_almost_equal(model.grand_potential_mu_derivative(deriv(14.31), 3),
                        0.0,
                        decimal=6)
    assert_almost_equal(model.grand_potential_mu_derivative(deriv(12.67), 4),
                        0.0,
                        decimal=6)
Ejemplo n.º 2
0
def test_global_quadratic_n0p_grand_potential_mu():
    # E(N) = -100 + 5*N^2, N0=5
    _, deriv, grand = make_symbolic_quadratic_model(5.0, 0., -100.)
    # build global tool
    model = QuadraticGlobalTool({5: 25.0, 6: 80.0, 4: -20.0})
    # check mu to N conversion
    assert_almost_equal(model.convert_mu_to_n(50), 5., decimal=6)
    assert_almost_equal(model.convert_mu_to_n(34.6), 3.46, decimal=6)
    assert_almost_equal(model.convert_mu_to_n(69.8), 6.98, decimal=6)
    assert_almost_equal(model.convert_mu_to_n(100.0), 10., decimal=6)
    # check grand potential (as a function of mu)
    assert_almost_equal(model.grand_potential_mu(deriv(5.)),
                        grand(5.),
                        decimal=6)
    assert_almost_equal(model.grand_potential_mu(deriv(5.641)),
                        grand(5.641),
                        decimal=6)
    assert_almost_equal(model.grand_potential_mu(deriv(4.56)),
                        grand(4.56),
                        decimal=6)
    assert_almost_equal(model.grand_potential_mu(deriv(3.905)),
                        grand(3.905),
                        decimal=6)
    # check grand potential derivative (as a function of mu)
    assert_almost_equal(model.grand_potential_mu_derivative(deriv(5.81), 1),
                        -5.81,
                        decimal=6)
    assert_almost_equal(model.grand_potential_mu_derivative(deriv(4.341), 1),
                        -4.341,
                        decimal=6)
    assert_almost_equal(model.grand_potential_mu_derivative(deriv(6.452), 1),
                        -6.452,
                        decimal=6)
    assert_almost_equal(model.grand_potential_mu_derivative(deriv(3.678), 2),
                        -0.1,
                        decimal=6)
    assert_almost_equal(model.grand_potential_mu_derivative(deriv(4.341), 2),
                        -0.1,
                        decimal=6)
    assert_almost_equal(model.grand_potential_mu_derivative(deriv(2.001), 3),
                        0.,
                        decimal=6)
    assert_almost_equal(model.grand_potential_mu_derivative(deriv(5.456), 4),
                        0.,
                        decimal=6)
Ejemplo n.º 3
0
def test_global_quadratic_pnp_grand_potential_mu():
    # E(N) = 30.0 + (-6.0)*N + 3*N^2, N0=10
    _, deriv, grand = make_symbolic_quadratic_model(3.0, -6.0, 30.0)
    # build global tool
    model = QuadraticGlobalTool({5: 75.0, 6: 102.0, 4: 54.0})
    # check mu to N conversion
    assert_almost_equal(model.convert_mu_to_n(24.0), 5., decimal=6)
    assert_almost_equal(model.convert_mu_to_n(30.06), 6.01, decimal=6)
    assert_almost_equal(model.convert_mu_to_n(20.16), 4.36, decimal=6)
    assert_almost_equal(model.convert_mu_to_n(24.15), 5.025, decimal=6)
    # check grand potential (as a function of mu)
    assert_almost_equal(model.grand_potential_mu(deriv(5.15)),
                        grand(5.15),
                        decimal=6)
    assert_almost_equal(model.grand_potential_mu(deriv(3.2)),
                        grand(3.2),
                        decimal=6)
    assert_almost_equal(model.grand_potential_mu(deriv(7.67)),
                        grand(7.67),
                        decimal=6)
    assert_almost_equal(model.grand_potential_mu(deriv(5.15)),
                        grand(5.15),
                        decimal=6)
    assert_almost_equal(model.grand_potential_mu(deriv(6.31)),
                        grand(6.31),
                        decimal=6)
    # check grand potential derivative (as a function of mu)
    assert_almost_equal(model.grand_potential_mu_derivative(deriv(5.81), 1),
                        -5.81,
                        decimal=6)
    assert_almost_equal(model.grand_potential_mu_derivative(deriv(4.2), 1),
                        -4.2,
                        decimal=6)
    assert_almost_equal(model.grand_potential_mu_derivative(deriv(5.81), 2),
                        -1 / 6.,
                        decimal=6)
    assert_almost_equal(model.grand_potential_mu_derivative(deriv(4.89), 2),
                        -1 / 6.,
                        decimal=6)
    assert_almost_equal(model.grand_potential_mu_derivative(deriv(6.79), 3),
                        0.,
                        decimal=6)
    assert_almost_equal(model.grand_potential_mu_derivative(deriv(3.12), 4),
                        0.,
                        decimal=6)