Skip to content

Commit

Permalink
changed measure to allow comparison off different junction resistance…
Browse files Browse the repository at this point in the history
… maps
  • Loading branch information
leobrowning92 committed May 14, 2018
1 parent b83b49b commit 564cf8e
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 30 deletions.
18 changes: 7 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,15 @@ The best and most comprehensive links for MNA on the web:
[Examples](https://www.swarthmore.edu/NatSci/echeeve1/Ref/mna/MNA4.html), and
[Matrix formation rules](https://www.swarthmore.edu/NatSci/echeeve1/Ref/mna/MNAMatrixRules.html).

the network is labeled:

|rows/columns->|0|1|2|...|c-1|
|---|:---:|:---:|:---:|:---:|:---:|
|0|0 |1 |2 | ... |c-1 |
|1|c |c+1|c+2|...|c+c-1|
|2|2c|2c+1|...|...|2c+c-1|
|...|...|...|...|...|...|
|(r-1)*c|(r-1)*c+1|...|...|...|(r-1)*c+c-1=r*c-1|

## electrical junction values:
Fuhrer: mm=200kOhm, ss=400kOhm
tombler : mm 400 to 600 ohm from on to off
tombler : mm 400 to 600 ohm from on to off. compares ms junction to Ti electrode-s junction.
Nirmalraj : 98kOhm to 2.6MOhm for 1.2nm to 14nm diameter bundles.
Topinka : 200kOhm junction resistance from tombler. Treats ms junctions and crosses as nonconductive
Stadermann : 100MOhm at some steps along the scan, attributed to junctions.
Lyons : estimates interjunction resistance from 70kOhm to 3.5Mohm for bundles and tubes
E. Lee : "demonstrate that potential barriers
located at nanotube crossings become dominant in the OFF state of cross-junction devices, as a result of the flattening of Schottky barriers present at the electrical contacts. Consequently, under applied bias, the electrostatic potential drop, and thus the photoresponse, occurs predominantly at these positions."
## Optimization
use cProfile and the [gprof2dot](https://github.com/jrfonseca/gprof2dot).py script to generate profiles of time spent for running the script.
explicit number to run optimization on is:
Expand Down
51 changes: 37 additions & 14 deletions measure_perc.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,30 @@
from multiprocessing import Pool
import uuid as id

#### preset offmappings #####
### 0 ###
# only intertube junctions have a 10^3 on off ratio
offmap0={'ms':1000,'sm':1000, 'mm':1,'ss':1,'vs':1,'sv':1,'vm':1,'mv':1}
### 1 ###
# all ms junctions including electrodes have a 10^3 on off ratio
offmap1={'ms':1000,'sm':1000, 'mm':1,'ss':1,'vs':1000,'sv':1000,'vm':1000,'mv':1000}
### 2 ###
# all junctions including electrodes have a 10^3 on off ratio
offmap2={'ms':1000,'sm':1000, 'mm':1000,'ss':1000,'vs':1000,'sv':1000,'vm':1000,'mv':1000}
offmappings=[offmap0,offmap1,offmap2]


def checkdir(directoryname):
if os.path.isdir(directoryname) == False:
os.system("mkdir " + directoryname)
pass


def measure_fullnet(n,scaling, l='exp', save=False, seed=0, v=True ,remote=False):
def measure_fullnet(n,scaling, l='exp', save=False, seed=0,offmap=1, v=True ,remote=False):
datacol=['sticks', 'size', 'density', 'nclust', 'maxclust', 'ion', 'ioff','gate', 'fname','seed','offmap']
start = timer()
data=pd.DataFrame(columns = ['sticks', 'size', 'density', 'nclust', 'maxclust', 'ion', 'ioff','ioff_totaltop', 'ioff_partialtop', 'runtime', 'fname','seed'])
data=pd.DataFrame(columns = datacol)
try:
collection=perc.StickCollection(n,scaling=scaling,notes='run',l=l,seed=seed)
collection=perc.StickCollection(n,scaling=scaling,notes='run',l=l,seed=seed,offmap=offmappings[offmap])
collection.label_clusters()
nclust=len(collection.sticks.cluster.drop_duplicates())
maxclust=len(max(nx.connected_components(collection.graph)))
Expand Down Expand Up @@ -45,9 +58,9 @@ def measure_fullnet(n,scaling, l='exp', save=False, seed=0, v=True ,remote=False
collection.cnet.set_global_gate(10)
collection.cnet.update()
ioff=sum(collection.cnet.source_currents)
gate='back'

except Exception as e:
ion=0
ioff=0
print("measurement failed: error global gating")
print("ERROR for {} sticks:\n".format(n),e)
traceback.print_exc(file=sys.stdout)
Expand All @@ -63,33 +76,42 @@ def measure_fullnet(n,scaling, l='exp', save=False, seed=0, v=True ,remote=False
except:
ioff_totaltop=0
ioff_partialtop=0
data.loc[0]=[n,scaling,n/scaling**2,nclust,maxclust,ion,ioff,'back',fname,seed,offmap]
data.loc[1]=[n,scaling,n/scaling**2,nclust,maxclust,ion,ioff_totaltop,'total',fname,seed,offmap]
data.loc[2]=[n,scaling,n/scaling**2,nclust,maxclust,ion,ioff_partialtop,'partial',fname,seed,offmap]
else:
ion=0
ioff=0
ioff_totaltop=0
ioff_partialtop=0
gate='back'
data.loc[0]=[n,scaling,n/scaling**2,nclust,maxclust,ion,ioff,gate,fname,seed,offmap]
end = timer()
runtime=end - start
data.loc[0]=[n,scaling,n/scaling**2,nclust,maxclust,ion,ioff,ioff_totaltop,ioff_partialtop,runtime,fname,seed]
data['runtime']=runtime
if fname:
data.to_csv(fname+"_data.csv")
return data

def measure_async(cores,start,step,number,scaling,save=False):
def measure_async(cores, start, step, number, scaling, save=False, offmap=1, seeds=[]):
uuid=id.uuid4()
starttime = timer()
nrange=[int(start+i*step) for i in range(number)]
seeds=np.random.randint(low=0,high=2**32,size=number)
np.savetxt("seeds_{}.csv".format(uuid), seeds, delimiter=",")
if not(len(seeds)==number):
seeds=np.random.randint(low=0,high=2**32,size=number)
if not(os.path.isfile("seeds_{}.csv".format(uuid))):
np.savetxt("seeds_{}.csv".format(uuid), seeds, delimiter=",")
pool=Pool(cores)
results=[pool.apply_async(measure_fullnet,args=(nrange[i],scaling,'exp',save,seeds[i])) for i in range(number)]
results=[]
for omap in offmap:
results= results+[pool.apply_async(measure_fullnet, args=(nrange[i],scaling,'exp',save,seeds[i],omap)) for i in range(number)]
print(len(results))
output=[res.get() for res in results]
endtime = timer()
runtime=endtime - starttime
print('finished with a runtime of {:.0f} seconds'.format(runtime))
data=pd.concat(output)
data.to_csv('measurement_batch_{}.csv'.format(uuid))


if __name__ == '__main__':
parser = argparse.ArgumentParser()
parser.add_argument("-t",'--test',action="store_true",default=False)
Expand All @@ -99,9 +121,10 @@ def measure_async(cores,start,step,number,scaling,save=False):
parser.add_argument("--step",type=int,default=0)
parser.add_argument("--number",type=int)
parser.add_argument("--scaling",type=int,default=5)
parser.add_argument("--offmap",nargs='*',type=int)
args = parser.parse_args()
checkdir('data')
if args.test:
measure_async(2,500,0,10,5,save=True)
else:
measure_async(args.cores, args.start, args.step, args.number,args.scaling, args.save)
measure_async(args.cores, args.start, args.step, args.number,args.scaling, args.save,args.offmap)
11 changes: 6 additions & 5 deletions percolation.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,16 @@


class StickCollection(object):
def __init__(self, n=2, l='exp', pm=0.135, scaling=5, fname='', directory='data', notes='',seed=0):
def __init__(self, n=2, l='exp', pm=0.135, scaling=5, fname='', directory='data', notes='', seed=0,
offmap={'ms':1000, 'sm':1000, 'mm':1, 'ss':1, 'vs':1000, 'sv':1000, 'vm':1000, 'mv':1000}):
self.scaling=scaling
self.n=n
self.pm=pm
self.l=l
self.notes=notes
self.directory=directory
self.percolating=False

self.offmap=offmap
#seeds are included to ensure proper randomness on slurm
if seed:
self.seed=seed
Expand Down Expand Up @@ -141,7 +142,7 @@ def make_graph(self):
if self.percolating:
self.ground_nodes=[1]
self.voltage_sources=[[0,0.1]]
self.populate_graph()
self.populate_graph(self.offmap)
for node in connected_graph.nodes():
connected_graph.nodes[node]['pos'] = [self.sticks.loc[node,'xc'], self.sticks.loc[node,'yc']]
for edge in connected_graph.edges():
Expand All @@ -150,8 +151,8 @@ def make_graph(self):
else:
return False,False,False

def populate_graph(self):
offmap={'ms':1000,'sm':1000, 'mm':1,'ss':1,'vs':1000,'sv':1000,'vm':1000,'mv':1000}
def populate_graph(self,offmap):

for edge in self.graph.edges():
self.graph.edges[edge]['component']=Transistor( off_resistance=offmap[self.graph.edges[edge]['kind']])

Expand Down

0 comments on commit 564cf8e

Please sign in to comment.