Skip to content

Commit 634b871

Browse files
update fstar
1 parent 42ec13e commit 634b871

24 files changed

+3797
-249
lines changed

pymatgen/analysis/fstar/fstar.py

Lines changed: 9 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,10 @@
1111
import os
1212
import numpy as np
1313
import pandas as pd
14-
from pymatgen.symmetry.analyzer import SpacegroupAnalyzer
1514
import plotly.express as px
1615

1716

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
2418
with open(os.path.join(os.path.dirname(__file__),
2519
"neutron_factors.csv")) as f:
2620
NEUTRON_SCATTER_DF = pd.read_csv(f)
@@ -32,23 +26,22 @@ class FStarDiagram:
3226
Take a list of structure objects and/or cifs and use them to generate an f* phase diagram.
3327
"""
3428

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):
3630
"""
3731
Initialize the f* diagram generator with the list of structures and scattering type.
3832
3933
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
4135
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.
4640
custom_scatter(function): when using custom scattering set this equal to a global varialble that is equal
4741
to the custom scattering function.
4842
"""
4943

50-
self._structures = [SpacegroupAnalyzer(structure).get_symmetrized_structure() for structure in
51-
structures]
44+
self._structures = structures
5245
self._scatter = scattering_type
5346
self._custscat = custom_scatter
5447
self._equiv_inds = [struct.equivalent_indices for struct in self._structures]
@@ -143,29 +136,8 @@ def get_fstar_coords(self):
143136
column = [label for label in self.site_labels if site_frac_coord in label]
144137
elements_and_occupancies = self._structures[ind1][site[0]].species.items()
145138
for sp, occ in elements_and_occupancies:
146-
if self._scatter == 'X-ray_simple':
147-
f_occ = sp.Z * occ
148139
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
169141
if self._scatter == 'Neutron':
170142
for i, n in enumerate(NEUTRON_SCATTER_DF['Isotope'].values):
171143
if hasattr(sp, "element"):

0 commit comments

Comments
 (0)