def test_hydrogen_energies():
    assert E_nl(n, Z) == -Z**2 / (2 * n**2)
    assert E_nl(n) == -1 / (2 * n**2)

    assert E_nl(1, 47) == -S(47)**2 / (2 * 1**2)
    assert E_nl(2, 47) == -S(47)**2 / (2 * 2**2)

    assert E_nl(1) == -S.One / (2 * 1**2)
    assert E_nl(2) == -S.One / (2 * 2**2)
    assert E_nl(3) == -S.One / (2 * 3**2)
    assert E_nl(4) == -S.One / (2 * 4**2)
    assert E_nl(100) == -S.One / (2 * 100**2)

    raises(ValueError, lambda: E_nl(0))
def test_hydrogen_energies():
    n = Symbol("n")
    assert E_nl(n, Z) == -Z**2 / (2 * n**2)
    assert E_nl(n) == -1 / (2 * n**2)

    assert E_nl(1, 47) == -S(47)**2 / (2 * 1**2)
    assert E_nl(2, 47) == -S(47)**2 / (2 * 2**2)

    assert E_nl(1) == -S(1) / (2 * 1**2)
    assert E_nl(2) == -S(1) / (2 * 2**2)
    assert E_nl(3) == -S(1) / (2 * 3**2)
    assert E_nl(4) == -S(1) / (2 * 4**2)
    assert E_nl(100) == -S(1) / (2 * 100**2)

    raises(ValueError, "E_nl(0)")
Beispiel #3
0
def print_exact_energies(N, l, Z):
    """
    Prints lowest N exact energies for the given "l" and "Z".
    """
    print "Z=%d" % Z
    print " n l      Schroed        Dirac (up)     Dirac (down)"
    print "-"*55
    for n in range(l+1, l+N+1):
        print "%2d %d %15.8f %15.8f" % (n, l, E_nl(n, Z=Z).n(),
                E_nl_dirac(n, l, Z=Z)),
        if l > 0:
            print "%15.8f" % E_nl_dirac(n, l, False, Z=Z)
        else:
            print
def test_hydrogen_energies_relat():
    # First test exact formulas for small "c" so that we get nice expressions:
    assert E_nl_dirac(2, 0, Z=1, c=1) == 1 / sqrt(2) - 1
    assert simplify(
        E_nl_dirac(2, 0, Z=1, c=2) -
        ((8 * sqrt(3) + 16) / sqrt(16 * sqrt(3) + 32) - 4)) == 0
    assert simplify(
        E_nl_dirac(2, 0, Z=1, c=3) -
        ((54 * sqrt(2) + 81) / sqrt(108 * sqrt(2) + 162) - 9)) == 0

    # Now test for almost the correct speed of light, without floating point
    # numbers:
    assert simplify(
        E_nl_dirac(2, 0, Z=1, c=137) -
        ((352275361 + 10285412 * sqrt(1173)) /
         sqrt(704550722 + 20570824 * sqrt(1173)) - 18769)) == 0
    assert simplify(
        E_nl_dirac(2, 0, Z=82, c=137) -
        ((352275361 + 2571353 * sqrt(12045)) /
         sqrt(704550722 + 5142706 * sqrt(12045)) - 18769)) == 0

    # Test using exact speed of light, and compare against the nonrelativistic
    # energies:
    for n in range(1, 5):
        for l in range(n):
            assert feq(E_nl_dirac(n, l), E_nl(n), 1e-5, 1e-5)
            if l > 0:
                assert feq(E_nl_dirac(n, l, False), E_nl(n), 1e-5, 1e-5)

    Z = 2
    for n in range(1, 5):
        for l in range(n):
            assert feq(E_nl_dirac(n, l, Z=Z), E_nl(n, Z), 1e-4, 1e-4)
            if l > 0:
                assert feq(E_nl_dirac(n, l, False, Z), E_nl(n, Z), 1e-4, 1e-4)

    Z = 3
    for n in range(1, 5):
        for l in range(n):
            assert feq(E_nl_dirac(n, l, Z=Z), E_nl(n, Z), 1e-3, 1e-3)
            if l > 0:
                assert feq(E_nl_dirac(n, l, False, Z), E_nl(n, Z), 1e-3, 1e-3)

    # Test the exceptions:
    raises(ValueError, lambda: E_nl_dirac(0, 0))
    raises(ValueError, lambda: E_nl_dirac(1, -1))
    raises(ValueError, lambda: E_nl_dirac(1, 0, False))
Beispiel #5
0
    li_sympy=-oo
    ls_sympy=oo
    # Límites del pozo definido de -oo a oo para scipy
    li_scipy=-inf
    ls_scipy=inf
        
if Problem=='Hydrogen atom (Helium correction)':
    if atomic_number.value=='1 (Show Hydrogen energies)':
        z=1
    if atomic_number.value=='2 (Correct Helium first energy)':
        z=2
    large=0
    omega=0
    
    # Energías del átomo hidrogenoide
    En=z*E_nl(n,z)
    
    # Funciones de onda del átomo de hidrógeno
    # Número cuántico l=0
    q=0 # La variable l ya esta siendo utilizada para el largo de la caja por ello se sustituyo por q
    Psin=(R_nl(n,q,r1,z)*R_nl(n,q,r2,z))
    
     # Límites del átomo de hidrógeno de 0 a oo para sympy
    li_sympy=0
    ls_sympy=oo
    # Límites del átomo de hidrógeno de 0 a oo para scipy
    li_scipy=0
    ls_scipy=inf


# Para sistemas no degenerados, la corrección a la energía a primer orden se calcula como 
Beispiel #6
0
from sympy.physics.hydrogen import E_nl, E_nl_dirac, R_nl
from sympy import var

var("n Z")
var("r Z")
var("n l")

E_nl(n, Z)
E_nl(1)
E_nl(2, 4)

E_nl(n, l)
E_nl_dirac(5, 2)  # l should be less than n
E_nl_dirac(2, 1)
E_nl_dirac(3, 2, False)

R_nl(5, 0, r)  # z = 1 by default
R_nl(5, 0, r, 1)