spin_m Module

This module defines the data type 'spin', which represents 2×2 complex matrices in spin space. The module overloads common arithmetic operators to work with the new data type, and defines and exports the Pauli matrices as constants. To make it easier to interact with common differential equation solvers, which often operate on real state vectors, the assignment operator is overloaded in such a way that 'spin' can be easily imported/exported to a real vector(8).


Uses


Contents


Variables

TypeVisibility AttributesNameInitial
type(spin), public, parameter:: pauli0 =spin(reshape([(1, 0), (0, 0), (0, 0), (1, 0)], [2, 2], order=[2, 1]))
type(spin), public, parameter:: pauli1 =spin(reshape([(0, 0), (1, 0), (1, 0), (0, 0)], [2, 2], order=[2, 1]))
type(spin), public, parameter:: pauli2 =spin(reshape([(0, 0), (0, -1), (0, 1), (0, 0)], [2, 2], order=[2, 1]))
type(spin), public, parameter:: pauli3 =spin(reshape([(1, 0), (0, 0), (0, 0), (-1, 0)], [2, 2], order=[2, 1]))
type(spin), public, parameter, dimension(0:3):: pauli =[pauli0, pauli1, pauli2, pauli3]

Interfaces

public interface inverse

Matrix inverse

  • private pure function spin_inv(this) result(r)

    Calculate the inverse of the spin matrix.

    Arguments

    Type IntentOptional AttributesName
    class(spin), intent(in) :: this

    Return Value type(spin)

public interface trace

Matrix trace

  • private pure elemental function spin_trace(this) result(r)

    Calculate the trace of the spin matrix.

    Arguments

    Type IntentOptional AttributesName
    class(spin), intent(in) :: this

    Return Value complex(kind=wp)

public interface sum

Matrix sum

  • private pure function spin_sum(this) result(r)

    Calculate the sum of an array of spin matrices.

    Arguments

    Type IntentOptional AttributesName
    class(spin), intent(in) :: this(:)

    Return Value type(spin)

public interface conjg

Complex conjugation

  • private pure elemental function spin_conjg(this) result(r)

    Calculate the complex conjugate of the spin matrix.

    Arguments

    Type IntentOptional AttributesName
    class(spin), intent(in) :: this

    Return Value type(spin)

public interface norm2

Matrix norm

  • private pure elemental function spin_norm(this) result(r)

    Calculate the Frobenius norm of the spin matrix.

    Arguments

    Type IntentOptional AttributesName
    class(spin), intent(in) :: this

    Return Value real(kind=wp)


Derived Types

type, public :: spin

Components

TypeVisibility AttributesNameInitial
complex(kind=wp), public :: matrix(2,2) =0.0_wp

Encapsulate a spin matrix

Type-Bound Procedures

generic, public :: spin => cons_rscalar, cons_cscalar, cons_cmatrix, cons_rvector, cons_spin
generic, public :: assignment(=) => assr_rscalar, assr_cscalar, assr_cmatrix, assr_rvector, assl_cmatrix, assl_rvector
generic, public :: operator(+) => addl_rscalar, addr_rscalar, addl_cscalar, addr_cscalar, addl_cmatrix, addr_cmatrix, add_spin
generic, public :: operator(-) => subl_rscalar, subr_rscalar, subl_cscalar, subr_cscalar, subl_cmatrix, subr_cmatrix, sub_spin
generic, public :: operator(*) => mull_rscalar, mulr_rscalar, mull_cscalar, mulr_cscalar, mull_cmatrix, mulr_cmatrix, mul_spin
generic, public :: operator(/) => divr_rscalar, divr_cscalar
generic, public :: operator(**) => expr_iscalar