pyemaps 2.0.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- pyemaps/COPYING +798 -0
- pyemaps/CifFile/CifFile_module.py +3117 -0
- pyemaps/CifFile/StarFile.py +2496 -0
- pyemaps/CifFile/TypeContentsParser.py +82 -0
- pyemaps/CifFile/YappsStarParser_1_0.py +289 -0
- pyemaps/CifFile/YappsStarParser_1_1.py +288 -0
- pyemaps/CifFile/YappsStarParser_2_0.py +369 -0
- pyemaps/CifFile/YappsStarParser_STAR2.py +382 -0
- pyemaps/CifFile/__init__.py +7 -0
- pyemaps/CifFile/drel/__init__.py +1 -0
- pyemaps/CifFile/drel/drel_ast_yacc.py +582 -0
- pyemaps/CifFile/drel/drel_lex.py +228 -0
- pyemaps/CifFile/drel/drel_runtime.py +126 -0
- pyemaps/CifFile/drel/parsetab.py +185 -0
- pyemaps/CifFile/drel/py_from_ast.py +628 -0
- pyemaps/CifFile/parsetab.py +185 -0
- pyemaps/CifFile/yapps3_compiled_rt.py +390 -0
- pyemaps/README.md +201 -0
- pyemaps/__config__.py +91 -0
- pyemaps/__init__.py +233 -0
- pyemaps/__main__.py +219 -0
- pyemaps/__version__.py +1 -0
- pyemaps/cdata/Aluminium.xtl +4 -0
- pyemaps/cdata/AluminiumOxide.xtl +5 -0
- pyemaps/cdata/Aluminium_FCC.xtl +4 -0
- pyemaps/cdata/BariumTitanate_180k.xtl +6 -0
- pyemaps/cdata/BariumTitanate_270k.xtl +7 -0
- pyemaps/cdata/BariumTitanate_Tetra.xtl +7 -0
- pyemaps/cdata/BiMnO3.xtl +27 -0
- pyemaps/cdata/Boron_Tetra.xtl +8 -0
- pyemaps/cdata/CadmiumSelenide_Hex.xtl +5 -0
- pyemaps/cdata/CadmiumSulfide_Cubic.xtl +5 -0
- pyemaps/cdata/CadmiumSulfide_Hex.xtl +5 -0
- pyemaps/cdata/Chromium_BCC.xtl +4 -0
- pyemaps/cdata/CoSb3_Skutterudite.xtl +5 -0
- pyemaps/cdata/CopperOxide.xtl +5 -0
- pyemaps/cdata/Copper_FCC.xtl +4 -0
- pyemaps/cdata/Cu2O_Cuprite.xtl +5 -0
- pyemaps/cdata/Diamond.xtl +4 -0
- pyemaps/cdata/ErbiumPyrogermanate.xtl +9 -0
- pyemaps/cdata/FePd_Tetra.xtl +5 -0
- pyemaps/cdata/FeS2_Pyrite.xtl +15 -0
- pyemaps/cdata/GalliumAntimonide.xtl +5 -0
- pyemaps/cdata/GalliumArsenide.xtl +5 -0
- pyemaps/cdata/GalliumNitride.xtl +5 -0
- pyemaps/cdata/Germanium.xtl +4 -0
- pyemaps/cdata/Gold_FCC.xtl +4 -0
- pyemaps/cdata/IndiumArsenide.xtl +5 -0
- pyemaps/cdata/LaMnO3.xtl +7 -0
- pyemaps/cdata/LeadZirconateTitanate.xtl +8 -0
- pyemaps/cdata/Li2MnO3.xtl +13 -0
- pyemaps/cdata/NaFeO2.xtl +6 -0
- pyemaps/cdata/Nb3Sn.xtl +5 -0
- pyemaps/cdata/Pentacene.xtl +39 -0
- pyemaps/cdata/Silicon.xtl +4 -0
- pyemaps/cdata/StrontiumTitanate.xtl +6 -0
- pyemaps/cdata/TelluriumDioxide.xtl +5 -0
- pyemaps/cdata/TinDioxide_RT.xtl +5 -0
- pyemaps/cdata/TitaniumDioxide_Anatase.xtl +5 -0
- pyemaps/cdata/TitaniumDioxide_Rutile.xtl +5 -0
- pyemaps/cdata/TungstenDiselenide.xtl +5 -0
- pyemaps/cdata/VanadiumDioxide_RT.xtl +6 -0
- pyemaps/cdata/ZincOxide.xtl +5 -0
- pyemaps/cdata/Zinc_HCP.xtl +4 -0
- pyemaps/cdata/ZirconiumNitride.xtl +5 -0
- pyemaps/cdata/limno2.xtl +6 -0
- pyemaps/crystals.py +1415 -0
- pyemaps/ddiffs.py +147 -0
- pyemaps/diffract/__init__.py +70 -0
- pyemaps/diffract/bloch_dec.py +779 -0
- pyemaps/diffract/csf_dec.py +242 -0
- pyemaps/diffract/dif_dec.py +519 -0
- pyemaps/diffract/dpgen_dec.py +175 -0
- pyemaps/diffract/mxtal_dec.py +201 -0
- pyemaps/diffract/powder_dec.py +137 -0
- pyemaps/diffract/stereo_dec.py +111 -0
- pyemaps/display.py +791 -0
- pyemaps/emcontrols.py +1017 -0
- pyemaps/errors.py +266 -0
- pyemaps/fileutils.py +1001 -0
- pyemaps/kdiffs.py +1221 -0
- pyemaps/license.txt +42 -0
- pyemaps/samples/adf.py +137 -0
- pyemaps/samples/al.img +0 -0
- pyemaps/samples/al_dpgen.py +57 -0
- pyemaps/samples/al_ediom.py +94 -0
- pyemaps/samples/convert_image.py +88 -0
- pyemaps/samples/dm_diff.py +225 -0
- pyemaps/samples/mask.im3 +0 -0
- pyemaps/samples/powder.py +51 -0
- pyemaps/samples/raw.img +0 -0
- pyemaps/samples/si_bloch.py +120 -0
- pyemaps/samples/si_constructor.py +51 -0
- pyemaps/samples/si_csf.py +59 -0
- pyemaps/samples/si_dif.py +134 -0
- pyemaps/samples/si_lacbed.py +59 -0
- pyemaps/samples/si_pyemaps.py +80 -0
- pyemaps/samples/si_scm.py +156 -0
- pyemaps/samples/si_stereo.py +116 -0
- pyemaps/scattering/__init__.py +26 -0
- pyemaps/scattering/sct_dec.py +31 -0
- pyemaps/spg/__init__.py +25 -0
- pyemaps/spg/spg_dec.py +60 -0
- pyemaps/stackimg.py +1031 -0
- pyemaps/xtal.py +222 -0
- pyemaps-2.0.0.dist-info/METADATA +231 -0
- pyemaps-2.0.0.dist-info/RECORD +112 -0
- pyemaps-2.0.0.dist-info/WHEEL +5 -0
- pyemaps-2.0.0.dist-info/entry_points.txt +2 -0
- pyemaps-2.0.0.dist-info/licenses/COPYING +798 -0
- pyemaps-2.0.0.dist-info/licenses/license.txt +42 -0
- pyemaps-2.0.0.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,242 @@
|
|
|
1
|
+
'''
|
|
2
|
+
.. This file is part of pyEMAPS
|
|
3
|
+
|
|
4
|
+
.. ----
|
|
5
|
+
|
|
6
|
+
.. pyEMAPS is free software. You can redistribute it and/or modify
|
|
7
|
+
.. it under the terms of the GNU General Public License as published
|
|
8
|
+
.. by the Free Software Foundation, either version 3 of the License,
|
|
9
|
+
.. or (at your option) any later version..
|
|
10
|
+
|
|
11
|
+
.. pyEMAPS is distributed in the hope that it will be useful,
|
|
12
|
+
.. but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
13
|
+
.. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
14
|
+
.. GNU General Public License for more details.
|
|
15
|
+
|
|
16
|
+
.. You should have received a copy of the GNU General Public License
|
|
17
|
+
.. along with pyEMAPS. If not, see `<https://www.gnu.org/licenses/>`_.
|
|
18
|
+
|
|
19
|
+
.. Contact supprort@emlabsoftware.com for any questions and comments.
|
|
20
|
+
|
|
21
|
+
.. ----
|
|
22
|
+
|
|
23
|
+
.. Author: EMLab Solutions, Inc.
|
|
24
|
+
.. Date Created: May 07, 2022
|
|
25
|
+
|
|
26
|
+
'''
|
|
27
|
+
def add_csf(target):
|
|
28
|
+
'''
|
|
29
|
+
Generate crystal structure factors. The following types
|
|
30
|
+
Structure Factors are currently supported:
|
|
31
|
+
|
|
32
|
+
* x-ray structure factor (default)
|
|
33
|
+
* electron structure factor in volts (V)
|
|
34
|
+
* electron structure factor in 1/angstrom^2 in (V)
|
|
35
|
+
* electron absorption structure factor in 1/angstrom^2 (V)
|
|
36
|
+
|
|
37
|
+
'''
|
|
38
|
+
try:
|
|
39
|
+
from . import csf
|
|
40
|
+
|
|
41
|
+
except ImportError as e:
|
|
42
|
+
print(f"Error: required module pyemaps.csf not found")
|
|
43
|
+
|
|
44
|
+
from .. import CSFError
|
|
45
|
+
|
|
46
|
+
# backend csf.generate_sf / csf.get_sf return codes
|
|
47
|
+
_CSF_ERR = {
|
|
48
|
+
1: 'structure factor generation failed',
|
|
49
|
+
2: 'invalid structure factor type (sftype must be 1-4)',
|
|
50
|
+
3: 'too many reflections within smax for the backend beam limit; '
|
|
51
|
+
'reduce smax and retry',
|
|
52
|
+
4: 'backend ran out of memory sizing the reflection set; reduce smax',
|
|
53
|
+
5: 'backend reflection-count estimate was too low (internal error)',
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
sf_type_lookup = ['X-ray Structure Factors',
|
|
57
|
+
'Electron Strcture Factors in kV',
|
|
58
|
+
'Electron Structure Factor in 1/lambda',
|
|
59
|
+
'Electron Absorption Structure Factor in 1/lambda^2']
|
|
60
|
+
|
|
61
|
+
sf_ap_flag = [('real', 'imaginary'), ('amplitude', 'phase')]
|
|
62
|
+
|
|
63
|
+
def printCSF(self, sfs):
|
|
64
|
+
"""
|
|
65
|
+
Formats and prints structure factors to standard output.
|
|
66
|
+
|
|
67
|
+
:param sfs: structure factor data generated from
|
|
68
|
+
`generateCSF <pyemaps.crystals.html#pyemaps.crystals.Crystal.generateCSF>`_.
|
|
69
|
+
:type sfs: dict, required
|
|
70
|
+
|
|
71
|
+
Example of the output for a X-Ray Structure Factor for Silicon:
|
|
72
|
+
|
|
73
|
+
.. code-block:: console
|
|
74
|
+
|
|
75
|
+
-----X-ray Structure Factors-----
|
|
76
|
+
crystal : Silicon
|
|
77
|
+
h k l : Miller Index
|
|
78
|
+
s-w : Sin(ϴ)/Wavelength <= 1.0
|
|
79
|
+
d-s : D-Spacing
|
|
80
|
+
|
|
81
|
+
h k l s-w d-s amplitude phase
|
|
82
|
+
|
|
83
|
+
1 1 1 0.1594684670 3.1354161069 58.89618 180.000000
|
|
84
|
+
0 0 2 0.1841383247 2.7153500000 6.565563e-31 0.000000
|
|
85
|
+
0 2 2 0.2604109162 1.9200423983 67.56880 180.000000
|
|
86
|
+
1 1 3 0.3053588663 1.6374176590 44.24472 180.000000
|
|
87
|
+
2 2 2 0.3189369340 1.5677080534 8.151511e-14 180.000000
|
|
88
|
+
...
|
|
89
|
+
|
|
90
|
+
"""
|
|
91
|
+
sftype =sfs[0]['sftype']
|
|
92
|
+
aptype =sfs[0]['aptype']
|
|
93
|
+
if sftype < 1 or sftype > 4:
|
|
94
|
+
print(f'Invalid structure factor type input: {sftype}')
|
|
95
|
+
return sfs
|
|
96
|
+
|
|
97
|
+
if aptype < 0 or aptype > 1:
|
|
98
|
+
print(f'Invalid structure factor output data flag: {aptype}')
|
|
99
|
+
return sfs
|
|
100
|
+
|
|
101
|
+
subj = sf_type_lookup[sftype-1]
|
|
102
|
+
print(f"-----{subj}----- ")
|
|
103
|
+
print(f" crystal\t\t: {self.name}")
|
|
104
|
+
|
|
105
|
+
mi = " h k l \t\t: Miller Index"
|
|
106
|
+
print(mi)
|
|
107
|
+
# ssw = str(f" s-w \t\t: Sin(\u03F4)/Wavelength <= {sfs[0]['smax']}")
|
|
108
|
+
ssw = str(f" s-w \t\t: Sin(theta)/Wavelength <= {sfs[0]['smax']}")
|
|
109
|
+
print(ssw )
|
|
110
|
+
dss = " d-s \t\t: D-Spacing"
|
|
111
|
+
print(dss)
|
|
112
|
+
|
|
113
|
+
if sftype > 1:
|
|
114
|
+
print(f" high voltage\t: {sfs[0]['kv']} V\n")
|
|
115
|
+
else:
|
|
116
|
+
print(f" ")
|
|
117
|
+
|
|
118
|
+
|
|
119
|
+
sap1 = sf_ap_flag[aptype][0]
|
|
120
|
+
sap2 = sf_ap_flag[aptype][1]
|
|
121
|
+
|
|
122
|
+
print(f"{'h':^4}{'k':^4}{'l':^5}{'s-w':^16}{'d-s':^16}{sap1:^16}{sap2:^16}\n")
|
|
123
|
+
|
|
124
|
+
nb = len(sfs)
|
|
125
|
+
for i in range(1, nb, 1):
|
|
126
|
+
h,k,l = sfs[i]['hkl']
|
|
127
|
+
sw,ds = sfs[i]['sw'], sfs[i]['ds']
|
|
128
|
+
sf1,sf2 = sfs[i]['amp_re'], sfs[i]['phase_im']
|
|
129
|
+
|
|
130
|
+
sh = '{0: < #04d}'. format(int(h))
|
|
131
|
+
sk = '{0: < #04d}'. format(int(k))
|
|
132
|
+
sl = '{0: < #05d}'. format(int(l))
|
|
133
|
+
|
|
134
|
+
ssw = '{0: < #016.10f}'. format(float(sw))
|
|
135
|
+
sds = '{0: < #016.10f}'. format(float(ds))
|
|
136
|
+
ssf1 = '{0: < #016.7g}'. format(float(sf1))
|
|
137
|
+
|
|
138
|
+
if aptype == 1:
|
|
139
|
+
ssf2 = '{0: < #016.6f}'. format(float(sf2))
|
|
140
|
+
else:
|
|
141
|
+
ssf2 = '{0: < #016.6g}'. format(float(sf2))
|
|
142
|
+
|
|
143
|
+
print(f"{sh}{sk}{sl}{ssw}{sds}{ssf1}{ssf2}")
|
|
144
|
+
|
|
145
|
+
print('\n')
|
|
146
|
+
|
|
147
|
+
def cleanCSF(self):
|
|
148
|
+
"""
|
|
149
|
+
Cleans up memories used by structure factor calculation.
|
|
150
|
+
This also includes the crystal data loaded into pyemaps'
|
|
151
|
+
backend simulation module.
|
|
152
|
+
|
|
153
|
+
"""
|
|
154
|
+
csf.delete_sfmem()
|
|
155
|
+
self.unload()
|
|
156
|
+
|
|
157
|
+
def generateCSF(self, kv = 100, smax = 0.5, sftype = 1, aptype = 0):
|
|
158
|
+
"""
|
|
159
|
+
Calculates structure factors.
|
|
160
|
+
|
|
161
|
+
:param kv:Accelaration Voltage in Kilo-Volts, default value 100
|
|
162
|
+
:type kv: int or float, optional
|
|
163
|
+
|
|
164
|
+
:param smax: Limit of Sin(theta)/Wave length, default value 0.5
|
|
165
|
+
:type smax: int or float, optional
|
|
166
|
+
|
|
167
|
+
:param sftype: Structure factor types to be generated, default value 1 - x-ray
|
|
168
|
+
:type sftype: , int, optional
|
|
169
|
+
|
|
170
|
+
:param aptype: Output format type, default value 0 - amplitude and phase
|
|
171
|
+
:type aptype: , int, optional
|
|
172
|
+
|
|
173
|
+
:return: a dict object with structure factor data
|
|
174
|
+
:rtype: dict
|
|
175
|
+
|
|
176
|
+
:raises CSFError: if the backend fails to generate structure factors,
|
|
177
|
+
*sftype* is invalid, or the number of reflections within *smax*
|
|
178
|
+
exceeds the backend beam limit (reduce *smax* and retry).
|
|
179
|
+
|
|
180
|
+
.. note:: *sftype* has the following value representing:
|
|
181
|
+
|
|
182
|
+
1. x-ray structure factor (default)
|
|
183
|
+
2. electron structure factor in volts (KV)
|
|
184
|
+
3. electron structure factor in 1/angstrom^2 in (KV)
|
|
185
|
+
4. electron absorption structure factor in 1/angstrom^2 (KV)
|
|
186
|
+
|
|
187
|
+
.. note:: *aptype* has the following value representing structure factor format:
|
|
188
|
+
|
|
189
|
+
0: amplitude and phase
|
|
190
|
+
1: real and imaginary
|
|
191
|
+
|
|
192
|
+
The return of an array of structure factors in the following
|
|
193
|
+
python dictionary format:
|
|
194
|
+
|
|
195
|
+
.. code-block:: python
|
|
196
|
+
|
|
197
|
+
{
|
|
198
|
+
'hkl': (h,k,l), # Miller Indices
|
|
199
|
+
'sw': s, # Sin(theta)/Wave length
|
|
200
|
+
'ds': d, # d-spacing value
|
|
201
|
+
'amp_re': ar # amplitude or real part
|
|
202
|
+
'phase_im': ph # phase or imaginary part
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
"""
|
|
206
|
+
sfs = [dict(kv = kv, smax = smax, sftype = sftype, aptype = aptype)]
|
|
207
|
+
|
|
208
|
+
self.load()
|
|
209
|
+
|
|
210
|
+
nb, ret = csf.generate_sf(kv, smax, sftype, aptype)
|
|
211
|
+
|
|
212
|
+
if ret != 0 or nb <= 0:
|
|
213
|
+
self.cleanCSF()
|
|
214
|
+
detail = _CSF_ERR.get(ret, f'backend returned code {ret}')
|
|
215
|
+
raise CSFError(f'{detail} (crystal {self.name})')
|
|
216
|
+
|
|
217
|
+
for i in range(2, nb+1):
|
|
218
|
+
ret = 0
|
|
219
|
+
ret,h,k,l,s,d,sf1,sf2 = csf.get_sf(i)
|
|
220
|
+
if ret != 0:
|
|
221
|
+
self.cleanCSF()
|
|
222
|
+
raise CSFError(f'failed to retrieve reflection {i} of {nb} '
|
|
223
|
+
f'(crystal {self.name})')
|
|
224
|
+
|
|
225
|
+
sf = dict(hkl = (h,k,l),
|
|
226
|
+
sw = s,
|
|
227
|
+
ds = d,
|
|
228
|
+
amp_re = sf1,
|
|
229
|
+
phase_im = sf2
|
|
230
|
+
)
|
|
231
|
+
sfs.append(sf)
|
|
232
|
+
|
|
233
|
+
#release the memory
|
|
234
|
+
self.cleanCSF()
|
|
235
|
+
|
|
236
|
+
return sfs
|
|
237
|
+
|
|
238
|
+
target.generateCSF = generateCSF
|
|
239
|
+
target.printCSF = printCSF
|
|
240
|
+
target.cleanCSF = cleanCSF
|
|
241
|
+
|
|
242
|
+
return target
|