@@ -250,45 +250,44 @@ def from_str(cls, data, sigfigs=8):
250
250
return LMTOCtrl .from_dict (structure_tokens )
251
251
252
252
@classmethod
253
- def from_dict (cls , d ):
253
+ def from_dict (cls , dct ):
254
254
"""
255
255
Creates a CTRL file object from a dictionary. The dictionary
256
256
must contain the items "ALAT", PLAT" and "SITE".
257
257
258
258
Valid dictionary items are:
259
259
ALAT: the a-lattice parameter
260
260
PLAT: (3x3) array for the lattice vectors
261
- SITE: list of dictionaries: {'ATOM': class label,
262
- 'POS': (3x1) array of fractional
263
- coordinates}
261
+ SITE: list of dictionaries: {'ATOM': class label, 'POS': (3x1) array of fractional coordinates}
264
262
CLASS (optional): list of unique atom labels as str
265
263
SPCGRP (optional): space group symbol (str) or number (int)
266
264
HEADER (optional): HEADER text as a str
267
265
VERS (optional): LMTO version as a str
268
266
269
267
Args:
270
- d : The CTRL file as a dictionary.
268
+ dct : The CTRL file as a dictionary.
271
269
272
270
Returns:
273
271
An LMTOCtrl object.
274
272
"""
275
- for cat in ["HEADER" , "VERS" ]:
276
- if cat not in d :
277
- d [cat ] = None
278
- alat = d ["ALAT" ] * bohr_to_angstrom
279
- plat = d ["PLAT" ] * alat
273
+ dct .setdefault ("HEADER" , None )
274
+ dct .setdefault ("VERS" , None )
275
+ alat = dct ["ALAT" ] * bohr_to_angstrom
276
+ plat = dct ["PLAT" ] * alat
280
277
species = []
281
278
positions = []
282
- for site in d ["SITE" ]:
279
+ for site in dct ["SITE" ]:
283
280
species .append (re .split ("[0-9*]" , site ["ATOM" ])[0 ])
284
281
positions .append (site ["POS" ] * alat )
285
282
286
283
# Only check if the structure is to be generated from the space
287
284
# group if the number of sites is the same as the number of classes.
288
285
# If lattice and the spacegroup don't match, assume it's primitive.
289
- if "CLASS" in d and "SPCGRP" in d and len (d ["SITE" ]) == len (d ["CLASS" ]):
286
+ if "CLASS" in dct and "SPCGRP" in dct and len (dct ["SITE" ]) == len (dct ["CLASS" ]):
290
287
try :
291
- structure = Structure .from_spacegroup (d ["SPCGRP" ], plat , species , positions , coords_are_cartesian = True )
288
+ structure = Structure .from_spacegroup (
289
+ dct ["SPCGRP" ], plat , species , positions , coords_are_cartesian = True
290
+ )
292
291
except ValueError :
293
292
structure = Structure (
294
293
plat ,
@@ -300,7 +299,7 @@ def from_dict(cls, d):
300
299
else :
301
300
structure = Structure (plat , species , positions , coords_are_cartesian = True , to_unit_cell = True )
302
301
303
- return cls (structure , header = d ["HEADER" ], version = d ["VERS" ])
302
+ return cls (structure , header = dct ["HEADER" ], version = dct ["VERS" ])
304
303
305
304
306
305
class LMTOCopl :
0 commit comments