Skip to content

Commit

Permalink
feat: add slip length information to post of Gamma.py
Browse files Browse the repository at this point in the history
  • Loading branch information
ZLI-afk committed Jan 4, 2024
1 parent ce3006e commit 710f211
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 18 deletions.
20 changes: 11 additions & 9 deletions apex/core/property/Gamma.py
Original file line number Diff line number Diff line change
Expand Up @@ -267,11 +267,12 @@ def make_confs(self, path_to_work, path_to_equi, refine=False):
np.array([relax_a, relax_b, relax_c]))
norm_length = np.linalg.norm(slip_vector_cartesian, 2)
frac_slip_vec = np.array([norm_length, 0, 0])
except:
except Exception:
raise RuntimeError(
'Only int | float or '
'Sequence[int | float, int | float, int | float] is allowed for the input_length'
)
self.slip_length = frac_slip_vec[0]
# get displaced structure
for obtained_slab in self.__displace_slab_generator(slab,
disp_vector=frac_slip_vec,
Expand Down Expand Up @@ -299,6 +300,7 @@ def make_confs(self, path_to_work, path_to_equi, refine=False):
# vasp.perturb_xz('POSCAR', 'POSCAR', self.pert_xz)
# record miller
dumpfn(self.plane_miller, "miller.json")
dumpfn(self.slip_length, 'slip_length.json')
count += 1
os.chdir(cwd)

Expand Down Expand Up @@ -546,12 +548,11 @@ def _compute_lower(self, output_file, all_tasks, all_res):
+ str(self.displace_direction)
)
"""
ptr_data += "No_task: \tDisplacement \tStacking_Fault_E(J/m^2) EpA(eV) slab_equi_EpA(eV)\n"
ptr_data += "No_task: \tDisplacement \tDisplace_Length(\AA) \tStacking_Fault_E(J/m^2) EpA(eV) slab_equi_EpA(eV)\n"
all_tasks.sort()
n_steps = len(all_tasks) - 1
task_result_slab_equi = loadfn(
os.path.join(all_tasks[0], "result_task.json")
)
task_result_slab_equi = loadfn(os.path.join(all_tasks[0], "result_task.json"))
slip_length = loadfn(os.path.join(all_tasks[0], "slip_length.json"))
for ii in all_tasks:
task_result = loadfn(os.path.join(ii, "result_task.json"))
natoms = np.sum(task_result["atom_numbs"])
Expand Down Expand Up @@ -581,16 +582,17 @@ def _compute_lower(self, output_file, all_tasks, all_res):
/ AA
* Cf
)

frac = int(ii[-4:]) / n_steps
miller_index = loadfn(os.path.join(ii, "miller.json"))
ptr_data += "%-25s %7.2f %7.3f %8.3f %8.3f\n" % (
ptr_data += "%-25s %7.2f %7.3f %7.3f %8.3f %8.3f\n" % (
str(miller_index) + "-" + structure_dir + ":",
int(ii[-4:]) / n_steps,
frac,
(slip_length * frac),
sfe,
epa,
equi_epa_slab,
)
res_data[int(ii[-4:]) / n_steps] = [sfe, epa, equi_epa]
res_data[frac] = [(slip_length * frac), sfe, epa, equi_epa]

else:
if "init_data_path" not in self.parameter:
Expand Down
20 changes: 14 additions & 6 deletions apex/reporter/property_report.py
Original file line number Diff line number Diff line change
Expand Up @@ -396,28 +396,33 @@ class GammaReport(PropertyReport):
@staticmethod
def plotly_graph(res_data: dict, name: str, **kwargs) -> [go, go.layout]:
displ = []
displ_length = []
fault_en = []
struct_en = []
equi_en = []
for k, v in res_data.items():
displ.append(k)
fault_en.append(v[0])
struct_en.append((v[1]))
equi_en.append(v[2])
displ_length.append(v[0])
fault_en.append(v[1])
struct_en.append((v[2]))
equi_en.append(v[3])
df = pd.DataFrame({
"displacement": displ,
"displace_length": displ_length,
"fault_en": fault_en
})
trace = go.Scatter(
name=name,
x=df['displacement'],
# x=df['displace_length'],
y=df['fault_en'],
mode='lines+markers'
)
layout = go.Layout(
title='Stacking Fault Energy (Gamma Line)',
xaxis=dict(
title_text="Displacement",
# title_text="Displace_Length (Å)",
title_font=dict(
size=18,
color="#7f7f7f"
Expand All @@ -437,16 +442,19 @@ def plotly_graph(res_data: dict, name: str, **kwargs) -> [go, go.layout]:
@staticmethod
def dash_table(res_data: dict, decimal: int = 3, **kwargs) -> dash_table.DataTable:
displ = []
displ_length = []
fault_en = []
struct_en = []
equi_en = []
for k, v in res_data.items():
displ.append(float(k))
fault_en.append(v[0])
struct_en.append((v[1]))
equi_en.append(v[2])
displ_length.append(v[0])
fault_en.append(v[1])
struct_en.append((v[2]))
equi_en.append(v[3])
df = pd.DataFrame({
"Displace": round_format(displ, decimal),
"Slip_Length (Å)": round_format(displ_length, decimal),
"E_Fault (J/m^2)": round_format(fault_en, decimal),
"E_Slab (eV)": round_format(struct_en, decimal),
"E_Equilib (eV)": round_format(equi_en, decimal)
Expand Down
6 changes: 3 additions & 3 deletions apex/reporter/relaxation_report.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,9 @@ def dash_table(res_data: dict, decimal: int = 3, **kwargs) -> dash_table.DataTab
df = pd.DataFrame({
"Conf": conf_list,
"Equi E (eV)": equi_en,
"Cell Vector length a (\AA)": cell_vec_a,
"Cell Vector length b (\AA)": cell_vec_b,
"Cell Vector length c (\AA)": cell_vec_c,
"Cell Vector length a (Å)": cell_vec_a,
"Cell Vector length b (Å)": cell_vec_b,
"Cell Vector length c (Å)": cell_vec_c,
"Space Group Symbol": space_group_symbol,
"Space Group Number": space_group_number,
"Point Group Symbol": point_group_symbol,
Expand Down
1 change: 1 addition & 0 deletions tests/output/gamma_00/task.000000/slip_length.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
5.075764016067081
1 change: 1 addition & 0 deletions tests/output/gamma_00/task.000001/slip_length.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
5.075764016067081
1 change: 1 addition & 0 deletions tests/output/gamma_00/task.000002/slip_length.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
5.075764016067081

0 comments on commit 710f211

Please sign in to comment.