def find_all_pp(obj, xc, family, label_dict={},pp_path=pp_path): symbols = [] if isinstance(obj, collections.Iterable) and ( not isinstance(obj, str)) and isinstance(obj[0], str): symbols = obj elif isinstance(obj, str) and os.path.isfile(obj): structure = Structure.as_structure(obj) symbols = set(structure.symbol_set) elif isinstance(obj, Structure): symbols = obj.symbol_set elif isinstance(obj, Atoms): for elem in obj.get_chemical_symbols(): if elem not in symbols: symbols.append(elem) else: raise ValueError( 'obj should be one of these: list of chemical symbols| abipy structure file name| abipy structure| ase atoms.' ) ppdict = OrderedDict() for elem in symbols: if elem not in ppdict: if elem in label_dict: label = label_dict else: label = '' ppdict[elem] = find_pp(elem, xc, family, label,pp_path=pp_path) return list(ppdict.values())
def to_abi_structure(obj, magmoms=False): ms = None if isinstance(obj, str) and os.path.isfile(obj): structure = Structure.as_structure(obj) elif isinstance(obj, Structure): structure = obj elif isinstance(obj, Atoms): structure = Structure.from_ase_atoms(obj) if magmoms: ms = obj.get_initial_magnetic_moments() else: raise ValueError( 'obj should be one of these: abipy structure file name| abipy structure| ase atoms.' ) if magmoms: return structure, ms else: return structure
def to_abi_structure(obj,magmoms=False): ms=None if isinstance(obj, str) and os.path.isfile(obj): structure = Structure.as_structure(obj) elif isinstance(obj, Structure): structure = obj elif isinstance(obj, Atoms): #cell=obj.get_cell() #acell0=np.linalg.norm(cell[0]) #acell1=np.linalg.norm(cell[1]) #acell2=np.linalg.norm(cell[2]) #cell0=cell[0]/acell0 #cell1=cell[1]/acell1 #cell2=cell[2]/acell2 #acell=[acell0, acell1, acell2] #rprim=[cell0, cell1, cell2] #xred=obj.get_scaled_positions() #znucl=list(set(obj.get_atomic_numbers())) #ntypat=len(znucl) #typat=[] #for z in obj.get_atomic_numbers(): # for i,n in enumerate(znucl): # if z==n: # typat.append(i) #structure = Structure.from_abivars(acell=acell, rprim=rprim, typat=typat, xred=xred, ntypat=ntypat, znucl=znucl) structure = Structure.from_ase_atoms(obj) if magmoms: ms=obj.get_initial_magnetic_moments() else: raise ValueError( 'obj should be one of these: abipy structure file name| abipy structure| ase atoms.' ) if magmoms: return structure,ms else: return structure