# state.m

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

## Syntax

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

## Arguments

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.

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

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