def chain_from_params(xyz,params): N = len(xyz.atoms) H = [ matrix(zeros((N,N))) for i in range(2) ] S = [ matrix(zeros((N,N))) for i in range(2) ] h00,s00 = params(0.0) assert s00 == 1.0 for i in range(N): H[0][i,i] = h00 for j in range(i+1,N): h,s = params(norm(xyz.atoms[i].pos - xyz.atoms[j].pos)) print h/eV,s H[0][i,j] = h H[0][j,i] = h S[0][i,j] = s S[0][j,i] = s for i in range(N): for j in range(N): h,s = params(norm(xyz.atoms[i].pos - (xyz.atoms[j].pos + xyz.period))) print h/eV,s H[1][i,j] = h S[1][i,j] = s if any(S[0] != 0.0): for i in range(N): S[0][i,i] = 1.0 else: assert all(S[1] == 0.0) S = None return chain.chain(H,xyz,S=S)
def test_chain_with_range_to_list(self): iterable_one = range(0, 4) iterable_two = range(4, 8) result = list(chain(iterable_one, iterable_two)) self.assertEqual(result, [0, 1, 2, 3, 4, 5, 6, 7])
def main(): ## Pass the kafka_url, e.g. `192.168.1.110:9092` kafka_url = sys.argv[1] ## Register to read messages from the "rousseau" list consumer = KafkaConsumer('rousseau', group_id='my_group', bootstrap_servers=[kafka_url]) ## Register to send to the rousseau-chain channel kafka = KafkaClient(kafka_url) producer = SimpleProducer(kafka) # Initialize a chain backed by 2 disk files c = chain(diskHashList("fentries.dat"), diskHashList("fnodes.dat")) ## The main even loop for message in consumer: # message value is raw byte string -- decode if necessary! # e.g., for unicode: `message.value.decode('utf-8')` print("%s:%d:%d: key=%s value=%s" % (message.topic, message.partition, message.offset, message.key, message.value)) seq = c.add(message.value) response = "%s|%s|%s" % (seq, hexlify(c.head()), message.value) print (response) # Note that the application is responsible for encoding messages to type bytes producer.send_messages(b'rousseau-chain', response)
def test_with_strings(self): list1 = '0123' list2 = '4567' result = list(chain(list1, list2)) self.assertEqual(result, ['0', '1', '2', '3', '4', '5', '6', '7'])
def test_with_atleast_one_set_returns_concatenated_list(self): it_1 = {1, 2} it_2 = (3, 4, 6) result = list(chain(it_1, it_2)) expected = [1, 2, 3, 4, 6] self.assertEqual(result, expected)
def test_with_sets(self): list1 = {0, 1, 2, 3} list2 = {4, 5, 6, 7} result = list(chain(list1, list2)) self.assertEqual(result, [0, 1, 2, 3, 4, 5, 6, 7])
def test_wiht_dicts(self): list1 = {0: 0, 1: 0, 2: 0, 3: 0} list2 = {4: 1, 5: 0, 6: 0, 7: 0} result = list(chain(list1, list2)) self.assertEqual(result, [0, 1, 2, 3, 4, 5, 6, 7])
def test_with_lists(self): list1 = [0, 1, 2, 3] list2 = [4, 5, 6, 7] result = list(chain(list1, list2)) self.assertEqual(result, [0, 1, 2, 3, 4, 5, 6, 7])
def test_with_tuples(self): list1 = (0, 1, 2, 3) list2 = (4, 5, 6, 7) result = list(chain(list1, list2)) self.assertEqual(result, [0, 1, 2, 3, 4, 5, 6, 7])
def test_when_both_iterables_are_empty(self): iterable1 = [] iterable2 = [] expected_result = [] self.assertEqual(list(chain(iterable1, iterable2)), expected_result)
def run_rangeapply(self, cbsrg, cbrange, chained_srg): RANGEAPPLY = [sys.executable, 'rangeapply.py', '--srcRoot', os.path.join(self.cb_dir, 'src', 'main', 'java'), '--srcRangeMap', cbrange, '--mcpConfDir', os.path.join(self.fml_dir, 'mcp', 'conf')] data = os.path.join(self.data, self.version) excs = [f for f in os.listdir(data) if f.endswith('.exc')] if len(excs) > 0: RANGEAPPLY += ['--excFiles'] RANGEAPPLY += [",".join([os.path.join(data, x) for x in excs])] srgs = [f for f in os.listdir(os.path.join(self.data, self.version)) if f.endswith('.srg') and not f == 'cb_to_vanilla.srg'] RANGEAPPLY += ['--srgFiles'] RANGEAPPLY += [",".join([chained_srg] + [os.path.join(data, x) for x in srgs])] from chain import chain chained = chain(os.path.join(self.fml_dir, 'mcp', 'conf', 'packaged.srg'), '^' + cbsrg, verbose=False) if os.path.isfile(chained_srg): os.remove(chained_srg) with open(chained_srg, 'wb') as out_file: out_file.write('\n'.join(chained)) if not self.run_command(RANGEAPPLY): sys.exit(1)
def test_when_iterables_are_tuples(self): iterable1 = (-1, 0) iterable2 = (1, 2) expected_result = tuple(range(-1, 3)) self.assertEqual(tuple(chain(iterable1, iterable2)), expected_result)
def test_when_both_iterables_are_non_empty_then_return_them_consecutively(self): iterable1 = list(range(4, 7)) iterable2 = list(range(1, 4)) expected_result = [4, 5, 6, 1, 2, 3] self.assertEqual(list(chain(iterable1, iterable2)), expected_result)
def test_check_negative(): c = chain() c.add("Hello") # Add a lot of those for _ in xrange(1000): c.add("Hello") e = c.evidence(100) import pytest # Wrong entry with pytest.raises(Exception): check_evidence(c.head(), 100, e, entry="Hello2") # Wrong nodes with pytest.raises(Exception): check_evidence(c.head(), 100, e, node="Hello2") # Wrong head with pytest.raises(Exception): check_evidence(c.nodes[-2], 100, e) # Wrong chain (en, no) = e no[88] = no[231] with pytest.raises(Exception): check_evidence(c.head(), 100, (en, no))
def test_when_first_iterable_is_empty(self): iterable1 = [] iterable2 = list(range(4, 7)) expected_result = list(range(4, 7)) self.assertEqual(list(chain(iterable1, iterable2)), expected_result)
def main(): ## Pass the kafka_url, e.g. `192.168.1.110:9092` kafka_url = sys.argv[1] ## Register to read messages from the "rousseau" list consumer = KafkaConsumer('rousseau', group_id='my_group', bootstrap_servers=[kafka_url]) ## Register to send to the rousseau-chain channel kafka = KafkaClient(kafka_url) producer = SimpleProducer(kafka) # Initialize a chain backed by 2 disk files c = chain(diskHashList("fentries.dat"), diskHashList("fnodes.dat")) ## The main even loop for message in consumer: # message value is raw byte string -- decode if necessary! # e.g., for unicode: `message.value.decode('utf-8')` print("%s:%d:%d: key=%s value=%s" % (message.topic, message.partition, message.offset, message.key, message.value)) seq = c.add(message.value) response = "%s|%s|%s" % (seq, hexlify(c.head()), message.value) print(response) # Note that the application is responsible for encoding messages to type bytes producer.send_messages(b'rousseau-chain', response)
def test_with_ranges(self): list1 = range(0, 4) list2 = range(4, 8) result = list(chain(list1, list2)) self.assertEqual(result, [0, 1, 2, 3, 4, 5, 6, 7])
def test_with_two_lists_returns_concatenated_list(self): it_1 = [1, 2, 3] it_2 = [4, 5, 6] result = list(chain(it_1, it_2)) expected = [1, 2, 3, 4, 5, 6] self.assertEqual(result, expected)
def test_with_atleast_one_dict_returns_concatenated_list(self): it_1 = {'one': 1, 'two': 2} it_2 = [3, 4] result = list(chain(it_1, it_2)) expected = [1, 2, 3, 4] self.assertEqual(result, expected)
def setup_chain(self,xyz_chain,do_cache=True): at = xyz_chain.atoms for a in at: a.rot4 = matrix(eye(4)) a.rot4[1:4,1:4] = a.rot period = xyz_chain.period Natoms = len(at) rho = zeros((Natoms,)) H = [] S = [] for n in range(20): at_sh = xyz_chain.shift(period*n).atoms h = matrix(zeros((4*Natoms,4*Natoms))) s = matrix(zeros((4*Natoms,4*Natoms))) nonzero = False for i in range(Natoms): for j in range(Natoms): if n==0 and i>=j: continue Rvec = at[i].pos - at_sh[j].pos drho, h_xyz, s_xyz = self.calc_pair_HS(Rvec) if drho is None: continue nonzero = True rho[i] += drho rho[j] += drho h[4*i:4*i+4,4*j:4*j+4] = at[i].rot4.T * h_xyz * at[j].rot4 s[4*i:4*i+4,4*j:4*j+4] = at[i].rot4.T * s_xyz * at[j].rot4 if not nonzero: break H.append(h) S.append(s) for i in range(Natoms): rho3 = rho[i]**(1/3.) h_s = self.alpha_s + self.beta_s * rho3**2 + self.gamma_s * rho3**4 + self.chi_s * rho3**6 h_p = self.alpha_p + self.beta_p * rho3**2 + self.gamma_p * rho3**4 + self.chi_p * rho3**6 H[0][4*i,4*i] = h_s H[0][4*i+1,4*i+1] = h_p H[0][4*i+2,4*i+2] = h_p H[0][4*i+3,4*i+3] = h_p S[0][4*i,4*i] = 1.0 S[0][4*i+1,4*i+1] = 1.0 S[0][4*i+2,4*i+2] = 1.0 S[0][4*i+3,4*i+3] = 1.0 for j in range(i): H[0][4*i:4*i+4,4*j:4*j+4] = H[0][4*j:4*(j+1),4*i:4*(i+1)].H S[0][4*i:4*i+4,4*j:4*j+4] = S[0][4*j:4*(j+1),4*i:4*(i+1)].H return chain.chain(H,S=S,xyz_chain=xyz_chain,do_cache=do_cache)
def __init__(self, diameter=4, graft_length=25, chain_type_list=['A']*12+['B']*12): super(janusGraftedSphere,self).__init__() self.name='janusGraftedSphere' self.placed=False self.natoms=0 self.dihedrals=[] self.positions=[] self.types=[] self.diameters=[] self.bonds=[] self.bodies=[] self.angles=[] self.beadVol=0 core = sphere(diameter=diameter, type=['F']) core.addBeads(radius=diameter/2.0-0.5, type=['E']) core.addBeads(radius=diameter/2.0-0.5, type=['E'], num_beads=int(len(chain_type_list)*1.25)) self.addMolecule(core) # self.bonds=[] self.beadVol+=sphereVol(diameter) anchorIndex=copy.deepcopy(self.natoms)-1 corePos = list(core.positions) coreTypes = list(core.types) for chain_type in chain_type_list: graft = chain(length=graft_length,sequence=[chain_type],angleName=None) graft.makeLinear() foundGraftPoint=False while not foundGraftPoint: select = np.random.randint(1,len(corePos)) if coreTypes[select] != 'E': corePos.pop(select) coreTypes.pop(select) foundGraftPoint=False elif corePos[select][2]>0 and chain_type=='A': anchorVec = corePos.pop(select) coreTypes.pop(select) foundGraftPoint=True elif corePos[select][2]<0 and chain_type=='B': anchorVec = corePos.pop(select) coreTypes.pop(select) foundGraftPoint=True graftVec = graft.positions[1]-graft.positions[0] anchorNorm=(anchorVec[0]**2.0+anchorVec[1]**2.0+anchorVec[2]**2.0)**(0.5) monomer1Pos=[anchorVec[0]*(diameter/2.0+1.4-0.5)/anchorNorm, anchorVec[1]*(diameter/2.0+1.4-0.5)/anchorNorm, anchorVec[2]*(diameter/2.0+1.4-0.5)/anchorNorm] graft.rotateTo(graftVec,anchorVec,transPos=monomer1Pos) self.bonds.extend([['bondA', anchorIndex,self.natoms]]) anchorIndex-=1 self.addMolecule(graft) self.beadVol+=sphereVol()*graft_length
def test_check_zero(): c = chain() c.add("Hello") # Add a lot of those for _ in xrange(1000): c.add("Hello") # Produce and check evidence e = c.evidence(0) assert check_evidence(c.head(), 0, e)
def test_recursion(self): self.assertEqual(list(chain(["test"])), list("test")) self.assertEqual(list(chain([["test"]])), list("test")) self.assertEqual(list(chain([[[["test"]]]])), list("test")) self.assertEqual(list(chain([["test"]], "test")), list("testtest")) self.assertEqual(list(chain([["test"]], [1, 2], ["test"])), list("test") + [1, 2] + list("test")) self.assertEqual(list(chain([["test"]], [[1], 2], ["test"])), list("test") + [1, 2] + list("test")) self.assertEqual(list(chain([[["test"]], [[[1], 2]], ["test"]])), list("test") + [1, 2] + list("test")) self.assertEqual(list(chain([[[["test"]], [[[1], 2]]], ["test"]])), list("test") + [1, 2] + list("test")) self.assertEqual([ i for i in chain( list(zip(range(1, 100, 2), [([[i]]) for i in range(2, 100, 2)]))) ], list(range(1, 99)))
def test_with_file_objects(self): with open('iterable1.txt', 'w') as f: f.write('0123') with open('iterable2.txt', 'w') as f: f.write('4567') with open('iterable1.txt', 'r') as f: list1 = f.read() with open('iterable2.txt', 'r') as f: list2 = f.read() result = list(chain(list1, list2)) self.assertEqual(result, ['0', '1', '2', '3', '4', '5', '6', '7'])
def main(): ## Pass the kafka_url, e.g. `192.168.1.110:9092` kafka_url = sys.argv[1] # channel = sys.argv[2] ## Register to read messages from the "rousseau" list consumer = KafkaConsumer('shards', group_id='my_group', bootstrap_servers=[kafka_url]) ## Register to send to the rousseau-chain channel kafka = KafkaClient(kafka_url) producer = SimpleProducer(kafka) # producer.send_messages(b'shards', "Hello") # Initialize a chain backed by 2 disk files c = chain(diskHashList("fentries.dat"), diskHashList("fnodes.dat")) class RousseauNode(Node): def on_commit(self, tx, yesno): obj = dumps([tx, yesno]) seq = c.add(obj) producer.send_messages(b'rousseau', dumps([obj, seq, hexlify(c.head())]) ) ## Commit to DB the chain. # The consistency engine n = RousseauNode() ## The main even loop for message in consumer: # message value is raw byte string -- decode if necessary! # e.g., for unicode: `message.value.decode('utf-8')` print("%s:%d:%d: key=%s value=%s" % (message.topic, message.partition, message.offset, message.key, message.value)) try: idx, deps, new_objs = loads(message.value) ## 1) Custom checker. ## 2) Store into DB. print("ID: %s Deps: %s New: %s" % (idx, str(deps), str(new_objs))) n.process((idx, deps, new_objs)) except: print("Cannot decode: %s" % message.value)
def test_args(self): self.assertEqual(list(chain(1, 2, 3, 4)), [1, 2, 3, 4]) self.assertEqual(list(chain("test", 1, 2)), list("test") + [1, 2]) expected = [1, 2, 1, 2, 1, 2] self.assertEqual(list(chain([1, 2], 1, 2, [1, 2])), expected) self.assertEqual(list(chain(1, [2], [1, 2], 1, [2])), expected) self.assertEqual(list(chain(1, 2, [1, 2, 1], [2])), expected) self.assertEqual(list(chain("test", 1, 2, [1, 2, 1], [2])), list("test") + expected)
def commit(date=None): """Make a commit of your work.""" if date is None: date = util.getdate() else: date = parsedate(date) # idx = chain[monthyear] monthchain = chain() oldcontent = monthchain.getdaytext(date) data = click.edit(oldcontent + markers['commit']) entry = '' if data is not None: entry = data.split(markers['commit'], 1)[0].rstrip() # store the data entry monthchain.addhunk(entry, date)
def test_ensure_prefix(): c = chain() c.add("Hello") # Add a lot of those for _ in xrange(1000): c.add("Hello") seq = c.add("hello") head = c.head() for _ in xrange(1000): c.add("Hello") new_head = c.head() e = c.evidence(seq) assert check_evidence(new_head, seq, e, node=head)
def test_return_args(self): def _test_ret_args(x): res = args('hello', world=x) return res def _test_accept_args(hello, world=''): return hello + ' ' + world def _test_1(x): return '1 ' + x def _test_2(x): return x + ' 2' res = chain( args('test') | _test_1 | _test_2 | _test_ret_args | _test_accept_args) expected = 'hello 1 test 2' self.assertEqual(res, expected)
def test_chain(self): def _test_x(x): return x + 'x' def _test_y(x): return x + 'y' def _test_z(x): return x + 'z' def _test_2(a, b): return a + b def _test_3(a, b, c): return a + b + c chain_res = chain( args('w') | _test_x | _test_y | args('2'), _test_2, _test_z, args('3', '4'), _test_3) native_res = _test_3(_test_z(_test_2(_test_y(_test_x('w')), '2')), '3', '4') self.assertEqual(chain_res, native_res)
def test_arg(self): self.assertEqual(list(chain(1)), [1]) self.assertEqual(list(chain([1, 2, 3])), [1, 2, 3]) self.assertEqual(list(chain("test")), list("test")) self.assertEqual(list(chain(range(10))), list(range(10)))
def test_generator(self): self.assertTrue(isinstance(chain(1), Generator), "Not a generator")
def __init__(self, rodLength=15, rodDiameters=[1.0], rodBondLength=1.0, rodBondTypes=[1.0], rodSequence=[1], rodAngleType=None, numRods=3, rodCentralDist=2.0, numCoils=3, coilLength=20, coilDiameters=[2.0], coilSequence=[2], coilBondLength=1.0, coilBondTypes=[1], coilAngleType=None): super(CLP,self).__init__() self.name='CLP' self.placed=False self.natoms=0 self.positions=[] self.dihedrals=[] self.diameters=[] self.bodies=[] self.types=[] self.bonds = [] self.angles=[] self.beadVol=0 self.moleculeIDs=[] #Make rod rod = chain(length=rodLength, beadDiameters=rodDiameters, bondTypes=rodBondTypes, angleType=rodAngleType, sequence=rodSequence) rod.makeLinear(bondLength=rodBondLength) rodList = [] newPos = np.array([0.,0.,0.]) newPos[0] += rodCentralDist th = 2*np.pi/numRods for i in range(numRods): cc = deepcopy(rod) cc.moleculeIDs = [0]*rodLength diff = np.subtract(newPos,cc.positions[0]) cc.positions = np.add(cc.positions,diff) rodList.append(cc) xy = newPos[:2] xy = np.dot(xy,[[np.cos(th),-np.sin(th)],[np.sin(th),np.cos(th)]]) newPos[:2]=xy #make coils coil = chain(length=coilLength, beadDiameters=coilDiameters, bondTypes=coilBondTypes, angleType=coilAngleType, sequence=coilSequence) coil.makeLinear(bondLength=coilBondLength) coilList = [] newPos = np.array([0.,0.,0.]) newPos[0] += 1.13*(rod.diameters[0]+coil.diameters[0])/2.0 + rodCentralDist th = 2*np.pi/numCoils for i in range(numCoils): cc = deepcopy(coil) cc.moleculeIDs = [i+1]*coilLength diff = np.subtract(newPos,cc.positions[0]) cc.positions = np.add(cc.positions,diff) coilList.append(cc) xy = newPos[:2] xy = np.dot(xy,[[np.cos(th),-np.sin(th)],[np.sin(th),np.cos(th)]]) newPos[:2]=xy #combine molecules for k,r in enumerate(rodList): self.addMolecule(r) newBondList = [] graftIndex = 0 for c in coilList: newBondList.append([coilBondTypes[0],graftIndex,self.natoms]) graftIndex += rodLength self.addMolecule(c) self.bonds.extend(newBondList)
from chain import chain summary = lambda s: chain(s).groupby().map(lambda t: str(len(t[1])) + str(t[0]) ).join('').value() s = '1' for i in range(10): print(s) s = summary(s)
def test_create(): c = chain() assert c.head() == initialH assert c.add("Hello") == 0
h_int[n,m] = conj(hop) H_int.append(h_int) H_hop = [] for i in range(1,len(xyz)): at_A = xyz[i-1].atoms at_B = xyz[i].atoms M = len(at_A) N = len(at_B) h_hop = matrix(zeros((M,N),'D')) for m in range(M): for n in range(N): if at_B[n].pos[2] - at_A[m].pos[2] > Z_CUTOFF: break hop = hopping(at_A[m].pos,at_B[n].pos) h_hop[m,n] = hop H_hop.append(h_hop) return conductor(xyz,H_int,H_hop) if __name__ == "__main__": import xyz import chain param.setdefaults() x = xyz.square_ladder(2) ch = chain.chain(x) cd = conductor(ch,length=3) cd.set_energy(1*eV) print cd.transmission_new(1j*matrix(eye(2)),1j*matrix(eye(2)))
def tight_binding_triozon(xyz_coords,do_cache=True,graphite=False): # based on the parametrization described in # doi:10.1103/PhysRevB.64.121401 CC_DIST = param.GRAPHENE_CC_DISTANCE NN_HOP = param.GRAPHENE_1STNN_HOPPING TRIO_CUTOFF = param.TRIOZON_CUTOFF Z_CUTOFF = param.TRIOZON_Z_CUTOFF BETA = param.TRIOZON_BETA A = param.TRIOZON_A DELTA = param.TRIOZON_DELTA at = xyz_coords.atoms period = xyz_coords.period Natoms = len(at) if isinstance(xyz_coords,xyz.chain): if graphite: def hopping(pos_a,pos_b): if abs(pos_a[2] - pos_b[2]) > Z_CUTOFF: return 0.0 elif abs(pos_a[1]-pos_b[1]) < CC_DIST*0.1: if norm(pos_a - pos_b) < CC_DIST*1.1: return -NN_HOP else: d = norm(pos_b-pos_a); if d < TRIO_CUTOFF: return -BETA * exp((A - d)/DELTA); return 0.0 else: # MWCNT def vdot(a,b): sum = 0.0 for i in range(len(a)): sum += a[i]*b[i] return sum def hopping(pos_a,pos_b): if abs(pos_a[2] - pos_b[2]) > Z_CUTOFF: return 0.0 elif abs(norm(pos_a[:2])-norm(pos_b[:2])) < CC_DIST*0.1: if norm(pos_a - pos_b) < CC_DIST*1.1: return -NN_HOP else: d = norm(pos_b-pos_a); if d < TRIO_CUTOFF: cos_theta = vdot(pos_a[:2],pos_b[:2])/(norm(pos_a[:2])*norm(pos_b[:2])); return -BETA * cos_theta * exp((A - d)/DELTA); return 0.0 elif isinstance(xyz_coords,xyz.sheet): def hopping(pos_a,pos_b): if abs(pos_a[2] - pos_b[2]) < CC_DIST*0.1: if norm(pos_a - pos_b) < CC_DIST*1.1: return -NN_HOP else: d = norm(pos_b-pos_a); if d < TRIO_CUTOFF: return -BETA * exp((A - d)/DELTA) return 0.0 if isinstance(xyz_coords,xyz.chain): H = [ matrix(zeros((Natoms,Natoms))) ] for i in range(Natoms): for j in range(i+1,Natoms): hop = hopping(at[i].pos,at[j].pos) if hop != 0.0: H[0][i,j] = hop H[0][j,i] = conj(hop) for n in range(1,100): h = matrix(zeros((Natoms,Natoms))) nonzero = False for i in range(Natoms): for j in range(Natoms): hop = hopping(at[i].pos,at[j].pos + period*n) if hop != 0.0: nonzero = True h[i,j] = hop if not nonzero: break H.append(h) assert n < 99 return chain.chain(H,xyz_coords,do_cache=do_cache) elif isinstance(xyz_coords,xyz.sheet): H = {} H[0,0] = matrix(zeros((Natoms,Natoms))) for i in range(Natoms): for j in range(i+1,Natoms): hop = hopping(at[i].pos,at[j].pos) if hop != 0.0: H[0,0][i,j] = hop H[0,0][j,i] = conj(hop) for i0 in range(6): for i1 in range(-6,6): if i0 == 0 and i1 <= 0: continue shift = i0 * period[0] + i1 * period[1] H_hop = matrix(zeros((Natoms,Natoms))) nonzero = False for i in range(Natoms): for j in range(Natoms): hop = hopping(at[i].pos,at[j].pos + shift) if hop != 0.0: H_hop[i,j] = hop nonzero = True if nonzero: assert norm(shift) <= Z_CUTOFF + norm(period[0]) + norm(period[1]) H[i0,i1] = H_hop return sheet.sheet(H,xyz_coords,do_cache=do_cache)
if __name__ == "__main__": import cnt, tightbinding import chain as NNlib_chain from units import eV set_printoptions(linewidth=10000) # xyz = cnt.swcnt((10,10)) # xyz = cnt.chiral(10,10) xyz = cnt.GNR_zigzag(6) # chain = tightbinding.tight_binding_3rdNN_graphene(xyz) papa = tightbinding.papaconstantopoulos("c_par.105.tbparam") chain = papa.setup_chain(xyz) chain = NNlib_chain.chain([h[2::4,2::4] for h in chain.H],chain.xyz,S=[s[2::4,2::4] for s in chain.S]) # chain = chain.multiply() scan = scan_bands( chain, precision=1e-4, verbose=True, ) scan.do_scan() scan.sort_crossing() band_k = scan.x band_energy = scan.y if scan.period is not None: