How crystal field Hamiltonian is generated

Dear forum,

We are in interested performing some crystal field calculations for RIXS and for this we would like to be able to independently generate the crystal field Hamiltonian and and apply basis transforms before passing it into our separate EDRIXS code. Would someone be able to point me towards the underlying code in mantid that generates the crystal field Hamiltonian (I’m presuming/hoping that it is open source). i.e. where can I see what exactly is happening when I call the code below:

from CrystalField import CrystalField

cf = CrystalField(‘Yb’, ‘C1’,
B20 =-0.257755, B21 =-1.02396, B22 =1.86686,
B40 =-0.0115496, B41 =0.00609532, B42 =0.035768, B43 =-0.0865939, B44 =0.0463316,
B60 =3.2935e-006, B61 =-0.00100726, B62 =0.000250686, B63 =-0.00230406,
B64 =0.000218702, B65 =0.0026247, B66 =0.000606366)

h = cf.getHamiltonian()

I appreciate that I could hack something together by saving and loading the matrix, but I would prefer to properly see which steps are happening in the underlying code.

Thanks in advance,
Mark

Hi Mark,

Thank you for your query.

CrystalField is part of the Mantid open source software rather than an imported library as you hoped. CrystalField and getHamiltonian are defined here - mantid/fitting.py at 394d5fa66b5bc4c7df51ab87a9d25e58f3cd53a6 · mantidproject/mantid · GitHub

If this doesn’t help or you end up with more questions let us know either in response to this forum thread or by e-mailing mantid-help@mantidproject.org .

All the best

Sarah

Dear Sarah,

Thank you. I see the CrystalField python class, but I believe that the Hamiltonian must be constructed at a lower level within the code. I believe that it is passed in via
from mantid.simpleapi import CrystalFieldEnergies

Could you point me towards which part of the code is assigning elements to the crystal field matrix based on the Steven’s parameters.

All the best,
Mark

Dear Mark,

you are probably looking for this file mantid/CrystalFieldEnergies.cpp at main · mantidproject/mantid · GitHub and this mantid/CrystalElectricField.cpp at 829dd9cc4a27bc6184d6bbf6a8d3e68ba37b358e · mantidproject/mantid · GitHub

Kind regards,

Silke