Author Topic: Calculate the electron density for a specific band-by atk 14.3  (Read 4773 times)

0 Members and 1 Guest are viewing this topic.

Offline kaypu

  • QuantumATK Guru
  • ****
  • Posts: 135
  • Country: 00
  • Reputation: 1
    • View Profile
Dear Quantumwise staff:

according to the page from http://quantumwise.com/forum/index.php?topic=2203.msg10537#msg10537
i try to do it using atk 14.3, but something wrong with it. the script as follows:
**********************************************
from NanoLanguage import *
import NLEngine

def makeGridValues(datagrid, cell, origin, unit):

    n0, n1, n2 = datagrid.shape
    gA, gB, gC = cell
    u0 = NLEngine.Cartesian3D(gA[0],gA[1],gA[2])
    u1 = NLEngine.Cartesian3D(gB[0],gB[1],gB[2])
    u2 = NLEngine.Cartesian3D(gC[0],gC[1],gC[2])
    cell_origin = NLEngine.Cartesian3D(origin[0],origin[1],origin[2])

    grid_descriptor = NLEngine.GridDescriptor(n0,n1,n2,
                                              NLEngine.UnitCell(u0,u1,u2,cell_origin))
    grid3d = NLEngine.RealGrid3D(grid_descriptor,
                                 NLEngine.doubleSequenceToRealVector(datagrid.flatten()),True)

    return GridValues(grid3d,unit)

bulk_configuration = nlread("C:\Users\kaypu\Desktop/zigzag12-band.nc", BulkConfiguration)[0]
conf = nlread("C:\Users\kaypu\Desktop/zigzag12-band.nc", BulkConfiguration, read_state=False)[0]

dm = bulk_configuration.calculator()._densityMatrixCalculator()
number_of_electrons = int(dm.fermiDistribution().numberOfElectrons())

LUMO = number_of_electrons/2
LLUMO = LUMO+1

# Which state to compute?
spin = Spin.Up
state = LUMO
filename = "bloch_z12_LUMO_up.nc"

# Number of points to sample from G to Z
Nk = 100

density = None
for kz in numpy.linspace(0.2,0.5,Nk):
    b = BlochState(bulk_configuration, quantum_number=state, k_point=[0,0,kz], spin=spin)
    psi = b.toArray()
    if density == None:
        density = (psi*psi.conj()).real
    else:
        density += (psi*psi.conj()).real

cell = conf.bravaisLattice().primitiveVectors().inUnitsOf(Bohr)
origin = conf.bravaisLattice().origin().inUnitsOf(Bohr)
grid = makeGridValues(density,cell,origin,unit = eV/eV)

nlsave(filename, grid)
nlsave(filename, conf)
******************************************************
the wrong message shows as follows:

Traceback (most recent call last):
  File "c:\users\kaypu\appdata\local\temp\1676064135181985.py", line 52, in <module>
    grid = makeGridValues(density,cell,origin,unit = eV/eV)
  File "c:\users\kaypu\appdata\local\temp\1676064135181985.py", line 12, in makeGridValues
    u0 = NLEngine.Cartesian3D(gA[0],gA[1],gA[2])
AttributeError: 'module' object has no attribute 'Cartesian3D'

what's wrong with it, i use 2014.3
« Last Edit: November 9, 2015, 09:20 by kaypu »

Offline Umberto Martinez

  • Supreme QuantumATK Wizard
  • *****
  • Posts: 479
  • Country: dk
  • Reputation: 26
    • View Profile
Re: Calculate the electron density for a specific band-by atk 14.3
« Reply #1 on: November 9, 2015, 09:04 »
In ATK 2014.3 you can use the BlochState analysis directly from the scripter and visualize the results in VNL in just one click.
Please, have a look at this tutorial: http://quantumwise.com/documents/tutorials/latest/GrapheneBloch/index.html/chap.blochstates.html

Offline kaypu

  • QuantumATK Guru
  • ****
  • Posts: 135
  • Country: 00
  • Reputation: 1
    • View Profile
Re: Calculate the electron density for a specific band-by atk 14.3
« Reply #2 on: November 9, 2015, 09:26 »
thank you prof. Umberto Martinez, the tutorial only contains how to calculate blochstate at one k-point. however, i want to get the electron density for a specific band, it means the summation of blochstate from G-Z.  how to modify the script?

Offline Anders Blom

  • QuantumATK Staff
  • Supreme QuantumATK Wizard
  • *****
  • Posts: 5565
  • Country: dk
  • Reputation: 93
    • View Profile
    • QuantumATK at Synopsys
Re: Calculate the electron density for a specific band-by atk 14.3
« Reply #3 on: November 9, 2015, 09:43 »
Actually you are probably using 13.8, if that's the error message... Cartesian3D works in 12.8 and 2014, but in 13.8 this class was renamed Cartesian3DDouble.

Offline kaypu

  • QuantumATK Guru
  • ****
  • Posts: 135
  • Country: 00
  • Reputation: 1
    • View Profile
Re: Calculate the electron density for a specific band-by atk 14.3
« Reply #4 on: November 9, 2015, 09:50 »
thank you prof.Anders Blom, it works.

i really use atk 2014.3

Offline Anders Blom

  • QuantumATK Staff
  • Supreme QuantumATK Wizard
  • *****
  • Posts: 5565
  • Country: dk
  • Reputation: 93
    • View Profile
    • QuantumATK at Synopsys
Re: Calculate the electron density for a specific band-by atk 14.3
« Reply #5 on: November 9, 2015, 10:50 »
Ok, yes, I was wrong... We've managed to confuse ourselves in this :)

2015 and onwards use Cartesian3D - as did 12.8
2014 and 13.8 intermediately used Cartesian3DDouble