Hamiltonian represent in hermitian

Dear all,

I would like to get the cf.getHamiltonian() output in hermitian form. How can I do that?
Thank you!

Hi Arima,

I don’t understand what you mean - the Hamiltonian is by definition Hermitian. For example:

from CrystalField import CrystalField

cf = CrystalField('Ce', 'C2', IB22=0.01, B20=0.02, B22=0.03)
np.set_printoptions(suppress=True, precision=3, linewidth=100)
Hcf = cf.getHamiltonian()
print Hcf
print
print np.sum(Hcf - Hcf.conj().T)

gives:

[[ 0.200+0.j     0.000+0.j     0.095+0.032j  0.000+0.j     0.000+0.j     0.000+0.j   ]
 [ 0.000+0.j    -0.040+0.j     0.000+0.j     0.127+0.042j  0.000+0.j     0.000+0.j   ]
 [ 0.095-0.032j  0.000+0.j    -0.160+0.j     0.000+0.j     0.127+0.042j  0.000+0.j   ]
 [ 0.000+0.j     0.127-0.042j  0.000+0.j    -0.160+0.j     0.000+0.j     0.095+0.032j]
 [ 0.000+0.j     0.000+0.j     0.127-0.042j  0.000+0.j    -0.040+0.j     0.000+0.j   ]
 [ 0.000+0.j     0.000+0.j     0.000+0.j     0.095-0.032j  0.000+0.j     0.200+0.j   ]]

0j

which is a Hermitian matrix.

Do you mean to output it in some kind of packed form (for example just the upper or lower triangle)? In which case you would have to do this manually - we use numpy for most of the numerical calculations and numpy doesn’t support converting matrices from densed to packed format.

Hello Mducle,

Thank you for your speedy reply!
Now I see my problem. It might come from the wrong B values from the fitting. My output looks like this
[[ 0.00000000+0.j 0.00000000+0.j 0.12592968+0.j 0.00000000+0.j 0.99203917+0.j 0.00000000+0.j]
[ 0.00000000+0.j 0.00000000+0.j 0.00000000+0.j -0.99203917+0.j 0.00000000+0.j -0.12592968+0.j]
[ 1.00000000+0.j 0.00000000+0.j 0.00000000+0.j 0.00000000+0.j 0.00000000+0.j 0.00000000+0.j]
[ 0.00000000+0.j 1.00000000+0.j 0.00000000+0.j 0.00000000+0.j 0.00000000+0.j 0.00000000+0.j]
[ 0.00000000+0.j 0.00000000+0.j -0.99203917+0.j 0.00000000+0.j 0.12592968+0.j 0.00000000+0.j]
[ 0.00000000+0.j 0.00000000+0.j 0.00000000+0.j 0.12592968+0.j 0.00000000+0.j -0.99203917+0.j]]
which confuses me previously.

Thanks again!

Hi Arima,

what you get looks like the eigenvectors matrix (which is obtained from cf.getEigenvectors()) rather than the Hamiltonian.

In this case each column represents the eigenvector of a particular eigenvalue, in the |J, mJ> (where J=5/2 here) basis with the top row being the coefficient of |mJ=J> (|mJ=5/2>), the next row is for |mJ=J-1> (|mJ=3/2>) etc until the last row which is |mJ=-J> (|mJ=-3/2>). The columns are sorted in the order of the eigenvalues from left to right, so the leftmost column is for the ground state, etc.

For your output, J=5/2 is a Kramers state so you’ve got 3 doublets, with the ground state being |mJ=+/- 1/2>, the first excited state is: 0.126|+/- 5/2> - 0.992|+/- 3/2>, and the second excited state is 0.992|+/-5/2> -/+ 0.126|+/-3/2>

Could you send me the script which is used to post this output? If you get this output from cf.getHamiltonian() then there’s a bug in the Python code, which we’ll try to fix.

All the best,

Duc.

Hi Duc,

You are right! I printed the wrong matrix [facepalm]…
Thank you :slight_smile:

Arima

Hi Arima,

Could you sent me the error message?

Or do you mean that the fit runs but that the fit result is not satisfactory? Note that for cgs units, the magnetic field Hmag is in units of Gauss rather than Tesla. So if you used a 1T field for the measurement, you need to put Hmag=10000 instead of Hmag=1.

I hope this helps,

Duc.

Hi Duc,

The script runs without error msg, but strangely the value of the fitting parameters stays the same.

Thank you.

Hi Arima,

in addition to our PM, I’d just like to note here for others to know that this is due to a bug in the Python part of the crystal field calculations which also affected another user: Crystal field parameters not updating in fitting procedure · Issue #22466 · mantidproject/mantid · GitHub

This should be fixed by the next Mantid release, and hopefully will be in the nightly version shortly. I’ll edit this message to note when the fixed in incorporated into Mantid nightly.

Duc.