2121_DEFAULT_RELAX_KWARGS : dict [str , Any ] = {
2222 "force_field_name" : "CHGNet" ,
2323 "relax_kwargs" : {"fmax" : 0.00001 },
24+ "fix_symmetry" : True ,
2425}
2526
2627
@@ -106,6 +107,7 @@ def from_force_field_name(
106107 cls ,
107108 force_field_name : str | MLFF | dict ,
108109 calculator_kwargs : dict | None = None ,
110+ relax_initial_structure : bool = True ,
109111 ** kwargs ,
110112 ) -> Self :
111113 """
@@ -117,13 +119,24 @@ def from_force_field_name(
117119 The name of the force field.
118120 calculator_kwargs : dict or None (default)
119121 calculator_kwargs to pass to `ForceFieldRelaxMaker`.
122+ relax_initial_structure : bool = True (default)
123+ Whether to relax the structure before computing
124+ the elastic tensor.
120125 **kwargs
121126 Additional kwargs to pass to ElasticMaker.
122127
123128 Returns
124129 -------
125130 ElasticMaker
126131 """
132+ warnings .warn (
133+ "Fixed symmetry relaxations are automatically enabled "
134+ "to improve elastic tensor stability. To disable this "
135+ "specify ForceFieldRelaxMaker objects explicitly. " ,
136+ category = UserWarning ,
137+ stacklevel = 2 ,
138+ )
139+
127140 if (mlff_kwargs := kwargs .pop ("mlff_kwargs" , None )) is not None :
128141 warnings .warn (
129142 "`mlff_kwargs` has been marked for deprecation. "
@@ -148,18 +161,22 @@ def from_force_field_name(
148161 "force_field_name" : force_field_name ,
149162 "calculator_kwargs" : calculator_kwargs or {},
150163 }
151- bulk_relax_maker = ForceFieldRelaxMaker (
152- relax_cell = True ,
164+
165+ elastic_relax_maker = ForceFieldRelaxMaker (
166+ relax_cell = False ,
153167 ** default_kwargs ,
154168 )
155- kwargs .update (
156- bulk_relax_maker = bulk_relax_maker ,
157- elastic_relax_maker = ForceFieldRelaxMaker (
158- relax_cell = False ,
159- ** default_kwargs ,
160- ),
161- )
169+
162170 return cls (
163- name = f"{ bulk_relax_maker .mlff .name } elastic" ,
171+ name = f"{ elastic_relax_maker .mlff .name } elastic" ,
164172 ** kwargs ,
173+ bulk_relax_maker = (
174+ ForceFieldRelaxMaker (
175+ relax_cell = True ,
176+ ** default_kwargs ,
177+ )
178+ if relax_initial_structure
179+ else None
180+ ),
181+ elastic_relax_maker = elastic_relax_maker ,
165182 )
0 commit comments