def create_nodes(self): """creates nodes atoms""" Lat = Lattice(self.topol, self.scale, self.n_) self.box, self.rcut = Lat.gen_lattice() print "generated lattice with bounds", self.box # self._cell_dims, self.rcut = Lat.gen_lattice() self.nnodes = Lat.nsites print self.nnodes self.nodes = [None] * self.nnodes for i, site in enumerate(Lat.site): # self.nodes[i] = Atom("C" + str(i+1), m=1.0) self.nodes[i] = Atom("C", m=1.0) # self.nodes[i].q = -1. self.nodes[i].position = np.array(site) self.nodes[i].idx = i + 1 for i1 in xrange(0, self.nnodes): for i2 in xrange(i1 + 1, self.nnodes): d_pbc = distances.dist_w_pbc(self.nodes[i1].position, self.nodes[i2].position, bounds=self.box) # d_pbc = distances.dist_wo_pbc(self.nodes[i1].position, self.nodes[i2].position, bounds=self.box) free_spots_flag = (self.nodes[i1].nneighs <= 4) if np.allclose(d_pbc, self.rcut) and i1 != i2 and free_spots_flag: self.nodes[i1].neighbors.append(i2) #iden-fy neigh nodes self.nodes[i2].neighbors.append(i1) self.neighs.append(Bond(i1, i2, d_pbc)) print "----------done node------------" print "node ", self.nodes[i1] # print return None
def create_nodes(self): """creates nodes atoms""" shift_idx = self.nparticles Lat = Lattice(self.topol, self.scale, self.n_) self.box, self.rcut = Lat.gen_lattice() if self.verbose: print("generated lattice with bounds", self.box) self.nnodes = Lat.nsites self.system_box = self.box if self.verbose: print(self.nnodes) self.nodes = [None] * self.nnodes _m_nodes = 1. node_ionization_every = 1 # if we have nx ny nz lattice # first ny*nz sites are so from 0 to ny*nz - 1 - are bottom # the last ny*nz sites are top ninterface_nodes = int(self.n_[1] * self.n_[2]) print("ninterface_nodes", ninterface_nodes) for i, site in enumerate(Lat.site): # self.nodes[i] = Atom("C" + str(i+1), m=1.0) self.nodes[i] = Atom("C", m=_m_nodes) self.nodes[i].position = np.array(site) self.nodes[i].idx = shift_idx + i + 1 if i <= (ninterface_nodes - 1): self.nodes[i].boundary_type = 'bottom' elif i >= (self.nnodes - ninterface_nodes): self.nodes[i].boundary_type = 'top' else: self.nodes[i].boundary_type = 'no' if (self.ionization_count % node_ionization_every == 0): self.nodes[i].q = -1 * (abs(self.valency)) self.ionization_count += 1 if self.static_mid_boundary_flag: if self.nodes[i].position[0] == 25. + int(self.n_[0] / 2 - 1) * self.scale: self.nodes[i].ityp = 2 for i1 in range(0, self.nnodes): for i2 in range(i1 + 1, self.nnodes): d_w_pbc = distances.dist_w_pbc(self.nodes[i1].position, self.nodes[i2].position, bounds=self.box) d_wo_pbc = distances.dist_wo_pbc(self.nodes[i1].position, self.nodes[i2].position, bounds=self.box) i2_pos_pbc = distances.get_pbc( self.nodes[i1].position, self.nodes[i2].position, bounds=self.box) # returns position of i2 with pbc free_spots_flag = (self.nodes[i1].nneighs <= self.max_connections) close_neigh_flag = np.allclose(d_wo_pbc, self.rcut) pbc_neigh_flag = np.allclose(d_w_pbc, self.rcut) # close_neigh_flag = d_wo_pbc < self.rcut # pbc_neigh_flag = d_w_pbc < self.rcut print("n1 = {0}, n2={1}".format(i1, i2)) print('rcut, d_w_pbc, d_wo_pbc') print(self.rcut, d_w_pbc, d_wo_pbc) print('flags ', close_neigh_flag, pbc_neigh_flag) connect_flag = False xlo = 0 xhi = self.box[0] ylo = 0 yhi = self.box[1] zlo = 0 zhi = self.box[2] # print( self.nodes[i2].position) if close_neigh_flag and i1 != i2 and free_spots_flag: connect_flag = True if pbc_neigh_flag and i1 != i2 and free_spots_flag and self.pbc_x: if ((i2_pos_pbc[0] < xlo) or (i2_pos_pbc[0] > xhi)): connect_flag = True if pbc_neigh_flag and i1 != i2 and free_spots_flag and self.pbc_y: if ((i2_pos_pbc[1] < ylo) or (i2_pos_pbc[1] > yhi)): connect_flag = True if pbc_neigh_flag and i1 != i2 and free_spots_flag and self.pbc_z: if ((i2_pos_pbc[2] < zlo) or (i2_pos_pbc[2] > zhi)): connect_flag = True if connect_flag: self.nodes[i1].neighbors.append(i2) #iden-fy neigh nodes self.nodes[i2].neighbors.append(i1) self.neighs.append( Bond(self.nodes[i1].idx, self.nodes[i2].idx, d_w_pbc[0])) if self.verbose: print("----------done node------------") print("node ", self.nodes[i1]) self.name_species.append('nodes') self.species.append(self.nodes) self.nspecies.append(self.nnodes) self.mspecies.append(float(_m_nodes)) return None