shankar1729 / jdftx

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

Use of the createVASP script #219

Closed moyulyy closed 2 years ago

moyulyy commented 2 years ago

Dear, Shanka, I am a beginner of JDFTX. In the process of continuing to learn and use JDFTX, I have encountered some doubts again. I am looking forward to your help.

1. Is this correct understanding of the ".n_dn" and the ".n_up" files? The ".n_up" file stores electron density data only contain the spin up state, The ".n_dn" file stores electron density data only contain the spin down state.

2. How to consider the parameter "Ninterp" of the createVASP script As stated in the createVASP script,

---------- function printUsageAndExit -----------------

......
createVASP \<jdftxOutFile\> \<vaspFile\> \[\<nFilename\>\] \[\<Ninterp\>=1\]
......
......
Optional <Ninterp> specifies a grid multiplier for Fourier interpolation.
......

--------------------------------------------------------

However, I do not understand the settings of the "Ninterp" parameter. In general, how to use the createVASP script? On a trial run, I evaluated the same opt.n_up file using "createVASP opt.out CHGCAR_1 opt.n_up" and "createVASP opt.out CHGCAR_2 opt. n_UP 5" respectively, but the resulting files CHGCAR_1 and CHGCAR_2 were very different. The CHGCAR_2 file occupies 7GB of storage, compared with 57MB for the CHGCAR_1 file. The difference is so great that I really don't know how to use the "Ninterp" parameter of the createVASP script.

3. How to create a CHGCAR file from the ".n_dn" and the ".n_up" files In issues #124, there is a discussion of the "spintype z-spin" setting. However, in my system I have the element Mo, And when it uses the Mo_ONCV_PBE.upf pseudopotential, it's described as follows,

---------- Setting up pseudopotentials -----------------

......
4S    l: 0   occupation:  2.0   eigenvalue: -2.465889
4P    l: 1   occupation:  6.0   eigenvalue: -1.510120
5S    l: 0   occupation:  2.0   eigenvalue: -0.179286
4D   l: 2   occupation:  4.0   eigenvalue: -0.207721
......

--------------------------------------------------------

Obviously, Mo contains four unpaired lone electrons, so using the "spintype Z-spin" setup seems like a natural choice. In the calculations that have been done, I have calculated spin polarization using the "spintype Z-spin" setting and output the ".n_dn" and the ".n_up" files. So, how to use createVASP next to create the ".n_dn" and the ".n_up" files into a CHGCAR file?

4. Could the value of "oxidation- State" parameter of "Lowdin Population Analysis" analyze the charge transfer? In fact, I want to analyze the charge transfer of atoms. From the existing experience, I had to prepare the CHGCAR file to use Bader charge analysis, so I faced the above difficulties. However, I noticed that at the end of the ".out" file there is a report "Lowdin Population Analysis", I wonder if the value of the "oxidation-state" parameter is helpful for my purpose? If so, can you describe how the "oxidation-state" parameter of the Lowdin Population analysis explains charge transfer?

I'm sorry to bother you with so many questions and thank you for your efforts again.

shankar1729 commented 2 years ago
  1. Yes, that's right
  2. Ninterp allows you to output the charge density at a higher grid resolution, if required. This may be the case for Bader analysis tools that operate on the CHGCAR files generated. You can start with Ninterp=1, and increase it as needed to converge the Bader analysis results (or whatever other tool you are using with the CHGCAR file). As such, Ninterp=1 has all the information in the .n files, and the interpolation to higher resolution is only provided for convenience (since many of these tools don't support doing this automatically). Also, I note that the script documentations are missing in the latest version of the website somehow; you can see the older documentation of this script for reference, and I'll look into the missing docs.
  3. It appears that createVASP currently does not support spin polarized output. If you work on adding this support, please send a pull request and we'd be happy to integrate it. (You can create individual CHGCAR files for each spin channel by specifying the filename for density explicitly, but not a single combined one at the moment.)
  4. Yes, you can use the Lowdin analysis for qualitative analyses of charge transfer and magnetization, but definitely work on the Bader analysis for more quantitative analysis. That being said, all charge analyses are at some level, qualitative. See some previous issues for further discussion on the Lowdin results.

Best, Shankar

moyulyy commented 2 years ago

Thanks for the clarity of your explanation, I already understand the use of the createVASP script, which is very rewarding. Sorry to bother you and I want to ask you some questions again.

1. Whether the CHARGE values of the upper and lower spins of the same atom can be simply added Since the createVASP script can output a.n file as a CHGCAR file. So, I think there's a simple calculation strategy. Step1: use the createVASP script to print the ". n_dn "as CHGCAR_dn and the ". n_up" as CHGCAR_up Step2: run the Bader program to output CHGCAR_dn as acf_dn. dat and CHGCAR_up as acf_up. dat Step3: Simply add the CHARGE values of the same atom to get a new value (CHARGE_sum). That is, CHARGE_sum = CHARGE_up + CHARGE_dn. Where: CHARGE_sum is the total CHARGE value of this atom, CHARGE_up is the CHARGE value of this atom in the acf_up. dat file, CHARGE_dn is the CHARGE value of this atom in the ACF_dn.dat file. In fact, I've already tried this strategy with the following results

----------------------From ACF_up.dat file--------------------------------

\ X Y Z CHARGE MIN DIST ATOMIC VOL

-----------------------------------------------------------------------------

\ 1 6.4197 3.5699 5.4000 6.6389 0.8991 139.8644 \ 2 7.9589 4.7308 5.4000 6.6264 0.8498 138.8841 \ ...... \ ......

----------------------------------------------------------------------------

----------------------From ACF_dn.dat file-------------------------------

\ X Y Z CHARGE MIN DIST ATOMIC VOL

---------------------------------------------------------------------------

\ 1 6.4197 3.5699 5.4000 6.6389 0.8991 139.9032 \ 2 7.9589 4.7308 5.4000 6.6264 0.8498 138.8478 \ ...... \ ......

---------------------------------------------------------------------------

So, the total CHARGE value for the first atom : _CHARGE_sum = CHARGE_up+CHARGEdn = 6.6389+6.6389 = 13.2778 In your opinion, is such a simple processing reasonable?

2. Whether it is precise to give up using "spintype Z-spin" when the magnetic moment is not displayed After the calculation, the.out file reports the following information.

--- Lowdin population analysis ----------

\ oxidation-state Mo +0.640 +0.641 \ magnetic-moments Mo +0.000 -0.000

--------------------------------------------

"Magnetic moments" parameter of "Lowdin Population Analysis" shows that the magnetic moment of Mo atom is zero, Is it precise to boldly drop the "spintype z-spin" setting for a calculation that only generates a ".n" file?

Thank you again for your generous contribution to my issue.

shankar1729 commented 2 years ago
  1. Yes, you can add the charges. However, note that Bader analysis is not additive because it relies on saddle points of the density to determine the partitioning of space between atoms. A better approach may be to create a CHGCAR with the total density. You can use a one-line python/numpy code to combine n_up and n_dn to n:

    import numpy as np
    (np.fromfile('X.n_up') + np.fromfile('X.n_dn')).tofile('X.n')

and then use createVasp on that resulting combined charge density.

  1. Yes, if the calculation ends up being not magnetized, it is equivalent to using no-spin. However, be careful about how you initialize magnetization. See previous issues and tutorials on this: you should use initial-magnetic-moments or elec-initial-magnetization to start at non-zero M; otherwise the calculation may be stuck in a local minimum of energy that is non-magnetized.

Best, Shankar

moyulyy commented 1 year ago

Dear, Shankar, After the createVASP script outputs the.n file to the CHGCAR file, run the Bader program and get the result that the CHARGE of the B atom in the slab structure is zero. I think that's a weird result, because even though B loses some electrons in the bonding process, it doesn't lose all three electrons in its valence shell. Attempts were made to increase the value of Ninterp, but nothing changed. Are there errors in the script operation? Attached is the relevant document of the slab for your reference, and I look forward to your suggestions on this. B-C2N.zip

shankar1729 commented 1 year ago

This may be an artefact of how Bader charges are defined based on saddle points of the electron density. It does sound strange to me, so I visualized the charge density you attached in VESTA (using createXSF). Changing the isosurface (contour) level in VESTA, there is never a contour surrounding the B atom. It always surrounds the remaining atoms and decreases towards B. So the saddle partitioning that Bader analysis prescribes will never attribute electrons to the B.

So, it is a weird result, yes. But I think that is a Bader definition issue fundamentally, not a numerical problem.

moyulyy commented 3 months ago

Dear, Shankar,

Page (https://theory.cm.utexas.edu/henkelman/code/bader/) is introduced to the following part,

One major issue with the charge density (CHGCAR) files from the VASP code is that they only contain the valance charge density. 
The Bader analysis assumes that charge density maxima are located at atomic centers (or at pseudoatoms).
Aggressive pseudopotentials remove charge from atomic centers where it is both expensive to calculate and irrelevant for the important bonding properties of atoms.

VASP contains a module (aedens) which allows for the core charge to be written out from PAW calculations. 
By adding the LAECHG=.TRUE. to the INCAR file, the core charge is written to AECCAR0 and the valance charge to AECCAR2. 
These two charge density files can be summed using the chgsum.pl script:  chgsum.pl AECCAR0 AECCAR2
The total charge will be written to CHGCAR_sum.

The bader analysis can then be done on this total charge density file: bader CHGCAR -ref CHGCAR_sum
One finally note is that you need a fine fft grid to accurately reproduce the correct total core charge. It is essential to do a few calculations, increasing NG(X,Y,Z)F until the total charge is correct.

Does jdftx have a parameter or command corresponding to "LAECHG=.true." to complete similar operations to get the total charge density file? Or, what can I do to get the total charge density?

best, lyy

shankar1729 commented 3 months ago

No, we don't have all-electron density outputs, but that seems unnecessary for Bader analysis in most cases. If you are encountering an issue, it should be okay to add something like a Gaussian (with known norm) of electron density to plug the holes in the cores. You can do this in a separate postprocessing code, or modify the createVASP script to add the functions, but this does not seem general enough to build into the code itself.

Another alternative is to use the partial core charges from the pseudopotential, and add an option to the createVASP script to use that. This should also plug any holes in the charge density near the nuclei. This would involve dumping CoreDensity from jdftx and reading and adding n_core in createVASP. The only challenge here is one would need to separately calculate the norm of the core density at each nucleus (need not be a sensible integer).