Difference between revisions of "Operator.m"

From Spinach Documentation Wiki
Jump to: navigation, search
Line 7: Line 7:
  
 
==Arguments==
 
==Arguments==
−
The function supports three types of calls:
+
This function supports three types of calls:
  
−
1. If an operator is given as a single string and spins are named by passing a single string, ''e.g.''
+
1. If operators is a string and spins is a string, for example
  
−
    sum_Lz=operator(spin_system,'Lz','13C','comm','csc');
+
            operators='Lz'; spins='13C';
  
−
the function returns the sum of the corresponding single-spin superoperators on all spins with that name. In the example above, the sum of [Lz, ] commutation superoperators on all carbons in the system will be returned. Valid labels for operators in this type of call are 'E', 'Lz', 'L+', 'L-' and 'Tl,m'. Valid labels for spins are standard isotope names as well as 'electrons', 'nuclei' and 'all'.
+
the function returns the sum of the corresponding single-spin operators
 +
(Hilbert space) or superoperators (Liouville space) on all spins of that
 +
type. Valid labels for operators in this type of call are 'E' (identity),
 +
'Lz', ,'Lx', 'Ly', 'L+', 'L-', and 'Tl,m' (irreducible spherical tensor,
 +
l and m are integers). Valid labels for spins are standard isotope names
 +
as well as 'electrons', 'nuclei' and 'all'.
  
−
2. If one input is a string and the other is a vector, ''e.g.''
+
2. If operators is a string and spins is a vector, for example
  
−
    sum_Lz=operator(spin_system,'Lz',[1 2 4],'comm','csc');
+
                    operators='Lz'; spins=[1 2 4];
  
−
the function returns the sum of all single-spin superoperators for all spins with the specified numbers. In the example above, the sum of [Lz, ] commutation superoperators for spins 1, 2, and 4 will be returned. Valid labels for operators in this type of call are 'E', 'Lz', 'L+', 'L-', and 'Tl,m'. In the latter case, l and m are integers.
+
the function returns the sum of all single-spin operators (Hilbert space)
 +
or superoperators (Liouville space) for all spins with the specified num-
 +
bers. Valid labels for operators are the same as in Item 1 above.
  
−
3. If the operators are supplied as a cell array of strings and spins as a cell array of numbers, a product superoperator is produced, ''e.g.''
+
3. If operators is a cell array of strings and spins is a cell array of
 +
numbers, for example:
  
−
    LzSp=operator(spin_system,{'Lz','L+'},{1,2},'comm','csc');
+
                    operators={'Lz','L+'}; spins={1,2};
  
−
will return the [LzL+, ] commutation superoperator with Lz on spin 1 and L+ on spin 2. Valid labels for operators in the cell array are 'E', 'Lz', 'L+', 'L-' and 'Tl,m'. In the latter case, l and m are integers.
+
then a product operator (Hilbert space) or its commutation superoperator
 +
(Liouville space) is produced. In the case above, Spinach will generate
 +
LzS+ in Hilbert space or its specified superoperator in Liouville space.
 +
Valid labels for operators are the same as in Item 1 above.
  
 
In Liouville space calculations, operator_type can be set to:
 
In Liouville space calculations, operator_type can be set to:
Line 55: Line 66:
 
'''2. A sum of Lx on all 15N spins in the system'''
 
'''2. A sum of Lx on all 15N spins in the system'''
  
−
     Lx=(operator(spin_system,'L+','15N')+operator(spin_system,'L-','15N'))/2;
+
     Lx=operator(spin_system,'Lx','15N');
  
 
An operator will be generated in Hilbert space and a commutation superoperator in Liouville space.
 
An operator will be generated in Hilbert space and a commutation superoperator in Liouville space.
Line 61: Line 72:
 
'''3. AxBx between spin 2 and spin 5'''
 
'''3. AxBx between spin 2 and spin 5'''
  
−
Both components are Cartesian and must therefore be translated into the convention above:
+
     AxBx=operator(spin_system,{'Lx','Lx'},{2,5});
−
 
 
−
<center><math>\begin{matrix}
 
−
  {{{\hat{A}}}_{\text{X}}}=\frac{{{{\hat{A}}}_{+}}+{{{\hat{A}}}_{-}}}{2};\text{    }{{{\hat{B}}}_{\text{X}}}=\frac{{{{\hat{B}}}_{+}}+{{{\hat{B}}}_{-}}}{2} \\
 
−
  {{{\hat{A}}}_{\text{X}}}{{{\hat{B}}}_{\text{X}}}=\frac{1}{4}\left( {{{\hat{A}}}_{\text{+}}}{{{\hat{B}}}_{+}}+{{{\hat{A}}}_{+}}{{{\hat{B}}}_{-}}+{{{\hat{A}}}_{-}}{{{\hat{B}}}_{+}}+{{{\hat{A}}}_{-}}{{{\hat{B}}}_{-}} \right) \\
 
−
\end{matrix}</math></center>
 
−
 
 
−
The Spinach code would therefore be:
 
−
 
 
−
     AxBx=(operator(spin_system,{'L+','L+'},{2,5})+...
 
−
          operator(spin_system,{'L+','L-'},{2,5})+...
 
−
          operator(spin_system,{'L-','L+'},{2,5})+...
 
−
          operator(spin_system,{'L-','L-'},{2,5}))/4;
 
  
 
An operator will be generated in Hilbert space and a commutation superoperator in Liouville space.
 
An operator will be generated in Hilbert space and a commutation superoperator in Liouville space.
Line 88: Line 87:
 
==See also==
 
==See also==
 
[[unit_state.m]], [[unit_oper.m]], [[mprealloc.m]], [[singlet.m]], [[equilibrium.m]], [[state.m]]
 
[[unit_state.m]], [[unit_oper.m]], [[mprealloc.m]], [[singlet.m]], [[equilibrium.m]], [[state.m]]
 +
 +
[[Kernel_functions#Elementary_operators|Elementary operators]]
 +
 +
[[Kernel_functions#Elementary_states|Elementary states]]
  
  
−
''Version 2.2, authors: [[Ilya Kuprov]], [[Luke Edwards]], [[Dmitry Savostyanov]]''
+
''Version 2.8, authors: [[Ilya Kuprov]], [[Luke Edwards]], [[Dmitry Savostyanov]]''

Revision as of 14:42, 28 July 2023

Generates Hilbert space operators and Liouville space superoperators from their human-readable descriptions.

Syntax

    A=operator(spin_system,operators,spins,operator_type,format)

Arguments

This function supports three types of calls:

1. If operators is a string and spins is a string, for example

operators='Lz'; spins='13C';

the function returns the sum of the corresponding single-spin operators (Hilbert space) or superoperators (Liouville space) on all spins of that type. Valid labels for operators in this type of call are 'E' (identity), 'Lz', ,'Lx', 'Ly', 'L+', 'L-', and 'Tl,m' (irreducible spherical tensor, l and m are integers). Valid labels for spins are standard isotope names as well as 'electrons', 'nuclei' and 'all'.

2. If operators is a string and spins is a vector, for example

                    operators='Lz'; spins=[1 2 4];

the function returns the sum of all single-spin operators (Hilbert space) or superoperators (Liouville space) for all spins with the specified num- bers. Valid labels for operators are the same as in Item 1 above.

3. If operators is a cell array of strings and spins is a cell array of numbers, for example:

                    operators={'Lz','L+'}; spins={1,2};

then a product operator (Hilbert space) or its commutation superoperator (Liouville space) is produced. In the case above, Spinach will generate LzS+ in Hilbert space or its specified superoperator in Liouville space. Valid labels for operators are the same as in Item 1 above.

In Liouville space calculations, operator_type can be set to:

           'left' - produces left side product superoperator

          'right' - produces right side product superoperator

           'comm' - produces commutation superoperator (default)

          'acomm' - produces anticommutation superoperator

In Hilbert space calculations operator_type parameter is ignored, and the operator itself is always returned.

The format parameter refers to the format of the output: 'csc' returns a Matlab sparse matrix, 'xyz' returns a [rows, cols, vals] array.

Outputs

   A   - a CSC sparse (default) or a [rows, cols, vals] repre-
         sentation of a spin operator or superoperator.

Examples

1. L+ on spin 3

    Lp=operator(spin_system,{'L+'},{3});

An operator will be generated in Hilbert space and a commutation superoperator in Liouville space.

2. A sum of Lx on all 15N spins in the system

    Lx=operator(spin_system,'Lx','15N');

An operator will be generated in Hilbert space and a commutation superoperator in Liouville space.

3. AxBx between spin 2 and spin 5

    AxBx=operator(spin_system,{'Lx','Lx'},{2,5});

An operator will be generated in Hilbert space and a commutation superoperator in Liouville space.

Notes

WARNING: do not try to obtain product commutation superoperators by multiplying them up! It is easy to see that

\({{\hat{\hat{O}}}^{2}}=\left[ \hat{O},\left[ \hat{O},\_ \right] \right]\ne \left[ {{{\hat{O}}}^{2}},\_ \right]\)

If you require a commutation superoperator corresponding to a multi-spin operator, use the syntax given in Section 3 above.

See also

unit_state.m, unit_oper.m, mprealloc.m, singlet.m, equilibrium.m, state.m

Elementary operators

Elementary states


Version 2.8, authors: Ilya Kuprov, Luke Edwards, Dmitry Savostyanov