11
11
import os
12
12
import numpy as np
13
13
import pandas as pd
14
- from pymatgen .symmetry .analyzer import SpacegroupAnalyzer
15
14
import plotly .express as px
16
15
17
16
18
- # Load in the form factors
19
-
20
- with open (os .path .join (os .path .dirname (__file__ ),
21
- "xray_factors_2.csv" )) as f :
22
- X_RAY_SCATTER_DF = pd .read_csv (f )
23
- # from https://it.iucr.org/Cb/ch6o1v0001/ table 6.1.1.4
17
+ # Load in the neutron form factors
24
18
with open (os .path .join (os .path .dirname (__file__ ),
25
19
"neutron_factors.csv" )) as f :
26
20
NEUTRON_SCATTER_DF = pd .read_csv (f )
@@ -32,23 +26,22 @@ class FStarDiagram:
32
26
Take a list of structure objects and/or cifs and use them to generate an f* phase diagram.
33
27
"""
34
28
35
- def __init__ (self , structures , scattering_type = 'X-ray_simple ' , custom_scatter = None ):
29
+ def __init__ (self , structures , scattering_type = 'X-ray ' , custom_scatter = None ):
36
30
"""
37
31
Initialize the f* diagram generator with the list of structures and scattering type.
38
32
39
33
Args:
40
- structures(list): List of structure objects to use in the diagram. These must be symmetrized structure
34
+ structures(list): List of structure objects to use in the diagram. These MUST be symmetrized structure
41
35
objects.
42
- scattering_type(str): Type of scattering to use in the f* calculation. Defaults to 'X-ray_simple '
43
- which uses the atomic number as the scattering factor. 'X-ray' and ' Neutron' are built in scattering
44
- types which use X-ray and neutron scattering factors, respectively . 'Custom' allows the user to
45
- supplement their own calculation with any set of scattering factors.
36
+ scattering_type(str): Type of scattering to use in the f* calculation. Defaults to 'X-ray '
37
+ which uses the atomic number as the scattering factor. 'Neutron' is a built in scattering
38
+ type which uses neutron scattering factors. 'Custom' allows the user to supplement their
39
+ own calculation with any set of scattering factors.
46
40
custom_scatter(function): when using custom scattering set this equal to a global varialble that is equal
47
41
to the custom scattering function.
48
42
"""
49
43
50
- self ._structures = [SpacegroupAnalyzer (structure ).get_symmetrized_structure () for structure in
51
- structures ]
44
+ self ._structures = structures
52
45
self ._scatter = scattering_type
53
46
self ._custscat = custom_scatter
54
47
self ._equiv_inds = [struct .equivalent_indices for struct in self ._structures ]
@@ -143,29 +136,8 @@ def get_fstar_coords(self):
143
136
column = [label for label in self .site_labels if site_frac_coord in label ]
144
137
elements_and_occupancies = self ._structures [ind1 ][site [0 ]].species .items ()
145
138
for sp , occ in elements_and_occupancies :
146
- if self ._scatter == 'X-ray_simple' :
147
- f_occ = sp .Z * occ
148
139
if self ._scatter == 'X-ray' :
149
- for i , n in enumerate (X_RAY_SCATTER_DF ['atom' ].values ):
150
- if hasattr (sp , "element" ):
151
- if n == str (sp .element ):
152
- f_occ = round (
153
- sum ([X_RAY_SCATTER_DF .loc [i ]['a1' ], X_RAY_SCATTER_DF .loc [i ]['a2' ],
154
- X_RAY_SCATTER_DF .loc [i ]['a3' ],
155
- X_RAY_SCATTER_DF .loc [i ]['a4' ], X_RAY_SCATTER_DF .loc [i ]['c' ]]), 0 ) * occ
156
- break
157
- else :
158
- continue
159
- else :
160
- if n == str (sp ):
161
- f_occ = round (
162
- sum ([X_RAY_SCATTER_DF .loc [i ]['a1' ], X_RAY_SCATTER_DF .loc [i ]['a2' ],
163
- X_RAY_SCATTER_DF .loc [i ]['a3' ],
164
- X_RAY_SCATTER_DF .loc [i ]['a4' ], X_RAY_SCATTER_DF .loc [i ]['c' ]]), 0 ) * occ
165
- break
166
- else :
167
- continue
168
-
140
+ f_occ = sp .Z * occ
169
141
if self ._scatter == 'Neutron' :
170
142
for i , n in enumerate (NEUTRON_SCATTER_DF ['Isotope' ].values ):
171
143
if hasattr (sp , "element" ):
0 commit comments