spin_m Module

This module defines the type 'spin', representing 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 to make 'spin' easily importable/exportable to real vectors.


Uses


Variables

Type Visibility Attributes Name Initial
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

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

    Calculate the inverse of the spin matrix.

    Arguments

    Type IntentOptional Attributes Name
    class(spin), intent(in) :: this

    Return Value type(spin)

public interface trace

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

    Calculate the trace of the spin matrix.

    Arguments

    Type IntentOptional Attributes Name
    class(spin), intent(in) :: this

    Return Value complex(kind=wp)

public interface sum

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

    Calculate the sum of an array of spin matrices.

    Arguments

    Type IntentOptional Attributes Name
    class(spin), intent(in) :: this(:)

    Return Value type(spin)

public interface conjg

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

    Calculate the complex conjugate of the spin matrix.

    Arguments

    Type IntentOptional Attributes Name
    class(spin), intent(in) :: this

    Return Value type(spin)

public interface norm2

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

    Calculate the Frobenius norm of the spin matrix.

    Arguments

    Type IntentOptional Attributes Name
    class(spin), intent(in) :: this

    Return Value real(kind=wp)


Derived Types

type, public ::  spin

Components

Type Visibility Attributes Name Initial
complex(kind=wp), public :: matrix(2,2) = 0.0_wp

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