19
19
def cell_relax (
20
20
calc_id : str ,
21
21
image : Dict ,
22
- prefix : str = '' ,
23
22
optimizer : str = 'BFGS' ,
24
- smax : float = 0.002 ,
23
+ fmax : float = 0.002 ,
25
24
mask : Optional [Sequence ] = None ,
25
+ prefix : Optional [str ] = None ,
26
26
) -> Dict :
27
27
"""Relax cell using ASE Optimizer
28
28
@@ -34,8 +34,8 @@ def cell_relax(
34
34
:type prefix: str, optional
35
35
:param optimizer: Optimizer class to use from ase.optimize, defaults to 'BFGS'
36
36
:type optimizer: str, optional
37
- :param smax : Maximum stress in eV/$\AA^3$, defaults to 0.002
38
- :type smax : float, optional
37
+ :param fmax : Maximum stress in eV/$\AA^3$, defaults to 0.002
38
+ :type fmax : float, optional
39
39
:param mask: Mask to constrain cell deformation while relaxing, defaults to None
40
40
:type mask: Optional[Sequence], optional
41
41
:return: Dictionary of results including, final energy, stress and output files
@@ -45,6 +45,11 @@ def cell_relax(
45
45
atoms = get_atoms (** image )
46
46
atoms .set_calculator (calc )
47
47
48
+ if prefix is not None :
49
+ prefix = prefix + '_'
50
+ else :
51
+ prefix = ''
52
+
48
53
traj_file = join_names ([prefix , 'cell_relax.traj' ])
49
54
sf = StrainFilter (atoms , mask = mask )
50
55
dyn = getattr (ase .optimize , optimizer )(sf )
@@ -56,7 +61,7 @@ def cell_relax(
56
61
)
57
62
dyn .attach (traj )
58
63
try :
59
- dyn .run (fmax = smax )
64
+ dyn .run (fmax = fmax )
60
65
except Exception :
61
66
print ('Failed to optimize atoms' )
62
67
raise
@@ -65,11 +70,11 @@ def cell_relax(
65
70
atoms .write (image_file , format = 'extxyz' )
66
71
67
72
energy = float (atoms .get_potential_energy ())
68
- final_smax = float (atoms .get_stress ().max ())
73
+ final_fmax = float (atoms .get_stress ().max ())
69
74
70
75
results = {
71
76
'energy' : energy ,
72
- 'final_smax ' : final_smax ,
77
+ 'final_fmax ' : final_fmax ,
73
78
'files' :{
74
79
'image' : image_file ,
75
80
'traj' : traj_file ,
0 commit comments