Author Topic: Script to dope graphene ribbon on edges only by subtitution - from me to you!  (Read 10263 times)

0 Members and 1 Guest are viewing this topic.

Offline esp

  • Supreme QuantumATK Wizard
  • *****
  • Posts: 318
  • Country: us
  • Reputation: 3
    • View Profile
    • University of Minnesota
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
« Last Edit: February 4, 2012, 00:48 by esp »

Offline Nordland

  • QuantumATK Staff
  • Supreme QuantumATK Wizard
  • *****
  • Posts: 812
  • Reputation: 18
    • View Profile
Thanks! :)

I will try it.

Offline esp

  • Supreme QuantumATK Wizard
  • *****
  • Posts: 318
  • Country: us
  • Reputation: 3
    • View Profile
    • University of Minnesota
updated above ... forgot to mention variable dopingLvl ... explained under "example usage"

Offline esp

  • Supreme QuantumATK Wizard
  • *****
  • Posts: 318
  • Country: us
  • Reputation: 3
    • View Profile
    • University of Minnesota
complete example

Offline esp

  • Supreme QuantumATK Wizard
  • *****
  • Posts: 318
  • Country: us
  • Reputation: 3
    • View Profile
    • University of Minnesota
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
« Last Edit: February 8, 2012, 09:29 by esp »

Offline esp

  • Supreme QuantumATK Wizard
  • *****
  • Posts: 318
  • Country: us
  • Reputation: 3
    • View Profile
    • University of Minnesota
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

Offline Nordland

  • QuantumATK Staff
  • Supreme QuantumATK Wizard
  • *****
  • Posts: 812
  • Reputation: 18
    • View Profile
It looks good, but there is a single problem and a suggestion for improvement.

  • As you write yourself, the gates are unlucky, since they are sticking of the central region area, meaning in your case, that the metallic region is not a part of the calculation. So either you have make the cell larger to contain these (more expensive in terms of calculation time) or make the regions more narrow. Since you have a reference for a paper I think it is because you want the exact same gate, so therefore I have opted with the increasing the cell size. If you add the keyword vacuum=12.0*Ang to all your nanosheet, and now the gates are perfect within the central region area.
  • When it comes to getting the errors if there is a error in the script, there is a much simpler and better way :), just write: traceback.print_exc() and it gives your all the information about the exception in a nicely formatted print
« Last Edit: February 4, 2012, 13:41 by Nordland »

Offline esp

  • Supreme QuantumATK Wizard
  • *****
  • Posts: 318
  • Country: us
  • Reputation: 3
    • View Profile
    • University of Minnesota
ok great thank you

Offline esp

  • Supreme QuantumATK Wizard
  • *****
  • Posts: 318
  • Country: us
  • Reputation: 3
    • View Profile
    • University of Minnesota
update this works better and devices converge too