Tensor Network Theory Library  Beta release 1.2.1
A library of routines for performing TNT-based operations
 All Data Structures Functions Variables Groups Pages
tntMatSpinOps.m
1 
2 %======================================================================
3 %> @ingroup matscripts
4 %> Creates matrices for N-species spin operators. These matrices can then be used to build Hamiltonian terms
5 %> If you wish to turn these matrices into nodes that can be loaded into the library use tntMatCreateOpArray().
6 %>
7 %> Returns the result in a cell having a number of elements equal to the
8 %> number of species.
9 %> i.e. sx{1}, sy{1} and sz{1} will be the operators for the first species and
10 %> sx{2}, sy{2} and sz{2} will be the operators for the second species etc.
11 %>
12 %> @param s Required spin
13 %> @param N The number of species
14 %>
15 %> @retval sx A cell, each entry containing the matrix representing \f$\hat{S}^x\f$ for a given species.
16 %> @retval sy A cell, each entry containing the matrix representing \f$\hat{S}^y\f$ for a given species.
17 %> @retval sz A cell, each entry containing the matrix representing \f$\hat{S}^z\f$ for a given species.
18 %> @retval sp A cell, each entry containing the matrix representing \f$\hat{S}^p\f$ for a given species.
19 %> @retval sm A cell, each entry containing the matrix representing \f$\hat{S}^m\f$ for a given species.
20 %======================================================================
21 
22 function [sx,sy,sz,sp,sm] = tntMatSpinOps(s,N)
23 %% tntMatBosonOps Creates N-species spin operators with a spin given by TwoS
24 
25 % z component of spin
26 m = s:-1:-s;
27 
28 % Build sparse matrix version of basic spin operators :
29 sz = diag(m);
30 sp = diag(sqrt((s-m(2:end)).*(s+m(2:end)+1)),1);
31 sm = diag(sqrt((s+m(1:(end-1))).*(s-m(1:(end-1))+1)),-1);
32 
33 sx = 0.5*(sp+sm);
34 sy = -0.5*1i*(sp-sm);
35 
36 % Construct spin operators for each spin in the full Hilbert space :
37 sx = tntMatExpandBasis(sx,N);
38 sy = tntMatExpandBasis(sy,N);
39 sz = tntMatExpandBasis(sz,N);
40 sp = tntMatExpandBasis(sp,N);
41 sm = tntMatExpandBasis(sm,N);
function tntMatSpinOps(in s, in N)
function tntMatBosonOps(in nmax, in N)
function tntMatCreateOpArray(in ops)
function tntMatExpandBasis(in ssop, in N)