7
7
from pymatgen .symmetry .analyzer import SpacegroupAnalyzer
8
8
from pymatgen .io .xyz import XYZ
9
9
from pymatgen .core .periodic_table import Element
10
+ from crystal2qmc import periodic_table # TODO should this be in crystal2qmc?
10
11
from xml .etree .ElementTree import ElementTree
11
12
import numpy as np
12
13
import os
@@ -255,15 +256,19 @@ def is_consistent(self,other):
255
256
def geom (self ):
256
257
"""Generate the geometry section for CRYSTAL"""
257
258
if self .struct_input is not None :
259
+ # TODO make into function like geom3d?
258
260
geomlines = [
259
261
'CRYSTAL' ,
260
262
'0 0 0' ,
261
263
str (self .struct_input ['symmetry' ]),
262
264
' ' .join (map (str ,self .struct_input ['parameters' ])),
263
265
str (len (self .struct_input ['coords' ]))
264
266
]
267
+ self ._elements = set ()
265
268
for coord in self .struct_input ['coords' ]:
266
- geomlines += [' ' .join (coord )]
269
+ geomlines += [' ' .join (map (str ,coord ))]
270
+ self ._elements .add (periodic_table [coord [0 ]- 200 - 1 ].capitalize ()) # Assumes ECP!
271
+ self ._elements = sorted (list (self ._elements )) # Standardize ordering.
267
272
if self .supercell is not None :
268
273
geomlines += ['SUPERCELL' ]
269
274
for row in self .supercell :
@@ -287,6 +292,11 @@ def geom(self):
287
292
def geom3d (self ):
288
293
lat = self .struct ['lattice' ]
289
294
sites = self .struct ['sites' ]
295
+ self ._elements = set ()
296
+ for s in self .struct ['sites' ]:
297
+ nm = s ['species' ][0 ]['element' ]
298
+ self ._elements .add (nm )
299
+ self ._elements = sorted (list (self ._elements )) # Standardize ordering.
290
300
291
301
if self .symmetry :
292
302
geomlines = [
@@ -373,13 +383,8 @@ def space_group_format(self):
373
383
374
384
def basis_section (self ):
375
385
if self .basislines is None :
376
- elements = set ()
377
- for s in self .struct ['sites' ]:
378
- nm = s ['species' ][0 ]['element' ]
379
- elements .add (nm )
380
386
basislines = []
381
- elements = sorted (list (elements )) # Standardize ordering.
382
- for e in elements :
387
+ for e in self ._elements :
383
388
basislines += self .generate_basis (e )
384
389
else :
385
390
basislines = self .basislines
0 commit comments