Author Topic: transmission spectrum  (Read 19535 times)

0 Members and 1 Guest are viewing this topic.

Offline premkumar85

  • Regular QuantumATK user
  • **
  • Posts: 21
  • Reputation: 0
    • View Profile
transmission spectrum
« on: July 30, 2009, 05:47 »
i am calculating the transmission spectrum for gold atoms. whenever i opened vnl file through result browser, i see transmission spectrum in which transmission is in horizontal axis and energy in  vertical axis. i wish to exchange that co ordinates. i.e to plot transmission in vertical axis and energy in horizontal axis. how to do it?

Offline zh

  • Supreme QuantumATK Wizard
  • *****
  • Posts: 1141
  • Reputation: 24
    • View Profile
Re: transmission spectrum
« Reply #1 on: July 30, 2009, 09:12 »
Now it seems impossible to exchange the axes in transmission spectrum using the "Result Browser" of VNL. But you can export the data of transmission spectrum into a text file, and then you can plot the transmission spectrum using other scientific graphic tools such as GNUPLOT and GRACE to easily achieve what you want.

Offline premkumar85

  • Regular QuantumATK user
  • **
  • Posts: 21
  • Reputation: 0
    • View Profile
Re: transmission spectrum
« Reply #2 on: July 30, 2009, 09:44 »
when i right clicked in the Result browser it shows option for "export plot". then there are 3 options to save that spectrum. ( .ps, .eps, .png) but all are exporting the plot. So tell me how to import the data into a text file.

Offline Anders Blom

  • QuantumATK Staff
  • Supreme QuantumATK Wizard
  • *****
  • Posts: 5577
  • Country: dk
  • Reputation: 96
    • View Profile
    • QuantumATK at Synopsys
Re: transmission spectrum
« Reply #3 on: July 30, 2009, 10:00 »
If you have the log file from the calculation, it should contain the transmission spectrum data as two columns (energy E, T(E)) somewhere towards the end.

If you don't have the log file any more (or, if you encounter the problem that there are too few decimals in the spectrum in the log file...), you can extract it from the VNL file using the method described here: http://quantumwise.com/forum/index.php?topic=3.0. Then, you can plot it in any software you prefer.

You may want to modify the script to load the VNL file internally (instead of prompting for it, interactively), and the same for the sample name (you know this from the Result Browser). Then, when you run the script, just pipe the output to a file, and you will have the spectrum in this file, ready for plotting in e.g. GNUPlot.

Hope you are able to figure this out, otherwise let us know if we need to post more detailed instructions.

Offline premkumar85

  • Regular QuantumATK user
  • **
  • Posts: 21
  • Reputation: 0
    • View Profile
Re: transmission spectrum
« Reply #4 on: July 30, 2009, 10:45 »
when i execute that file i got this following error in command prompt. since the vnl file contains only one sample i hit enter, when it asked me to enter sample name.

Please enter VNL file name: Au100-Au8-Au100_Transmission_4*4*100.vnl
The following samples are present in this VNL file:
['Au100-Au8-Au100']
Please enter sample name to extract (default=first sample):
---------------------------------------------------------------------------
exceptions.KeyError                                  Traceback (most recent call last)

/home/rocks2/valsa/prem/kpoints/extract_transmission_from_vnl_file.py
     30
     31 # Some older versions used "Transmission Spectrum" or "TransmissionSpectrum"
---> 32 trans = data['Transmission Spectrum Transmission Spectrum']
     33 print 'Energy (eV)\tTotal transmission'
     34 print '----------------------------------'

KeyError: 'Transmission Spectrum Transmission Spectrum'
WARNING: Failure executing file: <extract_transmission_from_vnl_file.py>
ATK 2008.10.0 Linux-x86_64 build 14677 2008-11-27

Offline Anders Blom

  • QuantumATK Staff
  • Supreme QuantumATK Wizard
  • *****
  • Posts: 5577
  • Country: dk
  • Reputation: 96
    • View Profile
    • QuantumATK at Synopsys
Re: transmission spectrum
« Reply #5 on: July 30, 2009, 10:52 »
Ok, time for some troubleshooting :) You could just email me the VNL file, if it isn't too huge (usually it isn't unless you saved any 3D grids into it), and I can quickly figure it out. Or (if it is too big, or you just don't want to share it), you can insert a print statement
Code
print data.keys()
before the statement "trans = ...", and let us know the output, and we'll take it from there.

Offline premkumar85

  • Regular QuantumATK user
  • **
  • Posts: 21
  • Reputation: 0
    • View Profile
Re: transmission spectrum
« Reply #6 on: July 30, 2009, 10:57 »
i got this following output in command line after adding that line

Please enter VNL file name: Au100-Au8-Au100_Transmission_4*4*100.vnl
The following samples are present in this VNL file:
['Au100-Au8-Au100']
Please enter sample name to extract (default=first sample):
['Transmission Spectrum T(E)']
---------------------------------------------------------------------------
exceptions.KeyError                                  Traceback (most recent call last)

/home/rocks2/valsa/prem/kpoints/extract_transmission_from_vnl_file.py
     32
     33 # Some older versions used "Transmission Spectrum" or "TransmissionSpectrum"
---> 34 trans = data['Transmission Spectrum Transmission Spectrum']
     35 print 'Energy (eV)\tTotal transmission'
     36 print '----------------------------------'

KeyError: 'Transmission Spectrum Transmission Spectrum'
WARNING: Failure executing file: <extract_transmission_from_vnl_file.py>
ATK 2008.10.0 Linux-x86_64 build 14677 2008-11-27


Offline Anders Blom

  • QuantumATK Staff
  • Supreme QuantumATK Wizard
  • *****
  • Posts: 5577
  • Country: dk
  • Reputation: 96
    • View Profile
    • QuantumATK at Synopsys
Re: transmission spectrum
« Reply #7 on: July 30, 2009, 11:01 »
Ok, this is because you (or whoever generated the script) made a customized label for this quantity when it was added to the VNL file. So, the only thing we need to change (after removing the "print" statement) is this line:
Code
trans = data['Transmission Spectrum Transmission Spectrum']
to
Code
trans = data['Transmission Spectrum T(E)']
Hope this works out for you now!

Offline premkumar85

  • Regular QuantumATK user
  • **
  • Posts: 21
  • Reputation: 0
    • View Profile
Re: transmission spectrum
« Reply #8 on: July 30, 2009, 11:06 »
ya it works well. how can i able to get these data into a text file for future reference?

Thanks in advance

Offline Anders Blom

  • QuantumATK Staff
  • Supreme QuantumATK Wizard
  • *****
  • Posts: 5577
  • Country: dk
  • Reputation: 96
    • View Profile
    • QuantumATK at Synopsys
Re: transmission spectrum
« Reply #9 on: July 30, 2009, 11:36 »
There are two ways. Either modify the script to contain the NC filename and sample explicitly, so you don't have to enter them when you run. Or, use "write" instead of "print". I will present both, although the "write" solution is probably best; there is a complete script for that at the end! (Btw, do you really have a star * in the file name? It's a bad idea, it might screw things up here and there; better use "4x4x100" :) ) Method 1 Pipe the output to a file when you run it, like
Quote
atk extract_transmission_from_vnl_file.py > trans.dat
To modify the script for this is quite easy, just replace
Code
filename = raw_input('Please enter VNL file name: ')
by
Code
filename = "Au100-Au8-Au100_Transmission_4*4*100.vnl"
Then, replace
Code
sname = raw_input('Please enter sample name to extract (default=first sample): ')
by
Code
sname = ""
This only works if the sample we want is the first/only one in the file, but that is the case at hand, so we're good! Method 2 Write a file from within the script, by replacing the "print" statements by "write" statements. This involved a few more lines to modify, so I'll just post the ready script.
Code
import zipfile, cPickle, sys

filename = raw_input('Please enter VNL file name: ')
try:
    f = zipfile.ZipFile(filename,'r')
except:
    print 'Unable to locate VNL file "%s"' % filename
    sys.exit(1)

# Restore the samples from the VNL file into a dict
samples = {}
for zinfo in f.infolist():
    s = f.read(zinfo.filename)
    try: 
        obj = cPickle.loads(s)
        samples[obj.name()] = {}
        for h in obj.history():
            samples[obj.name()][h.name] = h.resultsample.properties()
    except:
        pass

print 'The following samples are present in this VNL file:'
print samples.keys()

sname = raw_input('Please enter sample name to extract (default=first sample): ')
if sname.strip()=="":
    data = samples[samples.keys()[0]]['NanoLanguage']
else:
    data = samples[sname]['NanoLanguage']    

print 'The following properties are present for this sample:'
print data.keys()

# Write the transmission data to a file
f = open("trans_"+filename+"_"+sname+".dat","w")
f.write('# Energy (eV)\tTotal transmission\n')
f.write('# ----------------------------------\n')

# Some older versions used "Transmission Spectrum" or "TransmissionSpectrum"
trans = data['Transmission Spectrum']
energies = trans.energy()._dataarray_
# Check for energy unit, if you want to be sure
# e_unit = t.energy().units()
T = trans.average_transmission()

# Write the transmission data to a file
for i in range(len(energies)):
    f.write('%g\t%g\n' % (energies[i],T[i]))
f.close()
Note that I use the VNL file name to label the output file, so in case you run several times, with different samples or VNL files, you will not overwrite the output files.
« Last Edit: July 30, 2009, 11:44 by Anders Blom »

Offline Anders Blom

  • QuantumATK Staff
  • Supreme QuantumATK Wizard
  • *****
  • Posts: 5577
  • Country: dk
  • Reputation: 96
    • View Profile
    • QuantumATK at Synopsys
Re: transmission spectrum
« Reply #10 on: July 30, 2009, 11:45 »
Please note the previous post was heavily modified after I posted it, so make sure to use the latest version of it!