@@ -357,6 +357,11 @@ def formula(self) -> str:
357
357
"""Returns the formula as a string."""
358
358
return self .composition .formula
359
359
360
+ @property
361
+ def alphabetical_formula (self ) -> str :
362
+ """Returns the formula as a string."""
363
+ return self .composition .alphabetical_formula
364
+
360
365
@property
361
366
def elements (self ) -> list [Element | Species | DummySpecies ]:
362
367
"""Returns the elements in the structure as a list of Element objects."""
@@ -1172,11 +1177,9 @@ def from_magnetic_spacegroup(
1172
1177
f"{ msg .sg_symbol } !"
1173
1178
)
1174
1179
1175
- if len (species ) != len (coords ):
1176
- raise ValueError (f"Supplied species and coords lengths ({ len (species )} vs { len (coords )} ) are different!" )
1177
-
1178
- if len (species ) != len (magmoms ):
1179
- raise ValueError (f"Supplied species and magmom lengths ({ len (species )} vs { len (magmoms )} ) are different!" )
1180
+ for name , var in (("coords" , coords ), ("magmoms" , magmoms )):
1181
+ if len (var ) != len (species ):
1182
+ raise ValueError (f"Length mismatch: len({ name } )={ len (var )} != { len (species )= } " )
1180
1183
1181
1184
frac_coords = coords if not coords_are_cartesian else latt .get_fractional_coords (coords )
1182
1185
@@ -2138,13 +2141,16 @@ def interpolate(
2138
2141
interpolate_lattices : bool = False ,
2139
2142
pbc : bool = True ,
2140
2143
autosort_tol : float = 0 ,
2144
+ end_amplitude : float = 1 ,
2141
2145
) -> list [IStructure | Structure ]:
2142
2146
"""Interpolate between this structure and end_structure. Useful for
2143
- construction of NEB inputs.
2147
+ construction of NEB inputs. To obtain useful results, the cell setting
2148
+ and order of sites must consistent across the start and end structures.
2144
2149
2145
2150
Args:
2146
2151
end_structure (Structure): structure to interpolate between this
2147
- structure and end.
2152
+ structure and end. Must be in the same setting and have the
2153
+ same site ordering to yield useful results.
2148
2154
nimages (int,list): No. of interpolation images or a list of
2149
2155
interpolation images. Defaults to 10 images.
2150
2156
interpolate_lattices (bool): Whether to interpolate the lattices.
@@ -2157,6 +2163,13 @@ def interpolate(
2157
2163
closest points in this particular structure. This is usually
2158
2164
what you want in a NEB calculation. 0 implies no sorting.
2159
2165
Otherwise, a 0.5 value usually works pretty well.
2166
+ end_amplitude (float): The fractional amplitude of the endpoint
2167
+ of the interpolation, or a cofactor of the distortion vector
2168
+ connecting structure to end_structure. Thus, 0 implies no
2169
+ distortion, 1 implies full distortion to end_structure
2170
+ (default), 0.5 implies distortion to a point halfway
2171
+ between structure and end_structure, and -1 implies full
2172
+ distortion in the opposite direction to end_structure.
2160
2173
2161
2174
Returns:
2162
2175
List of interpolated structures. The starting and ending
@@ -2212,7 +2225,7 @@ def interpolate(
2212
2225
2213
2226
end_coords = sorted_end_coords
2214
2227
2215
- vec = end_coords - start_coords
2228
+ vec = end_amplitude * ( end_coords - start_coords )
2216
2229
if pbc :
2217
2230
vec [:, self .pbc ] -= np .round (vec [:, self .pbc ])
2218
2231
sp = self .species_and_occu
@@ -2222,7 +2235,7 @@ def interpolate(
2222
2235
# interpolate lattice matrices using polar decomposition
2223
2236
# u is a unitary rotation, p is stretch
2224
2237
u , p = polar (np .dot (end_structure .lattice .matrix .T , np .linalg .inv (self .lattice .matrix .T )))
2225
- lvec = p - np .identity (3 )
2238
+ lvec = end_amplitude * ( p - np .identity (3 ) )
2226
2239
lstart = self .lattice .matrix .T
2227
2240
2228
2241
for x in images :
0 commit comments