# Spin Dynamics Forum

## General Discussions => General Discussion => Topic started by: Ronghui on September 09, 2012, 04:01:05 AM

Title: how to convert density matrix into density operator?
Post by: Ronghui on September 09, 2012, 04:01:05 AM
If I have the density matrix for para-Hydrogen as 1/2 {{0,0,0,0},....}, how can I convert it into Bra and Ket form? Thanks.

Ronghui

Title: Re: how to convert density matrix into density operator?
Post by: kuprov on September 17, 2012, 05:34:29 PM
One way is to get your bra-ket density matrices (using kronecker products) and then compute the expansion coefficients with your density matrix, i.e.

rho=a1*A1+a2*A2+...   =>

a_k=trace(A_k'*rho)/norm(A_k);

So standard orthogonal expansion in matrix space, see Lecture 12 of the Spin Dynamics course.
Title: Re: how to convert density matrix into density operator?
Post by: Ronghui on September 23, 2012, 01:09:24 PM
Thank you very much.
Title: Re: how to convert density matrix into density operator?
Post by: MichaelTayler on December 18, 2012, 10:50:24 AM
Hi Ronghui,

There is a neat trick for this, which is used internally in SpinDynamica.  If the density matrix is represented in the Zeeman ket-bra basis, it can be flattened to a vector corresponding to the coefficients of the Zeeman ket-bra operators.  One can then take the dot product with the appropriately-ordered list of basis operators.

To solve your problem in SpinDynamica you can use the ExpressOperator routine, which works more-or-less in the way that Ilya (kuprov) has described:

Code: [Select]
` op=opI[1].opI[2]ExpressOperator[op,ZeemanKetBraOperatorBasis[]] `
For more information you can look up the help message by executing

Code: [Select]
`?ExpressOperator`