How to use the pyxtal.crystal.random_cluster function in pyxtal

To help you get started, we’ve selected a few pyxtal examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github qzhu2017 / PyXtal / pyxtal / test_cases / LJ_bug.py View on Github external
def generate_cluster(self, pgs=range(2, 33)):
        run = True
        while run:
            pg = choice(pgs)
            cluster = random_cluster(pg, ["Mo"], [self.numIons], 1.0)
            if cluster.valid:
                run = False
        return cluster.cart_coords
github qzhu2017 / PyXtal / examples / example_02_0D_LJ_4d.py View on Github external
def generate_cluster(self, pgs=range(2, 33)):
        run = True
        while run:
            pg = choice(pgs)
            cluster = random_cluster(pg, ["Mo"], [self.numIons], 1.0)
            if cluster.valid:
                run = False
        return cluster.coordinates
github qzhu2017 / PyXtal / examples / example_02_LJ_cluster.py View on Github external
def generate_cluster(self, pgs=range(2, 33)):
        run = True
        while run:
            pg = choice(pgs)
            cluster = random_cluster(pg, ["H"], [self.numIons], 0.6)
            if cluster.valid:
                run = False
        return cluster.molecule.cart_coords
github qzhu2017 / PyXtal / scripts / pyxtal_atom.py View on Github external
thickness = options.thickness

    if not os.path.exists(outdir):
        os.mkdir(outdir)

    for i in range(attempts):
        numIons0 = np.array(numIons)
        start = time()
        if dimension == 3:
            rand_crystal = random_crystal(sg, system, numIons0, factor)
        elif dimension == 2:
            rand_crystal = random_crystal_2D(sg, system, numIons0, thickness, factor)
        elif dimension == 1:
            rand_crystal = random_crystal_1D(sg, system, numIons0, thickness, factor)
        if dimension == 0:
            rand_crystal = random_cluster(sg, system, numIons0, factor)
        end = time()
        timespent = np.around((end - start), decimals=2)

        if rand_crystal.valid:
            # Output a cif or xyz file
            comp = str(rand_crystal.struct.composition)
            comp = comp.replace(" ", "")
            if dimension > 0:
                outpath = outdir + "/" + comp + ".cif"
                CifWriter(rand_crystal.struct, symprec=0.1).write_file(filename=outpath)
            else:
                outpath = outdir + "/" + comp + ".xyz"
                rand_crystal.to_file(filename=outpath, fmt="xyz")

            if dimension > 0:
                ans = get_symmetry_dataset(rand_crystal.spg_struct, symprec=1e-1)[
github qzhu2017 / PyXtal / examples / 01-compare_optalg.py View on Github external
def generate_cluster(self, pgs=range(2, 33)):
        run = True
        while run:
            pg = choice(pgs)
            cluster = random_cluster(
                pg,
                ["Mo"],
                [self.numIons],
                volume_factor,
                tm=Tol_matrix(prototype="atomic", factor=cluster_factor),
            )
            if cluster.valid:
                run = False
        try:
            return cluster.cart_coords
        except:
            return cluster.coordinates
github qzhu2017 / PyXtal / examples / LJ_38_Oh.py View on Github external
def generate_cluster(self, pgs = range(2, 33)):
        run = True
        while run:
            pg = choice(pgs)
            cluster = random_cluster(pg, ['Mo'], [self.numIons], 1.0)
            if cluster.valid:
                run = False
        return cluster.cart_coords
github qzhu2017 / PyXtal / examples / example_02_0D_LJ.py View on Github external
symbol = 'N/A'
    return symbol

N_attempts = 100
numIons = 12
factor = 1.1
ref = Collection('clusters')[str(numIons)]
print('The reference energy for LJ {0:3d} is {1:12.3f}, pointgroup: {2:4s}'.format(numIons, ref['energy'], ref['pointgroup']))

N_success = 0
t0 = time()
for i in range(N_attempts):
    run = True
    while run:
        pg = randint(2, 32)
        cluster = random_cluster(pg, ['Mo'], [numIons], factor)
        if cluster.valid:
            run = False

    pg1 = parse_symmetry(cluster.coordinates)
    pos = cluster.coordinates.flatten()
    [energy, pos] = single_optimize(pos)
    pg2 = parse_symmetry(pos)
    if abs(energy-ref['energy']) <1e-3:
        N_success += 1
        print('PG requested: {0:4s} relaxed: {1:4s} Energy: {2:12.3f} Time: {3:6.1f} mins ++++++'.format(pg1, pg2, energy, (time()- t0)/60.0))
    else:
        print('PG requested: {0:4s} relaxed: {1:4s} Energy: {2:12.3f} Time: {3:6.1f} mins'.format(pg1, pg2, energy, (time()- t0)/60.0))

print('Hit the ground state {0:4d} times out of {1:4d} attempts'.format(N_success, N_attempts))