QuantumATK Forum

QuantumATK => Scripts, Tutorials and Applications => Topic started by: esp on February 3, 2012, 02:28

Title: Script to dope graphene ribbon on edges only by subtitution - from me to you!
Post by: esp on February 3, 2012, 02:28
Code
# -------------------------------------------------------------
# dope the edges of a GNR ribbbon with specified atom
# -------------------------------------------------------------
def dopeEdges(atomsToInpect, coords, atom, ymax_, ymin_):

# get atoms on top (+y) edge of this electrode
edgeAtoms = []
for ind in range(len(atomsToInpect)):
if (coords[ind])[1] == ymax_: # is it an edge atom?
# we can quickly sort here
newInd = 0
for ind2 in range(len(edgeAtoms)):
# check if this new z coord is > each one in list, stop when not true and insert
if (coords[ind])[2] > (coords[edgeAtoms[ind2]])[2]:
pass
else:
# insert here
newInd = ind2
break
# now insert
#print ymax_, "edge", coords[ind], "inserting at", newInd, str(edgeAtoms)
edgeAtoms.insert(newInd, ind) # save this index

carbonCnt = 0
for ind in range(len(edgeAtoms)):
if atomsToInpect[edgeAtoms[ind]] == Carbon: # we know it is though
carbonCnt += 1
if carbonCnt % dopingLvl == 0:
atomsToInpect[edgeAtoms[ind]] = atom

# get atoms on bottom (-y) edge of this electrode
edgeAtoms = []
for ind in range(len(atomsToInpect)):
if (coords[ind])[1] == ymin_: # is it an edge atom?
# we can quickly sort here
newInd = 0
for ind2 in range(len(edgeAtoms)):
# check if this new z coord is > each one in list, stop when not true and insert
if (coords[ind])[2] > (coords[edgeAtoms[ind2]])[2]:
pass
else:
# insert here
newInd = ind2
break
# now insert
#print ymax_, "edge", coords[ind], "inserting at", newInd, str(edgeAtoms)
edgeAtoms.insert(newInd, ind) # save this index

carbonCnt = 0
for ind in range(len(edgeAtoms)):
if atomsToInpect[edgeAtoms[ind]] == Carbon: # we know it is though
carbonCnt += 1
if carbonCnt % dopingLvl == 0:
atomsToInpect[edgeAtoms[ind]] = atom

return atomsToInpect


example usage: set variable dopingLvl to something like 3, meaning replace every 3 Carbons with whatever you specify in the function call .. first loop through to get max and min y for the Carbon atoms in the structure, then call as below

Code

# find min and max y for Carbon atoms (edge atoms)
yminCarbon = 10000*Angstrom
ymaxCarbon = 0*Angstrom
for ind in range(len(central_region_coordinates)):
if central_region_elements[ind] == Carbon:
if (central_region_coordinates[ind])[1] < yminCarbon:
yminCarbon = (central_region_coordinates[ind])[1]
if (central_region_coordinates[ind])[1] > ymaxCarbon:
ymaxCarbon = (central_region_coordinates[ind])[1]

# NOW DOPE
left_electrode_elements = dopeEdges(left_electrode_elements, left_electrode_coordinates, Nitrogen, ymaxCarbon, yminCarbon)
right_electrode_elements = dopeEdges(right_electrode_elements, right_electrode_coordinates, Nitrogen, ymaxCarbon, yminCarbon)
central_region_elements = dopeEdges(central_region_elements, central_region_coordinates, Boron, ymaxCarbon, yminCarbon)




Oh yes then you also need this part:

Code

# now make sure electrodes are matched inside bulk
print "len(left_electrode_elements)", len(left_electrode_elements)
print "len(right_electrode_elements)", len(right_electrode_elements)
for ind in range(len(left_electrode_elements)):
central_region_elements[ind] = left_electrode_elements[ind]
for ind in range(len(right_electrode_elements)):
central_region_elements[\
len(central_region_elements) - len(right_electrode_elements) + ind] = right_electrode_elements[ind]




 ;D
Title: Re: Script to dope graphene ribbon on edges only by subtitution - from me to you!
Post by: Nordland on February 3, 2012, 09:53
Thanks! :)

I will try it.
Title: Re: Script to dope graphene ribbon on edges only by subtitution - from me to you!
Post by: esp on February 3, 2012, 09:59
updated above ... forgot to mention variable dopingLvl ... explained under "example usage"
Title: Re: Script to dope graphene ribbon on edges only by subtitution - from me to you!
Post by: esp on February 4, 2012, 00:51
complete example
Title: Re: Script to dope graphene ribbon on edges only by subtitution - from me to you!
Post by: esp on February 4, 2012, 04:58
new script ... this one uses pure atk python to create a AGNR FET (of any width), passivate it, add gate and dielectric and dope the edges of any combination of left, right or center, it if you want .... see the function call at bottom.  

:)


updated file to allow different doping on each electrode attached below
Title: Re: Script to dope graphene ribbon on edges only by subtitution - from me to you!
Post by: esp on February 4, 2012, 05:20
ok so i think this script is good, except that i think previously it came up that my gate was sticking out of "the box" ... i tried to get some clarification on this but did not get a response .... i think it has to do with needing to modify the unit cell .. ?  please run this script (with or without doping on), and tell me if the resulting device is valid for simulation ... if not, how can i modify the "box" include the gate structure?  and please explain this mysterious item if you can
Title: Re: Script to dope graphene ribbon on edges only by subtitution - from me to you!
Post by: Nordland on February 4, 2012, 13:36
It looks good, but there is a single problem and a suggestion for improvement.

Title: Re: Script to dope graphene ribbon on edges only by subtitution - from me to you!
Post by: esp on February 4, 2012, 21:38
ok great thank you
Title: Re: Script to dope graphene ribbon on edges only by subtitution - from me to you!
Post by: esp on February 8, 2012, 09:29
update this works better and devices converge too