def test_global_quadratic_n0p_grand_potential_n(): # E(N) = -100 + 5*N^2, N0=5 _, _, grand = make_symbolic_quadratic_model(5.0, 0., -100.) # build global tool model = QuadraticGlobalTool({5: 25.0, 6: 80.0, 4: -20.0}) # check grand potential (as a function of N) assert_almost_equal(model.grand_potential(5.), grand(5.), decimal=6) assert_almost_equal(model.grand_potential(4.), grand(4.), decimal=6) assert_almost_equal(model.grand_potential(6.), grand(6.), decimal=6) assert_almost_equal(model.grand_potential(4.678), grand(4.678), decimal=6) assert_almost_equal(model.grand_potential(6.123), grand(6.123), decimal=6) # check grand potential derivative (as a function of N) assert_almost_equal(model.grand_potential_derivative(5.), -5, decimal=6) assert_almost_equal(model.grand_potential_derivative(4., 1), -4, decimal=6) assert_almost_equal(model.grand_potential_derivative(6.), -6, decimal=6) assert_almost_equal(model.grand_potential_derivative(5.6001), -5.6001, decimal=6) assert_almost_equal(model.grand_potential_derivative(4.145, 1), -4.145, decimal=6) assert_almost_equal(model.grand_potential_derivative(5., 2), -0.1, decimal=6) assert_almost_equal(model.grand_potential_derivative(7.001, 2), -0.1, decimal=6) assert_almost_equal(model.grand_potential_derivative(5., 3), 0., decimal=6) assert_almost_equal(model.grand_potential_derivative(1.25, 4), 0., decimal=6) assert_almost_equal(model.grand_potential_derivative(6.5, 5), 0., decimal=6)
def test_global_quadratic_pnp_grand_potential_n(): # E(N) = 30.0 + (-6.0)*N + 3*N^2, N0=10 _, _, 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 grand potential (as a function of N) assert_almost_equal(model.grand_potential(5.), grand(5.), decimal=6) assert_almost_equal(model.grand_potential(5.75), grand(5.75), decimal=6) assert_almost_equal(model.grand_potential(6.3), grand(6.3), decimal=6) assert_almost_equal(model.grand_potential(4.21), grand(4.21), decimal=6) assert_almost_equal(model.grand_potential(10.), grand(10.), decimal=6) assert_almost_equal(model.grand_potential(15.6), grand(15.6), decimal=6) # check grand potential derivative (as a function of N) assert_almost_equal(model.grand_potential_derivative(4.), -4, decimal=6) assert_almost_equal(model.grand_potential_derivative(5.), -5, decimal=6) assert_almost_equal(model.grand_potential_derivative(6., 1), -6, decimal=6) assert_almost_equal(model.grand_potential_derivative(3.0123), -3.0123, decimal=6) assert_almost_equal(model.grand_potential_derivative(7.2, 1), -7.2, decimal=6) assert_almost_equal(model.grand_potential_derivative(8.1, 2), -1 / 6., decimal=6) assert_almost_equal(model.grand_potential_derivative(6.12, 2), -1 / 6., decimal=6) assert_almost_equal(model.grand_potential_derivative(5.1, 3), 0., decimal=6) assert_almost_equal(model.grand_potential_derivative(6.3, 4), 0., decimal=6) assert_almost_equal(model.grand_potential_derivative(7.45, 5), 0., decimal=6)
def test_global_quadratic_nnp_grand_potential_n(): # E(N) = -9.0 + (-25.0)*N + N^2, N0=15 _, _, 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 grand potential (as a function of N) assert_almost_equal(model.grand_potential(15), grand(15), decimal=6) assert_almost_equal(model.grand_potential(14), grand(14), decimal=6) assert_almost_equal(model.grand_potential(16.), grand(16.), decimal=6) assert_almost_equal(model.grand_potential(15.2), grand(15.2), decimal=6) assert_almost_equal(model.grand_potential(14.62), grand(14.62), decimal=6) assert_almost_equal(model.grand_potential(11.5), grand(11.5), decimal=6) # check grand potential derivative (as a function of N) assert_almost_equal(model.grand_potential_derivative(14.), -14, decimal=6) assert_almost_equal(model.grand_potential_derivative(15.), -15, decimal=6) assert_almost_equal(model.grand_potential_derivative(16.), -16, decimal=6) assert_almost_equal(model.grand_potential_derivative(15.001), -15.001, decimal=6) assert_almost_equal(model.grand_potential_derivative(14.67), -14.67, decimal=6) assert_almost_equal(model.grand_potential_derivative(16.91), -16.91, decimal=6) assert_almost_equal(model.grand_potential_derivative(model.n0, 1), -15, decimal=6) assert_almost_equal(model.grand_potential_derivative(16., 1), -16., decimal=6) assert_almost_equal(model.grand_potential_derivative(17.125, 1), -17.125, decimal=6) assert_almost_equal(model.grand_potential_derivative(model.n0, 2), -0.5, decimal=6) assert_almost_equal(model.grand_potential_derivative(15.89, 2), -0.5, decimal=6) assert_almost_equal(model.grand_potential_derivative(14.03, 2), -0.5, decimal=6) assert_almost_equal(model.grand_potential_derivative(16.51, 2), -0.5, decimal=6) assert_almost_equal(model.grand_potential_derivative(model.n0, 3), 0.0, decimal=6) assert_almost_equal(model.grand_potential_derivative(15, 4), 0.0, decimal=6) assert_almost_equal(model.grand_potential_derivative(17.5, 5), 0.0, decimal=6)