QuantumATK Forum

QuantumATK => General Questions and Answers => Topic started by: yangzw1985 on February 20, 2009, 09:45

Title: How to improve the accuracy of the results?
Post by: yangzw1985 on February 20, 2009, 09:45
Hi ,everyone! I have a question about the accuracy of the results. I have calculate the transimission spectrum, but the coefficients are all zero. The results are 0.0000. If I want to the results are more accuracy as:0.000000000 etc, I want to know if it is possible. And what should I do in order to obtain more accuracy? Thanks in advance!
Title: Re: How to improve the accuracy of the results?
Post by: Anders Blom on February 20, 2009, 09:57
Most likely you use a NanoLanguage script produced by VNL, in which case the part that prints the transmission spectrum contains the line

Code
if processIsMaster(): nlPrint(transmission_spectrum)

To print the values with proper accuracy, replace that line by something like

Code
energies = transmission_spectrum.energies()
coefficients = transmission_spectrum.coefficients()
print 'Energy (eV)     Transmission'
print '-----------------------------------'
for i in range(len(energies)):
    print "%g\t%g" % ( energies[i].inUnitsOf(eV),coefficients[i] )

Updated: Fixed error in code
Title: Re: How to improve the accuracy of the results?
Post by: yangzw1985 on February 20, 2009, 10:53
Thank you ! Great!
But it has an error, we have corrected it. It should be like this:


energies = transmission_spectrum.energies()
coefficients = transmission_spectrum.coefficients()
print 'Energy (eV)     Transmission'
print '-----------------------------------'
for i in range(len(energies)):
    print "%g\t%g" % ( energies.inUnitsOf(eV),coefficients )

Moderator note: This code doesn't work :)
Title: Re: How to improve the accuracy of the results?
Post by: Anders Blom on February 20, 2009, 11:01
Hmm, I'm sorry, I don't think your code will work.
"energies" is an object of type TransmissionSpectrum, and has no method inUnitsOf. Besides, even if it did, your loop would print the same thing for every step in the loop (each time the whole transmission spectrum).
Try my version, I'm sure it works ;)

Update: Now it works after I fixed it! :-[
Title: Re: How to improve the accuracy of the results?
Post by: yangzw1985 on February 20, 2009, 11:05
But it really is !
we have check my code with li-h2-li,it is right.
but in your code ,it has an error.
Title: Re: How to improve the accuracy of the results?
Post by: Anders Blom on February 20, 2009, 11:07
Ok, I think I know what might be the cause. Your test case probably only has a single point in the transmission spectrum? Post the script that works (Li-H2-Li) so we can confirm this, and I can update my version to work in general, for all cases :) Because your version will not work for a "usual" transmission spectrum with, say, 100 points from -2 to +2 eV.
Title: Re: How to improve the accuracy of the results?
Post by: yangzw1985 on February 20, 2009, 11:12
if I want to calculate the transimission spectrum of a li-znowire-li with 200 points -6--6 ev, what should I do ?

there is something with my code exhibited in the screen.
For your code, the error was occured in the second lines.

energies = transmission_spectrum.energies()
coefficients = transmission_spectrum.coefficients()


electron_transmission should be changed by transmission_spectrum

Is that right?

Title: Re: How to improve the accuracy of the results?
Post by: Anders Blom on February 20, 2009, 11:44
Ah! I copy-pasted from the manual, and forgot to change in one place...  :-[ Thanks for noticing it. So, the correct code should be

Code: python
energies = transmission_spectrum.energies()
coefficients = transmission_spectrum.coefficients()
print 'Energy (eV)     Transmission'
print '-----------------------------------'
for j in range(len(energies)):
    print "%g\t%g" % ( energies[j].inUnitsOf(eV),coefficients[j] )

To get 201 points (better than 200 since otherwise you don't get a point at E=0) from -6 to 6 eV, you could do

Code: python
from numpy import arange
energies = arange(-6,6.01,12./200)*eV
transmission_spectrum = calculateTransmissionSpectrum(scf,energies)

Assuming, that is, that the self-consistent object is called "scf" and that the system only needs (1x1) k-point sampling in the XY plane.
Title: Re: How to improve the accuracy of the results?
Post by: yangzw1985 on February 20, 2009, 11:57
Yes, this time is right.
Thanks!