Author Topic: error with plot the I-V  (Read 26197 times)

0 Members and 1 Guest are viewing this topic.

Offline zhangfuchun

  • Regular QuantumATK user
  • **
  • Posts: 7
  • Reputation: 0
    • View Profile
error with plot the I-V
« on: March 22, 2010, 05:10 »
error:
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


Offline Anders Blom

  • QuantumATK Staff
  • Supreme QuantumATK Wizard
  • *****
  • Posts: 5583
  • Country: dk
  • Reputation: 100
    • View Profile
    • QuantumATK at Synopsys
Re: error with plot the I-V
« Reply #1 on: March 22, 2010, 16:51 »
We'll have a look at it.

Offline eastnobil

  • Regular QuantumATK user
  • **
  • Posts: 19
  • Reputation: 0
    • View Profile
Re: error with plot the I-V
« Reply #2 on: April 1, 2010, 09:32 »
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
Code
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.
Code
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.
« Last Edit: April 1, 2010, 09:36 by eastnobil »

Offline Anders Blom

  • QuantumATK Staff
  • Supreme QuantumATK Wizard
  • *****
  • Posts: 5583
  • Country: dk
  • Reputation: 100
    • View Profile
    • QuantumATK at Synopsys
Re: error with plot the I-V
« Reply #3 on: April 2, 2010, 23:48 »
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.
Code
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!

Offline eastnobil

  • Regular QuantumATK user
  • **
  • Posts: 19
  • Reputation: 0
    • View Profile
Re: error with plot the I-V
« Reply #4 on: April 7, 2010, 04:45 »
The above script fails running on job manager windows. The message is showed as following.
Code
+ -------------------------------------------------------------
| 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?
« Last Edit: April 7, 2010, 04:51 by eastnobil »

Offline Anders Blom

  • QuantumATK Staff
  • Supreme QuantumATK Wizard
  • *****
  • Posts: 5583
  • Country: dk
  • Reputation: 100
    • View Profile
    • QuantumATK at Synopsys
Re: error with plot the I-V
« Reply #5 on: April 7, 2010, 09:31 »
You must have forgotten to copy some lines in the script... The temperature should be on line 4, not 2, so I suspect you left out "from NanoLanguage import *"

Offline eastnobil

  • Regular QuantumATK user
  • **
  • Posts: 19
  • Reputation: 0
    • View Profile
Re: error with plot the I-V
« Reply #6 on: April 10, 2010, 07:47 »
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.
Code
 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?
« Last Edit: April 10, 2010, 07:51 by eastnobil »

Offline Anders Blom

  • QuantumATK Staff
  • Supreme QuantumATK Wizard
  • *****
  • Posts: 5583
  • Country: dk
  • Reputation: 100
    • View Profile
    • QuantumATK at Synopsys
Re: error with plot the I-V
« Reply #7 on: April 10, 2010, 22:36 »
There is nothing strange with negative current, the sign depends on which way the bias is applied. It is, I admit, a bit odd to see the sign change in the middle of the bias sweep, however. But when you consider the magnitude of the current, 1-e8 nA is equivalent to zero current for all practical purposes.

For your reference: first of all, only the relative bias between the electrodes is relevant. If you apply 1 V on each, it's equivalent to zero bias. Moreover, the electrons will be attracted to the positive terminal, so a HIGHER bias on the left means electrons travel right to left. But current is the same as positive charge flow, i.e. opposite to the electrons, so you will get a positive current (from left to right).


Offline eastnobil

  • Regular QuantumATK user
  • **
  • Posts: 19
  • Reputation: 0
    • View Profile
Re: error with plot the I-V
« Reply #8 on: April 11, 2010, 07:46 »
For this calculating example, the lower bias is always applied on the left electrode. And all the bias is negative value showing above. Under such condition, the current is negative value when bias is -0.4 Volt. But the current changes to the positive value applying -0.6~-1.0 Volt. Why can I get the opposite current when the left electrode is always lower bias?
« Last Edit: April 11, 2010, 07:49 by eastnobil »

Offline Nordland

  • QuantumATK Staff
  • Supreme QuantumATK Wizard
  • *****
  • Posts: 812
  • Reputation: 18
    • View Profile
Re: error with plot the I-V
« Reply #9 on: April 11, 2010, 08:03 »
Is the system homogeneous or heterogeneous?

Offline Anders Blom

  • QuantumATK Staff
  • Supreme QuantumATK Wizard
  • *****
  • Posts: 5583
  • Country: dk
  • Reputation: 100
    • View Profile
    • QuantumATK at Synopsys
Re: error with plot the I-V
« Reply #10 on: April 11, 2010, 18:04 »
I admit it's unusual to have a change of sign of current in the middle, but as I said,  I would consider the currents for the low bias points as zero for all practical purposes. Are you sure the bias was set up right? It seems the bias points are not in order...

Offline eastnobil

  • Regular QuantumATK user
  • **
  • Posts: 19
  • Reputation: 0
    • View Profile
Re: error with plot the I-V
« Reply #11 on: April 14, 2010, 08:29 »
I have checked up the calculating carefully. And the low bias truly applied on the left electrode. For plotting the entire IV curve, the zero bias calculating have been performed after finish transmission calculating of -0.1~-0.5 Volt bias ,notwithstanding redunbance. Moreover, the system used in the simulation example is homogeneous and it is a graphene ribbon twoprobe device(armchaire graphene ribbon with 4 width). The leads and scattering region are set with the same ribbon unit. Is this reversal current normal?
« Last Edit: April 14, 2010, 08:31 by eastnobil »

Offline nori

  • QuantumATK Guru
  • ****
  • Posts: 122
  • Reputation: 12
    • View Profile
Re: error with plot the I-V
« Reply #12 on: April 14, 2010, 09:41 »
Have you investigated the transmission spectra at each bias?
I guess some negative transmission coefficients are included in integral range of current calculation.

Offline Nordland

  • QuantumATK Staff
  • Supreme QuantumATK Wizard
  • *****
  • Posts: 812
  • Reputation: 18
    • View Profile
Re: error with plot the I-V
« Reply #13 on: April 14, 2010, 09:57 »
I have been made aware that there has been a minor problem in the code that relates to calculating the current when the current is very small.
Perhaps this is the problem you are experiencing. This has been solved in the newest version and I would suggest that you download the newest version and try to do the I-V curve in that version. It is not need to redo all the calculation, only the I-V curve needs to be redone.

Offline eastnobil

  • Regular QuantumATK user
  • **
  • Posts: 19
  • Reputation: 0
    • View Profile
Re: error with plot the I-V
« Reply #14 on: April 16, 2010, 04:33 »
ATK2010.02 have already been installed but the IV curve analyzer cannot be performed correctly. The error as above description(Reply #2 on: April 1, 2010, 09:32 ) pushes me out of the ATK analyzer and makes me to find out some alternative analysis script. I don't know whether the released 2nd bug fix solves the problem or not.
« Last Edit: April 16, 2010, 04:36 by eastnobil »