Author Topic: single electron transistor: setting an array element with a sequenc  (Read 6827 times)

0 Members and 1 Guest are viewing this topic.

Offline Shan

  • QuantumATK Guru
  • ****
  • Posts: 101
  • Country: in
  • Reputation: 0
    • View Profile
Dear Experts,
when i am running the last script in benzene SET manual for self-consistent charge stability diagram. i got an error  "ValueError: setting an array element with a sequence."


please help me...


+------------------------------------------------------------------------------+
| NanoLanguageScript execution started                                         |
+------------------------------------------------------------------------------+
+------------------------------------------------------------------------------+
|                                                                              |
| Atomistix ToolKit 11.2.2 [Build 3069]                                        |
|                                                                              |
+------------------------------------------------------------------------------+
Traceback (most recent call last):
  File "c:\users\bhushan\appdata\local\temp\6043628770183943.py", line 31, in <module>
    voltage_list = numpy.array(voltage_list)
ValueError: setting an array element with a sequence.
NanoLanguageScript execution failure
+------------------------------------------------------------------------------+
| NanoLanguageScript execution finished                                        |
+------------------------------------------------------------------------------+

Offline Anders Blom

  • QuantumATK Staff
  • Supreme QuantumATK Wizard
  • *****
  • Posts: 5411
  • Country: dk
  • Reputation: 89
    • View Profile
    • QuantumATK at Synopsys
This is a "typical" numpy error message, simple to solve, but we'd need to see your input Python script to know how and why it's wrong.

Offline Shan

  • QuantumATK Guru
  • ****
  • Posts: 101
  • Country: in
  • Reputation: 0
    • View Profile
from readTotalEnergy import readTotalEnergy
import pylab
# define the work function of gold
w = 5.28
#gate bias interval
v_g_interval = numpy.linspace(-10,10,201)
#source-drain bias interval
v_sd_interval = numpy.linspace(-15,15,301)
#----------finished define parameters ----------#
#read in the total energy data from the files: benzene_set[-2,-1,0,1,2].nc
voltage_list= []
energy_list = []
#loop over the charge states
charge_states = [-2,-1,0,1,2]
for q in charge_states:
    voltage,energy = readTotalEnergy('benzene_set'+str(q)+'.nc')
    voltage_list = voltage_list + [voltage]
    # add energy of additional/missing electrons on benzene
    energy = energy -q*w
    energy_list = energy_list + [energy]
# make numpy arrays instead of lists
voltage_list = numpy.array(voltage_list)
energy_list = numpy.array(energy_list)
#make function that can return the charging energies
charging_energy = []
for i in range(len(charge_states)-1):
    f = SplineInterpolation1D(voltage_list,energy_list[i+1]-energy_list)
    charging_energy = charging_energy + [f]
#calculate number of charge states in the bias window
def conductionChannels(v_g,v_sd):
    channels = 0
    for f in charging_energy:
        channels = channels + (abs(f(v_g)) <= abs(v_sd/2) )
    return channels
#Generate the mesh points of the contour plot
X, Y = numpy.meshgrid(v_g_interval,v_sd_interval)
#evaluate number of charge states for each mesh point
Z = [ conductionChannels(X[i,j],Y[i,j])
     for i in range(numpy.shape(X)[0])
          for j in range(numpy.shape(X)[1])]
Z = numpy.array(Z).reshape(numpy.shape(X))
#make the plot
pylab.contour(X,Y,Z)
pylab.contourf(X,Y,Z)
pylab.xlabel("Gate voltage (Volt)")
pylab.ylabel("Source-Drain bias (Volt)")
pylab.show()

Offline Anders Blom

  • QuantumATK Staff
  • Supreme QuantumATK Wizard
  • *****
  • Posts: 5411
  • Country: dk
  • Reputation: 89
    • View Profile
    • QuantumATK at Synopsys
Remember to post code as [ code=python ]code here[ / code ] (without the spaces) to make it easier to read.

I can't solve this immediately; in principle if you follow the tutorial exactly, all the scripts should work, but if you deviate a bit, then small changes can mean that the specific analysis scripts receive some input they were not precisely designed for. In that case you may need to do a bit of Python troubleshooting, like inserting "print voltage_list" before line 31.

Offline Shan

  • QuantumATK Guru
  • ****
  • Posts: 101
  • Country: in
  • Reputation: 0
    • View Profile
 I am following the manual as it is. But still getting errors.

some errors are:
1. as mentioned in a post today i got some different charging energies than given in manual for SET phase.
2. for total energy vs gate voltage in SET phase, graph is coming from -8 to 0v of gate voltage instead of -8 to8v gate voltage.

 

Offline Anders Blom

  • QuantumATK Staff
  • Supreme QuantumATK Wizard
  • *****
  • Posts: 5411
  • Country: dk
  • Reputation: 89
    • View Profile
    • QuantumATK at Synopsys
1. The different number can probably be explained by the fact that you are running 11.2 and the numbers in the tutorial are from 11.8. We upgraded the multigrid solver from 11.2 to 11.8.

2. Do you have results for all gate voltages from -8 to 8 V in the NC files?

Offline Shan

  • QuantumATK Guru
  • ****
  • Posts: 101
  • Country: in
  • Reputation: 0
    • View Profile
yes, i have values for all the gate voltages from -8 to 8v.
 namely -8,-6,-4,-2,0,2,4,6,8v.

Offline Anders Blom

  • QuantumATK Staff
  • Supreme QuantumATK Wizard
  • *****
  • Posts: 5411
  • Country: dk
  • Reputation: 89
    • View Profile
    • QuantumATK at Synopsys
1. For all charge states?

2. Try inserting "print voltage_list" before the line "voltage_list = numpy.array(voltage_list)". You need to see what the problem is there.

PS: I'm on holiday, and will not be able to answer quickly, perhaps. So if I disappear for a few days, that's why.

Offline Shan

  • QuantumATK Guru
  • ****
  • Posts: 101
  • Country: in
  • Reputation: 0
    • View Profile
yes all the charge states namely -2,-1,0,1,2 there are values for gate voltages -8,-6,-4,-2,0,2,

Offline Shan

  • QuantumATK Guru
  • ****
  • Posts: 101
  • Country: in
  • Reputation: 0
    • View Profile
gate voltage 4,6,8v missed in above reply post.

Offline Shan

  • QuantumATK Guru
  • ****
  • Posts: 101
  • Country: in
  • Reputation: 0
    • View Profile
Anders sir,
After inserting the command print voltage_list i got same error, with some extra data as below.



+------------------------------------------------------------------------------+
| NanoLanguageScript execution started                                         |
+------------------------------------------------------------------------------+
+------------------------------------------------------------------------------+
|                                                                              |
| Atomistix ToolKit 11.2.2 [Build 3069]                                        |
|                                                                              |
+------------------------------------------------------------------------------+
[array([-8.,  0.,  0.]), array([-8.,  0.,  0.,  0.]), array([-8.,  0.]), array([-8.,  0.,  0.]), array([-8.,  0.])]
Traceback (most recent call last):
  File "c:\users\bhushan\appdata\local\temp\6999651209991004.py", line 25, in <module>
    voltage_list = numpy.array(voltage_list)
ValueError: setting an array element with a sequence.
NanoLanguageScript execution failure
+------------------------------------------------------------------------------+
| NanoLanguageScript execution finished                                        |
+------------------------------------------------------------------------------+

Offline Anders Blom

  • QuantumATK Staff
  • Supreme QuantumATK Wizard
  • *****
  • Posts: 5411
  • Country: dk
  • Reputation: 89
    • View Profile
    • QuantumATK at Synopsys
Yeah, that's wrong... What you should have is 5 identical arrays in a list:

[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., 2., 4., 6., 8.]), array([-8.,  -6.,  -4., -2., 0., 2., 4., 6., 8.])]

So, somehow readTotalEnergy doesn't like the object IDs in the NetCDF files perhaps... There is a risk the indentation got mangled when you saved the script (as would be indicated by your other error, about "return"). Try to download the script again, not by copy/pasting it, but just clicking the link to it in the tutorial HTML page, and then save it directly. Otherwise attach readTotalEnergy.py as a file to your Forum post so I can check this point.


Offline Shan

  • QuantumATK Guru
  • ****
  • Posts: 101
  • Country: in
  • Reputation: 0
    • View Profile
here is the attachment of readTotalEnergy.py file.

Offline Anders Blom

  • QuantumATK Staff
  • Supreme QuantumATK Wizard
  • *****
  • Posts: 5411
  • Country: dk
  • Reputation: 89
    • View Profile
    • QuantumATK at Synopsys
That looks fine. Ok, let's troubleshoot a bit more. Make a copy of your current "readTotalEnergy.py", let's say "readTotalEnergy_realone.py". This is just a backup. Then insert two lines into readTotalEnergy.py:
Code: python
print file_data
return [1],[1]
right after the line "file_data = nlinspect(filename)". Remember these two lines must be indented to the same level as "file_data = ", i.e. 4 spaces first on the line. Do not use TAB. Run the command again (atkpython charge_stability_diagram_full.py) and let's see what it prints.
« Last Edit: July 13, 2012, 15:14 by Anders Blom »

Offline Shan

  • QuantumATK Guru
  • ****
  • Posts: 101
  • Country: in
  • Reputation: 0
    • View Profile
Anders sir,
After inserting the commands print file_data and return [1],[1] in the specified we got another error.
"unsupported operand type(s) for -: 'list' and 'float'".

please check it...
thank you



+------------------------------------------------------------------------------+
| NanoLanguageScript execution started                                         |
+------------------------------------------------------------------------------+
+------------------------------------------------------------------------------+
|                                                                              |
| Atomistix ToolKit 11.2.2 [Build 3069]                                        |
|                                                                              |
+------------------------------------------------------------------------------+
[['BulkConfiguration' 'gID000']
 ['BulkConfiguration' 'gID004']
 ['ElectrostaticDifferencePotential' 'gID001']
 ['ElectrostaticDifferencePotential' 'gID005']
 ['ElectrostaticDifferencePotential' 'pot-2.0 V']
 ['ElectrostaticDifferencePotential' 'pot-4.0 V']
 ['ElectrostaticDifferencePotential' 'pot-6.0 V']
 ['ElectrostaticDifferencePotential' 'pot-8.0 V']
 ['ElectrostaticDifferencePotential' 'pot2.0 V']
 ['ElectrostaticDifferencePotential' 'pot4.0 V']
 ['ElectrostaticDifferencePotential' 'pot6.0 V']
 ['ElectrostaticDifferencePotential' 'pot8.0 V']
 ['MolecularEnergySpectrum' 'gID002']
 ['MolecularEnergySpectrum' 'gID006']
 ['MolecularEnergySpectrum' 'spec-8.0 V']
 ['TotalEnergy' 'energy-8.0 V']
 ['TotalEnergy' 'gID003']
 ['TotalEnergy' 'gID007']]
Traceback (most recent call last):
  File "c:\users\bhushan\appdata\local\temp\0450131338016601.py", line 21, in <module>
    energy = energy -q*w
TypeError: unsupported operand type(s) for -: 'list' and 'float'
NanoLanguageScript execution failure
+------------------------------------------------------------------------------+
| NanoLanguageScript execution finished                                        |
+------------------------------------------------------------------------------+