Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def cal_struc_d(structures, id_list, struc_d, spg_n, threshold, r_cut_off, volume, ilat, r_vector):
struc_d[id_list[0]][0] = -2
prototype_id = [id_list[0]]
# temp_c=[]
if spg_n > 15 and spg_n < 195 and ilat == 2:
l_same_cell = True
else:
l_same_cell = False
if len(id_list) != 1:
if ilat == 0 or volume == structures[id_list[0]].get_volume():
structures[id_list[0]].ccf = struc2ccf(structures[id_list[0]], r_cut_off, r_vector)
# if l_same_cell:
# temp_c=structures[id_list[0]].cell
else:
# temp_c=structures[id_list[0]].cell * (volume / structures[id_list[0]].get_volume()) ** (1.0 / 3.0)
structures[id_list[0]].ccf = \
struc2ccf(Atoms(
cell=structures[id_list[0]].cell * (volume / structures[id_list[0]].get_volume()) ** (1.0 / 3.0),
scaled_positions=structures[id_list[0]].get_scaled_positions(wrap=True),
numbers=structures[id_list[0]].numbers, pbc=structures[0].pbc), r_cut_off, r_vector)
# volume = structures[id_list[0]].get_volume()
for i in id_list[1:]:
if ilat == 0:
structures[i].ccf = struc2ccf(structures[i], r_cut_off, r_vector)
else:
scaled_positions = structures[i].get_scaled_positions(wrap=True)
structures[i].ccf = struc2ccf(
if len(id_list) != 1:
if ilat == 0 or volume == structures[id_list[0]].get_volume():
structures[id_list[0]].ccf = struc2ccf(structures[id_list[0]], r_cut_off, r_vector)
# if l_same_cell:
# temp_c=structures[id_list[0]].cell
else:
# temp_c=structures[id_list[0]].cell * (volume / structures[id_list[0]].get_volume()) ** (1.0 / 3.0)
structures[id_list[0]].ccf = \
struc2ccf(Atoms(
cell=structures[id_list[0]].cell * (volume / structures[id_list[0]].get_volume()) ** (1.0 / 3.0),
scaled_positions=structures[id_list[0]].get_scaled_positions(wrap=True),
numbers=structures[id_list[0]].numbers, pbc=structures[0].pbc), r_cut_off, r_vector)
# volume = structures[id_list[0]].get_volume()
for i in id_list[1:]:
if ilat == 0:
structures[i].ccf = struc2ccf(structures[i], r_cut_off, r_vector)
else:
scaled_positions = structures[i].get_scaled_positions(wrap=True)
structures[i].ccf = struc2ccf(
Atoms(cell=structures[i].cell * (volume / structures[i].get_volume()) ** (1.0 / 3.0),
scaled_positions=scaled_positions, numbers=structures[i].numbers, pbc=structures[0].pbc),
r_cut_off, r_vector)
# if i == 57:
# ccf_file = open('ccf.dat', 'wb')
# pickle.dump(structures[i].ccf,ccf_file)
# ccf_file.close()
# rvf=open('rvf.dat','wb')
# pickle.dump(r_vector,rvf)
# rvf.close()
# write('out.cif',Atoms(cell=structures[i].cell * (volume / structures[i].get_volume()) ** (1.0 / 3.0),
# scaled_positions=scaled_positions, numbers=structures[i].numbers,pbc=structures[0].pbc))
# print(Atoms(cell=structures[i].cell * (volume / structures[i].get_volume()) ** (1.0 / 3.0),
# ccf_file.close()
# rvf=open('rvf.dat','wb')
# pickle.dump(r_vector,rvf)
# rvf.close()
# write('out.cif',Atoms(cell=structures[i].cell * (volume / structures[i].get_volume()) ** (1.0 / 3.0),
# scaled_positions=scaled_positions, numbers=structures[i].numbers,pbc=True))
# print(Atoms(cell=structures[i].cell * (volume / structures[i].get_volume()) ** (1.0 / 3.0),
# scaled_positions=scaled_positions, numbers=structures[i].numbers,pbc=True).get_volume())
for j in [prototype_id[-1 - j2] for j2 in range(len(prototype_id))]:
struc_d[i][1] = cal_ccf_d(structures[j].ccf, structures[i].ccf)
if struc_d[i][1] < threshold:
struc_d[i][0] = j
break
elif l_same_cell:
struc_d[i][1] = cal_ccf_d(
structures[j].ccf, struc2ccf(Atoms(cell=structures[j].cell, scaled_positions=scaled_positions,
numbers=structures[i].numbers, pbc=True), r_cut_off,
r_vector))
if struc_d[i][1] < threshold:
struc_d[i][0] = j
break
# Mark this structure as a new prototype.
if struc_d[i][0] == -1:
struc_d[i] = [-2, 0.0]
prototype_id.append(i)
pass
l_same_cell = True
else:
l_same_cell = False
if len(id_list) != 1:
if volume == structures[id_list[0]].get_volume():
structures[id_list[0]].ccf = struc2ccf(structures[id_list[0]], r_cut_off, r_vector)
else:
structures[id_list[0]].ccf = \
struc2ccf(Atoms(
cell=structures[id_list[0]].cell * (volume / structures[id_list[0]].get_volume()) ** (1.0 / 3.0),
scaled_positions=structures[id_list[0]].get_scaled_positions(wrap=True),
numbers=structures[id_list[0]].numbers, pbc=True), r_cut_off, r_vector)
# volume = structures[id_list[0]].get_volume()
for i in id_list[1:]:
scaled_positions = structures[i].get_scaled_positions(wrap=True)
structures[i].ccf = struc2ccf(
Atoms(cell=structures[i].cell * (volume / structures[i].get_volume()) ** (1.0 / 3.0),
scaled_positions=scaled_positions, numbers=structures[i].numbers, pbc=True), r_cut_off, r_vector)
# if i == 57:
# ccf_file = open('ccf.dat', 'wb')
# pickle.dump(structures[i].ccf,ccf_file)
# ccf_file.close()
# rvf=open('rvf.dat','wb')
# pickle.dump(r_vector,rvf)
# rvf.close()
# write('out.cif',Atoms(cell=structures[i].cell * (volume / structures[i].get_volume()) ** (1.0 / 3.0),
# scaled_positions=scaled_positions, numbers=structures[i].numbers,pbc=True))
# print(Atoms(cell=structures[i].cell * (volume / structures[i].get_volume()) ** (1.0 / 3.0),
# scaled_positions=scaled_positions, numbers=structures[i].numbers,pbc=True).get_volume())
for j in [prototype_id[-1 - j2] for j2 in range(len(prototype_id))]:
struc_d[i][1] = cal_ccf_d(structures[j].ccf, structures[i].ccf)
if struc_d[i][1] < threshold:
def cal_struc_d(structures, id_list, struc_d, spg_n, threshold, r_cut_off, volume, ilat, r_vector):
struc_d[id_list[0]][0] = -2
prototype_id = [id_list[0]]
if spg_n > 15 and spg_n < 195 and ilat == 2:
l_same_cell = True
else:
l_same_cell = False
if len(id_list) != 1:
if volume == structures[id_list[0]].get_volume():
structures[id_list[0]].ccf = struc2ccf(structures[id_list[0]], r_cut_off, r_vector)
else:
structures[id_list[0]].ccf = \
struc2ccf(Atoms(
cell=structures[id_list[0]].cell * (volume / structures[id_list[0]].get_volume()) ** (1.0 / 3.0),
scaled_positions=structures[id_list[0]].get_scaled_positions(wrap=True),
numbers=structures[id_list[0]].numbers, pbc=True), r_cut_off, r_vector)
# volume = structures[id_list[0]].get_volume()
for i in id_list[1:]:
scaled_positions = structures[i].get_scaled_positions(wrap=True)
structures[i].ccf = struc2ccf(
Atoms(cell=structures[i].cell * (volume / structures[i].get_volume()) ** (1.0 / 3.0),
scaled_positions=scaled_positions, numbers=structures[i].numbers, pbc=True), r_cut_off, r_vector)
# if i == 57:
# ccf_file = open('ccf.dat', 'wb')
# pickle.dump(structures[i].ccf,ccf_file)
# ccf_file.close()
# rvf=open('rvf.dat','wb')
# pickle.dump(r_vector,rvf)
# rvf.close()
# ccf_file.close()
# rvf=open('rvf.dat','wb')
# pickle.dump(r_vector,rvf)
# rvf.close()
# write('out.cif',Atoms(cell=structures[i].cell * (volume / structures[i].get_volume()) ** (1.0 / 3.0),
# scaled_positions=scaled_positions, numbers=structures[i].numbers,pbc=structures[0].pbc))
# print(Atoms(cell=structures[i].cell * (volume / structures[i].get_volume()) ** (1.0 / 3.0),
# scaled_positions=scaled_positions, numbers=structures[i].numbers,pbc=structures[0].pbc).get_volume())
for j in [prototype_id[-1 - j2] for j2 in range(len(prototype_id))]:
struc_d[i][1] = cal_ccf_d(structures[j].ccf, structures[i].ccf)
if struc_d[i][1] < threshold:
struc_d[i][0] = j
break
elif l_same_cell:
struc_d[i][1] = cal_ccf_d(
structures[j].ccf, struc2ccf(Atoms(
cell=structures[j].cell * (volume / structures[j].get_volume()) ** (1.0 / 3.0),
scaled_positions=scaled_positions, numbers=structures[i].numbers,
pbc=structures[0].pbc), r_cut_off, r_vector))
if struc_d[i][1] < threshold:
struc_d[i][0] = j
break
# Mark this structure as a new prototype.
if struc_d[i][0] == -1:
struc_d[i] = [-2, 0.0]
prototype_id.append(i)
pass
def cal_struc_d(structures, id_list, struc_d, spg_n, threshold, r_cut_off, volume, ilat, r_vector):
struc_d[id_list[0]][0] = -2
prototype_id = [id_list[0]]
if spg_n > 15 and spg_n < 195 and ilat == 2:
l_same_cell = True
else:
l_same_cell = False
if len(id_list) != 1:
if volume == structures[id_list[0]].get_volume():
structures[id_list[0]].ccf = struc2ccf(structures[id_list[0]], r_cut_off, r_vector)
else:
structures[id_list[0]].ccf = \
struc2ccf(Atoms(
cell=structures[id_list[0]].cell * (volume / structures[id_list[0]].get_volume()) ** (1.0 / 3.0),
scaled_positions=structures[id_list[0]].get_scaled_positions(wrap=True),
numbers=structures[id_list[0]].numbers, pbc=True), r_cut_off, r_vector)
# volume = structures[id_list[0]].get_volume()
for i in id_list[1:]:
scaled_positions = structures[i].get_scaled_positions(wrap=True)
structures[i].ccf = struc2ccf(
Atoms(cell=structures[i].cell * (volume / structures[i].get_volume()) ** (1.0 / 3.0),
scaled_positions=scaled_positions, numbers=structures[i].numbers, pbc=True), r_cut_off, r_vector)
# if i == 57:
# ccf_file = open('ccf.dat', 'wb')
# pickle.dump(structures[i].ccf,ccf_file)
# ccf_file.close()
structures[i].ccf = struc2ccf(
Atoms(cell=structures[i].cell * (volume / structures[i].get_volume()) ** (1.0 / 3.0),
scaled_positions=scaled_positions, numbers=structures[i].numbers, pbc=True), r_cut_off, r_vector)
# if i == 57:
# ccf_file = open('ccf.dat', 'wb')
# pickle.dump(structures[i].ccf,ccf_file)
# ccf_file.close()
# rvf=open('rvf.dat','wb')
# pickle.dump(r_vector,rvf)
# rvf.close()
# write('out.cif',Atoms(cell=structures[i].cell * (volume / structures[i].get_volume()) ** (1.0 / 3.0),
# scaled_positions=scaled_positions, numbers=structures[i].numbers,pbc=True))
# print(Atoms(cell=structures[i].cell * (volume / structures[i].get_volume()) ** (1.0 / 3.0),
# scaled_positions=scaled_positions, numbers=structures[i].numbers,pbc=True).get_volume())
for j in [prototype_id[-1 - j2] for j2 in range(len(prototype_id))]:
struc_d[i][1] = cal_ccf_d(structures[j].ccf, structures[i].ccf)
if struc_d[i][1] < threshold:
struc_d[i][0] = j
break
elif l_same_cell:
struc_d[i][1] = cal_ccf_d(
structures[j].ccf, struc2ccf(Atoms(cell=structures[j].cell, scaled_positions=scaled_positions,
numbers=structures[i].numbers, pbc=True), r_cut_off,
r_vector))
if struc_d[i][1] < threshold:
struc_d[i][0] = j
break
# Mark this structure as a new prototype.
if struc_d[i][0] == -1:
struc_d[i] = [-2, 0.0]
prototype_id.append(i)
pass
# pickle.dump(structures[i].ccf,ccf_file)
# ccf_file.close()
# rvf=open('rvf.dat','wb')
# pickle.dump(r_vector,rvf)
# rvf.close()
# write('out.cif',Atoms(cell=structures[i].cell * (volume / structures[i].get_volume()) ** (1.0 / 3.0),
# scaled_positions=scaled_positions, numbers=structures[i].numbers,pbc=True))
# print(Atoms(cell=structures[i].cell * (volume / structures[i].get_volume()) ** (1.0 / 3.0),
# scaled_positions=scaled_positions, numbers=structures[i].numbers,pbc=True).get_volume())
for j in [prototype_id[-1 - j2] for j2 in range(len(prototype_id))]:
struc_d[i][1] = cal_ccf_d(structures[j].ccf, structures[i].ccf)
if struc_d[i][1] < threshold:
struc_d[i][0] = j
break
elif l_same_cell:
struc_d[i][1] = cal_ccf_d(
structures[j].ccf, struc2ccf(Atoms(cell=structures[j].cell, scaled_positions=scaled_positions,
numbers=structures[i].numbers, pbc=True), r_cut_off,
r_vector))
if struc_d[i][1] < threshold:
struc_d[i][0] = j
break
# Mark this structure as a new prototype.
if struc_d[i][0] == -1:
struc_d[i] = [-2, 0.0]
prototype_id.append(i)
pass
# pickle.dump(structures[i].ccf,ccf_file)
# ccf_file.close()
# rvf=open('rvf.dat','wb')
# pickle.dump(r_vector,rvf)
# rvf.close()
# write('out.cif',Atoms(cell=structures[i].cell * (volume / structures[i].get_volume()) ** (1.0 / 3.0),
# scaled_positions=scaled_positions, numbers=structures[i].numbers,pbc=structures[0].pbc))
# print(Atoms(cell=structures[i].cell * (volume / structures[i].get_volume()) ** (1.0 / 3.0),
# scaled_positions=scaled_positions, numbers=structures[i].numbers,pbc=structures[0].pbc).get_volume())
for j in [prototype_id[-1 - j2] for j2 in range(len(prototype_id))]:
struc_d[i][1] = cal_ccf_d(structures[j].ccf, structures[i].ccf)
if struc_d[i][1] < threshold:
struc_d[i][0] = j
break
elif l_same_cell:
struc_d[i][1] = cal_ccf_d(
structures[j].ccf, struc2ccf(Atoms(
cell=structures[j].cell * (volume / structures[j].get_volume()) ** (1.0 / 3.0),
scaled_positions=scaled_positions, numbers=structures[i].numbers,
pbc=structures[0].pbc), r_cut_off, r_vector))
if struc_d[i][1] < threshold:
struc_d[i][0] = j
break
# Mark this structure as a new prototype.
if struc_d[i][0] == -1:
struc_d[i] = [-2, 0.0]
prototype_id.append(i)
pass