QuantumATK Forum

QuantumATK => General Questions and Answers => Topic started by: dprai on March 6, 2022, 13:57

Title: Charge Density Difference
Post by: dprai on March 6, 2022, 13:57
Dear All,
How can we obtain a charge density difference plot in ATK?
I have attached a plot for reference. The reference doi for the article is https://doi.org/10.1021/acsomega.1c06860.
Title: Re: Charge Density Difference
Post by: Anders Blom on April 6, 2022, 04:24
If you have computed the difference electron density you just plot it in the Viewer. To get the geometry included as well you drop the structure onto the same open Viewer window.
Title: Re: Charge Density Difference
Post by: Kim_W on December 7, 2022, 04:58
As far as I know, ATK cannot calculate the charge density difference between two individuals, only the EDD
Title: Re: Charge Density Difference
Post by: Anders Blom on December 7, 2022, 17:17
EDD = electron difference density

Not sure what you mean by "individuals"
Title: Re: Charge Density Difference
Post by: Kim_W on December 8, 2022, 09:44
How can we obtain a charge density difference (CDD) of the system in ATK? Not EDD.
Title: Re: Charge Density Difference
Post by: filipr on December 12, 2022, 11:40
If I understand what you mean by charge density difference, you need to split it up in three different calculations: 1) Full system, e.g. surface + molecule 2) only surface 3) only molecule. It is important that you use the same unit cell and grid sampling for each calculation, even the small molecule. To set a specific grid sampling you can use: density_mesh_cutoff=GridSampling(Na, Nb, Nc). If you do the calculation of the full system you can read off the grid sampling used in the log output or using e.g. density.shape() in Python.

Calculate the electron density for each system, then you can calculate the difference as:

Code
density_full = nlread('calculation_surface+molecule.hdf5', ElectronDensity)[0]
density_surface = nlread('calculation_surface.hdf5', ElectronDensity)[0]
density_molecule = nlread('calculation_molecule.hdf5', ElectronDensity)[0]

charge_difference_density = density_full - density_surface - density_molecule
nlsave('charge_difference_density.hdf5', charge_difference_density)

The charge_difference_density variable will contain a generic GridValues object that can be opened and viewed in NanoLab.
Title: Re: Charge Density Difference
Post by: Kim_W on March 8, 2023, 08:04
I have an error while running.
 
Traceback (most recent call last):
  File "charge_difference_density.py", line 5, in <module>
    charge_difference_density = density_full - density_Graphene - density_MoSe2
TypeError: unsupported operand type(s) for -: 'list' and 'list'
Title: Re: Charge Density Difference
Post by: Anders Blom on March 8, 2023, 08:30
Did you remember the [ 0 ] at the end of each line? Else show your script. (I have to use spaces, else it gets formatted weirdly, you don't need those)

nlread always returns a list, even if the file only contains one object of each kind.

PS: Please do not use "Report" for a post unless it's spam
Title: Re: Charge Density Difference
Post by: Kim_W on March 23, 2023, 04:35
There should be some problems with my script, please help me to modify it, thank you.
Title: Re: Charge Density Difference
Post by: Anders Blom on March 27, 2023, 07:23
Right, as I said, you are missing the index 0. It should be
density_full = nlread('Interface.hdf5', ElectronDensity)[0]
and so on
Title: Re: Charge Density Difference
Post by: Kim_W on March 30, 2023, 08:37
Errors are still being reported. :'( :'(
Title: Re: Charge Density Difference
Post by: Anders Blom on March 30, 2023, 20:55
Well, then this file does not contain any object of the type ElectronDensity. Maybe it's an ElectronDifferenceDensity?

Note that the task you are trying to achieve can actually be done in the GUI. Select all 3 objects in the Data view or LabFloor for older versions, and right-click and choose Open with > Grid Operations Analyzer. Then you can subtract them, and save the result.
Title: Re: Charge Density Difference
Post by: Kim_W on March 31, 2023, 05:19
A new problem has arisen. How to keep three objects with same grid points?
Title: Re: Charge Density Difference
Post by: filipr on March 31, 2023, 10:00
If I understand what you mean by charge density difference, you need to split it up in three different calculations: 1) Full system, e.g. surface + molecule 2) only surface 3) only molecule. It is important that you use the same unit cell and grid sampling for each calculation, even the small molecule. To set a specific grid sampling you can use: density_mesh_cutoff=GridSampling(Na, Nb, Nc). If you do the calculation of the full system you can read off the grid sampling used in the log output or using e.g. density.shape() in Python.

Calculate the electron density for each system, then you can calculate the difference as:

Code
density_full = nlread('calculation_surface+molecule.hdf5', ElectronDensity)[0]
density_surface = nlread('calculation_surface.hdf5', ElectronDensity)[0]
density_molecule = nlread('calculation_molecule.hdf5', ElectronDensity)[0]

charge_difference_density = density_full - density_surface - density_molecule
nlsave('charge_difference_density.hdf5', charge_difference_density)

The charge_difference_density variable will contain a generic GridValues object that can be opened and viewed in NanoLab.