Skip to content

Commit 8754bfa

Browse files
committed
Version 1.8.1
Improvements to readcif, added atomic form factors and classes_orbitals, among other changes.
1 parent 57ba166 commit 8754bfa

18 files changed

+3419
-2476
lines changed

Dans_Diffraction/__init__.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44
55
Usage:
66
***In Python***
7-
from Dans_Diffraction import Crystal
7+
import Dans_Diffraction as dif
88
f = '/location/of/file.cif'
9-
xtl = Crystal(f)
9+
xtl = dif.Crystal(f)
1010
1111
Usage:
1212
***From Terminal***
@@ -17,8 +17,8 @@
1717
Diamond
1818
2017
1919
20-
Version 1.8
21-
Last updated: 05/05/20
20+
Version 1.8.1
21+
Last updated: 12/05/20
2222
2323
Version History:
2424
02/03/18 1.0 Version History started.
@@ -31,6 +31,7 @@
3131
31/03/20 1.7 Refactored multicrystal methods, other minor changes, improved powder diffraction
3232
19/04/20 1.7.1 Added writecif + spacegroup file + functions
3333
02/05/20 1.8 Updated readcif, added heavy atom properties, added magnetic spacegroups
34+
12/05/20 1.8.1 Updated readcif, added atomic_scattering_factors and classes_orbitals
3435
3536
-----------------------------------------------------------------------------
3637
Copyright 2020 Diamond Light Source Ltd.
@@ -53,6 +54,7 @@
5354
classes_plotting.py
5455
classes_properties.py
5556
classes_multicrystal.py
57+
classes_orbitals.py
5658
functions_general.py
5759
functions_plotting.py
5860
functions_crystallography.py
@@ -83,8 +85,8 @@
8385
from .classes_fdmnes import Fdmnes, FdmnesAnalysis
8486

8587

86-
__version__ = '1.8'
87-
__date__ = '05/05/20'
88+
__version__ = '1.8.1'
89+
__date__ = '12/05/20'
8890

8991

9092
# Build

Dans_Diffraction/__main__.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@
1010
For GUI use:
1111
ipython -m Dans_Diffraction gui
1212
13+
To Parse a cif:
14+
ipython -m Dans_Diffraction 'somefile.cif'
15+
1316
By Dan Porter, PhD
1417
Diamond
1518
2017
@@ -28,6 +31,7 @@
2831
for arg in sys.argv:
2932
if 'cif' in arg.lower():
3033
xtl = dif.Crystal(arg)
34+
print(xtl.info())
3135
elif 'gui' in arg.lower():
3236
xtl.start_gui()
3337

Dans_Diffraction/classes_crystal.py

Lines changed: 23 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@
5151
from . import functions_general as fg, functions_crystallography as fc
5252
from . import functions_crystallography as fc
5353
from .classes_properties import Properties
54+
#from .classes_orbitals import CrystalOrbitals
5455
from .classes_scattering import Scattering
5556
from .classes_multicrystal import MultiCrystal
5657
from .classes_plotting import Plotting, PlottingSuperstructure
@@ -127,6 +128,7 @@ def __init__(self, filename=None):
127128
self.Plot = Plotting(self)
128129
self.Scatter = Scattering(self)
129130
self.Properties = Properties(self)
131+
#self.Orbitals = CrystalOrbitals(self) # slows down cif parsing a lot!
130132
# self.Fdmnes = Fdmnes(self)
131133

132134
def generate_structure(self):
@@ -823,9 +825,14 @@ def fromcif(self, cifvals):
823825
label = cifvals['_atom_site_label']
824826

825827
if '_atom_site_type_symbol' in keys:
826-
element = [x.strip('+-.0123456789()') for x in cifvals['_atom_site_type_symbol']]
828+
element = [fc.str2element(x) for x in cifvals['_atom_site_type_symbol']]
827829
else:
828-
element = [x.strip('+-.0123456789()') for x in cifvals['_atom_site_label']]
830+
element = [fc.str2element(x) for x in cifvals['_atom_site_label']]
831+
832+
while False in element:
833+
fidx = element.index(False)
834+
warn('%s is not a valid element, replacing with H' % cifvals['_atom_site_label'][fidx])
835+
element[fidx] = 'H'
829836

830837
# Replace Deuterium with Hydrogen
831838
if 'D' in element:
@@ -1187,17 +1194,22 @@ def info(self, idx=None, type=None):
11871194

11881195
out = ''
11891196
if np.any(fg.mag(self.mxmymz()) > 0):
1190-
out += ' n Atom u v w Occ Uiso mx my mz \n'
1191-
fmt = '%3.0f %4s %7.4f %7.4f %7.4f %4.2f %6.4f %7.4f %7.4f %7.4f\n'
1197+
out += ' n Label Atom u v w Occ Uiso mx my mz \n'
1198+
fmt = '%3.0f %5s %4s %7.4f %7.4f %7.4f %4.2f %6.4f %7.4f %7.4f %7.4f\n'
11921199
for n in disprange:
11931200
out += fmt % (
1194-
n, self.type[n], self.u[n], self.v[n], self.w[n], self.occupancy[n], self.uiso[n], self.mx[n],
1195-
self.my[n], self.mz[n])
1201+
n, self.label[n], self.type[n], self.u[n], self.v[n], self.w[n],
1202+
self.occupancy[n], self.uiso[n],
1203+
self.mx[n], self.my[n], self.mz[n]
1204+
)
11961205
else:
1197-
out += ' n Atom u v w Occ Uiso\n'
1198-
fmt = '%3.0f %4s %7.4f %7.4f %7.4f %4.2f %6.4f\n'
1206+
out += ' n Label Atom u v w Occ Uiso\n'
1207+
fmt = '%3.0f %5s %4s %7.4f %7.4f %7.4f %4.2f %6.4f\n'
11991208
for n in disprange:
1200-
out += fmt % (n, self.type[n], self.u[n], self.v[n], self.w[n], self.occupancy[n], self.uiso[n])
1209+
out += fmt % (
1210+
n, self.label[n], self.type[n], self.u[n], self.v[n], self.w[n],
1211+
self.occupancy[n], self.uiso[n]
1212+
)
12011213
return out
12021214

12031215
def __repr__(self):
@@ -1887,8 +1899,8 @@ class Superstructure(Crystal):
18871899
superstructure Crystal class
18881900
"""
18891901

1890-
Parent = Crystal()
1891-
P = [[1, 0, 0], [0, 1, 0], [0, 0, 1]]
1902+
#Parent = Crystal()
1903+
#P = [[1, 0, 0], [0, 1, 0], [0, 0, 1]]
18921904

18931905
def __init__(self, Parent, P):
18941906
"""Initialise"""

Dans_Diffraction/classes_fdmnes.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,8 @@ def generate_parameters_string(self):
256256
param_string += '%s Quadrupole ! Allows quadrupolar E1E2 terms\n' % quadrupole
257257
param_string += '! magnetism ! performs magnetic calculations\n'
258258
param_string += ' Density ! Outputs the density of states as _sd1.txt\n'
259-
param_string += ' Spherical ! Outputs the spherical tensors as _sph_.txt\n'
259+
param_string += ' Sphere_all ! Outputs the spherical tensors as _sph_.txt\n'
260+
param_string += ' Cartesian ! Outputs the cartesian tensors as _car_.txt\n'
260261
param_string += ' energpho ! output the energies in real terms\n'
261262
param_string += ' Convolution ! Performs the convolution\n\n'
262263

0 commit comments

Comments
 (0)