Book Image

Mastering Python Scientific Computing

Book Image

Mastering Python Scientific Computing

Overview of this book

Table of Contents (17 chapters)
Mastering Python Scientific Computing
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

The physics module


The physics module contains functionality required to solve the problem from physics. There are several submodules of physics for performing activities related to vector physics, classic mechanics, quantum mechanics, optics, and much more.

Hydrogen wave functions

There are two functions under this category. The first one computes the energy of state (n, l) in Hartree atomic units. The other computes the relativistic energy of state (n, l, spin) in Hartree atomic units. The following program demonstrates the use of these functions:

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)

Matrices and Pauli algebra

There are several matrices related to physics that are available in physics.matrices module. The following program demonstrates how to...