QuantumATK Forum

QuantumATK => Scripts, Tutorials and Applications => Topic started by: Nordland on December 17, 2008, 23:12

Title: Script for calculating the voltage drop.
Post by: Nordland on December 17, 2008, 23:12
Hey everyone.

I just thought I wanted to share with you a small script for calculate the voltage drop using two selfconsistent calculations
on a twoprobe device.

The usage is straight forward:
1)  perform a calculation of a twoprobe at zero bias and store the results in a netcdf file.
2) Do the same for the finite bias, and store this in another netcdf file.
3) Modify the script to match the names of your two calculations, and run it using atk voltagedrop.py.

Then you are done, and you will recieve the voltage drop in a VNL file for visualization in VNL and the
average voltage drop will be printed to the screen. Alternative you can pipe the screen into a log file and plot it using fx GNUplot.

I have attached the script and I have attached a graph showing the voltage drop calculated using this script for a Li-H2-Li system.
Title: Re: Script for calculating the voltage drop.
Post by: Roc on January 5, 2009, 12:32
Dear Nordland,

If I want to calculate the voltage drop from 2V to -2V, could I do it using the followed script(just part of it and some changs from your script), is it right? (probe-molecular-probeHV2.nc is the .nc document at 2V, and the probe-molecular-probeLV-2.nc is at -2V)  Thanks!(Sorry, I am new to the Python Language :))

high_bias_filename = 'probe-molecular-probeHV2.nc'
low_bias_filename = 'probe-molecular-probeLV-2.nc'

vnl_filename = 'voltage_drop.vnl'


""" ------------ No need to modify anything below this point --------------------- """
# Implementation of the voltage drop.
from ATK.TwoProbe import *; import numpy

# High bias calculation.
high_bias
= restoreSelfConsistentCalculation(high_bias_filename )
# Low bias calculation.
low_bias = restoreSelfConsistentCalculation(low_bias_filename)
# Calculate the voltage drop.
voltage_drop = calculateEffectivePotential(low_bias) - calculateEffectivePotential(high_bias)


Thanks for your script again!
Title: Re: Script for calculating the voltage drop.
Post by: Nordland on January 5, 2009, 13:52
Yes that should be correct! :)
Title: Re: Script for calculating the voltage drop.
Post by: Roc on January 6, 2009, 01:19
Thanks :)

However, I got the questionable result, as follows, The polt descripes the voltage dropt from 0.1V to -0.1V.
All my scripts (Li-H2-Li as the example)are all upload. Moreover, the polt descriping the voltage dropt from 0V to -0.1V has the same curvilinear trend as that from 0.1V to -0.1V. How to explain it, or what's wrong with my scripts?Thanks again!
Title: Re: Script for calculating the voltage drop.
Post by: Nordland on January 6, 2009, 06:51
Your script is correct and the results is correct in the sense if you calculate the current etc, then it is okay. However since we want to see the voltage drop, you need to use the new electrode constraint 'DensityMatrix' instead of 'Off'.

The explaination is that since the electrodes are allowed to adjust to the bias, a microscopic charge is moved inside the electrode layer and then it tries to screen the voltage ramp. However we want the any charge transfered to the electrode to vanish and hence we should use the new constraint that ensures this behavior.
Title: Re: Script for calculating the voltage drop.
Post by: Roc on January 6, 2009, 08:45
Thank you, Nordland. I will try again!  :)

Another,I am confused with that when should I use the new electrode constraint 'DensityMatrix' instead of 'Off' and when not , could you list any examples when you have free time. ;).

Thanks again! ;D
Title: Re: Script for calculating the voltage drop.
Post by: Roc on January 14, 2009, 01:39
Hello,

I have try it again and use the new electrode constraint 'DensityMatrix' instead of 'Off'.

The results show that as follows (the voltage drop is from 0.5V to -0.5V), it seems that the curve trend is questionable. How to explain it?

Thanks.
Title: Re: Script for calculating the voltage drop.
Post by: Nordland on January 14, 2009, 13:47
Strange!

I don't know what you have done to get this curve, but I can't reproduce it :|

If I calculate the voltage drop over a Li-H2-Li chain with the same bias as you I get the following result:
(http://quantumwise.com/forum/index.php?action=dlattach;topic=21.0;attach=133;image)

The thing you have plotted looks more like the difference density as it shows the formation of a dipole to cancel
out the electric field.

Do you use the same script as posted above?

A second note: I noted that you use 110 eV mesh-cutoff and GGA.PBE at the same time. If you are doing GGA calculation,
you should go with atleast 200 eV mesh-cutoff and I would personally prefer 300 eV mesh-cutoff :)
Title: Re: Script for calculating the voltage drop.
Post by: Anders Blom on January 14, 2009, 14:45
I think there is a fundamental misconception here, which we should clear out first.

What we mean by voltage drop is the difference in real space effective potential V(r,bias) between two calculations, i.e.

V(r,bias1) - V(r,bias0)

where the reference calculation "bias0" is for zero bias, hence the notation. The obtained quantity shows how the applied bias is distributed across the structure, i.e. where the voltage drops, i.e. where the resistance is.

The calculations posted by anyipeng (lih2li01 and lih2li-0.1) are both calculations with 0.1 V bias applied, but in two different directions. Comparing them makes no real sense, at least not in terms of "voltage drop". What you want is one calculation with no bias, i.e.

Code
electrode_voltages = (0.0,0.0)*Volt

and one calculation with bias (one of those you already made), and take the difference between these.

However, the point about using "DensityMatrix" is still very valid; one can not expect to get a proper picture of the voltage drop using the other constraints.
Title: Re: Script for calculating the voltage drop.
Post by: Roc on January 15, 2009, 03:43
Thanks for your attention and patient reply ! ;)
Title: Re: Script for calculating the voltage drop.
Post by: carbn9 on February 9, 2009, 06:00
Dear friends

I tried to calculate the voltage drop of a nanotube using the script of this thread, but I got strange results. I have attached the input files and output voltage drop to this message. I could not interpret or judge the voltage drop curve. Could you please help me explain it? I expected to have a curve start at .2V and end at 0V but the curve starts as -.1V and ends at .05V or so with a strange behavior?
Title: Re: Script for calculating the voltage drop.
Post by: Nordland on February 9, 2009, 11:02
Hey !

As you say your self, there are couple of issues with your calculation.

First of all - and most important - the electrode length of your calculation is way too short! You need to increase the length of the electrode region, by at least a factor 3.

Secondly, if you want really good voltage drops you should use the new constraint DensityMatrix that are in ATK 2008.10

If you make these modifications, then I am pretty sure you are going to get very good voltage drops for this system! :) I am looking forward to see them.
Title: Re: Script for calculating the voltage drop.
Post by: Anders Blom on February 9, 2009, 11:15
In addition to the relevant comments by Nordland, I also note that the two most central C atoms in the scattering region have a bond length of 1.058 Angstrom. That seems very short, perhaps it is not what you intended (although this is not related to the problems with the voltage drop).

Second, consider the size of the unit cell in the XY directions. If you plot in VNL the system as ATK actually considers it when the periodic boundary conditions, there will be quite small separation between the carbon atoms in the XY directions. This might actually be what you intended, if it should perhaps be graphite, somehow, between gold, but in that case the atomic distances are not correctly set up.

Title: Re: Script for calculating the voltage drop.
Post by: carbn9 on February 9, 2009, 19:44
Thanks Sirs for yor replies...I'll try Nordland's recommendations, (to Anders Blom) I got the nanotube (scattering zone) from VNL nanotub grower as (1,0) nanotube. It generated atomic bond lenghts auomatically. Is there a problem???
Title: Re: Script for calculating the voltage drop.
Post by: Anders Blom on February 9, 2009, 22:43
Well, a (1,0) nanotube isn't really a nanotube (most notably, it's not a cylinder...).

Actually, in hindsight I think the VNL tube grower should not have allowed such a small number as n=1. In fact, it appears that the tube generation algorithm fails for (1,0) and (1,1) in the sense that the resulting structures are not cylinders. Moreover, while (2,0) does look like a tube, it is not really acceptable at all either.

Tubes (2,1), (2,2), (3,0) and (3,1) are passable; they are cylindrical and relatively regular. However, calculations indicate that for thermal and mechanical stability, carbon nanotubes must have a diameter above 3-4 Ångström, where the smaller radius only can be realized for tubes grown inside multi-wall nanotubes (see PRL 92, 125502 (2004) (http://dx.doi.org/10.1103/PhysRevLett.92.125502) but also Refs. 1 and 5 therein). In fact, even (4,0) and (4,1) fall below the 4 Å-diameter criterion (and (4,2) barely too), while (3,3) and (4,3) are above, and so would be possible to encounter in nature (and have, in fact, recently been identified in experiments, see Nano Letters 8 459 (2008) (http://pubs.acs.org/doi/abs/10.1021/nl072396j), together with the small-radius tube (5,1)).
Title: Re: Script for calculating the voltage drop.
Post by: nori on February 10, 2009, 01:40
I offer some calculation examples of voltage drop.
All calculations were done with the algorithm "ElectrodeConstraints.DensityMatrix".

As Nordland mentioned above, "ElectrodeConstraints.DensityMatrix" instead of "ElectrodeConstraints.Off" should be used when you calculate the voltage drop.
But in some cases such as "Au-DTB-Au", you might get less convergence of SCF with "ElectrodeConstraints.DensityMatrix" (More correctly, the electronic structure that seems to be strange is obtained).
Then, you had better use "ElectrodeConstraints.RealSpaceDensity" instead of "ElectrodeConstraints.DensityMatrix".
Title: Re: Script for calculating the voltage drop.
Post by: M.Albert on April 12, 2009, 15:51
Thank you ,Nordland.
But I have some questions.As we know ,the length of central scattering region
is 17.136A in Z axial in lih2li two probe system.You plot voltage drop from 0 to 140 Bohr(0 to 74.2 A)in the picture.What is the origin,the first Li atom in the central scattering region from the left?
Do you consider the voltage drop in the electrode in the picture?
Title: Re: Script for calculating the voltage drop.
Post by: Nordland on April 12, 2009, 16:04
Yes, as the potential calculated by ATK includes a padded layer of the electrode, the voltage drop includes the voltage drop into the first layer of the electrode. The origin is the left side of this paddede electrode layer in the left side.
Title: Re: Script for calculating the voltage drop.
Post by: M.Albert on April 14, 2009, 17:39
Sorry I don't know what's the mean about " a padded layer of the electrode".
The whole length of the lih2li system is 40.34A.Why you plot 140 Bohr,that is 74.2A?
Secondly, there are 4 Li atoms in the left electrode(also the right),then next is the first Li atom in the center scattering region which I call "Li(1)".
The origin is "Li(1)" I mentioned above. Is that right.
Lastly,why your picture is not symmetric?I think lih2li is a symmetric system.
Title: Re: Script for calculating the voltage drop.
Post by: Nordland on April 14, 2009, 19:03
I will try to illustrate it with a drawning done in ASCII :)

Quote
Left        |     Scattering region   |   Right
Li Li Li Li | Li Li Li Li H H Li Li Li Li | Li Li Li Li


So the scattering region is the number of elements you have entered as the scattering position in the TwoProbe configuration. Once the calculation starts, ATK includes the first layer of the electrode on each side, also called padding layers, and when the potential/voltage drop is calculated, the potential extends into these padding layers, therefore the value Z=0 bohr is the potential at the left side of the padded electrode layer. And the Z=140 bohr is the at the right side of the right padded layer.
Therefore the atoms you have specifed for the scattering region, is in the middle of the plot.

Yes, the Li-H2-Li is symmetric, and so should the voltage drop be, but it is a matter of convergence, if the tolerance is low!
Title: Re: Script for calculating the voltage drop.
Post by: Anders Blom on April 14, 2009, 19:31
The word "padding" should probably be avoided; the voltage drop (and all 3D grid quantities such as the electron denstiy etc) is simply computed over the left electrode + central cell + right electrode. This can easily be seen when plotting them in VNL together with the two-probe geometry.

Second, 70 Angstrom corresponds to over 24 "lattice constants"; the Li-Li distance is 2.88 Angstrom in these scripts, so probably the calculation behind the plot from 0 to 140 Bohr was for a larger system, with more atoms in the electrode and central region?
Title: Re: Script for calculating the voltage drop.
Post by: Nordland on April 14, 2009, 20:16
The Li-H2-Li system has 6 atoms in each electrode, and 6 Li atoms on each side of the H2, making it a total of 26 atoms.
Title: Re: Script for calculating the voltage drop.
Post by: nori on April 15, 2009, 02:30
Quote
Yes, the Li-H2-Li is symmetric, and so should the voltage drop be, but it is a matter of convergence, if the tolerance is low!

It seems there is no need for this system to have the symmetric voltage drop under finite bias.
Because the non-equilibrium part of the electron density exists.

I'll give you the example with attached, which is the voltage drop of au111_vacuum_au111 system.
The structure has symmetry but the voltage drop does not.
You can understand that It's reasonable with the following reasons:

# As regards left electrode part, any incident electron can't be transmitted from right to left due to vacuum region, so that the electric structure does not change compared with equilibrium and the potential gets flat-shift.
# As regards right electrode part, all incident electrons are perfectly reflected , so that the electric structure changes compared with equilibrium and the potential gets more complex.

That's why the voltage drop Norland offered has no matter.
Title: Re: Script for calculating the voltage drop.
Post by: Anders Blom on April 20, 2010, 23:23
If you are interested in computing the voltage drop, you might find my new post on extracting the effective potential from a VNL file useful!

See http://quantumwise.com/forum/index.php?topic=3.msg3210;topicseen#msg3210
Title: Re: Script for calculating the voltage drop.
Post by: zdhlover on April 22, 2010, 10:13
I offer some calculation examples of voltage drop.
All calculations were done with the algorithm "ElectrodeConstraints.DensityMatrix".

As Nordland mentioned above, "ElectrodeConstraints.DensityMatrix" instead of "ElectrodeConstraints.Off" should be used when you calculate the voltage drop.
But in some cases such as "Au-DTB-Au", you might get less convergence of SCF with "ElectrodeConstraints.DensityMatrix" (More correctly, the electronic structure that seems to be strange is obtained).
Then, you had better use "ElectrodeConstraints.RealSpaceDensity" instead of "ElectrodeConstraints.DensityMatrix".

I have been build all the two-probe system as you post, but I could't get none of the beautiful pictures of voltage drop as your examples,where is my problem?
I have been notice the use of "ElectrodeConstraints.DensityMatrix" instead of "ElectrodeConstraints.Off" when I calculate the voltage drop.

The append files is my au(111) scripts and outputs,all computation performed in VNL 2008.10.

 ;D ;D ;D I have been modify the scripts  that upload before because the wrong monkhorst_pack_parameters,but also the same results. And upload the modified scripts and results.

I also  test the FFT methods,but also the same results,and I can't get nori's beautiful  image!Why?
Title: Re: Script for calculating the voltage drop.
Post by: nori on April 23, 2010, 03:02
I regard your voltage drop as qualitatively the same as mine.
Perhaps the quantitative difference comes from k-point sampling.
I couldn't find out the script used for the calculation in my hard disc, so that I'm not sure precise k-point sampling in my calculation.
However, it would probably not be (10,10,10) but like (6,6,100).
  
Title: Re: Script for calculating the voltage drop.
Post by: zdhlover on April 23, 2010, 06:00
I regard your voltage drop as qualitatively the same as mine.
Perhaps the quantitative difference comes from k-point sampling.
I couldn't find out the script used for the calculation in my hard disc, so that I'm not sure precise k-point sampling in my calculation.
However, it would probably not be (10,10,10) but like (6,6,100).
 

I also test the k-point sampling  like (6,6,100)and even better ,but he same results happen? And I am very interesting to know how can I get the very beautiful voltage-drop image as you.
Title: Re: Script for calculating the voltage drop.
Post by: zdhlover on April 23, 2010, 15:31
Thanks nori and Anders Blom,the last voltage-drop I get is same as nori's.
After my  handling, I get the beautiful image as below!

Thanks again!
Wish good luck!
Title: Re: Script for calculating the voltage drop.
Post by: ipsecog on April 23, 2010, 16:25
@zdhlover: Your two last images are identical, I think, and not exactly the same as Nori's. Can you check, and perhaps also post the final script that made it all work out, for the benefit of others?
Title: Re: Script for calculating the voltage drop.
Post by: zdhlover on April 23, 2010, 16:46
I offer some calculation examples of voltage drop.
All calculations were done with the algorithm "ElectrodeConstraints.DensityMatrix".

As Nordland mentioned above, "ElectrodeConstraints.DensityMatrix" instead of "ElectrodeConstraints.Off" should be used when you calculate the voltage drop.
But in some cases such as "Au-DTB-Au", you might get less convergence of SCF with "ElectrodeConstraints.DensityMatrix" (More correctly, the electronic structure that seems to be strange is obtained).
Then, you had better use "ElectrodeConstraints.RealSpaceDensity" instead of "ElectrodeConstraints.DensityMatrix".

I have been build all the two-probe system as you post, but I could't get none of the beautiful pictures of voltage drop as your examples,where is my problem?
I have been notice the use of "ElectrodeConstraints.DensityMatrix" instead of "ElectrodeConstraints.Off" when I calculate the voltage drop.

The append files is my au(111) scripts and outputs,all computation performed in VNL 2008.10.

 ;D ;D ;D I have been modify the scripts  that upload before because the wrong monkhorst_pack_parameters,but also the same results. And upload the modified scripts and results.

I also  test the FFT methods,but also the same results,and I can't get nori's beautiful  image!Why?

Please notice the difference of unit between me and nori's image.
and the the final scripts that made it all work out as same that I have been send it above ,but only modify the k-point sampling  to (6,6,100).as nori said.

Title: Re: Script for calculating the voltage drop.
Post by: kalewu on March 7, 2013, 07:55
Hey everyone.

I just thought I wanted to share with you a small script for calculate the voltage drop using two selfconsistent calculations
on a twoprobe device.

The usage is straight forward:
1)  perform a calculation of a twoprobe at zero bias and store the results in a netcdf file.
2) Do the same for the finite bias, and store this in another netcdf file.
3) Modify the script to match the names of your two calculations, and run it using atk voltagedrop.py.

Then you are done, and you will recieve the voltage drop in a VNL file for visualization in VNL and the
average voltage drop will be printed to the screen. Alternative you can pipe the screen into a log file and plot it using fx GNUplot.

I have attached the script and I have attached a graph showing the voltage drop calculated using this script for a Li-H2-Li system.

useful, thanks