def run(self):
# Create directory contain POSCARs
import random
import string
import tempfile
rd_suffix = ''.join(random.choices(string.ascii_uppercase
+ string.digits, k=5))
working_path = os.getcwd()
poscars_dir = os.path.join(working_path,
'STRUCTURES_{0:}_{1:}'.format(self.comment,
rd_suffix))
if not os.path.exists(poscars_dir):
os.makedirs(poscars_dir)
else:
shutil.rmtree(poscars_dir)
os.makedirs(poscars_dir)
ogg = OccupyGenerator(self.cell)
g = ogg.gen_nodup_trinary_alloy(Specie(self.s1), self.n1,
Specie(self.s2), self.n2)
if self.tr is not None:
tr = (Specie(self.tr[0]), self.tr[1])
applied_restriction = MinDistanceRestriction(tr)
# For diff outmode
if self.outmode == 'vasp':
Output = VaspPOSCAR
prefix = 'POSCAR_A{:}B{:}C{:}_'
suffix = '.vasp'
else:
Output = YamlOutput
prefix = 'STRUCTURE_A{:}B{:}C{:}_'
suffix = '.yaml'
for n_count, c in enumerate(g):
if self.mpr:
if self.tr is not None:
condition = c.is_primitive() and applied_restriction.is_satisfied(c)
else:
condition = c.is_primitive()
else:
if self.tr is not None:
condition = applied_restriction.is_satisfied(c)
else:
condition = True
if condition:
if self.refined:
c = c.get_refined_pcell()
poscar = Output(c, 1)
tf = tempfile.NamedTemporaryFile(mode='w+b', dir=poscars_dir,
prefix=prefix.format(self.n0, self.n1, self.n2),
suffix=suffix, delete=False)
poscar.write(tf.name)
评论列表
文章目录