Difference between revisions of "Operator.m"

From Spinach Documentation Wiki
Jump to: navigation, search
(→‎See also)
(sync with Spinach main f053e432: central transition operator labels, op_cache note)
 
(24 intermediate revisions by 2 users not shown)
Line 1: Line 1:
−
Generates Hilbert space operators and Liouville space superoperators from their human-readable descriptions. Syntax:
+
{{DISPLAYTITLE:operator.m}} __NOTOC__
 +
Generates Hilbert space operators and Liouville space superoperators from their human-readable descriptions.
  
−
    A=operator(spin_system,operators,spins,operator_type)
+
==Syntax==
  
−
The function supports two types of calls:
+
    A=operator(spin_system,operators,spins,operator_type,format)
  
−
1. If an operator is given as a single string and spins are named by passing a single string, e.g.
+
==Parameters==
 +
This function supports three types of calls:
  
−
    sum_Lz=operator(spin_system,'Lz','13C');
+
'''1. If operators is a string and spins is a string'''
  
−
then the function returns the sum of the corresponding single-spin operators (in Hilbert space) or superoperators (in Liouville space) on all spins with that name. Valid labels for operators in this type of call are
+
                    operators='Lz'; spins='13C';
  
−
    'E', 'Lz', 'L+', 'L-', 'Tl,m'
+
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 states in this type of call are 'E' (identity), 'Lz', 'Lx', 'Ly', 'L+', 'L-', 'Tl,m' (irreducible spherical tensor, l and m are integers), 'CTx', 'CTy', 'CTz', 'CT+', 'CT-' (central transition operators in the Zeeman basis). Valid labels for spins are standard isotope names, as well as 'electrons', 'nuclei', and 'all'.
  
−
where l and m are integers. In the latter case a spherical tensor operator or superoperator is returned. Valid labels for spins are standard isotope names as well as
+
'''2. If operators is a string and spins is a vector'''
  
−
    'electrons', 'nuclei', 'all'
+
                    operators='Lz'; spins=[1 2 4];
  
−
2. If the operators are supplied as a cell array of strings and spins as a cell array of numbers, a product operator (in Hilbert space) or superoperator (in Liouville space) is produced, e.g.
+
the function returns the sum of all single-spin  operators (Hilbert space) or superoperators (Liouville space) for all spins with the specified numbers. Valid labels for operators are the same as in Item 1 above.
  
−
    LzSp=operator(spin_system,{'Lz','L+'},{1,2});
+
'''3. If operators is a cell array of strings and spins is a cell array of numbers'''
  
−
will return LzL+ operator in Hilbert space and [LzL+,_] commutation superoperator in Liouville space, with Lz on spin 1 and L+ on spin 2. Valid labels for operators in the cell array are
+
                    operators={'Lz','L+'}; spins={1,2};
  
−
    'E', 'Lz', 'L+', 'L-', 'Tl,m'
+
then a product operator (Hilbert space) or its 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.
  
−
where l and m are integers. In the latter case a spherical tensor operator or superoperator is included into the product.
+
Bosonic modes - cavities, phonon modes, and transmons - have their own operator labels: 'E' (identity), 'C' (creation), 'A' (annihilation), 'N' (population number), products such as 'CCAA', and 'BL#' for the projector onto the #-th Fock level, counted from 1, so that 'BL1' is the vacuum. These may be mixed with spin labels in product operator calls, for example operators={'L+','A'}; spins={1,2} builds one of the two flip-flop terms of a Jaynes-Cummings coupling.
  
 
In Liouville space calculations, operator_type can be set to:
 
In Liouville space calculations, operator_type can be set to:
  
−
                  'left' - produces left side product superoperator
+
            'left' - produces left side product superoperator
 +
 +
          'right' - produces right side product superoperator
 +
 +
            'comm' - produces commutation superoperator (default)
 +
 +
          'acomm' - produces anticommutation superoperator
  
−
                'right' - produces right side product superoperator
+
In Hilbert space calculations operator_type parameter is ignored, and the operator itself is always returned.
  
−
                  'comm' - produces commutation superoperator (default)
+
The format parameter refers to the format of the output:
  
−
                'acomm' - produces anticommutation superoperator
+
            'csc' - returns a Matlab sparse matrix
 +
 +
            'xyz' - returns a [rows, cols, vals] array
  
−
In Hilbert space calculations operator_type parameter is not permitted.
+
==Outputs==
  
−
'''WARNING''': do not try to obtain product commutation superoperators by multiplying them up! It is easy to see that
+
    A  - a CSC sparse (default) or a [rows, cols, vals] repre-
−
 
+
          sentation of a spin operator or superoperator.
−
<center>
 
−
<math>{{\hat{\hat{O}}}^{2}}=\left[ \hat{O},\left[ \hat{O},\_ \right] \right]\ne \left[ {{{\hat{O}}}^{2}},\_ \right]</math>
 
−
</center>
 
−
 
 
−
If you require a commutation superoperator corresponding to a multi-spin operator, use the syntax given in the Section 2 above.
 
  
 
==Examples==
 
==Examples==
Line 51: Line 56:
  
 
     Lp=operator(spin_system,{'L+'},{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'''
 
'''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.
+
'''3. AxBx between spin 2 and spin 5'''
  
−
'''3. AxBx between spin 2 and spin 5'''
+
    AxBx=operator(spin_system,{'Lx','Lx'},{2,5});
  
−
Both components are Cartesian and must therefore be translated into the convention above:
+
Operators will be generated in Hilbert space and superoperators in Liouville space.
  
−
<center><math>\begin{matrix}
+
==Notes==
−
  {{{\hat{A}}}_{\text{X}}}=\frac{{{{\hat{A}}}_{+}}+{{{\hat{A}}}_{-}}}{2};\text{    }{{{\hat{B}}}_{\text{X}}}=\frac{{{{\hat{B}}}_{+}}+{{{\hat{B}}}_{-}}}{2} \\
+
'''WARNING''': do not try to obtain product commutation superoperators by multiplying up single-spin commutation superoperators. It is easy to see that
−
  {{{\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:
+
<center>
 +
<math>{{\hat{\hat{O}}}^{2}}=\left[ \hat{O},\left[ \hat{O},\_ \right] \right]\ne \left[ {{{\hat{O}}}^{2}},\_ \right]</math>
 +
</center>
  
−
    AxBx=(operator(spin_system,{'L+','L+'},{2,5})+...
+
If you require a commutation superoperator corresponding to a multi-spin operator, use the syntax given in Section 3 above.
−
          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.
+
Operator caching is supported, add 'op_cache' to sys.enable array to enable; make sure your scratch storage is fast.
  
 
==See also==
 
==See also==
 +
[[unit_state.m]], [[unit_oper.m]], [[mprealloc.m]], [[singlet.m]], [[equilibrium.m]], [[state.m]], [[human2opspec.m]], [[bos2ist.m]], [[boson_mono.m]], [[boson_ortho.m]], [[centrans.m]], [[ct2ist.m]], [[enlev2bm.m]], [[enlev2ist.m]], [[hamiltonian.m]], [[kinetics.m]], [[lindbladian.m]], [[oper2bm.m]], [[oper2ist.m]], [[orientation.m]], [[propagator.m]], [[relaxation.m]], [[sin_tran.m]], [[weyl.m]], [[coherent.m]], [[device.m]], [[Kernel_functions]]
  
−
[[unit_state.m]], [[unit_oper.m]], [[mprealloc.m]], [[singlet.m]], [[equilibrium.m]]
+
''Version 2.8, authors: [[Ilya Kuprov]], [[Luke Edwards]], [[Dmitry Savostyanov]]''
−
 
 
−
 
 
−
''Version 1.9, authors: [[Ilya Kuprov]], [[Luke Edwards]], [[Dmitry Savostyanov]]''
 

Latest revision as of 07:04, 30 August 2026

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

Syntax

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

Parameters

This function supports three types of calls:

1. If operators is a string and spins is a string

                    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 states in this type of call are 'E' (identity), 'Lz', 'Lx', 'Ly', 'L+', 'L-', 'Tl,m' (irreducible spherical tensor, l and m are integers), 'CTx', 'CTy', 'CTz', 'CT+', 'CT-' (central transition operators in the Zeeman basis). 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

                    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 numbers. 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

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

then a product operator (Hilbert space) or its 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.

Bosonic modes - cavities, phonon modes, and transmons - have their own operator labels: 'E' (identity), 'C' (creation), 'A' (annihilation), 'N' (population number), products such as 'CCAA', and 'BL#' for the projector onto the #-th Fock level, counted from 1, so that 'BL1' is the vacuum. These may be mixed with spin labels in product operator calls, for example operators={'L+','A'}; spins={1,2} builds one of the two flip-flop terms of a Jaynes-Cummings coupling.

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});

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

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

3. AxBx between spin 2 and spin 5

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

Operators will be generated in Hilbert space and superoperators in Liouville space.

Notes

WARNING: do not try to obtain product commutation superoperators by multiplying up single-spin commutation superoperators. 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.

Operator caching is supported, add 'op_cache' to sys.enable array to enable; make sure your scratch storage is fast.

See also

unit_state.m, unit_oper.m, mprealloc.m, singlet.m, equilibrium.m, state.m, human2opspec.m, bos2ist.m, boson_mono.m, boson_ortho.m, centrans.m, ct2ist.m, enlev2bm.m, enlev2ist.m, hamiltonian.m, kinetics.m, lindbladian.m, oper2bm.m, oper2ist.m, orientation.m, propagator.m, relaxation.m, sin_tran.m, weyl.m, coherent.m, device.m, Kernel_functions

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