# # You should have received a copy of the GNU General Public License along with PyLaDa. If not, see # <http://www.gnu.org/licenses/>. ############################### from pylada.crystal.A2BX4 import b5 from pylada.enumeration import Enum from spinel_check import checkme # create spinel lattice and make it inverse. lattice = Enum(b5()) for site in lattice.sites: if "X" in site.type: continue site.type = 'A' if 'B' in site.type else ('A', 'B') lattice.find_space_group() # look at inverse only. def check_concentration(x, flavorbase, smith): from pylada.enumeration import as_numpy types = as_numpy(x, flavorbase) result = 2*len(types[types == 1]) == len(types) return result, None if result else False result = [i for i, dummy, dummy, dummy in lattice.xn(2)] result.append([i for i, dummy, dummy, dummy in lattice.xn(4)]) # creates file with result. # with open("spinel_check.py", "w") as file:
def create_start(path, nall = 3, nrand = 5, nmax=100, density=10e0, input='input.py'): """ Creates dictionary with input structures for Si/Ge. :Parameters: path : str Path to output dictionary. nall : int All structure with ``nall`` (excluded) unit-cells are included in the final dictionary. nrand : int Structures between ``nall`` (included) and ``nrand`` (excluded) unit-cells are also considered for inclusion in the final dictionary. However, only ``nmax`` are randomly chosen in the end. nmax : int Structures between ``nall`` (included) and ``nrand`` (excluded) unit-cells are also considered for inclusion in the final dictionary. However, only ``nmax`` are randomly chosen in the end. density : float Kpoint density for escan calculations, input : str Path to input file containing escan functional. Creates a job-dictionary with a number of structures sampled from an exhaustive list of structures to evaluate using escan. """ from random import shuffle from itertools import chain from IPython.ipapi import get as get_ipy from numpy.linalg import norm, inv from pylada.enumeration import Enum from pylada.crystal.binary import zinc_blende from pylada.jobs import JobFolder from pylada.escan import read_input, exec_input, ReducedKDensity from pylada.crystal.gruber import Reduction input = read_input(input) kescan = exec_input(repr(input.escan).replace('Escan', 'KEscan')).functional enum = Enum(zinc_blende()) enum.sites[0].type = 'Si', 'Ge' enum.sites[1].type = 'Si', 'Ge' enum.scale = 5.45 enum.find_space_group() density = density * max([1e0/norm(u) for u in inv(enum.cell * enum.scale).T]) strs = [u for n in range(nall, nrand) for u in enum.xn(n)] shuffle(strs) strs = [enum.as_structure(*u) for u in strs[:nmax]] alls = [structure for n in range(nall) for structure in enum.structures(n)] jobs = JobFolder() for i, structure in enumerate(chain(alls, strs)): structure.name = str(i) nSi = len([a.type for a in structure.atoms if a.type == 'Si']) structure.scale = float(nSi) / float(n) * enum.scale + float(n - nSi) / float(n) * 5.69 jobfolder = jobs / structure.name jobfolder.jobparams['structure'] = structure.copy() jobfolder.structure.cell = Reduction()(jobfolder.structure.cell) jobfolder.functional = kescan.copy() jobfolder.functional.kpoints = ReducedKDensity(density, (0.5, 0.5, 0.5)) jobfolder.functional.reference = None jobfolder.functional.fft_mesh = fftmesh(structure.cell) jobfolder.functional.nbstates = int(len(structure.atoms) * 4 * 1.5+0.5) ip = get_ipy() ip.user_ns["current_jobfolder"] = jobfolder.root ip.magic("savejobs " + path) return