I dragged the .py file to job manager following the operation of ATK2010.02 manual. The code of .py file is the same with the manual as follow
from NanoLanguage import *
#read in the old configuration
device_configuration = nlread("LiH2.nc",DeviceConfiguration)[0]
calculator = device_configuration.calculator()
# Define sample biases
voltage_list = numpy.linspace(0.1,1.0,10)
for voltage in voltage_list:
# Set the calculator and use the old scf state as starting input.
device_configuration.setCalculator(
calculator(electrode_voltages=(-0.5*voltage,0.5*voltage)*Volt ),
initial_state=device_configuration
)
#Analysis
filename = 'lih2li.nc'
electrostatic_potential = ElectrostaticDifferencePotential(device_configuration)
nlsave(filename, electrostatic_potential, object_id='pot'+str(voltage))
transmission_spectrum = TransmissionSpectrum(
configuration=device_configuration,
energies=numpy.linspace(-5,5,200)*eV,
)
nlsave(filename, transmission_spectrum,object_id='trans'+str(voltage))
molecular_energy_spectrum = MolecularEnergySpectrum(
configuration=device_configuration,
energy_zero_parameter=FermiLevel,
projection_list=ProjectionList([Hydrogen])
)
nlsave(filename, molecular_energy_spectrum,object_id='mpsh'+str(voltage) )
In the above code, I just changed the nc filename. After completion of calculation I had dropped the file lih2li.nc onto the NC file drop zone of the VNL Custom Analyzer tool. Then the following error appeared in the log window.
Traceback (most recent call last):
File ".\zipdir\NL\GUI\Core\Runner.py", line 220, in run
File ".\zipdir\NL\GUI\Tools\CustomAnalyzer\Analyzers\IVCurve.py", line 40, in analyzer
File ".\zipdir\NL\Analysis\TransmissionSpectrum.py", line 341, in current
File ".\zipdir\NL\IO\NLLogger.py", line 66, in write
IOError: [Errno 9] Bad file descriptor
I also wants to know why this error occurred like zhangfuchun and how to get the correct plot of IV curve.
We apologize, this is a bug. It has nothing to do with the NC file, as you might think (and I did, so it took some time to understand it), but it's an internal problem caused by the current() method on the TransmissionSpectrum class. It tries to write things to the output terminal, but doesn't figure it out...
For now, to make a simple I-V curve, just use the code below, which is a simplified version of the IVCurve analyzer.
You need to edit the file name and temperatures manually, then drop the script on the Job Manager, and extract the current vs. voltage values from the end of the log output, and plot them in Excel, GNUPlot, or whatever you prefer.
from NanoLanguage import *
filename = 'E:/users/anders/Documents/nl/LiH2Li_iv_sweep.nc'
left_temperature = 300*Kelvin
right_temperature = 300*Kelvin
transmission_spectrum_list = nlread(filename,TransmissionSpectrum)
n = len(transmission_spectrum_list)
voltage_list = numpy.zeros(n)
current_list = numpy.zeros(n)
for i in range(n):
voltage_list[i] = transmission_spectrum_list[i].bias().inUnitsOf(Volt)
current_list[i] = 1.e9*transmission_spectrum_list[i].current(electrode_temperatures=(left_temperature,right_temperature)).inUnitsOf(Ampere)
print "Voltage (V)\tCurrent(nA)"
print "==============================="
for i in range(n):
print voltage_list[i],'\t',current_list[i]
This also shows you how, actually, VNL computes the current, so it's instructive anyway!
The above script fails running on job manager windows. The message is showed as following.
+ -------------------------------------------------------------
| NanoLanguageScript execution started
+ -------------------------------------------------------------
Traceback (most recent call last):
File "c:\users\hfang\appdata\local\temp\0817546369726710.py", line 2, in <module>
left_temperature = 100*Kelvin
NameError: name 'Kelvin' is not defined
NanoLanguageScript execution failure
+ -------------------------------------------------------------
| NanoLanguageScript execution finished
+ -------------------------------------------------------------
How to deal with this error?
Thanks for your help. I have solved this calculating error follow your suggestion. But I met a strange problem. That is the negative value of current. The results of my IV calculation as following.
Voltage (V) Current(nA)
===============================
-0.1 -1.87583990988e-06
-0.2 -7.38462057173e-06
-0.3 -3.48761791403e-05
-0.4 -0.000168109047444
-0.5 -9.75295926357e-05
0.0 0.0
-0.6 2.02511109092e-05
-0.7 0.000175293199431
-0.8 0.000297218070319
-0.9 0.000474492254908
-1.0 0.000221309940839
What is the explanation of negative current showing above?
ATK SE2010.02 of the 2nd bug fix have been installed and tried to drop the nc file to the IV curve analyzer. The error message still exists as following.
Traceback (most recent call last):
File ".\zipdir\NL\GUI\Core\Runner.py", line 220, in run
File ".\zipdir\NL\GUI\Tools\CustomAnalyzer\Analyzers\IVCurve.py", line 40, in analyzer
File ".\zipdir\NL\Analysis\TransmissionSpectrum.py", line 357, in current
File ".\zipdir\NL\IO\NLLogger.py", line 66, in write
IOError: [Errno 9] Bad file descriptor
How to deal with this situation?