QuantumATK Forum

QuantumATK => General Questions and Answers => Topic started by: PR on March 31, 2014, 13:11

Title: Capacitance calculation as in tutorial
Post by: PR on March 31, 2014, 13:11
Dear sir,
I was trying to plot capacitance versus voltage curve as given in your mini tutorial at link : http://quantumwise.com/publications/tutorials/mini-tutorials/203
While doing so, I got an error during the execution of file mulliken-analysis.py. This file is given on the mentioned link.
The error I got is :
Traceback (most recent call last):
  File "/tmp/3700607190692751.py", line 54, in <module>
    axarr[1].plot(numpy.arange(len(c)),numpy.cumsum(c-net_charges[0]))
  File "./build/atkpython/lib/python2.7/site-packages/matplotlib/axes.py", line 3848, in plot
  File "./build/atkpython/lib/python2.7/site-packages/matplotlib/axes.py", line 323, in _grab_next_args
  File "./build/atkpython/lib/python2.7/site-packages/matplotlib/axes.py", line 300, in _plot_args
  File "./build/atkpython/lib/python2.7/site-packages/matplotlib/axes.py", line 240, in _xy_from_xy
ValueError: x and y must have same first dimension.

Please tell me how to proceed with this.

Thanks
Priyank
Title: Re: Capacitance calculation as in tutorial
Post by: Umberto Martinez on April 1, 2014, 13:35
The error occurs when trying to plot the data.
a workaround is to modify the lines 49 and 50 of the mulliken-analysis.py script with:

Code
    axarr[0].plot(numpy.arange(len(c[0])),c[0]-net_charges[0][0])
    axarr[1].plot(numpy.arange(len(c[0])),numpy.cumsum(c[0]-net_charges[0][0]))


or download the updated script (you may need to clean your browser's cache).
Title: Re: Capacitance calculation as in tutorial
Post by: Umberto Martinez on April 3, 2014, 08:44
let me add some more details regarding this problem.

Starting from ATK 13.8.0 we changed some default parameters for spin.
In particular when you the atoms method in MullikenPopulation you need to specify the spin components you want, even if the calculation is non-polarized.
You can do that by using the spin keyword, cf. http://www.quantumwise.com/documents/manuals/latest/ReferenceManual/index.html/ref.mullikenpopulation.html (http://www.quantumwise.com/documents/manuals/latest/ReferenceManual/index.html/ref.mullikenpopulation.html),

and change the original script from:
Code
mulliken_charges = [mulliken.atoms()-initial_population for mulliken in mulliken_list]
to:
Code
mulliken_charges = [mulliken.atoms(spin=Spin.Sum)-initial_population for mulliken in mulliken_list]