def phonopy_atoms_to_structure(cell): symbols = cell.get_chemical_symbols() positions = cell.get_positions() structure = DataFactory('structure')(cell=cell.get_cell()) for symbol, position in zip(symbols, positions): structure.append_atom(position=position, symbols=symbol) return structure
def _generate_structure(symbols=None): from aiida.plugins import DataFactory structure = DataFactory('structure')() valid_symbols = [value['symbol'] for value in elements.values()] if symbols is not None: for index, symbol in enumerate(symbols): if symbol not in valid_symbols: raise ValueError(f'symbol `{symbol}` is not a valid element.') structure.append_atom(position=(0. + index * 1, 0. + index * 1, 0. + index * 1), symbols=[symbol]) return structure
def get_primitive(structure, ph_settings): from phonopy import Phonopy phonon = Phonopy( phonopy_atoms_from_structure(structure), supercell_matrix=ph_settings.get_dict()['supercell_matrix'], primitive_matrix=ph_settings.get_dict()['primitive_matrix'], symprec=ph_settings.get_dict()['symmetry_tolerance']) primitive_phonopy = phonon.get_primitive() primitive_cell = primitive_phonopy.get_cell() symbols = primitive_phonopy.get_chemical_symbols() positions = primitive_phonopy.get_positions() primitive_structure = DataFactory('structure')(cell=primitive_cell) for symbol, position in zip(symbols, positions): primitive_structure.append_atom(position=position, symbols=symbol) return {'primitive_structure': primitive_structure}
def vasp_structure(request, fresh_aiida_env): """Fixture: StructureData or CifData.""" from aiida.plugins import DataFactory if request.param == 'cif': cif_path = data_path('cif', 'EntryWithCollCode43360.cif') structure = DataFactory('cif').get_or_create(cif_path)[0] elif request.param == 'str': larray = numpy.array([[0, .5, .5], [.5, 0, .5], [.5, .5, 0]]) alat = 6.058 structure = DataFactory('structure')(cell=larray * alat) structure.append_atom(position=[0, 0, 0], symbols='In') structure.append_atom(position=[.25, .25, .25], symbols='As') structure.append_atom(position=[.25, .33, .34], symbols='As') structure.append_atom(position=[.5, .5, .5], symbols='In', name='In_d') structure.append_atom(position=[.7896, .6234, .5], symbols='In', name='In_d') structure.append_atom(position=[.75, .75, .75], symbols='As') elif request.param == 'str-Al': larray = numpy.array([[1, 0, 0], [0, 1, 0], [0, 0, 1]]) alat = 4.04 structure = DataFactory('structure')(cell=larray * alat) structure.append_atom(position=numpy.array([0, 0, 0]) * alat, symbols='Al') structure.append_atom(position=numpy.array([0, .5, .5]) * alat, symbols='Al') structure.append_atom(position=numpy.array([.5, 0, .5]) * alat, symbols='Al') structure.append_atom(position=numpy.array([.5, .5, 0]) * alat, symbols='Al') elif request.param == 'str-InAs': structure_cls = DataFactory('structure') structure = structure_cls( cell=numpy.array([[0, .5, .5], [.5, 0, .5], [.5, .5, 0]]) * 6.058) structure.append_atom(position=(0, 0, 0), symbols='In', name='Hamburger') structure.append_atom(position=(0.25, 0.25, 0.25), symbols='As', name='Pizza') return structure
def _get_structure_data(pkey): """return test structure data""" if pkey == "Fe": cell = [ [2.848116, 0.000000, 0.000000], [0.000000, 2.848116, 0.000000], [0.000000, 0.000000, 2.848116], ] positions = [ (0.0000000, 0.0000000, 0.0000000), (0.5000000, 0.5000000, 0.5000000), ] fractional = True symbols = ["Fe", "Fe"] names = ["Fe1", "Fe2"] elif pkey == "Ar": cell = [ [3.987594, 0.000000, 0.000000], [-1.993797, 3.453358, 0.000000], [0.000000, 0.000000, 6.538394], ] symbols = names = ["Ar"] * 2 positions = [(0.33333, 0.66666, 0.25000), (0.66667, 0.33333, 0.75000)] fractional = True elif pkey == "GaN": cell = [ [3.1900000572, 0, 0], [-1.5950000286, 2.762621076, 0], [0.0, 0, 5.1890001297], ] positions = [ (0.6666669, 0.3333334, 0.0000000), (0.3333331, 0.6666663, 0.5000000), (0.6666669, 0.3333334, 0.3750000), (0.3333331, 0.6666663, 0.8750000), ] fractional = True symbols = names = ["Ga", "Ga", "N", "N"] elif pkey == "pyrite": cell = [ [5.38, 0.000000, 0.000000], [0.000000, 5.38, 0.000000], [0.000000, 0.000000, 5.38], ] positions = [ [0.0, 0.0, 0.0], [0.5, 0.0, 0.5], [0.0, 0.5, 0.5], [0.5, 0.5, 0.0], [0.338, 0.338, 0.338], [0.662, 0.662, 0.662], [0.162, 0.662, 0.838], [0.838, 0.338, 0.162], [0.662, 0.838, 0.162], [0.338, 0.162, 0.838], [0.838, 0.162, 0.662], [0.162, 0.838, 0.338], ] fractional = True symbols = names = ["Fe"] * 4 + ["S"] * 8 elif pkey == "fes_cubic-zincblende": cell = [[2.71, -2.71, 0.0], [2.71, 0.0, 2.71], [0.0, -2.71, 2.71]] symbols = names = ["Fe", "S"] positions = [[0, 0, 0], [4.065, -4.065, 4.065]] fractional = False elif pkey == "greigite": cell = [[0.0, 4.938, 4.938], [4.938, 0.0, 4.938], [4.938, 4.938, 0.0]] positions = [ (1.2345, 1.2345, 1.2345), (8.6415, 8.6415, 8.6415), (4.938, 4.938, 4.938), (2.469, 4.938, 2.469), (4.938, 2.469, 2.469), (2.469, 2.469, 4.938), (2.473938, 2.473938, 2.473938), (4.942938, 7.402062, 4.942938), (4.933062, 2.473938, 4.933062), (2.473938, 4.933062, 4.933062), (7.402062, 4.942938, 4.942938), (7.402062, 7.402062, 7.402062), (4.942938, 4.942938, 7.402062), (4.933062, 4.933062, 2.473938), ] fractional = False symbols = names = [ "Fe", "Fe", "Fe", "Fe", "Fe", "Fe", "S", "S", "S", "S", "S", "S", "S", "S", ] else: raise ValueError("Unknown structure key: {}".format(pkey)) # create structure structure = DataFactory("structure")(cell=cell) for position, symbol, name in zip(positions, symbols, names): if fractional: position = np.dot(position, cell).tolist() structure.append_atom(position=position, symbols=symbol, name=name) return structure