def test_laguerre(): alpha = Symbol("alpha") # generalized Laguerre polynomials: assert laguerre_l(0, alpha, x) == 1 assert laguerre_l(1, alpha, x) == -x + alpha + 1 assert laguerre_l(2, alpha, x).expand() == (x**2 / 2 - (alpha + 2) * x + (alpha + 2) * (alpha + 1) / 2).expand() assert laguerre_l( 3, alpha, x).expand() == (-x**3 / 6 + (alpha + 3) * x**2 / 2 - (alpha + 2) * (alpha + 3) * x / 2 + (alpha + 1) * (alpha + 2) * (alpha + 3) / 6).expand() # Laguerre polynomials: assert laguerre_l(0, 0, x) == 1 assert laguerre_l(1, 0, x) == 1 - x assert laguerre_l(2, 0, x).expand() == 1 - 2 * x + x**2 / 2 assert laguerre_l(3, 0, x).expand() == 1 - 3 * x + 3 * x**2 / 2 - x**3 / 6 # Test the lowest 10 polynomials with laguerre_poly, to make sure that it # works: for i in range(10): assert laguerre_l(i, 0, x).expand() == laguerre_poly(i, x)
def test_laguerre(): alpha = Symbol("alpha") # generalized Laguerre polynomials: assert laguerre_l(0, alpha, x) == 1 assert laguerre_l(1, alpha, x) == -x + alpha + 1 assert laguerre_l(2, alpha, x).expand() == (x**2/2 - (alpha+2)*x + (alpha+2)*(alpha+1)/2).expand() assert laguerre_l(3, alpha, x).expand() == (-x**3/6 + (alpha+3)*x**2/2 - (alpha+2)*(alpha+3)*x/2 + (alpha+1)*(alpha+2)*(alpha+3)/6).expand() # Laguerre polynomials: assert laguerre_l(0, 0, x) == 1 assert laguerre_l(1, 0, x) == 1 - x assert laguerre_l(2, 0, x).expand() == 1 - 2*x + x**2/2 assert laguerre_l(3, 0, x).expand() == 1 - 3*x + 3*x**2/2 - x**3/6 # Test the lowest 10 polynomials with laguerre_poly, to make sure that it # works: for i in range(10): assert laguerre_l(i, 0, x).expand() == laguerre_poly(i, x)
def R_nl(n, l, r, Z=1): """ Returns the Hydrogen radial wavefunction R_{nl}. n, l .... quantum numbers 'n' and 'l' r .... radial coordinate Z .... atomic number (1 for Hydrogen, 2 for Helium, ...) Everything is in Hartree atomic units. Examples:: >>> from sympy.physics.hydrogen import R_nl >>> from sympy import var >>> var("r Z") (r, Z) >>> R_nl(1, 0, r, Z) 2*(Z**3)**(1/2)*exp(-Z*r) >>> R_nl(2, 0, r, Z) 2**(1/2)*(Z**3)**(1/2)*(2 - Z*r)*exp(-Z*r/2)/4 >>> R_nl(2, 1, r, Z) Z*r*6**(1/2)*(Z**3)**(1/2)*exp(-Z*r/2)/12 For Hydrogen atom, you can just use the default value of Z=1:: >>> R_nl(1, 0, r) 2*exp(-r) >>> R_nl(2, 0, r) 2**(1/2)*(2 - r)*exp(-r/2)/4 >>> R_nl(3, 0, r) 2*3**(1/2)*(3 - 2*r + 2*r**2/9)*exp(-r/3)/27 For Silver atom, you would use Z=47:: >>> R_nl(1, 0, r, Z=47) 94*47**(1/2)*exp(-47*r) >>> R_nl(2, 0, r, Z=47) 47*94**(1/2)*(2 - 47*r)*exp(-47*r/2)/4 >>> R_nl(3, 0, r, Z=47) 94*141**(1/2)*(3 - 94*r + 4418*r**2/9)*exp(-47*r/3)/27 The normalization of the radial wavefunction is:: >>> from sympy import integrate, oo >>> integrate(R_nl(1, 0, r)**2 * r**2, (r, 0, oo)) 1 >>> integrate(R_nl(2, 0, r)**2 * r**2, (r, 0, oo)) 1 >>> integrate(R_nl(2, 1, r)**2 * r**2, (r, 0, oo)) 1 It holds for any atomic number: >>> integrate(R_nl(1, 0, r, Z=2)**2 * r**2, (r, 0, oo)) 1 >>> integrate(R_nl(2, 0, r, Z=3)**2 * r**2, (r, 0, oo)) 1 >>> integrate(R_nl(2, 1, r, Z=4)**2 * r**2, (r, 0, oo)) 1 """ # sympify arguments n, l, r, Z = S(n), S(l), S(r), S(Z) # radial quantum number n_r = n - l - 1 # rescaled "r" a = 1 / Z # Bohr radius r0 = 2 * r / (n * a) # normalization coefficient C = sqrt((S(2) / (n * a)) ** 3 * factorial(n_r) / (2 * n * factorial(n + l))) # This is an equivalent normalization coefficient, that can be found in # some books. Both coefficients seem to be the same fast: # C = S(2)/n**2 * sqrt(1/a**3 * factorial(n_r) / (factorial(n+l))) return C * r0 ** l * laguerre_l(n_r, 2 * l + 1, r0).expand() * exp(-r0 / 2)
def R_nl(n, l, r, Z=1): """ Returns the Hydrogen radial wavefunction R_{nl}. n, l quantum numbers 'n' and 'l' r radial coordinate Z atomic number (1 for Hydrogen, 2 for Helium, ...) Everything is in Hartree atomic units. Examples ======== >>> from sympy.physics.hydrogen import R_nl >>> from sympy import var >>> var("r Z") (r, Z) >>> R_nl(1, 0, r, Z) 2*sqrt(Z**3)*exp(-Z*r) >>> R_nl(2, 0, r, Z) sqrt(2)*(-Z*r + 2)*sqrt(Z**3)*exp(-Z*r/2)/4 >>> R_nl(2, 1, r, Z) sqrt(6)*Z*r*sqrt(Z**3)*exp(-Z*r/2)/12 For Hydrogen atom, you can just use the default value of Z=1: >>> R_nl(1, 0, r) 2*exp(-r) >>> R_nl(2, 0, r) sqrt(2)*(-r + 2)*exp(-r/2)/4 >>> R_nl(3, 0, r) 2*sqrt(3)*(2*r**2/9 - 2*r + 3)*exp(-r/3)/27 For Silver atom, you would use Z=47: >>> R_nl(1, 0, r, Z=47) 94*sqrt(47)*exp(-47*r) >>> R_nl(2, 0, r, Z=47) 47*sqrt(94)*(-47*r + 2)*exp(-47*r/2)/4 >>> R_nl(3, 0, r, Z=47) 94*sqrt(141)*(4418*r**2/9 - 94*r + 3)*exp(-47*r/3)/27 The normalization of the radial wavefunction is: >>> from sympy import integrate, oo >>> integrate(R_nl(1, 0, r)**2 * r**2, (r, 0, oo)) 1 >>> integrate(R_nl(2, 0, r)**2 * r**2, (r, 0, oo)) 1 >>> integrate(R_nl(2, 1, r)**2 * r**2, (r, 0, oo)) 1 It holds for any atomic number: >>> integrate(R_nl(1, 0, r, Z=2)**2 * r**2, (r, 0, oo)) 1 >>> integrate(R_nl(2, 0, r, Z=3)**2 * r**2, (r, 0, oo)) 1 >>> integrate(R_nl(2, 1, r, Z=4)**2 * r**2, (r, 0, oo)) 1 """ # sympify arguments n, l, r, Z = S(n), S(l), S(r), S(Z) # radial quantum number n_r = n - l - 1 # rescaled "r" a = 1 / Z # Bohr radius r0 = 2 * r / (n * a) # normalization coefficient C = sqrt((S(2) / (n * a))**3 * factorial(n_r) / (2 * n * factorial(n + l))) # This is an equivalent normalization coefficient, that can be found in # some books. Both coefficients seem to be the same fast: # C = S(2)/n**2 * sqrt(1/a**3 * factorial(n_r) / (factorial(n+l))) return C * r0**l * laguerre_l(n_r, 2 * l + 1, r0).expand() * exp(-r0 / 2)