def get_FeCl3_intercalated_graphite(nglayers=3, rectangular=True, distance=3.0, tgra=3.35, ncells=[1, 1, 1], iax_out=2): """ Create FeCl3-intercalated graphite nglayers : number of graphene layers distance : unit=[A] space between a graphene layer and the top or bottom of FeCl3 layer Note that FeCl3 layer is not 2D, but qusi-3D. ncells : array, shape=(3) number of unit cells """ ## prepare FeCl3 fecl3_std = get_FeCl3_structure(shape="standerdized") fecl3 = make_supercell(fecl3_std, [[2, 0, 0], [0, 2, 0], [0, 0, 1]]) ## prepare graphene graphene = get_stacking_graphene(na=5, nb=5, nc=nglayers, distance=tgra) ## set axis: z-axis will be c-axis. _rotate_in_2D(fecl3, a0=[1, 0]) _rotate_in_2D(graphene, a0=[1, 0]) ## apply strain to match two cells Lgra = np.linalg.norm(graphene.cell[0]) Lfecl3 = np.linalg.norm(fecl3.cell[0]) strain = Lgra / Lfecl3 - 1.0 print("") print(" Lattice mismatch bewteen graphene and FeCl3 : %.2f%%" % (strain * 100.)) print("") Lnew = (Lgra + Lfecl3) * 0.5 _apply_hydro_strain(fecl3, (Lnew - Lfecl3) / Lfecl3) _apply_hydro_strain(graphene, (Lnew - Lgra) / Lgra) ## merge the structures gic = _get_superposed_structure(graphene, fecl3, distance=distance, tgra=tgra) ## get a rectangular unit if rectangular: gic = make_supercell(gic, [[1, 0, 0], [1, 2, 0], [0, 0, 1]]) ## make a supercell gic = make_supercell( gic, [[ncells[0], 0, 0], [0, ncells[1], 0], [0, 0, ncells[2]]]) gic = get_ordered_structure(gic, iax=iax_out) gic.wrap() ## set charges _set_fecl3_charges(gic) ## set_tags4md_structure(gic, iax_out=iax_out, gap=2.0) return gic
def make_supercell(self, replicate): r1, r2, r3 = replicate P = np.array([[r1, 0, 0], [0, r2, 0], [0, 0, r3]]) self.bulk_ase = make_supercell(self.bulk_ase, P) self.custom_sites = make_supercell(self.custom_sites, P) self.duplications = replicate
def make_from_ase(self, supercell): from ase.spacegroup import crystal from ase.build import make_supercell a = self._a ni = crystal(self._name, [(0, 0, 0)], spacegroup=self._space_group, cellpar=[a, a, a, 90, 90, 90]) if len(supercell) != 3: raise Exception("Supercell must be a vector [a b c]") make_supercell(ni, supercell)
def supercell(at, supercell=None, min_distance=None, max_multiple=None): """Transforms an atoms object into a supercell. .. note:: If you don't specify an explicit supercell using `supercell` keyword, `matdb` will enumerate all unique supercells up to `max_multiple`. The selected supercell will be the *smallest* one that has at least `min_distance` between every atom and its periodic image. Args: supercell (list, tuple, numpy.ndarray): a list of `int` multiples that forms the supercell matrix. It should have length 3 or 9. If length 3, it is assumed to be a diagonal matrix. min_distance (float): for enumerated supercell selection, the minimum distance (in Angstrom) that should exist between every atom and its periodic image in the supercell. max_multiple (int): the number of atoms in the supercell is the number of atoms in the primitive, times the determinant of the supercell matrix. This value specifies the maximum determinant of enumerated supercell matrices. `matdb` will keep enumerating until all matrices of this determinant have been investigated. """ if supercell is not None: if len(supercell) == 3: scell = np.identity(supercell) elif len(supercell) == 9: scell = np.array(supercell).reshape(3, 3) else: scell = np.array(supercell) assert scell.shape == (3, 3) return make_supercell(at, scell) else: raise NotImplementedError("Supercell enumeration still needs a wheel " "implemented before it can be used here...")
def viewSuperCell(atoms): P = build.find_optimal_cell_shape_pure_python(atoms.cell, 32, "sc") atoms = build.make_supercell(atoms, P) atoms[0].symbol = "Mg" atoms[1].symbol = "Mg" atoms[2].symbol = "Mg" view(atoms, viewer="Avogadro")
def make_supercell(self, supercell): """Returns a new :class:`~matdb.atoms.Atoms` object that is a supercell of the current one. """ scell = conform_supercell(supercell) result = make_supercell(self, scell) return Atoms(result)
def get_FeCl3_structure(shape="standerdized", layer=True): """ cParameters ------------ shape : string primitive, standerdized, layer, rectangular layer : bool If True, only one layer will be returned. """ atoms_prim = get_FeCl3_primitive() ## primitive cell if 'prim' in shape.lower(): if layer: return _extract_layer(atoms_prim) else: return atoms_prim ## standerdized cell atoms_std = get_standerdized_cell(atoms_prim) if 'stand' in shape.lower(): if layer: return _extract_layer(atoms_std) else: return atoms_std ## rectangular cell P = [[1, 0, 0], [1, 2, 0], [0, 0, 1]] atoms_rec = make_supercell(atoms_std, P) if 'rect' in shape.lower(): if layer: return _extract_layer(atoms_rec) else: return atoms_rec
def init_pos(natom): from qharv.inspect import crystal from ase import Atoms from ase.build import make_supercell rho = 2.2e22 * 1e6 / 1e30 # atoms/A^3 lbox = (natom / rho)**(1. / 3) nxf = (natom / 4.)**(1. / 3) nx = int(round(nxf)) if not np.isclose(nx, nxf): raise RuntimeError('natom=%d nxf=%3.2f!=%d' % (natom, nxf, nx)) # create FCC crystal alat = lbox / nx axes0 = alat / 2 * (np.ones(3) - np.eye(3)) tmat = nx * (np.ones(3) - 2 * np.eye(3)) s0 = Atoms('H', cell=axes0, positions=[[0, 0, 0]], pbc=[1, 1, 1]) s1 = make_supercell(s0, tmat) pos = s1.get_positions() axes = s1.get_cell() # check density rho1 = natom / axes_pos.volume(axes) if not np.isclose(rho, rho1): raise RuntimeError('supercell density is wrong') # save/view crystal fig, ax = volumetric.figax3d() crystal.draw_cell(ax, axes) crystal.draw_atoms(ax, pos) plt.show() return pos
def _make_translate_maps(self): """ find the mapping between supercell and translated cell. Returns: =============== A N * nbasis array. index[i] is the mapping from supercell to translated supercell so that T(r_i) psi = psi[indices[i]]. TODO: vacancies/add_atoms not supported. How to do it? For vacancies, a ghost atom can be added. For add_atom, maybe we can just ignore them? Will it change the energy spectrum? """ a1 = Atoms(symbols='H', positions=[(0, 0, 0)], cell=[1, 1, 1]) sc = make_supercell(a1, self._scmat) rs = sc.get_scaled_positions() positions = self._positions indices = np.zeros([len(rs), len(positions)], dtype='int32') for i, ri in enumerate(rs): inds = [] Tpositions = positions + np.array(ri) close_to_int = lambda x: np.all(np.abs(x - np.round(x)) < self._tol_r) for i_basis, pos in enumerate(positions): for j_basis, Tpos in enumerate(Tpositions): dpos = Tpos - pos if close_to_int(dpos) and (self._basis[i_basis]==self._basis[j_basis]): #indices[i, j_atom * self._ndim:j_atom * self._ndim + self._ndim] = np.arange(i_atom * self._ndim, i_atom * self._ndim + self._ndim) indices[i, j_basis] = i_basis self._trans_rs = rs self._trans_indices = indices print(indices)
def test_spglib_standardize(): for i in [ "../tests/MoS2_2H_1l.xyz", "../tests/WS2_2H_1l.xyz", "../tests/graphene.xyz", ]: atoms = ase.io.read(PROJECT_ROOT_DIR.joinpath(i)) N = [[3, 1, 0], [-1, 2, 0], [0, 0, 1]] sc = make_supercell(atoms, N) cppatoms = ase_atoms_to_cpp_atoms(sc) cppatoms.standardize(1, 0, 1e-5, 5) cell = (sc.cell, sc.get_scaled_positions(), sc.numbers) spgcell = spglib.standardize_cell(cell, to_primitive=True, no_idealize=False, symprec=1e-5, angle_tolerance=5) atoms = Atoms( cell=spgcell[0], scaled_positions=spgcell[1], numbers=spgcell[2], pbc=[True, True, True], ) cppatoms = cpp_atoms_to_ase_atoms(cppatoms) comp = SymmetryEquivalenceCheck() is_equal = comp.compare(atoms, cppatoms) assert ( is_equal ), "Standardization in backend and from spglib do not yield same result."
def make_struc(formula, spacegroup, sc=1): """ Creates the crystal structure using ASE. :param alat: Lattice parameter in angstrom :return: structure object converted from ase """ #src_dir = 'bronze' if('Cu' in formula) else 'steel' src_dir = 'base' cif_in = read("./{}_cifs/{}_{}.cif".format(src_dir, formula, spacegroup)) supercell = make_supercell(cif_in, [[sc, 0, 0], [0, sc, 0], [0, 0, sc]]) structure = Struc(ase2struc(supercell)) #structure = make_supercell(structure, [[sc,0,0],[0,sc,0],[0,0,sc]]) #fecell = bulk('Fe', cell, a=alat) #fecell = make_supercell(fecell, [[2,0,0],[0,2,0],[0,0,2]]) # check how your cell looks like #write('s.cif', gecell) #if(cell == 'bcc' and (mag=='non' or mag=='ferro')): # fecell.set_atomic_numbers([26,26,26,26,26,26,26,26]) # print(fecell) #elif(cell == 'bcc' and mag == 'anti'): # fecell.set_atomic_numbers([26,27,26,27,26,27,26,27]) # print(fecell) #else: #fecell.set_atomic_numbers([26, 27,26,27,26,27,26,27,26, 27,26,27,26,27,26,27]) # print(fecell) #structure = Struc(ase2struc(fecell)) #print(structure.species) return structure
def gen_primitive(name=None,A=None,B=None,O=None, latticeconstant=3.9, mag_order='FM', m=5): """ generate primitive cell with magnetic order. Parameters: --------------- name: string ABO3, eg. BiFeO3, CsPbF3 """ if name is not None: symbols=string2symbols(name) A, B, O, _, _ = symbols atoms = PerovskiteCubic([A, B, O], latticeconstant=latticeconstant) direction_dict = { 'A': ([1, 0, 0], [0, 1, 0], [0, 0, 2]), 'C': ([1, -1, 0], [1, 1, 0], [0, 0, 1]), 'G': ([0, 1, 1], [1, 0, 1], [1, 1, 0]), 'FM': np.eye(3), } size_dict = {'A': (1, 1, 2), 'C': (1, 1, 1), 'G': (1, 1, 1)} A, B, O = atoms.get_chemical_symbols()[0:3] if mag_order == 'PM': atoms = atoms elif mag_order == 'FM': atoms = atoms atoms = set_element_mag(atoms, B, [m]) else: atoms.translate([0.045] * 3) atoms = normalize(atoms) atoms = make_supercell(atoms, direction_dict[mag_order]) atoms.translate([-0.045] * 3) atoms = set_element_mag(atoms, B, [m, -m]) return atoms
def RanPoAtoms(cut_off_radius, symbols=None, positions=None, numbers=None, tags=None, momenta=None, masses=None, magmoms=None, charges=None, scaled_positions=None, cell=None, pbc=None, celldisp=None, constraint=None, calculator=None, info=None): if positions is not None: print("\npositions must not be given\n") exit(1) if scaled_positions is not None: print("\nscaled_positions must not be given\n") exit(1) else: atoms = Atoms(symbols=symbols, positions=positions, numbers=numbers, tags=tags, momenta=momenta, masses=masses, magmoms=magmoms, charges=charges, scaled_positions=None, cell=cell, pbc=pbc, celldisp=celldisp, constraint=constraint, calculator=calculator, info=info) l = 0 while True: l += 1 print("trying step :: " + str(l)) scaled_posis = [] for i in range(len(atoms)): scaled_posi = [] for j in range(3): scaled_posi.append(random.random()) scaled_posis.append(scaled_posi) atoms.set_scaled_positions(scaled_posis) supercell = make_supercell(atoms, [[2, 0, 0], [0, 2, 0], [0, 0, 2]]) dist = supercell.get_all_distances() coll = [] for i in range(len(supercell)): for j in range(len(supercell)): if i is not j: coll.append(dist[i][j]) if min(coll) > cut_off_radius: break return atoms
def get_stacking_graphene(na=1, nb=1, nc=1, distance=3.35): """ Get ase.Atoms object for an AB stacking graphite """ graphene = get_graphene_structure(distance=distance) ## make a supercell along x and y directions sc = make_supercell(graphene, [[na, 0, 0], [0, nb, 0], [0, 0, 1]]) natoms_layer = len(sc) ## make a supercell along z direction graphite = ase.Atoms(cell=[sc.cell[0], sc.cell[1], sc.cell[2] * nc], pbc=[True, True, True]) elements = ['C', 'C'] for iz in range(nc): ## displacment to form AB stacking disp = np.zeros(3) if iz % 2 == 1: disp += (graphene.cell[0, :] + graphene.cell[1, :] * 2.) * 2. / 3. disp += sc.cell[2, :] * iz ## add atoms at the layer for ia in range(len(sc)): graphite.append( ase.Atom(symbol=elements[iz % 2], position=sc.positions[ia, :] + disp, tag=iz % 2 + 1)) ## graphite.wrap() return graphite
def _make_translate_maps(positions, basis, sc_mat, tol_r=1e-4): """ find the mapping between supercell and translated cell. Returns: =============== A N * nbasis array. index[i] is the mapping from supercell to translated supercell so that T(r_i) psi = psi[indices[i]]. """ a1 = Atoms(symbols='H', positions=[(0, 0, 0)], cell=[1, 1, 1]) sc = make_supercell(a1, self._scmat) rs = sc.get_scaled_positions() indices = np.zeros([len(rs), len(positions)], dtype='int32') for i, ri in enumerate(rs): inds = [] Tpositions = positions + np.array(ri) for i_basis, pos in enumerate(positions): for j_basis, Tpos in enumerate(Tpositions): dpos = Tpos - pos if close_to_int(dpos, tol_r) and (self._basis[i_basis] == self._basis[j_basis]): indices[i, j_basis] = i_basis self._trans_rs = rs self._trans_indices = indices
def make_na2_nh2_bh4_nxnxn_ase(n, write_file=False): nnb_unitcell = make_na2_nh2_bh4_unitcell_ase() nnb_nxnxn = make_supercell(nnb_unitcell, np.identity(3) * n) if write_file: write( structures_folder_path + 'nnb_' + str(n) + 'x' + str(n) + 'x' + str(n) + '.cif', nnb_nxnxn) return nnb_nxnxn
def plot(name): assert name in ("ZnVO", "CoVO") data, atoms = read_cube_data(cube_file(name)) lattice = atoms.cell na, nb, nc = data.shape layer = data[:, :, nc // 2].T print(layer.max(), layer.min()) x_ = numpy.linspace(0, 1, na) y_ = numpy.linspace(0, 1, nb) xx_s, yy_s = numpy.meshgrid(x_, y_) xx_fine, yy_fine = numpy.meshgrid(numpy.linspace(0, 1, 256), numpy.linspace(0, 1, 256)) xy_flat = numpy.vstack([xx_s.flat, yy_s.flat]).T print(xy_flat.shape) c_fine = griddata(xy_flat, layer.flat, (xx_fine, yy_fine), method="cubic") zz_fine = numpy.ones_like(yy_fine) * 0.5 xx, yy, zz = numpy.tensordot(lattice.T, numpy.array([xx_fine, yy_fine, zz_fine]), axes=1) # print(xx, yy) fig = plt.figure(figsize=(3.5, 3.0)) ax = fig.add_subplot(111) # layer = layer.T ax.pcolor( xx, yy, c_fine, cmap="rainbow_r", vmin=-10, # antialiased=True, # interpolate="bicubic", rasterized=True) sc = make_supercell(atoms, numpy.diag([2, 2, 1])) idx = [p.index for p in sc if (p.z > atoms.cell[-1, -1]*0.43) \ and (p.z < atoms.cell[-1, -1] * 0.58)] # and (p.x < atoms.cell[0, 0] * 1.1) \ # and (p.y < atoms.cell[1, 1] * 1.2)] new_atoms = sc[idx] rot = {"ZnVO": (-0.4, 1.30, 0.02), "CoVO": (0.00, 1.89, 0.00)} off = {"ZnVO": (-1.40, -1.15), "CoVO": (-0.9, -1.2)} plot_atoms(new_atoms, ax=ax, rotation="{0}x,{1}y,{2}z".format(*rot[name]), radii=0.6, offset=off[name]) # show_unit_cell=True) # offset=(-1.1, -0.8), # show_unit_cell=True) # plt.show() ax.set_aspect("equal") ax.set_xlim(xx.min(), xx.max()) ax.set_ylim(yy.min(), yy.max()) ax.set_axis_off() # ax.set_axis_off() fig.savefig(join(img_path, "{}_half.svg".format(name)))
def makeSupercellPristine_bui(cellPrim, numCells, shape = 'sc'): # overloaded # use ase.build.find_optimal_cell_shape and ase.biuld.make_supercell # primitive cell: cellPrim # number of cells: numCells # ideal shape: shape P = find_optimal_cell_shape(cellPrim.cell, numCells, shape) supercellPristine = make_supercell(cellPrim, P) return supercellPristine
def i4_conv(rs, ca): axes0, pos0 = i4_prim(rs, ca) tmat = np.ones(3) - np.eye(3) from ase import Atoms from ase.build import make_supercell s0 = Atoms('H%d' % len(pos0), cell=axes0, positions=pos0, pbc=[1, 1, 1]) s1 = make_supercell(s0, tmat) axes1 = s1.get_cell() pos1 = s1.get_positions() return axes1, pos1
def tile_points(axes0, pos0, tmat): """ tile primitive cell using given supercell matrix """ # make slab in 3D, tile using ase from ase import Atoms from ase.build import make_supercell cell0 = Atoms(cell=axes3d(axes0), positions=pos3d(pos0), pbc=[1, 1, 0]) cell1 = make_supercell(cell0, axes3d(tmat)) # get back 2D cell and coordinate axes1 = cell1.get_cell()[:2, :2] pos1 = cell1.get_positions()[:, :2] return axes1, pos1
def make_struc(formula, spacegroup, sc=1): """ Creates the crystal structure using ASE. :param alat: Lattice parameter in angstrom :return: structure object converted from ase """ #src_dir = 'bronze' if('Cu' in formula) else 'steel' src_dir = 'bronze' if (('C' in formula) and ('S' in formula)) else 'base' cif_in = read("./{}_cifs/{}_{}.cif".format(src_dir, formula, spacegroup)) supercell = make_supercell(cif_in, [[sc, 0, 0], [0, sc, 0], [0, 0, sc]]) structure = Struc(ase2struc(supercell)) return structure
def tube_convert(self): try: a = float(str(self.tube_radius.text())) if str(self.supported_structure.currentText()) == 'X': self.p = np.array([[1 ,0 ,0], [0 ,a ,0], [0 ,0 ,1]]) super_struct = make_supercell(self.primitive_cell, self.p) elif str(self.supported_structure.currentText()) == 'Y': self.p = np.array([[0 ,1 ,0], [-a ,0 ,0], [0 ,0 ,1]]) super_struct = make_supercell(self.primitive_cell, self.p) write('super.cif', super_struct) super_struct = read('super.cif') os.remove('super.cif') super_struct.center(vacuum=15.0, axis=2) R = super_struct.get_cell_lengths_and_angles()[1] RS = R / (2 * np.pi) s = super_struct.copy() anchor_position = (np.amax(s.get_positions()[:,2], axis = 0) - np.amin(s.get_positions()[:,2], axis = 0))/2 + np.amin(s.get_positions()[:,2], axis = 0) delta = [] for counter, value in enumerate(s.get_positions()[:,2]): delta.append(s.get_positions()[:,2][counter] - anchor_position) delta = np.array(delta) s.positions[:,2] = (RS + delta) * np.cos(2 * np.pi * s.positions[:,1]/R) s.positions[:,1] = (RS + delta) * np.sin(2 * np.pi * s.positions[:,1]/R) s.center(vacuum=float(str(self.vac.text())), axis=(1,2)) write('structs/nanotube.xsf', s) write('structs/nanotube.png', s, rotation='90z,-90x') except Exception as e: self.dialog_critical(str(e))
def make_2x2x2_supercell_1x1x1_central_Li(write_file=False): """ creates a 2x2x2 Si supercell with the 1, 1, 1 cell's central tetrahedral site occupied by Li """ unitcell = crystal('Si', [(0, 0, 0)], spacegroup=227, cellpar=3 * [Si_alat] + 3 * [90]) supercell = make_supercell(unitcell, np.identity(3) * 2) supercell.extend(Atoms('Li', positions=[tuple(3 * [0.5 * Si_alat])])) if write_file: write(structures_folder_path + '2x2x2_supercell_1x1x1_central_Li.cif', supercell) return Struc(ase2struc(supercell))
def make_supercell(self, replicate): """ Replicates the slab (ase version) according to replicate, which is an iterable with the number of replications in each direction. E.g. (2,2,1) would double the slab in the a and b directions, and leave the c direction unchanged. """ r1,r2,r3 = replicate P = np.array([[r1,0,0],[0,r2,0],[0,0,r3]]) self.blank_slab_ase = make_supercell(self.blank_slab_ase, P) self.duplications = replicate
def make_struc(size): """ Creates the crystal structure using ASE. :param size: supercell multiplier :return: structure object converted from ase """ alat = 4.10 unitcell = crystal('Al', [(0, 0, 0)], spacegroup=225, cellpar=[alat, alat, alat, 90, 90, 90]) multiplier = numpy.identity(3) * size supercell = make_supercell(unitcell, multiplier) structure = Struc(ase2struc(supercell)) return structure
def make_3x3x3_supercell_neighbor_central_Li(write_file=False): """ creates a 3x3x3 Si supercell with a single site that neighbors the central tetrahedral site occupied by Li """ unitcell = crystal('Si', [(0, 0, 0)], spacegroup=227, cellpar=3 * [Si_alat] + 3 * [90]) supercell = make_supercell(unitcell, np.identity(3) * 3) supercell.extend(Atoms('Li', positions=[tuple(3 * [1.75 * Si_alat])])) if write_file: write( structures_folder_path + '3x3x3_supercell_neighbor_central_Li.cif', supercell) return Struc(ase2struc(supercell))
def test_supercell(atoms): assert atoms.cell.get_bravais_lattice().name == 'FCC' # Since FCC and BCC are reciprocal, their product is cubic: P = BCC(2.0).tocell() assert np.allclose(np.linalg.det(P), 4) cubatoms = make_supercell(atoms, P) assert np.allclose(cubatoms.cell, a * np.eye(3)) # Also test some of the Cell object methods now that we are at it: assert len(cubatoms) == 4 assert cubatoms.cell.orthorhombic assert np.allclose(cubatoms.cell.lengths(), a) assert cubatoms.cell.get_bravais_lattice().name == 'CUB'
def __init__(self, *args, **kwargs): super(TestLocalOrbitListGeneratorHCP, self).__init__(*args, **kwargs) prim_structure = bulk('Ni', 'hcp', a=4.0) cutoffs = [4.2, 4.2] self.symprec = 1e-5 self.position_tolerance = 1e-5 self.fractional_position_tolerance = 1e-6 self.orbit_list = OrbitList( prim_structure, cutoffs, symprec=self.symprec, position_tolerance=self.position_tolerance, fractional_position_tolerance=self.fractional_position_tolerance) self.primitive = self.orbit_list.get_primitive_structure() super_structure = make_supercell(prim_structure, [[2, 0, 1000], [0, 2, 0], [0, 0, 2]]) self.supercell = Structure.from_atoms(super_structure)
def generate_muairss_collection(struct, params): if params["mu_symbol"] in struct.get_chemical_symbols(): print( "WARNING: chosen muon symbol conflicts with existing elements in" " the starting unit cell. This could cause mistakes" ) # Make a supercell sm = make_3x3(params["supercell"]) # ASE's make_supercell is weird, avoid if not necessary... smdiag = np.diag(sm).astype(int) if np.all(np.diag(smdiag) == sm): scell0 = struct.repeat(smdiag) else: scell0 = make_supercell(struct, sm) reduced_struct = find_primitive_structure(struct) print("Generating defect configurations...") # Seed the random generator Random.reseed(params["random_seed"]) # Now generate the defect configurations defect_gen = defectGen( reduced_struct, "H", poisson_r=params["poisson_r"], vdw_scale=params["vdw_scale"], ) defect_collection = AtomsCollection(defect_gen) print("{0} configurations generated".format(len(defect_collection))) collection = [] for atoms in defect_collection: # Where's the muon? # We rely on the fact that it's always put at the first place mupos = atoms.get_positions()[0] scell = scell0.copy() + Atoms( "H", positions=[mupos], masses=[constants.m_mu_amu] ) # Add castep custom species csp = scell0.get_chemical_symbols() + [params["mu_symbol"]] scell.set_array("castep_custom_species", np.array(csp)) scell.set_pbc(params["dftb_pbc"]) collection.append(scell) return AtomsCollection(collection)
def setUp(self): """Instantiate class for each test case.""" prim_structure = bulk('Al') cutoffs = [4.2, 4.2] self.orbit_list = OrbitList( prim_structure, cutoffs, symprec=self.symprec, position_tolerance=self.position_tolerance, fractional_position_tolerance=self.fractional_position_tolerance) self.primitive = self.orbit_list.get_primitive_structure() super_structure = make_supercell(prim_structure, [[2, 0, 1000], [0, 2, 0], [0, 0, 2]]) self.supercell = Structure.from_atoms(super_structure) self.lolg = LocalOrbitListGenerator( self.orbit_list, self.supercell, fractional_position_tolerance=self.fractional_position_tolerance)