Author Topic: Error in "ReadTtoalEnergy" file in Single Electron Transistor  (Read 3248 times)

0 Members and 1 Guest are viewing this topic.

Offline itsvikassh

  • Regular QuantumATK user
  • **
  • Posts: 10
  • Country: in
  • Reputation: 0
    • View Profile
Hello

While running "readTotalEnergy" file, the following error showed:-

+------------------------------------------------------------------------------+
| NanoLanguageScript execution started                                         |
+------------------------------------------------------------------------------+
+------------------------------------------------------------------------------+
|                                                                              |
| Atomistix ToolKit 11.2.2 [Build 3069]                                        |
|                                                                              |
+------------------------------------------------------------------------------+
  File "c:\users\vikash\appdata\local\temp\4220524954374833.py", line 13
    return
SyntaxError: 'return' outside function
NanoLanguageScript execution failure
+------------------------------------------------------------------------------+
| NanoLanguageScript execution finished                                        |
+-------------------------------------------------




i have used the following script:




from NL.IO.NLSaveUtilities import nlinspect
#define function for reading in total energy and gate voltage data from a file
def readTotalEnergy(filename):
    """
    function for reading a list of total energies and gate voltages from a file
        @param filename            : filename of the netcdf file
        @return voltages, energies : list of gate voltages and energies
                                     found in filename
    """
if filename == None:
    return
#get list of data in file
file_data = nlinspect(filename)
if file_data == None:
   raise ValueError, "Wrong file format"
total_energy_list = numpy.array([])
gate_voltage_list = numpy.array([])
for id in file_data:
    if (id[0] == 'TotalEnergy'):
       total_energy=nlread(filename, object_id = id[1])[0]
       total_energy_list = numpy.append(total_energy_list,
                                        total_energy.evaluate().inUnitsOf(eV))
#extract the gate voltage from the id of the data
if id[1][0:3] == 'gID':
   gate_voltage = 0.0
else:
    gate_voltage = float(id[1].strip(
                   "abcdefghijklmnopqrstuvxyzABCDEFGHIJKLMNOPQRSTUVXYZ"))
gate_voltage_list = numpy.append(gate_voltage_list,gate_voltage)
if len(total_energy_list) ==0:
    raise ValueError, "No total energy in NC file"
#sort the data
index_list = numpy.argsort(gate_voltage_list)
return gate_voltage_list[index_list], total_energy_list[index_list]



please do help....

Offline Anders Blom

  • QuantumATK Staff
  • Supreme QuantumATK Wizard
  • *****
  • Posts: 5565
  • Country: dk
  • Reputation: 93
    • View Profile
    • QuantumATK at Synopsys
The problems appears to be that you have somehow lost the indentation of the script, perhaps by using a non-programming editor (like Wordpad) or via a copy/paste procedure. Download the script exactly as it is rather than using copy/paste, and edit it in the built-in Editor in VNL, or a programmer's editor like Notepad++ or similar.

Offline itsvikassh

  • Regular QuantumATK user
  • **
  • Posts: 10
  • Country: in
  • Reputation: 0
    • View Profile
thanx anders for previous problem..

actually now there is problem in charge stability diagram

"
[array([-8., -6., -4., -2.,  0.,  2.,  4.,  6.,  8.]), array([-8., -6., -4., -2.,  0.,  2.,  4.,  6.,  8.]), array([-8., -6., -4., -2.,  0.,  2.,  4.,  6.,  8.]), array([-8., -6., -4., -2.,  0.,  0.,  2.,  4.,  6.,  8.]), array([-8., -6., -4., -2.,  0.,  2.,  4.,  6.,  8.])]
Traceback (most recent call last):
  File "c:\users\vikash\appdata\local\temp\5582308989099040.py", line 30, in <module>
    f = SplineInterpolation1D(voltage_list,energy_list[i+1]-energy_list)
ValueError: operands could not be broadcast together with shapes (10) (9) "
« Last Edit: August 2, 2013, 07:36 by itsvikassh »

Offline kstokbro

  • Supreme QuantumATK Wizard
  • *****
  • Posts: 392
  • Reputation: 13
    • View Profile
    • QuantumWise
You did not download the script, but copy pasted it and did not get all text copied, the line in the script is

f = SplineInterpolation1D(voltage_list,energy_list[i+1]-energy_list)

Offline Anders Blom

  • QuantumATK Staff
  • Supreme QuantumATK Wizard
  • *****
  • Posts: 5565
  • Country: dk
  • Reputation: 93
    • View Profile
    • QuantumATK at Synopsys
Actually, you may have the script correctly (or not), but note that when you attempt to make posts on the Forum containing [i] it will be shown wrong, since this is the code for making italic text on the Forum. You should always include code in [code=python]....[/code].

I can't tell what's wrong with your plot from the information you posted. Possibly you have too much data in one file, resulting from running a script more than once. This particular tutorial is a bit tricky and actually requires quite a fair amount of experience in Python and ATK. But at the very least, always post the script you are running (as attachment or inside the aforementioned code brackets) else we can't help.