learn-physics-0.6.2: Haskell code for learning physics

Copyright(c) Scott N. Walck 2016-2018
LicenseBSD3 (see LICENSE)
MaintainerScott N. Walck <walck@lvc.edu>
Stabilityexperimental
Safe HaskellSafe
LanguageHaskell98

Physics.Learn.Ket

Contents

Description

This module contains ket vectors, bra vectors, and operators for quantum mechanics.

Synopsis

Basic data types

type C = Complex Double #

i :: C Source #

data Ket Source #

A ket vector describes the state of a quantum system.

Instances

Num Ket Source # 

Methods

(+) :: Ket -> Ket -> Ket #

(-) :: Ket -> Ket -> Ket #

(*) :: Ket -> Ket -> Ket #

negate :: Ket -> Ket #

abs :: Ket -> Ket #

signum :: Ket -> Ket #

fromInteger :: Integer -> Ket #

Show Ket Source # 

Methods

showsPrec :: Int -> Ket -> ShowS #

show :: Ket -> String #

showList :: [Ket] -> ShowS #

Kron Ket Source # 

Methods

kron :: Ket -> Ket -> Ket Source #

HasNorm Ket Source # 
Dagger Bra Ket Source # 

Methods

dagger :: Bra -> Ket Source #

Dagger Ket Bra Source # 

Methods

dagger :: Ket -> Bra Source #

Mult C Ket Ket Source # 

Methods

(<>) :: C -> Ket -> Ket Source #

Mult Bra Ket C Source # 

Methods

(<>) :: Bra -> Ket -> C Source #

Mult Operator Ket Ket Source # 

Methods

(<>) :: Operator -> Ket -> Ket Source #

Mult Ket C Ket Source # 

Methods

(<>) :: Ket -> C -> Ket Source #

Mult Ket Bra Operator Source # 

Methods

(<>) :: Ket -> Bra -> Operator Source #

Representable Ket (Vector C) Source # 

data Bra Source #

A bra vector describes the state of a quantum system.

Instances

Num Bra Source # 

Methods

(+) :: Bra -> Bra -> Bra #

(-) :: Bra -> Bra -> Bra #

(*) :: Bra -> Bra -> Bra #

negate :: Bra -> Bra #

abs :: Bra -> Bra #

signum :: Bra -> Bra #

fromInteger :: Integer -> Bra #

Show Bra Source # 

Methods

showsPrec :: Int -> Bra -> ShowS #

show :: Bra -> String #

showList :: [Bra] -> ShowS #

Kron Bra Source # 

Methods

kron :: Bra -> Bra -> Bra Source #

HasNorm Bra Source # 
Dagger Bra Ket Source # 

Methods

dagger :: Bra -> Ket Source #

Dagger Ket Bra Source # 

Methods

dagger :: Ket -> Bra Source #

Mult C Bra Bra Source # 

Methods

(<>) :: C -> Bra -> Bra Source #

Mult Bra C Bra Source # 

Methods

(<>) :: Bra -> C -> Bra Source #

Mult Bra Operator Bra Source # 

Methods

(<>) :: Bra -> Operator -> Bra Source #

Mult Bra Ket C Source # 

Methods

(<>) :: Bra -> Ket -> C Source #

Mult Ket Bra Operator Source # 

Methods

(<>) :: Ket -> Bra -> Operator Source #

Representable Bra (Vector C) Source # 

Kets for spin-1/2 particles

xp :: Ket Source #

State of a spin-1/2 particle if measurement in the x-direction would give angular momentum +hbar/2.

xm :: Ket Source #

State of a spin-1/2 particle if measurement in the x-direction would give angular momentum -hbar/2.

yp :: Ket Source #

State of a spin-1/2 particle if measurement in the y-direction would give angular momentum +hbar/2.

ym :: Ket Source #

State of a spin-1/2 particle if measurement in the y-direction would give angular momentum -hbar/2.

zp :: Ket Source #

State of a spin-1/2 particle if measurement in the z-direction would give angular momentum +hbar/2.

zm :: Ket Source #

State of a spin-1/2 particle if measurement in the z-direction would give angular momentum -hbar/2.

np :: Double -> Double -> Ket Source #

State of a spin-1/2 particle if measurement in the n-direction, described by spherical polar angle theta and azimuthal angle phi, would give angular momentum +hbar/2.

nm :: Double -> Double -> Ket Source #

State of a spin-1/2 particle if measurement in the n-direction, described by spherical polar angle theta and azimuthal angle phi, would give angular momentum -hbar/2.

Operators for spin-1/2 particles

sx :: Operator Source #

The Pauli X operator.

sy :: Operator Source #

The Pauli Y operator.

sz :: Operator Source #

The Pauli Z operator.

sn :: Double -> Double -> Operator Source #

Pauli operator for an arbitrary direction given by spherical coordinates theta and phi.

sn' :: Double -> Double -> Operator Source #

Alternative definition of Pauli operator for an arbitrary direction.

Quantum Dynamics

timeEvOp :: Double -> Operator -> Operator Source #

Given a time step and a Hamiltonian operator, produce a unitary time evolution operator. Unless you really need the time evolution operator, it is better to use timeEv, which gives the same numerical results without doing an explicit matrix inversion. The function assumes hbar = 1.

timeEv :: Double -> Operator -> Ket -> Ket Source #

Given a time step and a Hamiltonian operator, advance the state ket using the Schrodinger equation. This method should be faster than using timeEvOp since it solves a linear system rather than calculating an inverse matrix. The function assumes hbar = 1.

Composition

class Kron a where Source #

Minimal complete definition

kron

Methods

kron :: a -> a -> a Source #

Instances

Measurement

possibleOutcomes :: Operator -> [Double] Source #

The possible outcomes of a measurement of an observable. These are the eigenvalues of the operator of the observable.

outcomesProjectors :: Operator -> [(Double, Operator)] Source #

Given an obervable, return a list of pairs of possible outcomes and projectors for each outcome.

outcomesProbabilities :: Operator -> Ket -> [(Double, Double)] Source #

Given an observable and a state ket, return a list of pairs of possible outcomes and probabilites for each outcome.

Generic multiplication

class Mult a b c | a b -> c where Source #

Generic multiplication including inner product, outer product, operator product, and whatever else makes sense. No conjugation takes place in this operation.

Minimal complete definition

(<>)

Methods

(<>) :: a -> b -> c infixl 7 Source #

Adjoint operation

class Dagger a b | a -> b where Source #

The adjoint operation on complex numbers, kets, bras, and operators.

Minimal complete definition

dagger

Methods

dagger :: a -> b Source #

Normalization

class HasNorm a where Source #

Minimal complete definition

norm, normalize

Methods

norm :: a -> Double Source #

normalize :: a -> a Source #

Representation

class Representable a b | a -> b where Source #

Minimal complete definition

rep, dim

Methods

rep :: OrthonormalBasis -> a -> b Source #

dim :: a -> Int Source #

Orthonormal bases

makeOB :: [Ket] -> OrthonormalBasis Source #

Make an orthonormal basis from a list of linearly independent kets.

Orthonormal bases for spin-1/2 particles

xBasis :: OrthonormalBasis Source #

The orthonormal basis composed of xp and xm.

yBasis :: OrthonormalBasis Source #

The orthonormal basis composed of yp and ym.

zBasis :: OrthonormalBasis Source #

The orthonormal basis composed of zp and zm.

nBasis :: Double -> Double -> OrthonormalBasis Source #

Given spherical polar angle theta and azimuthal angle phi, the orthonormal basis composed of np theta phi and nm theta phi.