====== Definition of density matrix ====== ;;# asked by [[mailto:dwt2004@gmail.com|David Tam]] (2024/08/06 03:21) ;;# == == The Mathematica documentation states that the density matrix is constructed from Subscript[B, \[Rho]]=Flatten[Table[{SphericalHarmonicY[l,m,\[Theta],\[Phi]],SphericalHarmonicY[l,m,\[Theta],\[Phi]]},{m,-l,l}]] r[\[Theta],\[Phi]]== Subscript[B, \[Rho]]\[Conjugate] \[CenterDot] M \[CenterDot] Subscript[B, \[Rho]] I tried to define this basis using: <\code> basis3 =With[{l = 3}, Flatten[Table[{SphericalHarmonicY[l, m, \[Theta], \[Phi]], SphericalHarmonicY[l, m, \[Theta], \[Phi]]}, {m, -l, l}]]] <\code> which is exactly as written on the help page for Hydrogen wavefunctions, and then I calculated B* as basis3conj = Simplify[Conjugate[#], \[Theta] \[Element] Reals && \[Phi] \[Element] Reals] & /@ basis3 I then looked at the real part of the density matrix given for CeRu2Al10 in the help files, using at the real and imaginary parts of the charge density (with some tricks to simplify the expressions): Chop@Simplify@Chop@ComplexExpand@Re[basis3conj . dm1 . basis3] Chop@Simplify@Chop@ComplexExpand@Im[basis3conj . dm1 . basis3] which gives 0 for the imaginary part as I expected. I then tried to plot the real part of the charge density using SphericalPlot3D[Chop@Simplify@Chop@ComplexExpand@Re[basis3conj . dm1 . basis3], {\[Theta], 0, \[Pi]}, {\[Phi], 0, 2 \[Pi]}, PlotRange -> All, Axes -> False, Boxed -> False, PlotStyle -> Lighter@Gray] The result looks similar to the shape given in the help, but not exactly. Moreover, repeating the exercise for the simple p-shell wavefunction in the "Quanty/tutorial/wavefunctions_and_density" page also reflects the orientation around the xy plane compared to the result you show. Some kind of phase problem is appearing in both these cases. Is there a different definition of the spherical harmonics used inside the DensityMatrixPlot function? Could you otherwise shed some light on how to understand why this problem occurs? ~~DISCUSSION|Answers~~