Exemple #1
0
def test_global_linear_nn_grand_potential_n():
    # E(N) =  0.0 - 0.7 * N, N <= 5
    # E(N) = -1.5 - 0.4 * N, N >= 5
    # build global tool
    model = LinearGlobalTool({5: -3.5, 6: -3.9, 4: -2.8})
    # check grand potential (as a function of N)
    assert_equal(model.grand_potential(None), None)
    assert_equal(model.grand_potential(5.), None)
    assert_almost_equal(model.grand_potential(5.1), -1.5, decimal=6)
    assert_almost_equal(model.grand_potential(6.0), -1.5, decimal=6)
    assert_almost_equal(model.grand_potential(4.1), 0.0, decimal=6)
    assert_almost_equal(model.grand_potential(3.9), 0.0, decimal=6)
    # check derivative of grand potential
    assert_almost_equal(model.grand_potential_derivative(5.0, 1),
                        -5.0,
                        decimal=6)
    assert_almost_equal(model.grand_potential_derivative(6.0, 1),
                        -6.0,
                        decimal=6)
    assert_almost_equal(model.grand_potential_derivative(4.0, 1),
                        -4.0,
                        decimal=6)
    assert_almost_equal(model.grand_potential_derivative(5.6, 1),
                        -5.6,
                        decimal=6)
    assert_almost_equal(model.grand_potential_derivative(3.3, 1),
                        -3.3,
                        decimal=6)
    assert_equal(model.grand_potential_derivative(5., 2), None)
    assert_equal(model.grand_potential_derivative(4., 3), None)
    assert_equal(model.grand_potential_derivative(5., 4), None)
    assert_equal(model.grand_potential_derivative(5.7, 5), None)
    assert_equal(model.grand_potential_derivative(4.2, 3), None)
    assert_equal(model.grand_potential_derivative(6.3, 2), None)
    assert_equal(model.grand_potential_derivative(3.6, 3), None)
    assert_equal(model.grand_potential_derivative(0.0, 4), None)
    assert_equal(model.grand_potential_derivative(None, 10), None)
Exemple #2
0
def test_global_linear_np_grand_potential_n():
    # E(N) = -1.0 - 0.5 * N, N <= 10
    # E(N) = -7.0 + 0.1 * N, N >= 10
    # build global tool
    model = LinearGlobalTool({10: -6.0, 11: -5.9, 9: -5.5})
    # check grand potential (as a function of N)
    assert_equal(model.grand_potential(None), None)
    assert_equal(model.grand_potential(10.), None)
    assert_almost_equal(model.grand_potential(9.), -1.0, decimal=6)
    assert_almost_equal(model.grand_potential(6.3), -1.0, decimal=6)
    assert_almost_equal(model.grand_potential(11.), -7.0, decimal=6)
    assert_almost_equal(model.grand_potential(10.1), -7.0, decimal=6)
    # check grand potential derivative (as a function of N)
    assert_almost_equal(model.grand_potential_derivative(9.3, 1),
                        -9.3,
                        decimal=6)
    assert_almost_equal(model.grand_potential_derivative(10.0, 1),
                        -10.,
                        decimal=6)
    assert_almost_equal(model.grand_potential_derivative(11.2, 1),
                        -11.2,
                        decimal=6)
    assert_almost_equal(model.grand_potential_derivative(10.7, 1),
                        -10.7,
                        decimal=6)
    assert_equal(model.grand_potential_derivative(10., 2), None)
    assert_equal(model.grand_potential_derivative(10., 3), None)
    assert_equal(model.grand_potential_derivative(10., 4), None)
    assert_equal(model.grand_potential_derivative(9.3, 2), None)
    assert_equal(model.grand_potential_derivative(8.2, 3), None)
    assert_equal(model.grand_potential_derivative(6.1, 4), None)
    assert_equal(model.grand_potential_derivative(9.8, 5), None)
    assert_equal(model.grand_potential_derivative(10.1, 10), None)
    assert_equal(model.grand_potential_derivative(11.5, 2), None)
    assert_equal(model.grand_potential_derivative(12.9, 3), None)
    assert_equal(model.grand_potential_derivative(0.0, 4), None)
    assert_equal(model.grand_potential_derivative(None, 10), None)