Difference between revisions of "State.m"

From Spinach Documentation Wiki
Jump to: navigation, search
(Examples)
(Document Spinach 2.12 bosonic mode functionality (PR 195))
 
(15 intermediate revisions by 2 users not shown)
Line 1: Line 1:
Generates states from their human-readable descriptions. In Liouville space formalisms, a state vector is produced. In Hilbert space formalisms, a density matrix is produced. Syntax:
+
{{DISPLAYTITLE:state.m}} __NOTOC__
 +
Generates Hilbert space density matrices and Liouville space state vectors from their human-readable descriptions.
 +
 
 +
==Syntax==
  
 
     rho=state(spin_system,states,spins,method)
 
     rho=state(spin_system,states,spins,method)
  
The function supports two types of calls:
+
==Parameters==
 +
This function supports three types of calls:
 +
 
 +
'''1. If states is a string and spins is a string'''
 +
 
 +
                      states='Lz'; spins='13C';
 +
 
 +
the function returns the sum of the corresponding single-spin density matrices (Hilbert space) or state vectors (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-', 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'.
  
'''1. If the state description is given as a character string and spins are named by a character string, for example'''
+
'''2. If states is a string and spins is a vector'''
  
    rho=state(spin_system,'Lz','13C');
+
                      states='Lz'; spins=[1 2 4];
  
then the function returns the sum of the corresponding single-spin states on all spins with that name. In the example above, the sum of Lz states on all carbons in the system will be returned:
+
the function returns the sum of all single-spin density matrices (Hilbert space) or state vectors (Liouville space) for all spins with the specified numbers. Valid labels for states are the same as in Item 1 above.
  
<center><math>\hat{\rho }=\hat{L}_{\text{Z}}^{\left( 1 \right)}+\hat{L}_{\text{Z}}^{\left( 2 \right)}+\hat{L}_{\text{Z}}^{\left( 3 \right)}+...</math></center>
+
'''3. If states is a cell array of strings and spins is a cell array of numbers:'''
  
Valid labels for states in this type of call are
+
                      states={'Lz','L+'}; spins={1,2};
  
    'E', 'Lz', 'L+', 'L-', 'Tl,m'
+
then a product state density matrix (Hilbert space) or state vector (Liouville space) is produced. In the case above, Spinach will generate LzS+ density matrix in Hilbert space or its state vector in Liouville space. Valid labels for operators are the same as in Item 1 above.
  
the latter case specifies an irreducible spherical tensor operator <math>{{{\hat{T}}}_{l,m}}</math>. Valid labels for spins are standard isotope names as well as
+
Bosonic modes have their own state labels: 'E' (identity), 'C' (creation), 'A' (annihilation), 'N' (population number), and 'BL#' for the projector onto the #-th Fock level, counted from 1, so that 'BL1' is the vacuum; spin energy level projectors use the parallel 'ZL#' notation. Coherent states of a mode are built by [[coherent.m]].
  
    'nuclei', 'electrons', 'all'
+
Method argument has the following effect in sphten-liouv formalism:
  
'''2. If the state description is given as a cell array of strings and spins are named by a cell array of numbers, for example'''
+
    'cheap' - the state vector is generated without
 +
                normalisation. For very large spin sys-
 +
                tens this is much faster
 
   
 
   
     rho=state(spin_system,{'Lz','L+'},{1,2});
+
     'exact' - exact state vector with correct normalisation
 
+
then a product state is is returned. In the example above, the function would return the followinsg state:
+
    'chem'   - the exact state vector weighted with the
 +
                concentrations specified in [[inter]].chem.concs
 +
                field under [[chemical kinetics parameters]]
  
<center><math>\hat{\rho }=\hat{L}_{\text{Z}}^{\left( 1 \right)}\otimes \hat{L}_{+}^{\left( 2 \right)}</math></center>
+
This option is ignored in zeeman-hilb and zeeman-liouv formalisms because there are no cheap shortcuts and kinetics is not available.
  
Valid labels for states in the cell array are the same as in the previous case.
+
==Outputs==
  
In situations where the norm of the requested state vector is inconsequential, the method parameter may be specified. Setting method to 'cheap' triggers a very fast state vector generation procedure with the caveat that the norm of the resulting state vector is not guaranteed to be consistent with other state vectors. This switch is only applicable to the spherical tensor basis set.
+
    rho    - a Hilbert space density matrix or a Liouville
 +
              space state vector
  
 
==Examples==
 
==Examples==
Line 40: Line 55:
 
'''2. A sum of Lx states on all 15N spins in the system'''
 
'''2. A sum of Lx states on all 15N spins in the system'''
  
     rho=(state(spin_system,'L+','15N')+state(spin_system,'L+','15N'))/2;
+
     rho=state(spin_system,'Lx','15N');
  
 
'''3. AxBx state between spin 2 and spin 5'''
 
'''3. AxBx state between spin 2 and spin 5'''
Both components are Cartesian and must therefore be translated into the convention above:
 
  
<center><math>\begin{matrix}
+
    rho=state(spin_system,{'Lx','Lx'},{2,5});
  {{{\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:
+
Density matrices will be generated in Hilbert space and a state vectors in Liouville space.
  
    AxBx=(state(spin_system,{'L+','L+'},{2,5})+...
+
==See also==
          state(spin_system,{'L+','L-'},{2,5})+...
 
          state(spin_system,{'L-','L+'},{2,5})+...
 
          state(spin_system,{'L-','L-'},{2,5}))/4;
 
  
 +
[[unit_state.m]], [[unit_oper.m]], [[mprealloc.m]], [[singlet.m]], [[equilibrium.m]], [[operator.m]], [[human2opspec.m]], [[deut_pair.m]], [[four_spin_states.m]], [[partner_state.m]], [[triplet.m]], [[zftrip.m]], [[Kernel_functions]]
  
''Revision 3180, authors: [[Ilya Kuprov]], [[Luke Edwards]], [[Dmitry Savostyanov]]''
+
''Version 2.8, authors: [[Ilya Kuprov]], [[Luke Edwards]], [[Dmitry Savostyanov]]''

Latest revision as of 05:40, 6 August 2026

Generates Hilbert space density matrices and Liouville space state vectors from their human-readable descriptions.

Syntax

    rho=state(spin_system,states,spins,method)

Parameters

This function supports three types of calls:

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

                     states='Lz'; spins='13C';

the function returns the sum of the corresponding single-spin density matrices (Hilbert space) or state vectors (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-', 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 states is a string and spins is a vector

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

the function returns the sum of all single-spin density matrices (Hilbert space) or state vectors (Liouville space) for all spins with the specified numbers. Valid labels for states are the same as in Item 1 above.

3. If states is a cell array of strings and spins is a cell array of numbers:

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

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

Bosonic modes have their own state labels: 'E' (identity), 'C' (creation), 'A' (annihilation), 'N' (population number), and 'BL#' for the projector onto the #-th Fock level, counted from 1, so that 'BL1' is the vacuum; spin energy level projectors use the parallel 'ZL#' notation. Coherent states of a mode are built by coherent.m.

Method argument has the following effect in sphten-liouv formalism:

    'cheap'  - the state vector is generated without
               normalisation. For very large spin sys-
               tens this is much faster

    'exact'  - exact state vector with correct normalisation

    'chem'   - the exact state vector weighted with the 
               concentrations specified in inter.chem.concs
               field under chemical kinetics parameters

This option is ignored in zeeman-hilb and zeeman-liouv formalisms because there are no cheap shortcuts and kinetics is not available.

Outputs

    rho     - a Hilbert space density matrix or a Liouville
              space state vector

Examples

1. L+ state on spin 3

    rho=state(spin_system,{'L+'},{3});

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

    rho=state(spin_system,'Lx','15N');

3. AxBx state between spin 2 and spin 5

    rho=state(spin_system,{'Lx','Lx'},{2,5});

Density matrices will be generated in Hilbert space and a state vectors in Liouville space.

See also

unit_state.m, unit_oper.m, mprealloc.m, singlet.m, equilibrium.m, operator.m, human2opspec.m, deut_pair.m, four_spin_states.m, partner_state.m, triplet.m, zftrip.m, Kernel_functions

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