shankar1729 / jdftx

JDFTx: software for joint density functional theory
http://jdftx.org
82 stars 54 forks source link

meta-GGA compatibility with SOC #331

Open sergbuto opened 4 months ago

sergbuto commented 4 months ago

Are meta-GGA functionals from LibXC compatible with SOC calculations in JDFTx?

shankar1729 commented 4 months ago

Yes, they should be compatible. For handling XC in SOC mode, the DFT code transforms the gradients, kinetic energy, laplacian etc. into the local spin-diagonal basis. For this reason, LibXC doesn't need to deal with SOC at all, since the quantities it receives are identical in SOC and non-SOC mode (as far as I know). This may not be true for relativistic XC functionals, but that's a rather rare case that I don't even know if LibXC actually supports.

shankar1729 commented 4 months ago

(Please elaborate if you found an inconsistency / error in trying this.)

sergbuto commented 4 months ago

I just tried to run the SOC calculations for MAPbBr3 with built-in meta-gga TPSS. JDFTx fails producing an error after trying to read and use the first pseudopotential. If I comment-out the 'elec-ex-corr mgga-TPSS' command in the input file, JDFTx runs fine.

Input file:

include common.in kpoint-folding 4 4 4 kpoint 0.5 0.5 0.5 1 elec-ex-corr mgga-TPSS spintype spin-orbit dump End ElecDensity dump-name totalE-rel.$VAR electronic-SCF energyDiffThreshold 1e-10 \ residualThreshold 1e-09 eigDiffThreshold 1e-10 nIterations 300

common.in :

lattice\ 11.187181847981090 0.000000000000000 0.000000000000000 \ 0.000000000000000 11.187181847981090 0.000000000000000 \ 0.000000000000000 0.000000000000000 11.187181847981090

latt-scale 1 1 1

coords-type lattice ion C 0.8962732309267807 0.9999835575561917 0.9885225897978458 0 ion N 0.1421229416578313 0.9998276714532324 0.0326818543098426 0 ion H 0.8669576230289806 0.9997673821304502 0.8051964671801670 0 ion H 0.8224554777663400 0.1524554610094526 0.0646689097381810 0 ion H 0.8222031293734631 0.8478330826230547 0.0650649063082653 0 ion H 0.2212941063647946 0.1424140526496274 0.9656588034540547 0 ion H 0.2210818272207788 0.8569803126825306 0.9659456519655976 0 ion H 0.1804492545013900 0.9999679128432390 0.2053791894684025 0 ion Pb 0.4753317996463835 0.5000043839523016 0.4779234319137089 0 ion Br 0.4287771039399573 0.4998766652154316 0.9726919535286029 0 ion Br 0.4334819150903257 0.0000195562303063 0.5128482885866177 0 ion Br 0.9675529784829351 0.5001724086541017 0.4392056937486757 0

ion-species $ID_PBE-abi-strg-FR.UPF elec-cutoff 50

Last part of the output file with error:

---------- Setting up pseudopotentials ---------- Width of ionic core gaussian charges (only for fluid interactions / plotting) set to 0

Reading pseudopotential file 'C_PBE-abi-strg-FR.UPF': 'C' pseudopotential, 'PBE' functional Generated using ONCVPSP code by D. R. Hamann Author: anonymous Date: 180423. 4 valence electrons, 3 orbitals, 6 projectors, 1248 radial grid points, with lMax = 1 Transforming local potential to a uniform radial grid of dG=0.02 with 1757 points. Transforming nonlocal projectors to a uniform radial grid of dG=0.02 with 680 points. 2S l: 0 occupation: 2.0 eigenvalue: -0.505326 2P l: 1 occupation: 1.3 eigenvalue: -0.194125 2P l: 1 occupation: 0.7 eigenvalue: -0.194446 Transforming atomic orbitals to a uniform radial grid of dG=0.02 with 680 points.

Stack trace: 0: /media/sergei/SSD-2TB/jdftx-1.6.0/build/libjdftx.so(_Z10printStackb+0x3a) [0x7ff213e428da] 1: /media/sergei/SSD-2TB/jdftx-1.6.0/build/libjdftx.so(_Z14stackTraceExiti+0xd) [0x7ff213e42e3d] 2: /media/sergei/SSD-2TB/jdftx-1.6.0/build/libjdftx.so(_Z20assertStackTraceExitPKcS0_S0_l+0x37) [0x7ff213e42ec7] 3: /media/sergei/SSD-2TB/jdftx-1.6.0/build/libjdftx.so(_Z6getTauRK15RadialFunctionRd+0x557) [0x7ff21402c0f7] 4: /media/sergei/SSD-2TB/jdftx-1.6.0/build/libjdftx.so(_ZN11SpeciesInfo7setCoreER15RadialFunctionR+0x2ff) [0x7ff21402c49f] 5: /media/sergei/SSD-2TB/jdftx-1.6.0/build/libjdftx.so(_ZN11SpeciesInfo7readUPFERSi+0xfaa) [0x7ff21409ceea] 6: /media/sergei/SSD-2TB/jdftx-1.6.0/build/libjdftx.so(_ZN11SpeciesInfo5setupERK10Everything+0x4cf) [0x7ff21401c62f] 7: /media/sergei/SSD-2TB/jdftx-1.6.0/build/libjdftx.so(_ZN7IonInfo5setupERK10Everything+0x229) [0x7ff213fe0f29] 8: /media/sergei/SSD-2TB/jdftx-1.6.0/build/libjdftx.so(_ZN10Everything5setupEv+0x581) [0x7ff213fa8ce1] 9: /media/sergei/SSD-2TB/jdftx-1.6.0/build/jdftx(main+0x923) [0x555e068faa43] 10: /lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xe7) [0x7ff212decc87] 11: /media/sergei/SSD-2TB/jdftx-1.6.0/build/jdftx(_start+0x2a) [0x555e068fb3aa] Writing 'jdftx-stacktrace' (for use with script printStackTrace):

shankar1729 commented 4 months ago

This issue is related to the generation of a (partial-)core kinetic energy density from the corresponding (partial-)core electron density of the pseudopotential.

This is essentially a problem that the pseudopotentials only include core corrections for electron density and not KE density, which leads to n and tau not satisfying bounds required by meta-GGAs. JDFTx attempts to fix this by adding a tau model derived from a thomas-fermi + von-Weisacker functional applied to the core-n.

Please post the pseudopotentials you are using here: there may be a fix using http://jdftx.org/CommandTauCore.html. Regardless, this is definitely unrelated to LibXC / spin-orbit coupling.

Best, Shankar

sergbuto commented 4 months ago

The pseudopotentials I used were full-relativistic stringent from Pseudo Dojo database. Now I have replaced them with full-relativistic pseudos from SG15 database (regenerated by pipidog) in the same input files and JDFTx runs.

shankar1729 commented 4 months ago

Sounds good: if you run into SCF issues with meta-GGA, try the minimize; there are challenges in dealing with the KE density in SCF that can occasionally cause issues.

If you still want to use the pseudo-DOJO PSPs, try using the tau-core command to tweak the generation of the kinetic density core model. For example, tau-core C 0.5 yes seems to fix the crash for the C pseudopotential you reported. This pseudizes the calculated KE-density for the C atom for less than 0.5 bohrs. The final yes outputs the tau and n core models in a plain text file for debugging the generated model, and you can switch that to no, once happy. I'd recommend picking a core radius smaller than the pseudopotential core radius till the crash goes away, but not too small, as that will lead to a very large KE density near the origin.

Best, Shankar