Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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
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
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
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)[
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
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
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))