learn-physics-0.6.2: Haskell code for learning physics

Copyright (c) Scott N. Walck 2016-2018 BSD3 (see LICENSE) Scott N. Walck experimental Safe Haskell98

Physics.Learn.Ket

Description

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

Synopsis

Basic data types

type C = Complex Double #

data Ket Source #

A ket vector describes the state of a quantum system.

Instances

 Source # Methods(+) :: Ket -> Ket -> Ket #(-) :: Ket -> Ket -> Ket #(*) :: Ket -> Ket -> Ket #negate :: Ket -> Ket #abs :: Ket -> Ket #signum :: Ket -> Ket # Source # MethodsshowsPrec :: Int -> Ket -> ShowS #show :: Ket -> String #showList :: [Ket] -> ShowS # Source # Methodskron :: Ket -> Ket -> Ket Source # Source # Methods Source # Methods Source # Methods Source # Methods(<>) :: C -> Ket -> Ket Source # Source # Methods(<>) :: Bra -> Ket -> C Source # Source # Methods Source # Methods(<>) :: Ket -> C -> Ket Source # Source # Methods Source # Methodsdim :: Ket -> Int Source #

data Bra Source #

A bra vector describes the state of a quantum system.

Instances

 Source # Methods(+) :: Bra -> Bra -> Bra #(-) :: Bra -> Bra -> Bra #(*) :: Bra -> Bra -> Bra #negate :: Bra -> Bra #abs :: Bra -> Bra #signum :: Bra -> Bra # Source # MethodsshowsPrec :: Int -> Bra -> ShowS #show :: Bra -> String #showList :: [Bra] -> ShowS # Source # Methodskron :: Bra -> Bra -> Bra Source # Source # Methods Source # Methods Source # Methods Source # Methods(<>) :: C -> Bra -> Bra Source # Source # Methods(<>) :: Bra -> C -> Bra Source # Source # Methods Source # Methods(<>) :: Bra -> Ket -> C Source # Source # Methods Source # Methodsdim :: Bra -> Int Source #

data Operator Source #

An operator describes an observable (a Hermitian operator) or an action (a unitary operator).

Instances

 Source # Methods Source # MethodsshowList :: [Operator] -> ShowS # Source # Methods Source # Methods Source # Methods Source # Methods Source # Methods Source # Methods Source # Methods Source # Methods Source # Methods

Kets for spin-1/2 particles

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

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

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

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

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

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

The Pauli X operator.

The Pauli Y operator.

The Pauli Z operator.

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

Alternative definition of Pauli operator for an arbitrary direction.

Quantum Dynamics

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.

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

 Source # Methodskron :: Bra -> Bra -> Bra Source # Source # Methods Source # Methodskron :: Ket -> Ket -> Ket Source #

Measurement

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

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

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 #

Instances

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

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 #

Instances

 Source # Methodsdagger :: C -> C Source # Source # Methods Source # Methods Source # Methods

Normalization

class HasNorm a where Source #

Minimal complete definition

Methods

norm :: a -> Double Source #

normalize :: a -> a Source #

Instances

 Source # Methods Source # Methods

Representation

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

Minimal complete definition

Methods

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

dim :: a -> Int Source #

Instances

 Source # Methodsdim :: Bra -> Int Source # Source # Methods Source # Methodsdim :: Ket -> Int Source #

Orthonormal bases

An orthonormal basis of kets.

Instances

 Source # MethodsshowList :: [OrthonormalBasis] -> ShowS #

makeOB :: [Ket] -> OrthonormalBasis Source #

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

Orthonormal bases for spin-1/2 particles

The orthonormal basis composed of xp and xm.

The orthonormal basis composed of yp and ym.

The orthonormal basis composed of zp and zm.

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