Author Topic: How to improve the accuracy of the results?  (Read 6962 times)

0 Members and 1 Guest are viewing this topic.

Offline yangzw1985

  • QuantumATK Guru
  • ****
  • Posts: 113
  • Reputation: 0
    • View Profile
How to improve the accuracy of the results?
« 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!

Offline Anders Blom

  • QuantumATK Staff
  • Supreme QuantumATK Wizard
  • *****
  • Posts: 5418
  • Country: dk
  • Reputation: 89
    • View Profile
    • QuantumATK at Synopsys
Re: How to improve the accuracy of the results?
« Reply #1 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
« Last Edit: February 20, 2009, 11:44 by Anders Blom »

Offline yangzw1985

  • QuantumATK Guru
  • ****
  • Posts: 113
  • Reputation: 0
    • View Profile
Re: How to improve the accuracy of the results?
« Reply #2 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 :)
« Last Edit: February 20, 2009, 11:45 by Anders Blom »

Offline Anders Blom

  • QuantumATK Staff
  • Supreme QuantumATK Wizard
  • *****
  • Posts: 5418
  • Country: dk
  • Reputation: 89
    • View Profile
    • QuantumATK at Synopsys
Re: How to improve the accuracy of the results?
« Reply #3 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! :-[
« Last Edit: February 20, 2009, 11:46 by Anders Blom »

Offline yangzw1985

  • QuantumATK Guru
  • ****
  • Posts: 113
  • Reputation: 0
    • View Profile
Re: How to improve the accuracy of the results?
« Reply #4 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.

Offline Anders Blom

  • QuantumATK Staff
  • Supreme QuantumATK Wizard
  • *****
  • Posts: 5418
  • Country: dk
  • Reputation: 89
    • View Profile
    • QuantumATK at Synopsys
Re: How to improve the accuracy of the results?
« Reply #5 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.

Offline yangzw1985

  • QuantumATK Guru
  • ****
  • Posts: 113
  • Reputation: 0
    • View Profile
Re: How to improve the accuracy of the results?
« Reply #6 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?

« Last Edit: February 20, 2009, 11:30 by yangzw1985 »

Offline Anders Blom

  • QuantumATK Staff
  • Supreme QuantumATK Wizard
  • *****
  • Posts: 5418
  • Country: dk
  • Reputation: 89
    • View Profile
    • QuantumATK at Synopsys
Re: How to improve the accuracy of the results?
« Reply #7 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.
« Last Edit: March 4, 2011, 10:06 by Anders Blom »

Offline yangzw1985

  • QuantumATK Guru
  • ****
  • Posts: 113
  • Reputation: 0
    • View Profile
Re: How to improve the accuracy of the results?
« Reply #8 on: February 20, 2009, 11:57 »
Yes, this time is right.
Thanks!

« Last Edit: February 20, 2009, 12:10 by yangzw1985 »