aiida-common-workflows
aiida-common-workflows copied to clipboard
Allowed `magnetization_per_site` in case of non-collinear calculaions
The magnetization_per_site argument of get_builder has been created in order to pass the initial magnetization for a magnetic calculation. It is a list containing info for each site of the structure. In case of COLLINEAR calculations, the list is composed by floats/integers representing the spin polarization per site.
In case of NON-COLLINEAR (and SPIN-ORBIT) calculations, it is necessary to pass something more than just a float or an integer for each site. An idea could be to allow magnetization_per_site to be a list of lists and pass the spin vector for each site. Another idea can be to allow a list of dict with keys such as angle_theta, angle_phi, magnitude etc. Both options can cohabit, in that case get_builder must be smart enough to recognize and handle the various cases.
In any case, the point of the entire project is to have a common interface, therefore we should agree exactly on what we want to allow.
Thanks @zhubonan for contributing all the ideas reported in this issue.
In siesta the spin direction is specified for each atom by the polar angle theta and the azimuthal angle phi (using the physics ISO convention), given in degrees. For the magnitude we can use the same convention of the collinear case. Regarding passing a list of lists with the spin vector for each site, I think this should be supported as well and I guess the module of the vector should be the atomic spin polarization.
Hello. This is not directly linked with non-collinear but is to avoid the creation of a new issue.
It seems the CLI it does not work with negative values.
i.e. aiida-common-workflows launch eos abinit -S Fe -p precise -s collinear -X 71 --magnetization-per-site 4.0 -4.0 returns
Error: no such option: -4
while aiida-common-workflows launch eos abinit -S Fe -p precise -s collinear -X 71 --magnetization-per-site 4.0 4.0 works
What happens if you wrap the negative value in quotes?
aiida-common-workflows launch eos abinit -S Fe -p precise -s collinear -X 71 --magnetization-per-site 4.0 "-4.0"
The problem is that without it, the parser is interpreting the - sign as the beginning of a new option but the option 4.0 obviously does not exist.
I tried with quotes and it is not working. But:
aiida-common-workflows launch eos abinit -S Fe -p precise -s collinear -X 71 --magnetization-per-site -4.0 4.0
works. This is just a workaround for the moment. I'll try to find a better solution.
Hello, yes I confirm @sphuber suggestion does not work but @bosonie does, thanks.
For reference, this is a problem of the aiida.cmdline.params.options.MultiValueOption class and may even be considered a bug, although I am not sure if this is fixable. It might be a fundamental limitation of this approach to multiple value options.
so currently if the quotes do not work, we can parse only one negative number to a multiple value option. I also think as sphuber pointed out that this is probably not fixable. So a solution would be to implement an option which takes a list of an arbitrary length instead. i.e like
--magnetization-per-site [-4.0 4.0 -4.0]
also see https://stackoverflow.com/questions/47631914/how-to-pass-several-list-of-arguments-to-click-option
Apparently the trick is to add a space before the - in the quotes, e.g.:
$ aiida-common-workflows launch dissociation-curve -d -S H2 -s collinear --magnetization-per-site 1 " -1" -- quantum_espresso
I take no credit for figuring this out, I just saw it somewhere 😅 (I think when @yakutovicha showed me some of the issues he was having with Quantum ESPRESSO?). But, it does work, see:
$ verdi calcjob inputcat 4327 | grep magnetization
starting_magnetization(1) = -1.0000000000d+00
starting_magnetization(2) = 1.0000000000d+00