Debian Codegraph @

periodictable/nsf.py

raw
1 # -*- coding: utf-8 -*-
2 # This program is public domain
3 # Author: Paul Kienzle
4 r"""
5
6 Neutron scattering factors for the elements and isotopes.
7
8 For details of neutron scattering factor values, see :class:`Neutron`.
9 The property is set to *None* if there is no neutron scattering information
10 for the element. Individual isotopes may have their own scattering
11 information.
12
13 Example
14 =======
15
16 Print a table of coherent scattering length densities for isotopes
17 of a particular element:
18
19 .. doctest::
20
21 >>> import periodictable
22 >>> for iso in periodictable.Ni:
23 ... if iso.neutron.has_sld():
24 ... print("%s %7.4f"%(iso,iso.neutron.sld()[0]))
25 58-Ni 13.1526
26 60-Ni 2.5575
27 61-Ni 6.9417
28 62-Ni -7.9464
29 64-Ni -0.3379
30
31
32 Details
33 =======
34
35 There are a number of functions available in periodictable.nsf
36
37 :func:`neutron_energy`
38 Return neutron energy given wavelength.
39
40 :func:`neutron_wavelength`
41 Return wavelength given neutron energy.
42
43 :func:`neutron_wavelength_from_velocity`
44 Return wavelength given neutron velocity.
45
46 :func:`neutron_scattering`
47 Computes scattering length density, cross sections and
48 penetration depth for a compound.
49
50 :func:`neutron_sld`
51 Computes scattering length density for a compound.
52
53 :func:`neutron_composite_sld`
54 Returns a scattering length density for a compound whose composition
55 is variable.
56
57 :func:`energy_dependent_table`
58 Lists isotopes with energy dependence.
59
60 :func:`sld_table`
61 Lists scattering length densitys for all elements in natural abundance.
62
63 :func:`absorption_comparison_table`
64 Compares the imaginary bound coherent scattering length to the
65 absorption cross section.
66
67 :func:`coherent_comparison_table`
68 Compares the bound coherent scattering length to the
69 coherent scattering cross section.
70
71 :func:`total_comparison_table`
72 Compares the total scattering cross section to the sum of the
73 coherent and incoherent scattering cross sections.
74
75 For private tables use :func:`init` to set the data.
76
77 The neutron scattering information table is reproduced from the Atomic
78 Institute for Austrian Universities\ [#Rauch2003]_,\ [#Rauch2000]_:
79
80 `<http://www.ati.ac.at/~neutropt/scattering/table.html>`_
81
82 The above site has references to the published values for every entry in
83 the table. We have included these in the documentation directory
84 within the periodictable source package. Some typographical errors have
85 been fixed. In particular, Zn-70 has b_c listed as 6.9 in the table,
86 but 6.0 in the source materials for the table.
87
88 Note that enteries in the table have been measured independently, so the values
89 for the scattering length of an element or isotope may be inconsistent with
90 the values measured for the corresponding cross section. The comparison table
91 functions highlight these differences.
92
93 Tables from Sears (1992)\ [#Sears1992]_\ [#Sears2006]_, Rauch (2003)\ [#Rauch2003]_ and
94 Dawidowski (2013)\ [#Dawidowski2013]_ make different choices for the recommended
95 values. These are noted in periodictable issue #59
96 `<https://github.com/python-periodictable/periodictable/issues/59>`_
97 with changes from Sears to Rauch
98 `(a) <https://github.com/python-periodictable/periodictable/issues/59#issuecomment-1693686953>`__
99 and from Rauch to Dawidowski
100 `(b) <https://github.com/python-periodictable/periodictable/issues/59#issuecomment-1690212205>`__.
101 Mughabghab (2018)\ [#Mughabghab2018]_ provides further updates, including calculated
102 values for those values that have not been measured. These are not yet incorporated into the
103 the table.
104
105 The following newer measurements from the literature are included::
106
107 1H b_c -3.7423(12) => -3.7395(11) [1]
108 2H b_c 6.674(6) => 6.6681(27) [1]
109 4He b_c 3.26(3) => 3.0982(21) [3] (see also [5], which gives 3.075(6))
110 natHe b_c 3.26(3) => 3.0985(21) [3] computed from 3He and 4He
111 6Li b_c 2.0(1) => 2.27(2) [8]
112 7Li b_c -2.22(2) => -2.28(2) [8]
113 natLi b_c -1.90(3) => -1.93(2) [8]
114 12C b_c 6.6535(13) => 6.6472(9) [1]
115 13C b_c 6.19(9) => 6.542(3); bp 5.6(5) => 6.30(14); bm 6.2(5) => 7.27(42); incoherent 0.034(11) => 0.022(20) [7]
116 16O b_c 5.805(4) => 5.8037(29) [1]
117 17O b_c 5.6(5) => 5.867(4) [2]
118 18O b_c 5.84(7) => 6.009(5) [2]
119 119Sn b_c 6.225(2) => 6.2239(13) [1]
120 70Zn b_c 6.9(1.0) => 6.0(1.0) [OCR misidentified the the number]
121 141Pr b_c 4.58(5) => 4.44(4) [9]
122 natNd b_c 7.69(5) => 7.87(11) [9]
123 142Nd b_c 7.7(3) => 7.24(4) [9]
124 143Nd b_c 14.0(2.0) => 17.51(6) [9]
125 144Nd b_c 2.8(3) => 3.06(7) [9]
126 145Nd b_c 14.0(2.0) => 10.40(12) [9]
127 146Nd b_c 8.7(2) => 8.56(9) [9]
128 148Nd b_c 5.7(3) => 4.44(13) [9]
129 150Nd b_c 5.28(20) => 6.87(5) [9]
130 144Sm b_c -3.0(4.0) => 4.63(4) [11] calculated
131 147Sm b_c 14.0(3.0) => 6.68(5) [9]
132 148Sm b_c -3.0(4.0) => 6.67(7) [9]
133 149Sm b_c 18.7(28) => 17.84(28) [11]
134 150Sm b_c 14.0(3.0) => 10.05(10) [9]
135 152Sm b_c -5.0(6) =? -6.14(12) [9]
136 154Sm b_c 8.0(1.0) => 8.97(6) [4] => 9.34(9) [9]
137 151Eu b_c => 6.92(15) [from 94Mug1; value was missing from ATI table]
138 153Eu b_c 8.22(12) => 8.85(3) [4] => 8.33(11) [9]
139 174Yb b_c 19.2(1) => 22.02(7) [9]
140 191Ir b_c => 12.1(9) [6]
141 193Ir b_c => 9.71(18) [6]
142 207Pb b_c 9.401(2) => 9.4024(13) [1]
143 209Bi b_c 8.532(2) => 8.5242(18) [1]
144
145 He coh, total 1.34(2) => 1.188(5) [5] => 1.2065(16) [3] (using 4 pi b_c^2/100)
146 Ar total 0.683(4) => 0.683(5) [5] (ignored; existing value is more precise)
147 Kr total 7.68(13) => 7.685(26) [5]
148 Xe total --- => 4.344(17) [5]
149
150 [1] Snow (2020) 10.1103/PhysRevD.101.062004 [average of values in Table 1]
151 [2] Fischer (2012) 10.1088/0953-8984/24/50/505105
152 [3] Haun (2020) 10.1103/PhysRevLett.124.012501
153 [4] Kohlmann (2016) 10.1515/zkri-2016-1984
154 [5] Haddock (2019) 10.1103/PhysRevC.100.064002
155 [6] Hannon (2018) 10.1107/S1600576718006064
156 [7] Fischer (2008) 10.1088/0953-8984/20/04/045221
157 [8] Gehlhaar (2025) 10.1088/1361-648X/add3a6
158 [9] Gehlhaar (2026) 10.1088/1361-648X/ae1ec0
159 [10] Mughabghab (2018) 10.1016/C2015-0-00522-6 [Z=1-60]
160 [11] Mughabghab (2018) 10.1016/C2015-0-00524-X [Z=61-102]
161
162 Use energy dependent b_c and σ_a from\ [#Lynn1990]_. The values at the standard
163 wavelength do not match the recommended values for that wavelength from other sources.
164 The following elements and isotopes are affected::
165
166 natSm 149Sm
167 natEu 151Eu
168 natGd 155Gd 157Gd
169 164Dy
170 natEr 167Er
171 natYb 168Yb 174Yb
172 natLu 176Lu
173
174 Other measurements since 2000 (incomplete list)::
175
176 Black (2003) 10.1103/PhysRevLett.90.192502
177 2H b_c => 6.665(4); we are using 6.6681(27) from Snow (2020)
178
179 Lu (2023) 10.1103/PhysRevC.108.L031001
180 3He Δb = -5.27(10)
181 Huber (2014) 10.1103/PhysRevC.90.064004
182 3He Δb = b+ - b- = -5.411(70) => bi = -2.343(30) => b+,b- = 4.39(7),9.80(9)
183 Using the tabulated b-'' = -5.925j we can calculate bi complex, and from
184 that σ_i = 4π |bi|²/100 = 1.517(18). This does not match the reference value
185 of 3He σ_i = 6.0(4) in the tables.
186 Zimmer (2001) 10.1007/s1010502a0001
187 3He Δb = -5.462(46)
188
189 Lu (2024) 10.1103/PhysRevC.111.019902
190 129Xe bi = -0.184(7); 131Xe bi = 2.12(17)
191
192 Ketter (2006) 10.1140/epja/i2005-10267-y
193 3He bc' = 6.010(21)
194 refs Kaiser (1979) for the current value of 5.74(7)
195 Huffman (2004) 0.1103/PhysRevC.70.014004
196 3He bc' = 5.853(7)
197
198 Kohlmann (2016) Zeitschrift fuer Kristallographie-Crystalline Materials 231.9 (2016): 517-523.
199 154Sm b_c = 8.97(6)
200
201 Von Dreele (2024) 10.1107/S1600576724005375
202 A fit to the Lynn and Seeger fitted resonance curves for the rare earths
203 using a simpler model. Also provides parameters for 103Rh, 113Cd, and 239,240Pu
204
205 Gehlhaar (2026) 10.1088/1361-648X/ae1ec0
206 170Yb b_c = 4.83(3) ignored: they note their value is not yet recommendable
207 because of uncertainty in b_c for other isotopes in their sample.
208 natSm b_c = 5.29(5) ignored: it was measured at 330.3(9) meV not 25.3 meV
209 natEu b_c = 5.84(5) ignored: it was measured at 168.10(5) meV not 25.3 meV
210
211 .. [#Rauch2003] Rauch, H. and Waschkowski, W. (2003)
212 Neutron Scattering Lengths in ILL
213 Neutron Data Booklet (second edition), A.-J. Dianoux, G. Lander, Eds.
214 Old City Publishing, Philidelphia, PA. pp 1.1-1 to 1.1-17.
215 (https://www.ill.eu/fileadmin/user_upload/ILL/1_About_ILL/Documentation/NeutronDataBooklet.pdf
216 Retrieved March 2008)
217
218 .. [#Rauch2000] Rauch, H. and Waschkowski, W. (2000)
219 Neutron scattering lengths. Schopper, H. (ed.). SpringerMaterials -
220 The Landolt-Börnstein Database (http://www.springermaterials.com).
221 doi:10.1007/10499706_6
222
223 .. [#Lynn1990] Lynn, J.E. and Seeger, P.A. (1990)
224 Resonance effects in neutron scattering lengths of rare-earth nuclides.
225 Atomic Data and Nuclear Data Tables 44, 191-207.
226 doi:10.1016/0092-640X(90)90013-A
227
228 .. [#Sears2006] Sears, V. F. (2006)
229 4.4.4 Scattering lengths for neutrons.
230 In Prince, E. ed. Intl. Tables for Crystallography C.
231 Kluwer Academic Publishers. pp 444-454.
232 (https://it.iucr.org/Cb/ch4o4v0001/sec4o4o4/)
233 doi:10.1107/97809553602060000103
234
235 .. [#Sears1992] Sears, V.F. (1992)
236 Neutron scattering lengths and cross sections.
237 Neutron News 3, No. 3, 26-37.
238
239 .. [#May1982] May, R.P., Ibel, K. and Haas, J. (1982)
240 The forward scattering of cold neutrons by mixtures of light and heavy water.
241 J. Appl. Cryst. 15, 15-19. doi:10.1107/S0021889882011285
242
243 .. [#Mildner1998] Mildner, D.F.R., Lamaze, G.P. (1998)
244 Neutron Transmission of Single-Crystal Sapphire.
245 J Appl Crystallogr 31, 835–840. doi:10.1107/S0021889898005846
246
247 .. [#Glinka2011] Glinka, C.J. (2011)
248 Incoherent Neutron Scattering from Multi-element Materials.
249 J. Appl. Cryst. 44, 618-624. doi:10.1107/S0021889811008223
250
251 .. [#Dawidowski2013] Dawidowski, J., Granada, J. R., Santisteban,
252 J. R., Cantargi, F., & Palomino, L. A. R. (2013)
253 Appendix—Neutron Scattering Lengths and Cross Sections.
254 In F. Fernandez-Alonso & D. L. Price (Eds.),
255 Experimental Methods in the Physical Sciences (Vol. 44, pp. 471–528).
256 Academic Press. doi:10.1016/B978-0-12-398374-9.09989-7
257
258 .. [#Mughabghab2018] Mughabghab (2018)
259 Atlas of Neutron Resonances (Sixth Edition). Elsevier.
260 Vol I (Z=1-60) 10.1016/C2015-0-00522-6
261 Vol II (Z=61-102) 10.1016/C2015-0-00524-X
262
263 """
264
265 #.. [#Koester1991] Koester, L., Rauch, H., Seymann. E. (1991)
266 # Atomic Data Nuclear Data Tables 49, 65. doi:10.1016/0092-640X(91)90012-S
267 #.. [#Smith2006] Smith, G.S. and Majkrzak, C.M. (2006)
268 # 2.9 Neutron reflectometry.
269 # In E. Prince ed. Intl. Tables for Crystallography C.
270 # Wiley InterScience. pp 126-146. doi:10.1107/97809553602060000584
271 #
272
273 from pathlib import Path
274 from typing import TYPE_CHECKING, cast
275
276 import numpy as np
277 from numpy import sqrt, pi, asarray, inf
278 from numpy.typing import NDArray
279 from .core import Element, Isotope, PeriodicTable, Atom, default_table, iselement
280 from .constants import (avogadro_number, planck_constant, electron_volt,
281 neutron_mass, atomic_mass_constant)
282
283 DoubleArray = NDArray[np.float64]
284
285 __all__ = ['init', 'Neutron',
286 'neutron_energy', 'neutron_wavelength',
287 'neutron_wavelength_from_velocity',
288 'neutron_scattering', 'neutron_sld', 'neutron_composite_sld',
289 'sld_plot',
290 'absorption_comparison_table', 'coherent_comparison_table',
291 'incoherent_comparison_table', 'total_comparison_table',
292 'energy_dependent_table', 'sld_table',
293 'neutron_sld_from_atoms',
294 #'scattering_potential',
295 ]
296
297 #: Wavelength [Å] for which neutron scattering cross sections are tabulated.
298 ABSORPTION_WAVELENGTH = 1.798 # [Å]
299
300
301 #: Energy [eV] <=> wavelength [Å]:
302 #: E = 1/2 m v² = h² / (2 m λ²)
303 #: E[meV s] = h[J s]²/(2 m_n[u] m_u[kg/u] λ[Å]²/10^20[Å/m])
304 #: * 1000[meV/eV] / electron_volt[J/eV]
305 ENERGY_FACTOR = (
306 1e23 * planck_constant**2/electron_volt
307 / (2 * neutron_mass * atomic_mass_constant))
308
309 #: Velocity[m/s] <=> wavelength[Å]:
310 #: h = p λ = m v λ
311 #: λ[Å] = h[J s] / ( m_n[kg] v[m/s] ) 10^10[Å/m]
312 VELOCITY_FACTOR = (
313 1e10 * planck_constant / (neutron_mass * atomic_mass_constant))
314
315 def neutron_wavelength(energy: float|NDArray) -> NDArray:
316 r"""
317 Convert neutron energy to wavelength.
318
319 :Parameters:
320 *energy* \: float or vector | meV
321
322 :Returns:
323 *wavelength* \: float or vector | |Ang|
324
325 Energy is converted to wavelength using
326
327 .. math::
328
329 E = 1/2 m_n v^2 = h^2 / (2 m_n \lambda^2)
330 \Rightarrow \lambda = \sqrt{h^2 / (2 m_n E)}
331
332 where
333
334 $h$ = Planck constant in |Js|
335
336 $m_n$ = neutron mass in kg
337
338 """
339 return sqrt(ENERGY_FACTOR / asarray(energy))
340
341 # TODO: why is neutron_wavelength_from_velocity not using asarray() ?
342 def neutron_wavelength_from_velocity(velocity: float|NDArray) -> float|NDArray:
343 r"""
344 Convert neutron velocity to wavelength.
345
346 :Parameters:
347 *velocity* \: float or vector | m/s
348
349 :Returns:
350 *wavelength* \: float or vector | |Ang|
351
352 Velocity is converted to wavelength using
353
354 .. math::
355
356 \lambda = h/p = h/(m_n v)
357
358 where
359
360 $h$ = Planck constant in |Js|
361
362 $m_n$ = neutron mass in kg
363 """
364 return VELOCITY_FACTOR / velocity
365
366 def neutron_energy(wavelength: float|NDArray) -> NDArray:
367 r"""
368 Convert neutron wavelength to energy.
369
370 :Parameters:
371 *wavelength* \: float or vector | |Ang|
372
373 :Returns:
374 *energy* \: float or vector | meV
375
376 Wavelength is converted to energy using
377
378 .. math::
379
380 E = 1/2 m_n v^2 = h^2 / (2 m_n \lambda^2)
381
382 where:
383
384 $h$ = Planck constant in |Js|
385
386 $m_n$ = neutron mass in kg
387 """
388 return ENERGY_FACTOR / asarray(wavelength)**2
389
390 def _CHECK_scattering_potential(sld):
391 r"""
392 Convert neutron scattering length density to energy potential.
393
394 :Parameters:
395 *sld* \: float or vector | |1e-6/Ang^2|
396
397 Scattering length density.
398
399 :Returns:
400 *energy* \: float or vector | $10^{-6}$ eV
401
402 Scattering potential.
403
404 Computes:[#Smith2006]_
405
406 .. math::
407
408 V = 2 \pi \hbar^2 N_b / m_n
409
410 where:
411
412 $\hbar = h / (2 \pi)$
413
414 $h$ = Planck constant in |Js|
415
416 $N_b = \sum{ n_i b_i } / V$
417
418 $m_n$ = neutron mass in kg
419 """
420 return (ENERGY_FACTOR/pi) * asarray(sld)
421
422 _4PI_100 = 4*np.pi/100
423 class Neutron:
424 r"""
425 Neutron scattering factors are attached to each element in the periodic
426 table for which values are available. If no information is available,
427 then the neutron field of the element will be *None*. Even when neutron
428 information is available, it may not be complete, so individual fields
429 may be *None*.
430
431 The following fields are defined:
432
433 * b_c (fm)
434 Bounds coherent scattering length.
435
436 * total (barn)
437 Total scattering cross section $\sigma_s$. This does not include the
438 absorption cross section. To compute the total collision cross
439 section use $\sigma_t = \sigma_s + \sigma_a$
440
441 * absorption (barn)
442 Absorption cross section $\sigma_a$ at 1.798 |Ang|. Scale to your beam
443 by dividing by periodictable.nsf.ABSORPTION_WAVELENGTH and multiplying
444 by your wavelength. This wavelength corresponds to a neutron velocity
445 of 2200 m/s and neutron energy of 25.3 meV.
446
447 * b_c_complex (fm)
448 Complex coherent scattering length derived from the tabulated
449 values using $b_c - i \sigma_a / (1000 \cdot 2 \lambda)$.
450
451 Additional columns not used for calculation include:
452
453 * b_c_i (fm)
454 Imaginary bound coherent scattering length. This is related to
455 absorption cross section by $\sigma_a = 4 \pi \mathrm{Im}(b_c)/k$ where
456 $k = 2 \pi/\lambda$ and an additional factor of 1000 for converting
457 between |Ang|\ |cdot|\ fm and barns. b_c_i is not available for
458 all isotopes for which absorption cross sections have been measured.
459
460 * bp, bm (fm)
461 Spin-dependent scattering for I+1/2 and I-1/2 (not always available).
462 Incoherent scattering arises from the spin-dependent scattering b+
463 and b-. The Neutron Data Booklet\ [#Rauch2003]_ gives formulas for
464 calculating coherent and incoherent scattering from b+ and b- alone.
465
466 * bp_i, bm_i (fm)
467 Imaginary portion of bp and bm.
468
469 * is_energy_dependent (boolean)
470 Do not use this data if scattering is energy dependent.
471
472 * coherent (barn)
473 Coherent scattering cross section. This is tabulated but not used.
474 In theory coherent scattering is related to bound coherent scattering
475 by $\sigma_c = 4 \pi |\mathrm{Re}(b_c) + i \mathrm{Im}(b_c)|^2/100$.
476 In practice, these values are different, with the following table
477 showing the largest relative difference:
478
479 ======== ======== ======== ======== ========
480 Sc 3% Ti 4% V 34% Mn 1% Cd 2%
481 Te 4% Xe 9% Sm 19% Eu 44% Tb 1%
482 Ho 11% W 4% Au 7% Hg 2% Ra 3%
483 ======== ======== ======== ======== ========
484
485 * incoherent (barn)
486 Incoherent scattering cross section $\sigma_i$. This is tabulated but
487 not used. Instead, the incoherent cross section is computed from the
488 total cross section minus the coherent cross section even for single
489 atoms so that results from compounds are consistent with results from
490 single atoms.
491
492 For elements, the scattering cross-sections are based on the natural
493 abundance of the individual isotopes. Individual isotopes may have
494 the following additional fields
495
496 * abundance (%)
497 Isotope abundance used to compute the properties of the element in
498 natural abundance. Note that this data is taken from the ATI scattering
499 tables. Each isotope has an abundance provided by the latest mass tables
500 from IUPAC.
501
502 * nuclear_spin (string)
503 Spin on the nucleus: '0', '1/2', '3/2', etc.
504
505 Each field ``T`` above has a corresponding ``T_units`` attribute with
506 the name of the units.
507
508 For scattering calculations the scattering length density is the value
509 of interest. This is computed from the *number_density* of the individual
510 elements, as derived from the element density and atomic mass.
511
512 .. Note:: 1 barn = 100 |fm^2|
513 """
514 b_c: float|None = None
515 b_c_unc: float|None = None
516 b_c_units: str = "fm"
517 b_c_i: float|None = None
518 b_c_i_unc: float|None = None
519 b_c_i_units: str = "fm"
520 b_c_complex: complex|None = None
521 b_c_complex_units: str = "fm"
522 bp: float|None = None # Not all isotopes provide b+/b- values
523 bp_unc: float|None = None
524 bp_i: float|None = None
525 bp_i_unc: float|None = None
526 bp_units: str = "fm"
527 bm: float|None = None # Not all isotopes provide b+/b- values
528 bm_unc: float|None = None
529 bm_i: float|None = None
530 bm_i_unc: float|None = None
531 bm_units: str = "fm"
532 coherent: float|None = None
533 coherent_unc: float|None = None
534 coherent_units: str = "barn"
535 incoherent: float|None = None
536 incoherent_unc: float|None = None
537 incoherent_units: str = "barn"
538 total: float|None = None
539 total_unc: float|None = None
540 total_units: str = "barn"
541 absorption: float|None = None
542 absorption_unc: float|None = None
543 absorption_units: str = "barn"
544 abundance: float = 0.
545 abundance_units: str = "%"
546 is_energy_dependent: bool = False
547 nsf_table: tuple[DoubleArray, DoubleArray]|None = None
548
549 def __init__(self):
550 self._number_density = None
551 def __str__(self) -> str:
552 if not self.has_sld():
553 return "unknown"
554 b_c, coh, inc, abs = self.b_c, self.coherent, self.incoherent, self.absorption
555 return f"b_c={cast(float, b_c):.3g} coh={cast(float, coh):.3g} inc={cast(float, inc):.3g} abs={cast(float, abs):.3g}"
556
557 def has_sld(self) -> bool:
558 """Returns *True* if sld is defined for this element/isotope."""
559 # TODO: use NaN for missing information
560 #return np.isnan(self.b_c * self._number_density)
561 return self.b_c is not None and self._number_density is not None
562
563 # PAK 2021-04-05: allow energy dependent b_c
564 def scattering_by_wavelength(self, wavelength: float | NDArray) -> tuple[float | NDArray, float | NDArray]|tuple[None, None]:
565 r"""
566 Return scattering length and total cross section for each wavelength.
567
568 For rare earth isotopes this returns the energy-dependent
569 $\mathrm{Re}(b_c)$ and $\mathrm{Im}(b_c)$ interpolated into the
570 scattering length tables. Values are extrapolated with constant
571 values at the ends of the table. Total scattering is returned as
572 $4\pi/100 |b_c|^2$ with no contribution for bound incoherent
573 scattering.
574
575 :Parameters:
576 *wavelength* \: float(s) | |Ang|
577
578 :Returns:
579 *b_c* \: complex(s) | fm
580
581 *sigma_s* \: float(s) | barn
582 """
583 if not self.has_sld():
584 return None, None
585
586 # TODO: do vector conversion at the end rather than the beginning.
587 if self.nsf_table is None:
588 ones = 1 if np.isscalar(wavelength) else np.ones_like(wavelength)
589 return ones*cast(float, self.b_c_complex), ones*cast(float, self.total)
590 #energy = neutron_energy(wavelength)
591 #b_c = np.interp(energy, self.nsf_table[0], self.nsf_table[1])
592 b_c = np.interp(wavelength, self.nsf_table[0], self.nsf_table[1])
593 # TODO: sigma_s should include an incoherent contribution
594 sigma_s = _4PI_100*np.abs(b_c)**2 # 1 barn = 1 fm^2 1e-2 barn/fm^2
595 return b_c, sigma_s
596
597 def sld(self, *, wavelength: float | NDArray =ABSORPTION_WAVELENGTH) -> NDArray|None:
598 r"""
599 Returns scattering length density for the element at natural
600 abundance and density.
601
602 :Parameters:
603 *wavelength* \: float(s) | |Ang|
604
605 :Returns:
606 *sld* \: float(s), float(s), float(s) | |1e-6/Ang^2|
607 (*real*, -*imaginary*, *incoherent*) scattering length density.
608
609 Returns (None, None, None) if sld is not known for this element.
610
611 See :func:`neutron_scattering` for details.
612 """
613 # TODO: deprecate in favour of neutron_scattering(el)
614 if not self.has_sld():
615 return None
616 return self.scattering(wavelength=wavelength)[0]
617
618 def scattering(self, *, wavelength: float | NDArray=ABSORPTION_WAVELENGTH) -> tuple[NDArray, NDArray, NDArray]|tuple[None, None, None]:
619 r"""
620 Returns neutron scattering information for the element at natural
621 abundance and density.
622
623 :Parameters:
624 *wavelength* \: float(s) | |Ang|
625
626 :Returns:
627 *sld* \: float(s), float(s), float(s) | |1e-6/Ang^2|
628 (*real*, -*imaginary*, *incoherent*) scattering length density
629
630 *xs* \: float(s), float(s), float(s) | |1/cm|
631 (*coherent*, *absorption*, *incoherent*) cross sections.
632 :w
633
634 *penetration* \: float(s) | cm
635 1/e penetration length.
636
637 Returns (None, None, None) if sld is not known for this element.
638
639 See :func:`neutron_scattering` for details.
640 """
641 # TODO: deprecate in favour of neutron_scattering(el)
642 # Compute number and absorption density assuming isotope has
643 # same structure as the bulk element
644 if not self.has_sld():
645 return None, None, None
646
647 number_density = self._number_density*1e-24 # N/A^3 = N/cm^3 (1e-8 cm/A)^3
648 b_c, sigma_s = self.scattering_by_wavelength(wavelength)
649 return _calculate_scattering(number_density, wavelength, b_c, sigma_s)
650
651 def energy_dependent_init(table: PeriodicTable) -> None:
652 from .nsf_tables import ENERGY_DEPENDENT_TABLES
653
654 for (el_name, iso_num), values in ENERGY_DEPENDENT_TABLES.items():
655 energy, re_a, im_a, _ = zip(*values) # Ignoring abs(a)
656 wavelength = neutron_wavelength(asarray(energy)*1000) # 1 eV = 1000 meV
657 el = getattr(table, el_name)
658 atom = el if iso_num is None else el[iso_num]
659 xs = asarray(re_a) + 1j*asarray(im_a)
660 #atom.neutron.nsf_table = asarray(energy)*1000, xs
661 atom.neutron.nsf_table = wavelength[::-1], xs[::-1]
662 #print(f"adding {atom}")
663
664 # Lu nat missing from Lynn and Seeger, so mix Lu[175] and Lu[176]
665 Lu175 = table.Lu[175]
666 Lu176 = table.Lu[176]
667 bc_175 = cast(complex, Lu175.neutron.b_c_complex)
668 wavelength, bc_176 = cast(tuple[DoubleArray, DoubleArray], Lu176.neutron.nsf_table)
669 bc_nat = (bc_175*Lu175.abundance + bc_176*Lu176.abundance)/100.0 # 1 fm = 1fm * %/100
670 table.Lu.neutron.nsf_table = wavelength, cast(DoubleArray, bc_nat)
671 #table.Lu.neutron.total = 0. # zap total cross section
672
673 def init(table: PeriodicTable, reload: bool=False) -> None:
674 """
675 Loads the Rauch table from the neutron data book.
676 """
677 if 'neutron' in table.properties and not reload:
678 return
679 table.properties.append('neutron')
680 assert ('density' in table.properties and 'mass' in table.properties), \
681 "Neutron table requires mass and density properties"
682
683 # Defaults for missing neutron information
684 missing = Neutron()
685 Isotope.neutron = missing
686 Element.neutron = missing
687
688 for line in nsftable.split('\n'):
689 columns = line.split(',')
690
691 nsf = Neutron()
692 p = columns[1]
693 spin = columns[2]
694 nsf.b_c, nsf.b_c_unc = _fix_number(columns[3])
695 nsf.bp, nsf.bp_unc = _fix_number(columns[4])
696 nsf.bm, nsf.bm_unc = _fix_number(columns[5])
697 nsf.is_energy_dependent = (columns[6] == 'E')
698 nsf.coherent, nsf.coherent_unc = _fix_number(columns[7])
699 nsf.incoherent, nsf.incoherent_unc = _fix_number(columns[8])
700 nsf.total, nsf.total_unc = _fix_number(columns[9])
701 nsf.absorption, nsf.absorption_unc = _fix_number(columns[10])
702 # 1 fm = (1 barn)(100 fm^2/barn)/(1 A) (1e-5 A/fm)
703 # Note: Sears (1992) uses b = b' - i b'', so negate sigma_a for b''.
704 # Warning: -b_c.imag may be -0, which can mess with your calculations.
705 #if nsf.b_c is None: print(f"b_c unavailable for {columns[0]}")
706 b_c = nsf.b_c if nsf.b_c is not None else np.nan
707 b_c_i = -nsf.absorption/(2000*ABSORPTION_WAVELENGTH)
708 nsf.b_c_complex = b_c + 1j*b_c_i
709
710 if not np.isnan(b_c):
711 # Ir-191 and Ir-193 don't list scattering cross sections so deduce
712 # them from the bound coherent cross section. Since these are both
713 # odd isotopes there ought to be some incoherent scattering, but
714 # zero is well within the uncertainty measured in bulk Ir.
715 if nsf.coherent is None:
716 nsf.coherent = 4*pi/100*abs(nsf.b_c_complex)**2
717 nsf.coherent_unc = np.nan # derived value
718 if nsf.incoherent is None:
719 nsf.incoherent = 0
720 nsf.incoherent_unc = np.nan # derived value
721 if nsf.total is None:
722 nsf.total = nsf.coherent + nsf.incoherent
723 nsf.total_unc = np.nan # derived value
724
725 parts = columns[0].split('-')
726 Z = int(parts[0])
727 symbol = parts[1]
728 isotope_number = int(parts[2]) if len(parts) == 3 else 0
729
730 # Fetch element from the table and check that the symbol matches
731 element = table[Z]
732 assert element.symbol == symbol, \
733 "Symbol %s does not match %s" % (symbol, element.symbol)
734
735 # Plug the default number density for the element into the nsf so
736 # it can calculate sld.
737 nsf._number_density = element.number_density # N/cm^3 = N/cm^3
738
739 if isotope_number == 0:
740 # Value for element using laboratory abundances of isotopes
741 element.neutron = nsf
742 else:
743 # Values for the individual isotope
744 isotope = element.add_isotope(isotope_number)
745 isotope.neutron = nsf
746 isotope.nuclear_spin = spin
747 # p column contains either abundance(uncertainty) or "half-life Y"
748 isotope.neutron.abundance = _fix_number(p)[0] if ' ' not in p else 0
749
750 # If the element is not yet initialized, copy info into the atom.
751 # This serves to set the element info for elements with only
752 # one isotope.
753 if element.neutron is missing:
754 element.neutron = nsf
755
756 for line in nsftableI.split('\n'):
757 columns = line.split(',')
758
759 # Fetch the nsf record
760 parts = columns[0].split('-')
761 Z = int(parts[0])
762 symbol = parts[1]
763 isotope_number = int(parts[2]) if len(parts) == 3 else 0
764 element = table[Z]
765 if isotope_number == 0:
766 nsf = element.neutron
767 else:
768 nsf = element[isotope_number].neutron
769
770 # Read imaginary values
771 nsf.b_c_i, nsf.b_c_i_unc = _fix_number(columns[1])
772 nsf.bp_i, nsf.bp_i_unc = _fix_number(columns[2])
773 nsf.bm_i, nsf.bm_i_unc = _fix_number(columns[3])
774
775 # Add energy-dependent tables
776 energy_dependent_init(table)
777
778
779 # TODO: split incoherent into spin and isotope incoherence (eq 17-19 of Sears)
780 # TODO: require parsed compound rather than including formula() keywords in api
781 # Note: docs and function prototype are reproduced in __init__
782 # CRUFT: deprecated circular import with periodictable.formulas
783 if TYPE_CHECKING:
784 from .formulas import FormulaInput
785 def neutron_scattering(
786 compound: "FormulaInput", *,
787 density: float|None=None,
788 wavelength: float|NDArray|None=None,
789 energy: float|NDArray|None=None,
790 natural_density: float|None=None,
791 table: PeriodicTable|None=None,
792 ) -> tuple[NDArray, NDArray, NDArray]|tuple[None, None, None]:
793 r"""
794 Computes neutron scattering cross sections for molecules.
795
796 :Parameters:
797 *compound* \: Formula initializer
798 Chemical formula
799 *density* \: float | |g/cm^3|
800 Mass density
801 *natural_density* \: float | |g/cm^3|
802 Mass density of formula with naturally occuring abundances
803 *wavelength* 1.798 \: float(s) | |Ang|
804 Neutron wavelength (default=1.798 |Ang|).
805 *energy* \: float(s) | meV
806 Neutron energy. If energy is specified then wavelength is ignored.
807 *table* \: PeriodicTable
808 Alternate table to use when parsing *compound*.
809
810 :Returns:
811 *sld* \: float(s), float(s), float(s) | |1e-6/Ang^2|
812 (*real*, -*imaginary*, *incoherent*) scattering length density.
813 *xs* \: float(s), float(s), float(s) | |1/cm|
814 (*coherent*, *absorption*, *incoherent*) cross sections.
815 *penetration* \: float(s) | cm
816 1/e penetration depth of the beam
817
818 Returns (None, None, None) if sld is unknown for any component.
819
820 :Raises:
821 *AssertionError* \: density is missing.
822
823
824 .. Note:
825
826 The returned values will be vectors if *wavelength* is a vector.
827
828 Neutron scattering cross sections for materials are calculated from
829 tabulated values for the different nuclei. The result is only an
830 approximation. Actual scattering depends on details of sample composition,
831 as well as the incoming neutron energy and sample temperature, especially
832 for light elements. For low energy neutrons the tabulated
833 cross sections are generally a lower limit. The measured incoherent
834 scattering from hydrogen, for example, can be considerably larger
835 (by more than 20%) than its bound value, leading to an estimate of 5.621/cm
836 for H2O as computed compared to ~7.0/cm as measured with 5 meV neutrons
837 at 290K.\ [#May1982]_ The alignment of the neutron spin with the nuclei
838 spin also matters, as demonstrated by $^3\mathrm{He}$ polarizers.
839
840 The tables themselves are not self-consistent. Because the different
841 quantities are measured indirectly with a variety of techniques, there
842 are discrepencies when converting values from one column to another. These
843 differences can be seen with the following:
844
845 :func:`absorption_comparison_table`
846
847 :func:`coherent_comparison_table`
848
849 :func:`total_comparison_table`
850
851 For our calculations we use the real part of the bound coherent scattering
852 length $\mathrm{Re}(b_c)$ (labelled b_c in the tables) and the absorption
853 cross section $\sigma_a$ from which we derive the imaginary scattering
854 length, $\mathrm{Im}(b_c)$. See Sears (1992) for details.\ [#Sears1992]_
855
856 We first need to average quantities for the unit cell of the molecule.
857 Molar mass *m* (g/mol) is the sum of the masses of each component:
858
859 .. math::
860
861 m = \sum{n_k m_k}\ {\rm for\ each\ atom}\ k=1,2,\ldots
862
863 Cell volume $V$ (|Ang^3|/molecule) is molar mass $m$ over density
864 $\rho$, with a correction based on Avogadro's number $N_A$ (atoms/mol)
865 and the length conversion $10^8$ |Ang|/cm:
866
867 .. math::
868
869 V = m/\rho \cdot 1/N_A \cdot (10^8)^3
870
871 Number density $N$ is the number of scatterers per unit volume:
872
873 .. math::
874
875 N = \left.\sum{n_k} \right/ V
876
877 The coherent scattering length of the molecule is computed from the
878 average scattering length $b_c = \mathrm{Re}(b_c) + i \mathrm{Im}(b_c)$
879 weighted by frequency:
880
881 .. math::
882
883 \mathrm{Re}(b_c) &= \left.\sum n_k \mathrm{Re}(b_{ck}) \right/ \sum n_k \\
884 \mathrm{Im}(b_c) &= \left.\sum n_k \mathrm{Im}(b_{ck}) \right/ \sum n_k
885
886 The individual $\mathrm{Im}(b_{ck})$ values are derived from the absorption
887 cross sections $\sigma_a$, tabulated at wavelength $\lambda = 1.798$ |Ang|
888 and scaled to fm (with 1000 fm = 1 barn/|Ang|):
889
890 .. math::
891
892 \mathrm{Im}(b_{ck}) = -\left. \sigma_{ak} \right/ (1000 \cdot 2 \lambda)
893
894 Note the sign change relative to $b''$ in Sears (1992), with Eq 2
895 defining $b = b' - i b''$. Since we are not considering polarized
896 nuclei, the imaginary incoherent contribution is zero and
897 $b'' = -\mathrm{Im}(b_c)$.
898
899 Some rare earth isotopes are energy-dependent with complex bound coherent
900 scattering length $b_c$ tabulated by energy.\ [#Lynn1990]_ For the given
901 input wavelength $\lambda$, $b_c$ is interpolated from the table values,
902 with the end points used for values outside the tabulated range.
903
904 The average scattering length is converted to scattering cross
905 sections, with $\sigma_c$ scaled to barn (with 1 barn= 100 |fm^2|)
906 and $\sigma_a$ scaled to barn (with 1000 barn = 1 fm |Ang|):
907
908 .. math::
909
910 \sigma_c &= \left. 4 \pi |\mathrm{Re}(b_c) + i \mathrm{Im}(b_c)|^2 \right/ 100 \\
911 \sigma_a &= -\left. 1000 \cdot 4 \pi \left< \mathrm{Im}(b_c) \right> \right/k
912 \ {\rm for} \ k=2\pi / \lambda
913
914 For most elements the scattering length is independent of energy in
915 the thermal neutron energy range so the coherent scattering length
916 $\sigma_c$ is unchanged. The absorption cross section $\sigma_a$ for
917 these elements scales linearly with wavelength and can be adjusted
918 with a simple multiplication:
919
920 .. math::
921
922 \sigma_a' = \sigma_a \lambda' / \lambda_o = \sigma_a \lambda' / 1.798
923
924 The incoherent scattering length is more complicated, including
925 contributions from spin incoherence for different possible spin states
926 as well as isotope incoherence from diffuse coherent
927 scattering.\ [#Glinka2011]_ Using the total cross section $\sigma_s$ from
928 the table, the incoherent scattering length is estimated as:
929
930 .. math::
931
932 \sigma_s &= \left.\sum n_k \sigma_{sk} \right/ \sum n_k \\
933 \sigma_i &= \sigma_s - \sigma_c \\
934 b_i &= \sqrt{ 100 \sigma_i / (4 \pi) }
935
936 For the energy dependent rare earth isotopes the total scattering is
937 estimated from $b = \mathrm{Re}(b_c) + i \mathrm{Im}(b_c)$, ignoring
938 any spin incoherence effects. As a result, incoherent scattering for
939 materials with energy-dependent rare earth isotopes with non-zero
940 nuclear spin will be underestimated.
941
942 The scattering potential can be expressed as a scattering length
943 density (SLD). This is the number density of the scatterers
944 (per |Ang^3|) times their scattering lengths, scaled to
945 |1e-6/Ang^2| (with |1/Ang^2| = $10^{5}$ fm/|Ang^3|).
946 Following the convention of Sears (1992), we define sld as
947 $\rho = \rho_{\rm re} - i \rho_{\rm im}$.
948
949 .. math::
950
951 \rho_{\rm re} (10^6 / Å^2) &= 10 N \mathrm{Re}(b_c) \\
952 \rho_{\rm im} (10^6 / Å^2) &= -10 N \mathrm{Im}(b_c) \\
953 \rho_{\rm inc} (10^6 / Å^2) &= 10 N b_i
954
955 Similarly, the macroscopic scattering cross section for the sample includes
956 number density:
957
958 .. math::
959
960 \Sigma_{\rm coh} (1/{\rm cm}) &= N \sigma_c \\
961 \Sigma_{\rm inc} (1/{\rm cm}) &= N \sigma_i \\
962 \Sigma_{\rm abs} (1/{\rm cm}) &= N \sigma_a \\
963 \Sigma_{\rm s} (1/{\rm cm}) &= N \sigma_s
964
965 The 1/e penetration depth $t_u$ represents the the depth into the sample
966 at which the unscattered intensity is reduced by a factor of $e$:
967
968 .. math::
969
970 t_u (cm) = \left. 1 \right/ (\Sigma_{\rm s} + \Sigma_{\rm abs})
971
972 The calculated penetration depth includes the effects of both
973 absorption and incoherent scattering (which spreads the beam over the
974 full $4\pi$ spherical surface, and so it looks like absorption with
975 respect to the beam), as well as the coherent scattering from the sample.
976 If you instead want to calculate the effective shielding of the sample,
977 you should recalculate penetration depth with absorption only.
978
979 Transmission rate can be computed from $e^{-d/t_u}$ for penetration
980 depth $t_u$ and sample thickness $d$. This does not include many
981 real world effects, such as single phonon scattering\ [#Mildner1998]_
982 and forward scattering\ [#May1982]_, which result in measured
983 transmission significantly different from the values predicted from
984 nuclear properties alone.
985
986 There is also a wavelength dependence for single phonon interactions which
987 gives rise to significant inelastic scattering for lighter isotopes (H, D)
988 and/or longer wavelengths (above 5 |Ang|). This factor is both
989 temperature and material dependent and will not be included
990 in the scattering calculations. In particular, penetration length and
991 transmitted flux are going to be significantly overestimated.
992
993 Including unit conversion with $\mu=10^{-6}$ the full scattering equations
994 are:
995
996 .. math::
997
998 \rho_{\rm re}\,(\mu/Å^2) &= (N/Å^3)
999 \, (\mathrm{Re}(b_c)\,{\rm fm})
1000 \, (10^{-5} Å/{\rm\,fm})
1001 \, (10^6\,\mu) \\
1002 \rho_{\rm im}\,(\mu/Å^2) &= (N/Å^3)
1003 \, (\sigma_a\,{\rm barn})
1004 \, (10^{-8}\,Å^2/{\rm barn}) / (2 \lambda\, Å)
1005 \, (10^6\,\mu) \\
1006 &= (N/Å^3)
1007 \, (-\mathrm{Im}(b_c)\,{\rm fm})
1008 \, (10^{-5} Å/{\rm\,fm})
1009 \, (10^6\,\mu) \\
1010 \rho_{\rm inc}\,(\mu/Å^2) &= (N/Å^3)
1011 \, \sqrt{(\sigma_i\, {\rm barn})/(4 \pi)
1012 \, (100\, {\rm fm}^2/{\rm barn})}
1013 \, (10^{-5}\, Å/{\rm fm})
1014 \, (10^6\, \mu) \\
1015 \Sigma_{\rm coh}\,(1/{\rm cm}) &= (N/Å^3)
1016 \, (\sigma_c\, {\rm barn})
1017 \, (10^{-8}\, Å^2/{\rm barn})
1018 \, (10^8\, Å/{\rm cm}) \\
1019 \Sigma_{\rm inc}\,(1/{\rm cm}) &= (N/Å^3)
1020 \,(\sigma_i\, {\rm barn})
1021 \, (10^{-8}\, Å^2/{\rm barn})
1022 \, (10^8\, Å/{\rm cm}) \\
1023 \Sigma_{\rm abs}\,(1/{\rm cm}) &= (N/Å^3)
1024 \,(\sigma_a\,{\rm barn})
1025 \, (10^{-8}\, Å^2/{\rm barn})
1026 \, (10^8\, Å/{\rm cm}) \\
1027 \Sigma_{\rm s}\,(1/{\rm cm}) &= (N/Å^3)
1028 \,(\sigma_s\,{\rm barn})
1029 \, (10^{-8}\, Å^2/{\rm barn})
1030 \, (10^8\, Å/{\rm cm}) \\
1031 t_u\,({\rm cm}) &= 1/(\Sigma_{\rm s}\, 1/{\rm cm}
1032 \,+\, \Sigma_{\rm abs}\, 1/{\rm cm})
1033 """
1034 from . import formulas
1035
1036 compound = formulas.formula(
1037 compound, density=density, natural_density=natural_density, table=table)
1038 assert compound.density is not None, "scattering calculation needs density"
1039 #print("sld", compound, compound.density)
1040 if energy is not None:
1041 wavelength = neutron_wavelength(energy)
1042 # PAK: 1.5.3 wavelength now defaults to ABSORPTION_WAVELENGTH
1043 elif wavelength is None:
1044 wavelength = ABSORPTION_WAVELENGTH
1045
1046 # Sum over the quantities (note: formulas can have fractional atoms)
1047 molar_mass, num_atoms = 0., 0.
1048 b_c: float|NDArray = 0.
1049 sigma_s: float|NDArray = 0.
1050 is_energy_dependent = False
1051 for element, quantity in compound.atoms.items():
1052 # TODO: use NaN rather than None
1053 if not element.neutron.has_sld():
1054 return None, None, None
1055 molar_mass += element.mass*quantity
1056 num_atoms += quantity
1057 # PAK 2021-04-05: allow energy dependent b_c, b''
1058 b_ck, sigma_sk = cast(tuple[float|NDArray, float|NDArray], element.neutron.scattering_by_wavelength(wavelength))
1059 #print(f"{element=}; {b_ck=}; {sigma_sk=}")
1060 b_c += quantity * b_ck
1061 sigma_s += quantity * sigma_sk
1062 is_energy_dependent |= element.neutron.is_energy_dependent
1063
1064 # If nothing to sum, return values for a vacuum. This might be because
1065 # the material has no atoms or it might be because the density is zero.
1066 if molar_mass*compound.density == 0:
1067 return (0, 0, 0), (0, 0, 0), inf # type: ignore[return-value]
1068
1069 # Turn weighted sums into scattering factors
1070 b_c /= num_atoms
1071 sigma_s /= num_atoms
1072
1073 # Compute number density (N/A^3)
1074 # volume A^3/N = ((1 g/mole) / (1 g/cm^3)) / (N/mole) * (10^8 A/cm)^3
1075 cell_volume = (molar_mass/compound.density)/avogadro_number*1e24
1076 number_density = num_atoms / cell_volume # N/A^3 = N/A^3
1077
1078 return _calculate_scattering(number_density, wavelength, b_c, sigma_s)
1079
1080
1081 def _calculate_scattering(number_density, wavelength, b_c, sigma_s):
1082 r"""
1083 :Parameters:
1084 *number_density* \: float | N/|Ang^3|
1085 Scatterers per unit volume.
1086 *wavelength* \: float(s) | |Ang|
1087 Neutron wavelength(s).
1088 *b_c* \: complex(s) | fm
1089 Complex bound coherent scattering length $b_c$.
1090 *sigma_c* \: float(s) | barn
1091 Total cross section.
1092
1093 See neutron_scattering docstring for calculation details.
1094
1095 Note: returns -sld_im for historical reasons.
1096 """
1097 #print("in scat", number_density, wavelength, b_c, sigma_s)
1098 # Compute SLD (1e-6/A^2). Extending Sears (1992) convention, b = b' - i b'',
1099 # returning sld = sld_re - i sld_im.
1100 sld = 10*number_density * b_c # 1e-6/A^2 = 1/A^3 1 fm 1e-5 A/fm 1e6 1e-6
1101 sld_re, sld_im = sld.real, abs(sld.imag)
1102
1103 # PAK 2017-04-21: compute incoherent xs from total xs
1104 # PAK 2021-04-20: include imaginary b_c in coherent cross section
1105 # Compute coherent and incoherent cross sections (barn)
1106 sigma_c = _4PI_100 * abs(b_c)**2 # 1 barn = 1e-2 fm^2
1107 sigma_i = np.maximum(sigma_s - sigma_c, 0.) # 1 barn = 1 barn
1108
1109 # Compute incoherent scattering length from incoherent cross section (fm)
1110 b_i = sqrt(sigma_i / _4PI_100) # 1 fm = sqrt(1 barn * 1e-2 fm^2/barn)
1111
1112 # Compute incoherent scattering length density (1e-6/A^2)
1113 sld_inc = number_density * b_i * 10 # 1e-6/A^2 = 1/A^3 1 fm 1e-5 A/fm 1e6 1e-6
1114
1115 # Compute absorption cross section (barn)
1116 # Note: Sears (1992) uses b = b' - i b'', so use |Im(b_c)| for sigma_a.
1117 sigma_a = 2000 * abs(b_c.imag) * wavelength # 1 barn = 1 fm 1 A 1e5 A/fm 1e-2 barn/fm
1118
1119 # print(f"σ_a {sigma_c:.3f} σ_i {sigma_i:.3f} σ_s {sigma_s:.3f} σ_a {sigma_a:.3f}")
1120
1121 # Compute macroscopic scattering cross section per unit volume (1/cm)
1122 total_xs = number_density * sigma_s # 1/cm = 1/A^3 1 barn 1e-8 A^2/barn 1e8 A/cm
1123 coh_xs = number_density * sigma_c
1124 abs_xs = number_density * sigma_a
1125 inc_xs = number_density * sigma_i
1126
1127 # Compute 1/e length (cm)
1128 penetration = 1/(abs_xs + total_xs) # 1 cm = 1 / (1/cm)
1129
1130 return (sld_re, sld_im, sld_inc), (coh_xs, abs_xs, inc_xs), penetration
1131
1132
1133 def neutron_sld(*args, **kw):
1134 r"""
1135 Computes neutron scattering length densities for molecules.
1136
1137 :Parameters:
1138 *compound* \: Formula initializer
1139 Chemical formula
1140 *density* \: float | |g/cm^3|
1141 Mass density
1142 *natural_density* \: float | |g/cm^3|
1143 Mass density of formula with naturally occuring abundances
1144 *wavelength* \: float | |Ang|
1145 Neutron wavelength (default=1.798 |Ang|).
1146 *energy* \: float | meV
1147 Neutron energy. If energy is specified then wavelength is ignored.
1148 *table* \: PeriodicTable
1149 Alternate table to use when parsing *compound*.
1150 :Returns:
1151 *sld* \: (float, float, float) | |1e-6/Ang^2|
1152 (*real*, -*imaginary*, *incoherent*) scattering length density.
1153
1154 :Raises:
1155 *AssertionError* \: density is missing.
1156
1157 Returns the scattering length density of the compound.
1158 See :func:`neutron_scattering` for details.
1159 """
1160 return neutron_scattering(*args, **kw)[0]
1161
1162 def neutron_sld_from_atoms(*args, **kw):
1163 r"""
1164 .. deprecated:: 0.91
1165
1166 :func:`neutron_sld` accepts dictionaries of \{atom\: count\}.
1167
1168 """
1169 return neutron_scattering(*args, **kw)[0]
1170
1171
1172 def D2O_match(compound, **kw):
1173 """
1174 Find the D2O contrast match point for the compound.
1175
1176 *wavelength* or *energy* select neutron wavelength or energy.
1177
1178 Additional keyword arguments (*density*, *natural_density*, *name*, *table*)
1179 are passed to :func:`formulas.formula` when parsing the compound.
1180
1181 Returns *D2O_fraction* and *SLD* at match point.
1182
1183 See :func:`D2O_sld` for details on the calculation.
1184
1185 Note that the resulting fraction is only meaningful in [0, 1]. Beyond
1186 100% you will need an additional constrast agent in the 100% D2O
1187 solvent to increase the SLD enough to match.
1188 """
1189 H2O_sld, D2O_sld, Hsld, Dsld = _D2O_slds(compound, **kw)
1190 # SLD(%Dsample + (1-%)Hsample) = SLD(%D2O + (1-%)H2O)
1191 # => %SLD(Dsample) + (1-%)SLD(Hsample) = %SLD(D2O) + (1-%)SLD(H2O)
1192 # => %(SLD(Dsample) - SLD(Hsample) + SLD(H2O) - SLD(D2O))
1193 # = SLD(H2O) - SLD(Hsample)
1194 # => % = 100*(SLD(H2O) - SLD(Hsample))
1195 # / (SLD(Dsample) - SLD(Hsample) + SLD(H2O) - SLD(D2O))
1196 D2O_fraction = (
1197 (H2O_sld[0] - Hsld[0]) / (Dsld[0] - Hsld[0] + H2O_sld[0] - D2O_sld[0]))
1198
1199 match_point_sld = mix_values(Dsld, Hsld, D2O_fraction)
1200 return D2O_fraction, match_point_sld[0]
1201
1202 def D2O_sld(compound, volume_fraction=1., D2O_fraction=0., **kw):
1203 """
1204 Compute the neutron SLD for a D2O contrast solution.
1205
1206 *compound* is a string or parsed formula object. Labile hydrogen should
1207 be marked as H[1] in the formula. These will be substituted according to
1208 %D2O in the solvent.
1209
1210 The D2O contrast mixture is assumed to be made using pure H2O (with
1211 its natural H:D ratios) and pure D2O with no H present, so H[1] will be
1212 substituted alternately with H and D when computing mixture SLD.
1213 Solvent SLD is calculated using the density at 20 C.
1214
1215 Only the coherent scattering crosssection will be matched. Incoherent
1216 and absorption crosssections are likely to be different for the compound
1217 and the solvent, especially due to the large incoherent crosssection for
1218 hydrogen.
1219
1220 Note that incoherent scattering does not mix linearly, so the incoherent
1221 sld for the mixture will differ slightly from incoherent scattering
1222 computed returned from a compound with the same isotope ratios.
1223
1224 *volume_fraction* is the portion by volume of solute in the solution.
1225
1226 *D2O_fraction* is the portion by volume of D2O in the solvent.
1227
1228 *wavelength* or *energy* to select neutron wavelength or energy.
1229
1230 Additional keyword arguments (*density*, *natural_density*, *name*, *table*)
1231 are passed to :func:`formulas.formula` when parsing the compound.
1232
1233 Returns (real, imag, incoh) SLD.
1234 """
1235 # TODO: fix incoherent scattering so it is consistent with compound
1236 # Need to compute sld from mixture rather than mixing parts
1237 H2O_sld, D2O_sld, Hsld, Dsld = _D2O_slds(compound, **kw)
1238 solvent_sld = mix_values(D2O_sld, H2O_sld, D2O_fraction)
1239 solute_sld = mix_values(Dsld, Hsld, D2O_fraction)
1240 solution_sld = mix_values(solute_sld, solvent_sld, volume_fraction)
1241 #print(D2O_fraction, volume_fraction)
1242 #print(compound, "solvent", solvent_sld)
1243 #print(compound, "solute", solute_sld)
1244 #print(compound, "solution", solution_sld)
1245 return solution_sld
1246
1247
1248 def _D2O_slds(compound, **kw):
1249 from . import formulas
1250
1251 # Water density at 20C; neutron wavelength doesn't matter.
1252 sld_args = dict(
1253 wavelength=kw.pop("wavelength", None),
1254 energy=kw.pop("energy", None),
1255 # Note: using get() rather than pop() for table since table can be a
1256 # parameter for formula and for neutron_sld (which calls formula)
1257 table=kw.get('table', None),
1258 )
1259 # TODO: use same table for solvent as solute?
1260 H2O_sld = neutron_sld("[email protected]", **sld_args)
1261 D2O_sld = neutron_sld("[email protected]", **sld_args)
1262 mol = formulas.formula(compound, **kw)
1263 # Be sure to pull H and H[1] from the table for the compound, otherwise
1264 # the elements may not match in the substitution.
1265 # TODO: include table in compound so parsed
1266 table = default_table(kw.get('table', None))
1267 labile_H, H, D = table.H[1], table.H, table.D
1268 Hsld = neutron_sld(mol.replace(labile_H, H), **sld_args)
1269 Dsld = neutron_sld(mol.replace(labile_H, D), **sld_args)
1270
1271 return H2O_sld, D2O_sld, Hsld, Dsld
1272
1273
1274 def mix_values(a, b, fraction):
1275 """
1276 Mix two tuples with floating point values according to fraction of a.
1277 """
1278 return tuple(aj*fraction + bj*(1-fraction) for aj, bj in zip(a, b))
1279
1280
1281 def _sum_piece(wavelength, compound):
1282 """
1283 Helper for neutron_composite_sld which precomputes quantities of interest
1284 for material fragments in a composite formula.
1285 """
1286 # Sum over the quantities.
1287 molar_mass = num_atoms = 0
1288 b_c = sigma_s = 0
1289 for element, quantity in compound.atoms.items():
1290 molar_mass += element.mass*quantity
1291 num_atoms += quantity
1292 b_ck, sigma_sk = element.neutron.scattering_by_wavelength(wavelength)
1293 b_c += quantity * b_ck
1294 sigma_s += quantity * sigma_sk
1295
1296 return num_atoms, molar_mass, b_c, sigma_s
1297
1298 # TODO: compute density from material densities if requested
1299 # You ought to be able to use mixby="mass" or "volume" when creating the
1300 # calculator, and ignore any density provided.
1301 def neutron_composite_sld(materials, wavelength=ABSORPTION_WAVELENGTH):
1302 r"""
1303 Create a composite SLD calculator.
1304
1305 :Parameters:
1306 *materials* \: [Formula]
1307 List of materials
1308 *wavelength* = 1.798: float OR [float] | |Ang|
1309 Probe wavelength(s).
1310
1311 :Returns:
1312 *calculator* \: f(w, density=1) -> (*real*, -*imaginary*, *incoherent*)
1313
1314 The composite calculator takes a vector of weights and returns the
1315 scattering length density of the composite. This is useful for operations
1316 on large molecules, such as calculating a set of contrasts or fitting
1317 a material composition. Note that density must be provided for each set
1318 of material weights. The density on the individual materials is ignored.
1319
1320 The returned slds will be vectors if the input wavelength is a vector
1321 and if any of the elements are energy dependent.
1322
1323 Table lookups and partial sums and constants are precomputed so that
1324 the calculation consists of a few simple array operations regardless
1325 of the size of the material fragments.
1326 """
1327 # Input may be a scalar or a sequence. If it is a sequence, turn it into
1328 # an array before proceeding. If it is a scalar leave it as a scalar so
1329 # that float input returns float output.
1330 is_multi = not np.isscalar(wavelength)
1331 if is_multi:
1332 wavelength = np.asarray(wavelength)
1333 # Query all parts of the composition
1334 parts = [_sum_piece(wavelength, m) for m in materials]
1335 num_atoms_parts, molar_mass_parts, bc_parts, sigma_parts = [
1336 np.array(v) for v in zip(*parts)
1337 ]
1338
1339 #for name, v in zip("N mass bc b'' total".split(), V): print(name, v)
1340 def _compute(weights, density=1):
1341 multiweights = weights[:, None] if is_multi else weights
1342 # Sum over the quantities
1343 molar_mass = np.sum(weights*molar_mass_parts)
1344 num_atoms = np.sum(weights*num_atoms_parts)
1345 b_c = np.sum(multiweights*bc_parts, axis=0)
1346 sigma_s = np.sum(multiweights*sigma_parts, axis=0)
1347
1348 # If nothing to sum, return values for a vacuum. This might be because
1349 # the material has no atoms or it might be because the density is zero.
1350 if molar_mass*density == 0:
1351 return 0, 0, 0
1352
1353 # Compute number density (1/A^3)
1354 cell_volume = (molar_mass/density)/avogadro_number*1e24
1355 number_density = num_atoms / cell_volume
1356 #print("in compute", b_c, number_density)
1357
1358 # Turn sums into scattering factors
1359 b_c /= num_atoms
1360 sigma_s /= num_atoms
1361
1362 # TODO: duplicated from _calculate_scattering
1363 # Compute SLD (1e-6/A^2). Extending Sears (1992) convention, b = b' - i b'',
1364 # returning sld = sld_re - i sld_im.
1365 sld = 10*number_density * b_c # 1e-6/A^2 = 1/A^3 1 fm 1e-5 A/fm 1e6 1e-6
1366 sld_re, sld_im = sld.real, abs(sld.imag)
1367
1368 # PAK 2017-04-21: compute incoherent xs from total xs
1369 # PAK 2021-04-20: include imaginary b_c in coherent cross section
1370 sigma_c = _4PI_100 * abs(b_c)**2 # 1 barn = 1e-2 fm^2
1371 sigma_i = np.maximum(sigma_s - sigma_c, 0.) # 1 barn = 1 barn
1372 b_i = sqrt(sigma_i / _4PI_100) # 1 fm = sqrt(1 barn * 1e-2 fm^2/barn)
1373 sld_inc = number_density * b_i * 10 # 1e-6/A^2 = 1/A^3 1 fm 1e-5 A/fm 1e6 1e-6
1374
1375 return sld_re, sld_im, sld_inc
1376
1377 return _compute
1378
1379
1380 def sld_plot(table: PeriodicTable|None=None) -> None:
1381 r"""
1382 Plots SLD as a function of element number.
1383
1384 :Parameters:
1385 *table* \: PeriodicTable
1386 The default periodictable unless a specific table has been requested.
1387
1388 :Returns: None
1389 """
1390 from .plot import table_plot
1391
1392 table = default_table(table)
1393
1394 def sld_re(atom) -> float:
1395 sld = atom.neutron.sld()
1396 return sld[0]
1397
1398 SLDs: dict[Atom, float] = {el: sld_re(el) for el in table if el.neutron.has_sld()}
1399 SLDs[table.D] = sld_re(table.D)
1400
1401 table_plot(SLDs, label='Scattering length density ($10^{-6}$ Nb)',
1402 title='Neutron SLD for elements in natural abundance')
1403
1404
1405 # We are including the complete original table here in case somebody in
1406 # future wants to extract uncertainties or other information.
1407 #
1408 # Z-Symbol-A
1409 # This is the atomic number, the symbol and the isotope.
1410 # If Z-Symbol only, the line represents an element with scattering determined
1411 # by the natural abundance of the isotopes in laboratory samples. If there
1412 # is only one isotope, then there is no corresponding element definition.
1413 # concentration/half-life
1414 # This is the natural abundance of the isotope expressed as a percentage, or
1415 # it is the half-life in years (number Y) or seconds (number S).
1416 # spin I
1417 # For isotopes, the nuclear spin.
1418 # b_c, bp, bm
1419 # Bound coherent scattering length in fm
1420 # b+/b- if present are spin dependent scattering for I+1/2 and I-1/2
1421 # respectively
1422 # c
1423 # 'E' if there is a strong energy dependency.
1424 # '+/-' if separate b+/b- values are available [PAK: doesn't seem true]
1425 # coherent, incoherent, total
1426 # The coherent and incoherent scattering cross-sections in barns.
1427 # absorption
1428 # The thermal absorption cross section in barns at 1.798 A; 25.30 meV; 2200 m/s
1429 #
1430 # Numbers in parenthesis represents uncertainty.
1431 # Numbers followed by '*' are estimated.
1432 # Numbers may be given as limit, e.g., <1.0e-6
1433 #
1434 # Changes to the table are listed in the docstring at the top of the file.
1435
1436 # TODO: check isotope spin; some of them were wrong.
1437 # TODO: add missing b+, b- to table using b_i values from Sears table
1438 # Tables for Crystallography Ch. 4 defines b_i for the following isotopes which
1439 # are missing b+, b- entries (though many of them with 100% uncertainty). Otherwise
1440 # we need to invert.
1441 #
1442 # Using the b_coh and b_inc defined as:
1443 # b_c = ((I+1) b+ + I b-) / (2I+1)
1444 # b_i = sqrt(I(I+1)) (b+ - b-) / (2I+1)
1445 # and solving for b+, b- gives:
1446 # b+ = b_c + b_i I / sqrt(I(I+1)) = b_c + b_i sqrt(I/(I+1))
1447 # b- = b_c - b_i (I+1) / sqrt(I(I+1)) = b_c - b_i sqrt((I+1)/I)
1448 # The square root fails if spin is negative, which is the case for some isotopes.
1449 #
1450 # Those with b_i > 0 (so positive branch of sqrt when inverting incoherent)
1451 # 9Be 21Ne 31P 33S 40,41K 43Ca 50V 57Fe 61Si 63Cu 65Cu 77Se 81Br 85,87Rb
1452 # 87Sr 113In 115Sn 133Cs 135,137Ba 138La 143,145Nd 147Pm 147Sm 153Eu 161Dy 175Lu
1453 # 177Hf 179Hf 185,187Re 189Os 207Pb 233,235U 239Pu
1454 # Those with b_i < 0 (so negative branch of sqrt when inverting incoherent)
1455 # 79Br 141Pr 169Tm 181Ta 187Os
1456 # Those with b_c and b_i complex (don't know what this means)
1457 # 149Sm 151Eu 155,157Gd 176Lu
1458 # Those with b_i unknown:
1459 # 95,97Mo 99Tc 99,101Ru 105Pd 111,113Cd 231Pa 237Np 243Am
1460 nsftable = """\
1461 0-n-1,618 S,1/2,-37.0(6),0,-37.0(6),,43.01(2),,43.01(2),0
1462 1-H,,,-3.7409(11),,,,1.7568(10),80.26(6),82.02(6),0.3326(7)
1463 1-H-1,99.985,1/2,-3.7395(11),10.817(5),-47.420(14),+/-,1.7583(10),80.27(6),82.03(6),0.3326(7)
1464 1-H-2,0.0149,1,6.6681(27),9.53(3),0.975(60),,5.592(7),2.05(3),7.64(3),0.000519(7)
1465 1-H-3,12.26 Y,1/2,4.792(27),4.18(15),6.56(37),,2.89(3),0.14(4),3.03(5),<6.0E-6
1466 2-He,,,3.0985(21),,,,1.2065(16),0,1.2065(16),0.00747(1)
1467 2-He-3,0.013,1/2,5.74(7),4.7(5),8.8(1.4),E,4.42(10),1.6(4),6.0(4),5333.0(7.0)
1468 2-He-4,99.987,0,3.0982(21),,,,1.2062(16),0,1.2062(16),0
1469 3-Li,,,-1.93(2),,,,0.454(10),0.92(3),1.37(3),70.5(3)
1470 3-Li-6,7.5,1,2.27(2),0.67(14),4.67(17),+/-,0.51(5),0.46(5),0.97(7),940.0(4.0)
1471 3-Li-7,92.5,3/2,-2.28(4),-4.15(6),1.00(8),+/-,0.619(11),0.78(3),1.40(3),0.0454(3)
1472 4-Be-9,100,3/2,7.79(1),,,,7.63(2),0.0018(9),7.63(2),0.0076(8)
1473 5-B,,,5.30(4),,,,3.54(5),1.70(12),5.24(11),767.0(8.0)
1474 5-B-10,19.4,3,-0.2(4),-4.2(4),5.2(4),,0.144(6),3.0(4),3.1(4),3835.0(9.0)
1475 5-B-11,80.2,3/2,6.65(4),5.6(3),8.3(3),,5.56(7),0.21(7),5.77(10),0.0055(33)
1476 6-C,,,6.6472(9),,,,5.551(2),0.001(4),5.551(3),0.00350(7)
1477 6-C-12,98.89,0,6.6535(14),,,,5.559(3),0,5.559(3),0.00353(7)
1478 6-C-13,1.11,1/2,6.542(3),6.30(14),7.27(42),+/-,4.81(14),0.022(20),4.84(14),0.00137(4)
1479 7-N,,,9.36(2),,,,11.01(5),0.50(12),11.51(11),1.90(3)
1480 7-N-14,99.635,1,9.37(2),10.7(2),6.2(3),,11.03(5),0.50(12),11.53(11),1.91(3)
1481 7-N-15,0.365,1/2,6.44(3),6.77(10),6.21(10),,5.21(5),0.00005(10),5.21(5),0.000024(8)
1482 8-O,,,5.8037(29),,,,4.232(6),0.000(8),4.232(6),0.00019(2)
1483 8-O-16,99.75,0,5.805(5),,,,4.232(6),0,4.232(6),0.00010(2)
1484 8-O-17,0.039,5/2,5.867(4),5.52(20),5.17(20),,4.20(22),0.004(3),4.20(22),0.236(10)
1485 8-O-18,0.208,0,6.009(5),,,,4.29(10),0,4.29(10),0.00016(1)
1486 9-F-19,100,1/2,5.654(12),5.632(10),5.767(10),+/-,4.017(14),0.0008(2),4.018(14),0.0096(5)
1487 10-Ne,,,4.566(6),,,,2.620(7),0.008(9),2.628(6),0.039(4)
1488 10-Ne-20,90.5,0,4.631(6),,,,2.695(7),0,2.695(7),0.036(4)
1489 10-Ne-21,0.27,3/2,6.66(19),,,,5.6(3),0.05(2),5.7(3),0.67(11)
1490 10-Ne-22,9.2,0,3.87(1),,,,1.88(1),0,1.88(1),0.046(6)
1491 11-Na-23,100,3/2,3.63(2),6.42(4),-1.00(6),+/-,1.66(2),1.62(3),3.28(4),0.530(5)
1492 12-Mg,,,5.375(4),,,,3.631(5),0.08(6),3.71(4),0.063(3)
1493 12-Mg-24,78.99,0,5.49(18),,,,4.03(4),0,4.03(4),0.050(5)
1494 12-Mg-25,10,5/2,3.62(14),4.73(30),1.76(20),+/-,1.65(13),0.28(4),1.93(14),0.19(3)
1495 12-Mg-26,11,0,4.89(15),,,,3.00(18),0,3.00(18),0.0382(8)
1496 13-Al-27,100,5/2,3.449(5),3.67(2),3.15(2),,1.495(4),0.0082(6),1.503(4),0.231(3)
1497 14-Si,,,4.15071(22),,,,2.1633(10),0.004(8),2.167(8),0.171(3)
1498 14-Si-28,92.2,0,4.106(6),,,,2.120(6),0,2.120(6),0.177(3)
1499 14-Si-29,4.7,1/2,4.7(1),4.50(15),4.7(4),+/-,2.78(12),0.001(2),2.78(12),0.101(14)
1500 14-Si-30,3.1,0,4.58(8),,,,2.64(9),0,2.64(9),0.107(2)
1501 15-P-31,100,1/2,5.13(1),,,+/-,3.307(13),0.005(10),3.312(16),0.172(6)
1502 16-S,,,2.847(1),,,,1.0186(7),0.007(5),1.026(5),0.53(1)
1503 16-S-32,95,0,2.804(2),,,,0.9880(14),0,0.9880(14),0.54(4)
1504 16-S-33,0.74,3/2,4.74(19),,,+/-,2.8(2),0.3(6),3.1(6),0.54(4)
1505 16-S-34,4.2,0,3.48(3),,,,1.52(3),0,1.52(3),0.227(5)
1506 16-S-36,0.02,0,3.0(1.0)*,,,,1.1(8),0,1.1(8),0.15(3)
1507 17-Cl,,,9.5792(8),,,,11.528(2),5.3(5),16.8(5),33.5(3)
1508 17-Cl-35,75.77,3/2,11.70(9),16.3(2),4.0(3),+/-,17.06(6),4.7(6),21.8(6),44.1(4)
1509 17-Cl-37,24.23,3/2,3.08(6),3.10(7),3.05(7),+/-,1.19(5),0.001(3),1.19(5),0.433(6)
1510 18-Ar,,,1.909(6),,,,0.458(3),0.225(5),0.683(4),0.675(9)
1511 18-Ar-36,0.34,0,24.9(7),,,,77.9(4),0,77.9(4),5.2(5)
1512 18-Ar-38,0.07,0,3.5(3.5),,,,1.5(3.1),0,1.5(3.1),0.8(5)
1513 18-Ar-40,99.59,0,1.7,,,,0.421(3),0,0.421(3),0.660(9)
1514 19-K,,,3.67(2),,,,1.69(2),0.27(11),1.96(11),2.1(1)
1515 19-K-39,93.3,3/2,3.79(2),5.15,1.51,+/-,1.76(2),0.25(11),2.01(11),2.1(1)
1516 19-K-40,0.012,4,3.1(1.0)*,,,,1.1(6),0.5(5)*,1.6(9),35.0(8.0)
1517 19-K-41,6.7,3/2,2.69(8),,,,0.91(5),0.3(6),1.2(6),1.46(3)
1518 20-Ca,,,4.70(2),,,,2.78(2),0.05(3),2.83(2),0.43(2)
1519 20-Ca-40,96.94,0,4.78(5),,,,2.90(2),0,2.90(2),0.41(2)
1520 20-Ca-42,0.64,0,3.36(10),,,,1.42(8),0,1.42(8),0.68(7)
1521 20-Ca-43,0.13,7/2,-1.56(9),,,,0.31(4),0.5(5),0.8(5),6.2(6)
1522 20-Ca-44,2.13,0,1.42(6),,,,0.25(2),0,0.25(2),0.88(5)
1523 20-Ca-46,0.003,0,3.55(21),,,,1.6(2),0,1.6(2),0.74(7)
1524 20-Ca-48,0.18,0,0.39(9),,,,0.019(9),0,0.019(9),1.09(14)
1525 21-Sc-45,100,7/2,12.1(1),6.91(22),18.99(28),+/-,19.0(3),4.5(3),23.5(6),27.5(2)
1526 22-Ti,,,-3.370(13),,,,1.485(2),2.87(3),4.35(3),6.09(13)
1527 22-Ti-46,8,0,4.72(5),,,,3.05(7),0,3.05(7),0.59(18)
1528 22-Ti-47,7.5,5/2,3.53(7),0.46(23),7.64(13),,1.66(11),1.5(2),3.2(2),1.7(2)
1529 22-Ti-48,73.7,0,-5.86(2),,,,4.65(3),0,4.65(3),7.84(25)
1530 22-Ti-49,5.5,7/2,0.98(5),2.6(3),-1.2(4),,0.14(1),3.3(3),3.4(3),2.2(3)
1531 22-Ti-50,5.3,0,5.88(10),,,,4.80(12),0,4.80(12),0.179(3)
1532 23-V,,,-0.443(14),,,,0.01838(12),5.08(6),5.10(6),5.08(4)
1533 23-V-50,0.25,6,7.6(6)*,,,,7.3(1.1),0.5(5)*,7.8(1.0),60.0(40.0)
1534 23-V-51,99.75,7/2,-0.402(2),4.93(25),-7.58(28),+/-,0.0203(2),5.07(6),5.09(6),4.9(1)
1535 24-Cr,,,3.635(7),,,,1.660(6),1.83(2),3.49(2),3.05(6)
1536 24-Cr-50,4.35,0,-4.50(5),,,,2.54(6),0,2.54(6),15.8(2)
1537 24-Cr-52,83.8,0,4.914(15),,,,3.042(12),0,3.042(12),0.76(6)
1538 24-Cr-53,9.59,3/2,-4.20(3),1.16(10),-13.0(2),,2.22(3),5.93(17),8.15(17),18.1(1.5)
1539 24-Cr-54,2.36,0,4.55(10),,,,2.60(11),0,2.60(11),0.36(4)
1540 25-Mn-55,100,5/2,-3.750(18),-4.93(46),-1.46(33),,1.75(2),0.40(2),2.15(3),13.3(2)
1541 26-Fe,,,9.45(2),,,,11.22(5),0.40(11),11.62(10),2.56(3)
1542 26-Fe-54,5.8,0,4.2(1),,,,2.2(1),0,2.2(1),2.25(18)
1543 26-Fe-56,91.7,0,10.1(2),,,,12.42(7),0,12.42(7),2.59(14)
1544 26-Fe-57,2.19,1/2,2.3(1),,,,0.66(6),0.3(3)*,1.0(3),2.48(30)
1545 26-Fe-58,0.28,0,15(7),,,,28.0(26.0),0,28.0(26.0),1.28(5)
1546 27-Co-59,100,7/2,2.49(2),-9.21(10),3.58(10),+/-,0.779(13),4.8(3),5.6(3),37.18(6)
1547 28-Ni,,,10.3(1),,,,13.3(3),5.2(4),18.5(3),4.49(16)
1548 28-Ni-58,67.88,0,14.4(1),,,,26.1(4),0,26.1(4),4.6(3)
1549 28-Ni-60,26.23,0,2.8(1),,,,0.99(7),0,0.99(7),2.9(2)
1550 28-Ni-61,1.19,3/2,7.60(6),,,,7.26(11),1.9(3),9.2(3),2.5(8)
1551 28-Ni-62,3.66,0,-8.7(2),,,,9.5(4),0,9.5(4),14.5(3)
1552 28-Ni-64,1.08,0,-0.37(7),,,,0.017(7),0,0.017(7),1.52(3)
1553 29-Cu,,,7.718(4),,,,7.485(8),0.55(3),8.03(3),3.78(2)
1554 29-Cu-63,69.1,3/2,6.477(13),,,+/-,5.2(2),0.006(1),5.2(2),4.50(2)
1555 29-Cu-65,30.9,3/2,10.204(20),,,+/-,14.1(5),0.40(4),14.5(5),2.17(3)
1556 30-Zn,,,5.680(5),,,,4.054(7),0.077(7),4.131(10),1.11(2)
1557 30-Zn-64,48.9,0,5.23(4),,,,3.42(5),0,3.42(5),0.93(9)
1558 30-Zn-66,27.8,0,5.98(5),,,,4.48(8),0,4.48(8),0.62(6)
1559 30-Zn-67,4.1,5/2,7.58(8),5.8(5),10.1(7),+/-,7.18(15),0.28(3),7.46(15),6.8(8)
1560 30-Zn-68,18.6,0,6.04(3),,,,4.57(5),0,4.57(5),1.1(1)
1561 30-Zn-70,0.62,0,6.0(1.0)*,,,,4.5(1.5),0,4.5(1.5),0.092(5)
1562 31-Ga,,,7.288(2),,,,6.675(4),0.16(3),6.83(3),2.75(3)
1563 31-Ga-69,60,3/2,8.043(16),6.3(2),10.5(4),+/-,7.80(4),0.091(11),7.89(4),2.18(5)
1564 31-Ga-71,40,3/2,6.170(11),5.5(6),7.8(1),+/-,5.15(5),0.084(8),5.23(5),3.61(10)
1565 32-Ge,,,8.185(20),,,,8.42(4),0.18(7),8.60(6),2.20(4)
1566 32-Ge-70,20.7,0,10.0(1),,,,12.6(3),0,12.6(3),3.0(2)
1567 32-Ge-72,27.5,0,8.51(10),,,,9.1(2),0,9.1(2),0.8(2)
1568 32-Ge-73,7.7,9/2,5.02(4),8.1(4),1.2(4),,3.17(5),1.5(3),4.7(3),15.1(4)
1569 32-Ge-74,36.4,0,7.58(10),,,,7.2(2),0,7.2(2),0.4(2)
1570 32-Ge-76,7.7,0,8.2(1.5),,,,8.0(3.0),0,8.0(3.0),0.16(2)
1571 33-As-75,100,3/2,6.58(1),6.04(5),7.47(8),+/-,5.44(2),0.060(10),5.50(2),4.5(1)
1572 34-Se,,,7.970(9),,,,7.98(2),0.32(6),8.30(6),11.7(2)
1573 34-Se-74,0.9,0,0.8(3.0),,,,0.1(6),0,0.1(6),51.8(1.2)
1574 34-Se-76,9,0,12.2(1),,,,18.7(3),0,18.7(3),85.0(7.0)
1575 34-Se-77,7.5,-1/2,8.25(8),,,,8.6(2),0.05(25),8.65(16),42.0(4.0)
1576 34-Se-78,23.5,0,8.24(9),,,,8.5(2),0,8.5(2),0.43(2)
1577 34-Se-80,50,0,7.48(3),,,,7.03(6),0,7.03(6),0.61(5)
1578 34-Se-82,8.84,0,6.34(8),,,,5.05(13),0,5.05(13),0.044(3)
1579 35-Br,,,6.79(2),,,,5.80(3),0.10(9),5.90(9),6.9(2)
1580 35-Br-79,50.49,3/2,6.79(7),,,+/-,5.81(2),0.15(6),5.96(13),11.0(7)
1581 35-Br-81,49.31,3/2,6.78(7),,,+/-,5.79(12),0.05(2),5.84(12),2.7(2)
1582 36-Kr,,,7.81(2),,,,7.67(4),0.01(14),7.685(26),25.0(1.0)
1583 36-Kr-78,0.35,0,,,,,,0,,6.4(9)
1584 36-Kr-80,2.5,0,,,,,,0,,11.8(5)
1585 36-Kr-82,11.6,0,,,,,,0,,29.0(20.0)
1586 36-Kr-83,11.5,9/2,,,,,,,,185.0(30.0)
1587 36-Kr-84,57,0,,,,,,0,6.6,0.113(15)
1588 36-Kr-86,17.3,0,8.07(26),,,,8.2(4),0,8.2(4),0.003(2)
1589 37-Rb,,,7.08(2),,,,6.32(4),0.5(4),6.8(4),0.38(1)
1590 37-Rb-85,72.17,5/2,7.07(10),,,,6.2(2),0.5(5)*,6.7(5),0.48(1)
1591 37-Rb-87,27.83,3/2,7.27(12),,,,6.6(2),0.5(5)*,7.1(5),0.12(3)
1592 38-Sr,,,7.02(2),,,,6.19(4),0.06(11),6.25(10),1.28(6)
1593 38-Sr-84,0.56,0,5.0(2.0),,,,6.0(2.0),0,6.0(2.0),0.87(7)
1594 38-Sr-86,9.9,0,5.68(5),,,,4.04(7),0,4.04(7),1.04(7)
1595 38-Sr-87,7,9/2,7.41(7),,,,6.88(13),0.5(5)*,7.4(5),16.0(3.0)
1596 38-Sr-88,82.6,0,7.16(6),,,,6.42(11),0,6.42(11),0.058(4)
1597 39-Y-89,100,1/2,7.75(2),8.4(2),5.8(5),+/-,7.55(4),0.15(8),7.70(9),1.28(2)
1598 40-Zr,,,7.16(3),,,,6.44(5),0.02(15),6.46(14),0.185(3)
1599 40-Zr-90,51.48,0,6.5(1),,,,5.1(2),0,5.1(2),0.011(5)
1600 40-Zr-91,11.23,5/2,8.8(1),7.9(2),10.1(2),+/-,9.5(2),0.15(4),9.7(2),1.17(10)
1601 40-Zr-92,17.11,0,7.5(2),,,,6.9(4),0,6.9(4),0.22(6)
1602 40-Zr-94,17.4,0,8.3(2),,,,8.4(4),0,8.4(4),0.0499(24)
1603 40-Zr-96,2.8,0,5.5(1),,,,3.8(1),0,3.8(1),0.0229(10)
1604 41-Nb-93,100,9/2,7.054(3),7.06(4),7.35(4),+/-,6.253(5),0.0024(3),6.255(5),1.15(6)
1605 42-Mo,,,6.715(20),,,,5.67(3),0.04(5),5.71(4),2.48(4)
1606 42-Mo-92,15.48,0,6.93(8),,,,6.00(14),0,6.00(14),0.019(2)
1607 42-Mo-94,9.1,0,6.82(7),,,,5.81(12),0,5.81(12),0.015(2)
1608 42-Mo-95,15.72,5/2,6.93(7),,,,6.00(10),0.5(5)*,6.5(5),13.1(3)
1609 42-Mo-96,16.53,0,6.22(6),,,,4.83(9),0,4.83(9),0.5(2)
1610 42-Mo-97,9.5,5/2,7.26(8),,,,6.59(15),0.5(5)*,7.1(5),2.5(2)
1611 42-Mo-98,23.78,0,6.60(7),,,,5.44(12),0,5.44(12),0.127(6)
1612 42-Mo-100,9.6,0,6.75(7),,,,5.69(12),0,5.69(12),0.4(2)
1613 43-Tc-99,210000 Y,9/2,6.8(3),,,,5.8(5),0.5(5)*,6.3(7),20.0(1.0)
1614 44-Ru,,,7.02(2),,,,6.21(5),0.4(1),6.6(1),2.56(13)
1615 44-Ru-96,5.8,0,,,,,,0,,0.28(2)
1616 44-Ru-98,1.9,0,,,,,,0,,<8.0
1617 44-Ru-99,12.7,5/2,,,,,,,,6.9(1.0)
1618 44-Ru-100,12.6,0,,,,,,0,,4.8(6)
1619 44-Ru-101,17.07,5/2,,,,,,,,3.3(9)
1620 44-Ru-102,31.61,0,,,,,,0,,1.17(7)
1621 44-Ru-104,18.58,0,,,,,,0,,0.31(2)
1622 45-Rh-103,100,1/2,5.90(4),8.15(6),6.74(6),,4.34(6),0.3(3)*,4.6(3),144.8(7)
1623 46-Pd,,,5.91(6),,,,4.39(9),0.093(9),4.48(9),6.9(4)
1624 46-Pd-102,1,0,7.7(7)*,,,,7.5(1.4),0,7.5(1.4),3.4(3)
1625 46-Pd-104,11,0,7.7(7)*,,,,7.5(1.4),0,7.5(1.4),0.6(3)
1626 46-Pd-105,22.33,5/2,5.5(3),,,+/-,3.8(4),0.8(1.0),4.6(1.1),20.0(3.0)
1627 46-Pd-106,27.33,0,6.4(4),,,,5.1(6),0,5.1(6),0.304(29)
1628 46-Pd-108,26.71,0,4.1(3),,,,2.1(3),0,2.1(3),8.5(5)
1629 46-Pd-110,11.8,0,7.7(7)*,,,,7.5(1.4),0,7.5(1.4),0.226(31)
1630 47-Ag,,,5.922(7),,,,4.407(10),0.58(3),4.99(3),63.3(4)
1631 47-Ag-107,51.8,1/2,7.555(11),8.14(9),5.8(3),+/-,7.17(2),0.13(3),7.30(4),37.6(1.2)
1632 47-Ag-109,48.2,1/2,4.165(11),3.24(8),6.9(2),+/-,2.18(1),0.32(5),2.50(5),91.0(1.0)
1633 48-Cd,,,4.83(5),,,E,3.04(6),3.46(13),6.50(12),2520.0(50.0)
1634 48-Cd-106,1.2,0,5.0(2.0)*,,,,3.1(2.5),0,3.1(2.5),1.0(2.0)
1635 48-Cd-108,0.9,0,5.31(24),,,,3.7(1),0,3.7(1),1.1(3)
1636 48-Cd-110,12.39,0,5.78(8),,,,4.4(1),0,4.4(1),11.0(1.0)
1637 48-Cd-111,12.75,1/2,6.47(8),,,,5.3(2),0.3(3)*,5.6(4),24.0(5.0)
1638 48-Cd-112,24.07,0,6.34(6),,,,5.1(2),0,5.1(2),2.2(5)
1639 48-Cd-113,12.36,1/2,-8.0(1),,,E,12.1(4),0.3(3)*,12.4(5),20600.0(400.0)
1640 48-Cd-114,28.86,0,7.48(5),,,,7.1(2),0,7.1(2),0.34(2)
1641 48-Cd-116,7.58,0,6.26(9),,,,5.0(2),0,5.0(2),0.075(13)
1642 49-In,,,4.065(20),,,,2.08(2),0.54(11),2.62(11),193.8(1.5)
1643 49-In-113,4.28,9/2,5.39(6),,,,3.65(8),0.000037(5),3.65(8),12.0(1.1)
1644 49-In-115,95.72,9/2,4.00(3),2.1(1),6.4(4),,2.02(2),0.55(11),2.57(11),202.0(2.0)
1645 50-Sn,,,6.2239(13),,,,4.871(3),0.022(5),4.892(6),0.626(9)
1646 50-Sn-112,1,0,6.0(1.0)*,,,,4.5(1.5),0,4.5(1.5),1.00(11)
1647 50-Sn-114,0.66,0,6.0(3),,,,4.8(5),0,4.8(5),0.114(30)
1648 50-Sn-115,0.35,1/2,6.0(1.0)*,,,,4.5(1.5),0.3(3)*,4.8(1.5),30.0(7.0)
1649 50-Sn-116,14.3,0,6.10(1),,,,4.42(7),0,4.42(7),0.14(3)
1650 50-Sn-117,7.61,1/2,6.59(8),0.22(10),-0.23(10),,5.28(8),0.3(3)*,5.6(3),2.3(5)
1651 50-Sn-118,24.03,0,6.23(4),,,,4.63(8),0,4.63(8),0.22(5)
1652 50-Sn-119,8.58,1/2,6.28(3),0.14(10),0.0(1),,4.71(8),0.3(3)*,5.0(3),2.2(5)
1653 50-Sn-120,32.86,0,6.67(4),,,,5.29(8),0,5.29(8),0.14(3)
1654 50-Sn-122,4.72,0,5.93(3),,,,4.14(7),0,4.14(7),0.18(2)
1655 50-Sn-124,5.94,0,6.15(3),,,,4.48(8),0,4.48(8),0.133(5)
1656 51-Sb,,,5.57(3),,,,3.90(4),0.00(7),3.90(6),4.91(5)
1657 51-Sb-121,57.25,5/2,5.71(6),5.7(2),5.8(2),,4.10(9),0.0003(19),4.10(19),5.75(12)
1658 51-Sb-123,42.75,7/2,5.38(7),5.2(2),5.4(2),,3.64(9),0.001(4),3.64(9),3.8(2)
1659 52-Te,,,5.68(2),,,,4.23(4),0.09(6),4.32(5),4.7(1)
1660 52-Te-120,0.09,0,5.3(5),,,,3.5(7),0,3.5(7),2.3(3)
1661 52-Te-122,2.4,0,3.8(2),,,,1.8(2),0,1.8(2),3.4(5)
1662 52-Te-123,0.87,1/2,-0.05(25),-1.2(2),3.5(2),,0.002(3),0.52(5),0.52(5),418.0(30.0)
1663 52-Te-124,4.61,0,7.95(10),,,,8.0(2),0,8.0(2),6.8(1.3)
1664 52-Te-125,6.99,1/2,5.01(8),4.9(2),5.5(2),,3.17(10),0.008(8),3.18(10),1.55(16)
1665 52-Te-126,18.71,0,5.55(7),,,,3.88(10),0,3.88(10),1.04(15)
1666 52-Te-128,31.79,0,5.88(8),,,,4.36(10),0,4.36(10),0.215(8)
1667 52-Te-130,34.48,0,6.01(7),,,,4.55(11),0,4.55(11),0.29(6)
1668 53-I-127,100,5/2,5.28(2),6.6(2),3.4(2),,3.50(3),0.31(6),3.81(7),6.15(6)
1669 54-Xe,,,4.69(4),,,,3.04(4),0,4.344(17),23.9(1.2)
1670 54-Xe-124,0.1,0,,,,,,0,,165.0(20.0)
1671 54-Xe-126,0.09,0,,,,,,0,,3.5(8)
1672 54-Xe-128,1.9,0,,,,,,0,,<8.0
1673 54-Xe-129,26.14,1/2,,,,,,,,21.0(5.0)
1674 54-Xe-130,3.3,0,,,,,,0,,<26.0
1675 54-Xe-131,21.18,3/2,,,,,,,,85.0(10.0)
1676 54-Xe-132,26.89,0,,,,,,0,,0.45(6)
1677 54-Xe-134,10.4,0,,,,,,0,,0.265(20)
1678 54-Xe-136,8.9,0,,,,,,0,,0.26(2)
1679 55-Cs-133,100,7/2,5.42(2),,,+/-,3.69(15),0.21(5),3.90(6),29.0(1.5)
1680 56-Ba,,,5.07(3),,,,3.23(4),0.15(11),3.38(10),1.1(1)
1681 56-Ba-130,0.1,0,-3.6(6),,,,1.6(5),0,1.6(5),30.0(5.0)
1682 56-Ba-132,0.09,0,7.8(3),,,,7.6(6),0,7.6(6),7.0(8)
1683 56-Ba-134,2.4,0,5.7(1),,,,4.08(14),0,4.08(14),2.0(1.6)
1684 56-Ba-135,6.59,3/2,4.66(10),,,,2.74(12),0.5(5)*,3.2(5),5.8(9)
1685 56-Ba-136,7.81,0,4.90(8),,,,3.03(10),0,3.03(10),0.68(17)
1686 56-Ba-137,11.32,3/2,6.82(10),,,,5.86(17),0.5(5)*,6.4(5),3.6(2)
1687 56-Ba-138,71.66,0,4.83(8),,,,2.94(10),0,2.94(10),0.27(14)
1688 57-La,,,8.24(4),,,,8.53(8),1.13(19),9.66(17),8.97(2)
1689 57-La-138,0.09,5,8.0(2.0)*,,,,8.0(4.0),0.5(5)*,8.5(4.0),57.0(6.0)
1690 57-La-139,99.91,7/2,8.24(4),11.4(3),4.5(4),+/-,8.53(8),1.13(15),9.66(17),8.93(4)
1691 58-Ce,,,4.84(2),,,,2.94(2),0.00(10),2.94(10),0.63(4)
1692 58-Ce-136,0.19,0,5.76(9),,,,4.23(13),0,4.23(13),7.3(1.5)
1693 58-Ce-138,0.26,0,6.65(9),,,,5.64(15),0,5.64(15),1.1(3)
1694 58-Ce-140,88.48,0,4.81(9),,,,2.94(11),0,2.94(11),0.57(4)
1695 58-Ce-142,11.07,0,4.72(9),,,,2.84(11),0,2.84(11),0.95(5)
1696 59-Pr-141,100,5/2,4.44(4),,,+/-,2.64(6),0.015(3),2.66(6),11.5(3)
1697 60-Nd,,,7.87(11),,,,7.43(19),9.2(8),16.6(8),50.5(1.2)
1698 60-Nd-142,27.11,0,7.24(4),,,,7.5(6),0,7.5(6),18.7(7)
1699 60-Nd-143,12.17,7/2,17.51(6)*,,,,25.0(7.0),55.0(7.0),80.0(2.0),337.0(10.0)
1700 60-Nd-144,23.85,0,3.06(7),,,,1.0(2),0,1.0(2),3.6(3)
1701 60-Nd-145,8.5,7/2,10.40(12)*,,,,25.0(7.0),5.0(5.0)*,30.0(9.0),42.0(2.0)
1702 60-Nd-146,17.22,0,8.56(9),,,,9.5(4),0,9.5(4),1.4(1)
1703 60-Nd-148,5.7,0,4.44(13),,,,4.1(4),0,4.1(4),2.5(2)
1704 60-Nd-150,5.6,0,6.87(5),,,,3.5(3),0,3.5(3),1.2(2)
1705 61-Pm-147,2.62 Y,7/2,12.6(4),,,,20.0(1.3),1.3(2.0),21.3(1.5),168.4(3.5)
1706 62-Sm,,,0.00(5),,,E,0.422(9),39.0(3.0),39.4(3.0),5922.0(56.0)
1707 62-Sm-144,3.1,0,4.63(4)*,,,,1.0(3.0),0,1.0(3.0),0.7(3)
1708 62-Sm-147,15,7/2,6.68(5),,,,25.0(11.0),14.0(19.0),39.0(16.0),57.0(3.0)
1709 62-Sm-148,11.2,0,6.67(7)*,,,,1.0(3.0),0,1.0(3.0),2.4(6)
1710 62-Sm-149,13.8,7/2,17.84(28),,,E,63.5(6),137.0(5.0),200.0(5.0),42080.0(400.0)
1711 62-Sm-150,7.4,0,10.05(10),,,,25.0(11.0),0,25.0(11.0),104.0(4.0)
1712 62-Sm-152,26.7,0,-6.14(12),,,,3.1(8),0,3.1(8),206.0(6.0)
1713 62-Sm-154,22.8,0,9.34(9),,,,11.0(2.0),0,11.0(2.0),8.4(5)
1714 63-Eu,,,5.3(3),,,E,6.57(4),2.5(4),9.2(4),4530.0(40.0)
1715 63-Eu-151,47.8,5/2,6.92(15),,,E,5.5(2),3.1(4),8.6(4),9100.0(100.0)
1716 63-Eu-153,52.8,5/2,8.33(11),,,,8.5(2),1.3(7),9.8(7),312.0(7.0)
1717 64-Gd,,,9.5(2),,,E,29.3(8),151.0(2.0),180.0(2.0),49700.0(125.0)
1718 64-Gd-152,0.2,0,10.0(3.0)*,,,,13.0(8.0),0,13.0(8.0),735.0(20.0)
1719 64-Gd-154,2.2,0,10.0(3.0)*,,,,13.0(8.0),0,13.0(8.0),85.0(12.0)
1720 64-Gd-155,14.9,3/2,13.8(3),,,E,40.8(4),25.0(6.0),66.0(6.0),61100.0(400.0)
1721 64-Gd-156,20.6,0,6.3(4),,,,5.0(6),0,5.0(6),1.5(1.2)
1722 64-Gd-157,15.7,3/2,4.0(2.0),,,E,650.0(4.0),394.0(7.0),1044.0(8.0),259000.0(700.0)
1723 64-Gd-158,24.7,0,9.0(2.0),,,,10.0(5.0),0,10.0(5.0),2.2(2)
1724 64-Gd-160,21.7,0,9.15(5),,,,10.52(11),0,10.52(11),0.77(2)
1725 65-Tb-159,100,3/2,7.34(2),6.8(2),8.1(2),+/-,6.84(6),0.004(3),6.84(6),23.4(4)
1726 66-Dy,,,16.9(3),,,,35.9(8),54.4(1.2),90.3(9),994.0(13.0)
1727 66-Dy-156,0.06,0,6.1(5),,,,4.7(8),0,4.7(8),33.0(3.0)
1728 66-Dy-158,0.1,0,6.0(4.0)*,,,,5.0(6.0),0,5.(6.),43.0(6.0)
1729 66-Dy-160,2.3,0,6.7(4),,,,5.6(7),0,5.6(7),56.0(5.0)
1730 66-Dy-161,18.9,5/2,10.3(4),,,,13.3(1.0),3.0(1.0),16.0(1.0),600.0(25.0)
1731 66-Dy-162,25.5,0,-1.4(5),,,,0.25(18),0,0.25(18),194.0(10.0)
1732 66-Dy-163,24.9,5/2,5.0(4),6.1(5),3.5(5),,3.1(5),0.21(19),3.3(5),124.0(7.0)
1733 66-Dy-164,28.2,0,49.4(5),,,,307.0(3.0),0,307.0(3.0),2840.0(40.0)
1734 67-Ho-165,100,7/2,8.44(3),6.9(2),10.3(2),+/-,8.06(8),0.36(3),8.42(16),64.7(1.2)
1735 68-Er,,,7.79(2),,,,7.63(4),1.1(3),8.7(3),159.0(4.0)
1736 68-Er-162,0.14,0,9.01(11),,,,9.7(4),0,9.7(4),19.0(2.0)
1737 68-Er-164,1.6,0,7.95(14),,,,8.4(4),0,8.4(4),13.0(2.0)
1738 68-Er-166,33.4,0,10.51(19),,,,14.1(5),0,14.1(5),19.6(1.5)
1739 68-Er-167,22.9,7/2,3.06(5),5.3(3),0.0(3),,1.1(2),0.13(6),1.2(2),659.0(16.0)
1740 68-Er-168,27,0,7.43(8),,,,6.9(7),0,6.9(7),2.74(8)
1741 68-Er-170,15,0,9.61(6),,,,11.6(1.2),0,11.6(1.2),5.8(3)
1742 69-Tm-169,100,1/2,7.07(3),,,+/-,6.28(5),0.10(7),6.38(9),100.0(2.0)
1743 70-Yb,,,12.41(3),,,,19.42(9),4.0(2),23.4(2),34.8(8)
1744 70-Yb-168,0.14,0,-4.07(2),,,E,2.13(2),0,2.13(2),2230.0(40.0)
1745 70-Yb-170,3,0,6.8(1),,,,5.8(2),0,5.8(2),11.4(1.0)
1746 70-Yb-171,14.3,1/2,9.7(1),6.5(2),19.4(4),,11.7(2),3.9(2),15.6(3),48.6(2.5)
1747 70-Yb-172,21.9,0,9.5(1),,,,11.2(2),0,11.2(2),0.8(4)
1748 70-Yb-173,16.3,5/2,9.56(10),2.5(2),13.3(3),,11.5(2),3.5,15,17.1(1.3)
1749 70-Yb-174,31.8,0,22.02(7),,,,46.8(5),0,46.8(5),69.4(5.0)
1750 70-Yb-176,12.7,0,8.7(1),,,,9.6(2),0,9.6(2),2.85(5)
1751 71-Lu,,,7.21(3),,,,6.53(5),0.7(4),7.2(4),74.0(2.0)
1752 71-Lu-175,97.4,7/2,7.28(9),,,,6.59(5),0.6(4),7.2(4),21.0(3.0)
1753 71-Lu-176,2.6,7,6.1(2),,,,4.7(2),1.2(3),5.9,2065.(35.)
1754 72-Hf,,,7.77(14),,,,7.6(3),2.6(5),10.2(4),104.1(5)
1755 72-Hf-174,0.184,0,10.9(1.1),,,,15.0(3.0),0,15.0(3.0),561.0(35.0)
1756 72-Hf-176,5.2,0,6.61(18),,,,5.5(3),0,5.5(3),23.5(3.1)
1757 72-Hf-177,18.5,-7/2,0.8(1.0)*,,,,0.1(2),0.1(3),0.2(2),373.0(10.0)
1758 72-Hf-178,27.2,0,5.9(2),,,,4.4(3),0,4.4(3),84.0(4.0)
1759 72-Hf-179,13.8,9/2,7.46(16),,,,7.0(3),0.14(2),7.1(3),41.0(3.0)
1760 72-Hf-180,35.1,0,13.2(3),,,,21.9(1.0),0,21.9(1.0),13.04(7)
1761 73-Ta,,,6.91(7),,,,6.00(12),0.01(17),6.01(12),20.6(5)
1762 73-Ta-180,0.012,9,7.0(2.0)*,,,,6.2(3.5),0.5(5)*,7.0(4.0),563.0(60.0)
1763 73-Ta-181,99.98,7/2,6.91(7),,,+/-,6.00(12),0.011(2),6.01(12),20.5(5)
1764 74-W,,,4.755(18),,,,2.97(2),1.63(6),4.60(6),18.3(2)
1765 74-W-180,0.13,0,5.0(3.0)*,,,,3.0(4.0),0,3.0(4.0),30.0(20.0)
1766 74-W-182,26.3,0,7.04(4),,,,6.10(7),0,6.10(7),20.7(5)
1767 74-W-183,14.3,1/2,6.59(4),6.3(4),7.0(4),,5.36(7),0.3(3)*,5.7(3),10.1(3)
1768 74-W-184,30.7,0,7.55(6),,,,7.03(11),0,7.03(11),1.7(1)
1769 74-W-186,28.6,0,-0.73(4),,,,0.065(7),0,0.065(7),37.9(6)
1770 75-Re,,,9.2(2),,,,10.6(5),0.9(6),11.5(3),89.7(1.0)
1771 75-Re-185,37.5,5/2,9.0(3),,,,10.2(7),0.5(9),10.7(6),112.0(2.0)
1772 75-Re-187,62.5,5/2,9.3(3),,,,10.9(7),1.0(6),11.9(4),76.4(1.0)
1773 76-Os,,,10.7(2),,,,14.4(5),0.3(8),14.7(6),16.0(4.0)
1774 76-Os-184,0.02,0,10.0(2.0)*,,,,13.0(5.0),0,13.0(5.0),3000.0(150.0)
1775 76-Os-186,1.6,0,12.0(1.7),,,,17.0(5.0),0,17.0(5.0),80.0(13.0)
1776 76-Os-187,1.6,1/2,10.0(2.0)*,,,,13.0(5.0),0.3(3)*,13.0(5.0),320.0(10.0)
1777 76-Os-188,13.3,0,7.8(3),,,,7.3(6),0,7.3(6),4.7(5)
1778 76-Os-189,16.1,3/2,11.0(3),,,,14.4(8),0.5(5)*,14.9(9),25.0(4.0)
1779 76-Os-190,26.4,0,11.4(3),,,,15.2(8),0,15.2(8),13.1(3)
1780 76-Os-192,41,0,11.9(4),,,,16.6(1.2),0,16.6(1.2),2.0(1)
1781 77-Ir,,,10.6(3),,,,14.1(8),0.0(3.0),14.0(3.0),425.0(2.0)
1782 77-Ir-191,37.4,3/2,12.1(9),,,,,,,954.0(10.0)
1783 77-Ir-193,62.6,3/2,9.71(18),,,,,,,111.0(5.0)
1784 78-Pt,,,9.60(1),,,,11.58(2),0.13(11),11.71(11),10.3(3)
1785 78-Pt-190,0.01,0,9.0(1.0),,,,10.0(2.0),0,10.0(2.0),152.0(4.0)
1786 78-Pt-192,1.78,0,9.9(5),,,,12.3(1.2),0,12.3(1.2),10.0(2.5)
1787 78-Pt-194,32.9,0,10.55(8),,,,14.0(2),0,14.0(2),1.44(19)
1788 78-Pt-195,33.8,1/2,8.91(9),9.5(3),7.2(3),+/-,9.8(2),0.13(4),9.9(2),27.5(1.2)
1789 78-Pt-196,25.3,0,9.89(8),,,,12.3(2),0,12.3(2),0.72(4)
1790 78-Pt-198,7.2,0,7.8(1),,,,7.6(2),0,7.6(2),3.66(19)
1791 79-Au-197,100,3/2,7.90(7),6.26(10),9.90(14),+/-,7.32(12),0.43(5),7.75(13),98.65(9)
1792 80-Hg,,,12.595(45),,,,20.24(5),6.6(1),26.8(1),372.3(4.0)
1793 80-Hg-196,0.15,0,30.3(1.0),,,E,115.0(8.0),0,115.0(8.0),3080.0(180.0)
1794 80-Hg-198,10.1,0,,,,,,0,,2.0(3)
1795 80-Hg-199,16.9,0,16.9(4),,,E,36.0(2.0),30.0(3.0),66.0(2.0),2150.0(48.0)
1796 80-Hg-200,23.1,0,,,,,,0,,<60.0
1797 80-Hg-201,13.2,3/2,,,,,,,,7.8(2.0)
1798 80-Hg-202,29.7,0,11.002(43),,,,15.2108(2),0,15.2108(2),4.89(5)
1799 80-Hg-204,6.8,0,,,,,,0,,0.43(10)
1800 81-Tl,,,8.776(5),,,,9.678(11),0.21(15),9.89(15),3.43(6)
1801 81-Tl-203,29.5,1/2,8.51(8),9.08(10),6.62(10),,6.14(28),0.14(4),6.28(28),11.4(2)
1802 81-Tl-205,70.5,1/2,8.87(7),5.15(10),9.43(10),+/-,11.39(17),0.007(1),11.40(17),0.104(17)
1803 82-Pb,,,9.4024(13),,,,11.115(7),0.0030(7),11.118(7),0.171(2)
1804 82-Pb-204,1.4,0,10.893(78),,,,12.3(2),0,12.3(2),0.65(7)
1805 82-Pb-206,24.1,0,9.221(78),,,,10.68(12),0,10.68(12),0.0300(8)
1806 82-Pb-207,22.1,1/2,9.286(16),,,+/-,10.82(9),0.002(2),10.82(9),0.699(10)
1807 82-Pb-208,52.4,0,9.494(30),,,,11.34(5),0,11.34(5),0.00048(3)
1808 83-Bi-209,100,9/2,8.5242(18),8.26(1),8.74(1),,9.148(4),0.0084(19),9.156(4),0.0338(7)
1809 88-Ra-226,1620 Y,0,10.0(1.0),,,,13.0(3.0),0,13.0(3.0),12.8(1.5)
1810 90-Th-232,100,0,10.31(3),,,,13.36(8),0,13.36(8),7.37(6)
1811 91-Pa-231,32500 Y,3/2,9.1(3),,,,10.4(7),0.1(3.3),10.5(3.2),200.6(2.3)
1812 92-U,,,8.417(5),,,,8.903(11),0.005(16),8.908(11),7.57(2)
1813 92-U-233,159000 Y,5/2,10.1(2),,,,12.8(5),0.1(6),12.9(3),574.7(1.0)
1814 92-U-234,0.005,0,12.4(3),,,,19.3(9),0,19.3(9),100.1(1.3)
1815 92-U-235,0.72,7/2,10.50(3),,,,13.78(11),0.2(2),14.0(2),680.9(1.1)
1816 92-U-238,99.27,0,8.407(7),,,,8.871(11),0,8.871(11),2.68(2)
1817 93-Np-237,2140000 Y,5/2,10.55(10),,,,14.0(3),0.5(5)*,14.5(6),175.9(2.9)
1818 94-Pu-239,24400 Y,1/2,7.7(1),,,,7.5(2),0.2(6),7.7(6),1017.3(2.1)
1819 94-Pu-240,6540 Y,0,3.5(1),,,,1.54(9),0,1.54(9),289.6(1.4)
1820 94-Pu-242,376000 Y,0,8.1(1),,,,8.2(2),0,8.2(2),18.5(5)
1821 95-Am-243,7370 Y,5/2,8.3(2),,,,8.7(4),0.3(2.6),9.0(2.6),75.3(1.8)
1822 96-Cm-244,17.9 Y,0,9.5(3),,,,11.3(7),0,11.3(7),16.2(1.2)
1823 96-Cm-246,4700 Y,0,9.3(2),,,,10.9(5),0,10.9(5),1.36(17)
1824 96-Cm-248,340000 Y,0,7.7(2),,,,7.5(4),0,7.5(4),3.00(26)\
1825 """
1826
1827 # Imaginary values for select isotopes
1828 # isotope, b_c_i, bp_i, bm_i
1829 nsftableI = """\
1830 2-He-3,-1.48,,-5.925
1831 3-Li-6,-0.26,-0.08(1),-0.62(2)
1832 5-B,-0.21,,
1833 47-Ag-107,-0.01,,
1834 47-Ag-109,-0.025,,
1835 48-Cd,-1.2,,
1836 48-Cd-113,-12,,
1837 49-In,-0.054,,
1838 49-In-115,-0.056,,
1839 52-Te-123,-0.1,,
1840 62-Sm,-1.5,,
1841 62-Sm-149,-11,,
1842 64-Gd,-13.6,,
1843 64-Gd-155,-10.3,,
1844 71-Lu-176,-0.57(2),,
1845 80-Hg-196,-0.8,,\
1846 """
1847 # Excluding the following because the measurements for the real parts
1848 # were not used in nsftable table.
1849 # 63-Eu-151,-2.46,,
1850 # 64-Gd-157,-47,-75,
1851
1852 def _fix_number(str):
1853 """
1854 Converts strings of the form e.g., 35.24(2)* into numbers without
1855 uncertainty. Also accepts a limited range, e.g., <1e-6, which is
1856 converted as 1e-6. Missing values are set to 0.
1857 """
1858 from .util import parse_uncertainty
1859 return parse_uncertainty(str.replace('<','').replace('*',''))
1860
1861
1862 # TODO: add a citation column to the html scattering table
1863 def scattering_table_html(path: Path|str|None=None, table: PeriodicTable|None=None) -> str:
1864 """
1865 Generate an html table, returning it as a string. If path is given, write the
1866 html to that path.
1867
1868 Note: requires the uncertainties package, which is not otherwise required by periodictable.
1869 """
1870 from uncertainties import ufloat as U # type: ignore[import-untyped]
1871
1872 head = """\
1873 <head>
1874 <meta charset="UTF-8">
1875 <title>Neutron Cross Sections</title>
1876 <style>
1877 table {
1878 border-collapse: separate;
1879 border-spacing: 0;
1880 }
1881 tbody tr {
1882 /* This offset ensures the target row isn't hidden behind the sticky header */
1883 scroll-margin-top: 60px;
1884 }
1885 tbody tr:target td {
1886 background-color: yellow; /* Light yellow highlight */
1887 transition: background-color 2s ease-out;
1888 }
1889 th, td {
1890 border: 1px solid black;
1891 padding: 5px;
1892 border-top: none;
1893 border-right: none;
1894 }
1895 tr:first-child td, tr:first-child th {
1896 border-top: 1px solid black;
1897 }
1898 td:last-child, th:last-child {
1899 border-right: 1px solid black;
1900 }
1901 th {
1902 position: sticky;
1903 top: 0;
1904 background: #e8edf3;
1905 z-index: 1;
1906 }
1907 .centered {
1908 text-align: center;
1909 }
1910
1911 </style>
1912 </head>"""
1913 table = default_table(table)
1914
1915 def format_num(re, re_unc, im=None, im_unc=None):
1916 # Note: using NaN for uncertainty for derived values that should be
1917 # left blank in the table (currently 191,193Ir cross sections)
1918 re_str = "" if re is None or np.isnan(re_unc) else f"{U(re, re_unc):fS}" if re_unc else str(re) if re else "0"
1919 if im is not None:
1920 im_value = f"{U(abs(im), im_unc):fS}" if im_unc else str(abs(im))
1921 im_str = f"<br>{'+' if im >= 0 else '–'} {im_value}j"
1922 else:
1923 im_str = ""
1924 return f"{re_str}{im_str}"
1925
1926 rows = []
1927 rows.append(f"""
1928 <tr>
1929 <th></th>
1930 <th>Z</th>
1931 <th>A</th>
1932 <th>I(π)</th>
1933 <th>abundance %</th>
1934 <th>b<sub>c</sub> {Neutron.b_c_units}</th>
1935 <th>b<sub>+</sub> {Neutron.bp_units}</th>
1936 <th>b<sub>–</sub> {Neutron.bm_units}</th>
1937 <th>σ<sub>c</sub> {Neutron.coherent_units}</th>
1938 <th>σ<sub>i</sub> {Neutron.incoherent_units}</th>
1939 <th>σ<sub>s</sub> {Neutron.total_units}</th>
1940 <th>σ<sub>a</sub> {Neutron.absorption_units}</th>
1941 </tr>""")
1942
1943 # Generate table rows
1944 for el in [table.n, *table]:
1945 element_number = el.number
1946 isotopes = [iso for iso in el if iso.neutron.absorption is not None or iso.abundance]
1947 singleton = len(isotopes) == 1
1948 # print(f"{el=} {A=} {singleton=} {el.neutron.has_sld()=} {[*el]}")
1949 if element_number <= 96 and not singleton:
1950 # Multiple isotopes: put element summary above
1951 n = el.neutron
1952 rows.append(f"""
1953 <tr class="element-row" id="{el}">
1954 <td>{el}</td>
1955 <td>{element_number}</td>
1956 <td></td>
1957 <td></td>
1958 <td></td>
1959 <td>{format_num(n.b_c, n.b_c_unc, n.b_c_i, n.b_c_i_unc)}</td>
1960 <td>{format_num(n.bp, n.bp_unc, n.bp_i, n.bp_i_unc)}</td>
1961 <td>{format_num(n.bm, n.bm_unc, n.bm_i, n.bm_i_unc)}</td>
1962 <td>{format_num(n.coherent, n.coherent_unc)}</td>
1963 <td>{format_num(n.incoherent, n.incoherent_unc)}</td>
1964 <td>{format_num(n.total, n.total_unc)}</td>
1965 <td>{format_num(n.absorption, n.absorption_unc)}</td>
1966 </tr>""")
1967
1968 for iso in isotopes:
1969 isotope_number = iso.isotope
1970 spin = getattr(iso, "nuclear_spin", "")
1971 n = iso.neutron
1972 abundance = (
1973 f"{U(iso.abundance, iso._abundance_unc):fS}" if iso._abundance_unc
1974 else "100" if iso.abundance == 100.0
1975 else "" if iso.abundance == 0.0
1976 else f"{iso.abundance}"
1977 )
1978 rows.append(f"""
1979 <tr{f' class="element-row" id="{el}"' if singleton else ''}>
1980 <td>{el if singleton else ''}</td>
1981 <td>{element_number if singleton else ''}</td>
1982 <td>{isotope_number}</td>
1983 <td class="centered">{spin}</td>
1984 <td>{abundance}</td>
1985 <td>{format_num(n.b_c, n.b_c_unc, n.b_c_i, n.b_c_i_unc)}</td>
1986 <td>{format_num(n.bp, n.bp_unc, n.bp_i, n.bp_i_unc)}</td>
1987 <td>{format_num(n.bm, n.bm_unc, n.bm_i, n.bm_i_unc)}</td>
1988 <td>{format_num(n.coherent, n.coherent_unc)}</td>
1989 <td>{format_num(n.incoherent, n.incoherent_unc)}</td>
1990 <td>{format_num(n.total, n.total_unc)}</td>
1991 <td>{format_num(n.absorption, n.absorption_unc)}</td>
1992 </tr>""")
1993
1994 # Note: don't need \n between rows since we add it to each.
1995 formatted_table = ''.join(rows)
1996 html = f"""
1997 <html>
1998 {head}
1999 <body>
2000 <p>Scattering lengths and cross sections for various isotopes evaluated at 2200 m s<sup>–1</sup>
2001 </p>
2002 <table>
2003 {formatted_table}
2004 </table>
2005 <p>This table has been compiled from various sources for the user's convenience and does not represent a critical evaluation by the NIST Center for Neutron Research.
2006 See <a href="https://github.com/python-periodictable/periodictable/blob/master/periodictable/nsf.py">python-periodictable</a> on github for a list of citations.</p>
2007 <p>Natural abundance is from IUPAC Commission on Isotopic Abundances and Atomic Weights (<a href="ciaaw.org">CIAAW</a>)</p>
2008 </body>
2009 </html>
2010 """
2011
2012 if path:
2013 # Save the HTML to a file
2014 with open(path, 'w', encoding='utf-8') as f:
2015 f.write(html)
2016
2017 print(f"HTML table saved to {str(path)}")
2018
2019 return html
2020
2021 def sld_table(wavelength=1, table=None, isotopes=True):
2022 r"""
2023 Scattering length density table for wavelength 4.75 |Ang|.
2024
2025 :Parameters:
2026
2027 *table* \: PeriodicTable
2028 If *table* is not specified, use the common periodic table.
2029
2030 *isotopes* = True \: boolean
2031 Whether to consider isotopes or not.
2032
2033 :Returns: None
2034
2035 Example
2036
2037 >>> sld_table(wavelength=4.75) # doctest: +ELLIPSIS, +NORMALIZE_WHITESPACE
2038 Neutron scattering length density table
2039 atom mass density sld imag incoh
2040 H 1.008 0.071 -1.582 0.000 10.690
2041 1-H 1.008 0.071 -1.582 0.000 10.691
2042 D 2.014 0.141 2.820 0.000 1.709
2043 T 3.016 0.212 2.027 0.000 0.453
2044 He 4.003 0.122 0.569 0.000 0.003
2045 3-He 3.016 0.092 1.054 0.272 0.652 *
2046 4-He 4.003 0.122 0.569 0.000 0.000
2047 ...
2048 248-Cm 248.072 13.569 2.536 0.000 0.207
2049 * Energy dependent cross sections
2050 """
2051 table = default_table(table)
2052 # Table for comparison with scattering length density calculators
2053 # b_c for Sc, Te, Xe, Sm, Eu, Gd, W, Au, Hg are different from Neutron News
2054 # The Rauch data have cited references to back up the numbers
2055 # (see doc directory), though it is not clear what criteria are
2056 # used to select amongst the available measurements.
2057 print(" Neutron scattering length density table")
2058 print("%-7s %7s %7s %7s %7s %7s"
2059 %('atom', 'mass', 'density', 'sld', 'imag', 'incoh'))
2060 for el in table:
2061 if el.neutron.has_sld():
2062 coh, jcoh, inc = el.neutron.sld(wavelength=wavelength)
2063 print("%-7s %7.3f %7.3f %7.3f %7.3f %7.3f%s"
2064 %(el, el.mass, el.density, coh, jcoh, inc,
2065 ' *' if el.neutron.is_energy_dependent else ''))
2066 if isotopes:
2067 isos = [iso for iso in el if iso.neutron is not None and iso.neutron.has_sld()]
2068 else:
2069 isos = []
2070 for iso in isos:
2071 coh, jcoh, inc = iso.neutron.sld(wavelength=wavelength)
2072 print("%-7s %7.3f %7.3f %7.3f %7.3f %7.3f%s"
2073 %(iso, iso.mass, iso.density, coh, jcoh, inc,
2074 ' *' if iso.neutron.is_energy_dependent else ''))
2075 print("* Energy dependent cross sections")
2076
2077 def energy_dependent_table(table=None):
2078 r"""
2079 Prints a table of energy dependent isotopes.
2080
2081 :Parameters:
2082 *table* \: PeriodicTable
2083 If *table* is not specified, use the common periodic table.
2084
2085 :Returns: None
2086
2087 Example
2088
2089 >>> energy_dependent_table()
2090 Elements and isotopes with energy dependent absorption:
2091 He-3
2092 Cd Cd-113
2093 Sm Sm-149
2094 Eu Eu-151
2095 Gd Gd-155 Gd-157
2096 Yb-168
2097 Hg-196 Hg-199
2098 """
2099 table = default_table(table)
2100 # List of energy dependent elements and isotopes
2101 print("Elements and isotopes with energy dependent absorption:")
2102 for el in table:
2103 if not hasattr(el, 'neutron'):
2104 continue
2105 dep = []
2106 if el.neutron.is_energy_dependent:
2107 dep += [str(el)]
2108 dep += [str(el)+'-'+str(iso.isotope)
2109 for iso in el
2110 if iso.neutron is not None and iso.neutron.is_energy_dependent]
2111 if dep:
2112 print(" " + " ".join(dep))
2113
2114 def _diff(iso, measured, calculated, tol):
2115 if None in (measured, calculated):
2116 if measured is not None or calculated is not None:
2117 if measured is None and calculated > tol:
2118 print(f"{str(iso):>10s} {'---':>8s} {calculated:8.2f}")
2119 elif calculated is None and measured > tol:
2120 print(f"{str(iso):>10s} {measured:8.2f} {'----':>8s}")
2121 # Tricky code: Using tolerance of -tol selects for items within tolerance
2122 # rather than outside tolerance by using -|a-b| > -tol. Note that sign(0)
2123 # is zero, so using >= tol so that tol=0 prints every element of the table.
2124 # If a or b is nan then the expression on the left is nan and the condition
2125 # fails so the row will not be printed.
2126 # Note: for relative tolerance use tol*measured
2127 elif np.sign(tol)*abs(measured - calculated) >= tol:
2128 diff = (measured-calculated)/calculated if calculated != 0 else 0.0 if measured == 0 else 1
2129 # print(f"{tol=} {measured=} {calculated=} {diff=}")
2130 print(f"{str(iso):>10s} {measured:8.2f} {calculated:8.2f} {100*diff:5.1f}%")
2131
2132 def compare(fn1, fn2, table=None, tol=None):
2133 if tol is None:
2134 tol = 0.1
2135 table = default_table(table)
2136 for el in table:
2137 try:
2138 res1 = fn1(el)
2139 except Exception:
2140 #raise
2141 res1 = None
2142 try:
2143 res2 = fn2(el)
2144 except Exception:
2145 #raise
2146 res2 = None
2147 _diff(el, res1, res2, tol=tol)
2148 for iso in el:
2149 # Don't show isotope details if the isotope defers to the natural
2150 # natural abundance for its value.
2151 if 'neutron' not in iso.__dict__:
2152 #print("dict has", iso.__dict__.keys())
2153 continue
2154 try:
2155 res1 = fn1(iso)
2156 except Exception:
2157 #raise
2158 res1 = None
2159 try:
2160 res2 = fn2(iso)
2161 except Exception:
2162 #raise
2163 res2 = None
2164 _diff(iso, res1, res2, tol=tol)
2165
2166 def absorption_comparison_table(table=None, tol=None):
2167 r"""
2168 Prints a table comparing absorption to the imaginary bound coherent
2169 scattering length b_c_i. This is used to checking the integrity
2170 of the data and formula.
2171
2172 The relationship between absorption and b_c_i is:
2173
2174 .. math::
2175
2176 \sigma_a = -2 \lambda \mathrm{Im}(b_c) \cdot 1000
2177
2178 The wavelength $\lambda = 1.798$ |Ang| is the neutron wavelength at which
2179 the absorption is tallied. The factor of 1000 transforms from
2180 |Ang|\ |cdot|\ fm to barn.
2181
2182 :Parameters:
2183 *table* \: PeriodicTable
2184 The default periodictable unless a specific table has been requested.
2185 *tol* = 0.01 \: float | barn
2186 Show differences greater than this amount.
2187
2188 :Returns: None
2189
2190 Example
2191
2192 >>> absorption_comparison_table (tol=0.5) # doctest: +ELLIPSIS, +NORMALIZE_WHITESPACE
2193 Comparison of absorption and (-2000 lambda b_c_i)
2194 3-He 5333.00 5322.08 0.2%
2195 Li 70.50 ----
2196 6-Li 940.00 934.96 0.5%
2197 B 767.00 755.16 1.6%
2198 10-B 3835.00 ----
2199 N 1.90 ----
2200 ...
2201
2202 """
2203
2204 print("Comparison of absorption and (-2000 lambda b_c_i)")
2205 compare(lambda el: el.neutron.absorption,
2206 lambda el: -2000*el.neutron.b_c_i*ABSORPTION_WAVELENGTH,
2207 table=table, tol=tol)
2208
2209 def coherent_comparison_table(table=None, tol=None):
2210 r"""
2211 Prints a table of $4 \pi |b_c|^2/100$ and coherent for each isotope.
2212 This is useful for checking the integrity of the data and formula.
2213
2214 The table only prints where b_c exists.
2215
2216 :Parameters:
2217 *table* \: PeriodicTable
2218 The default periodictable unless a specific table has been requested.
2219 *tol* = 0.01 \: float | barn
2220 Amount of difference to show. Use -tol to show elements within
2221 tolerance rather than those outside tolerance.
2222
2223 :Returns: None
2224
2225 Example
2226
2227 >>> coherent_comparison_table (tol=0.5) # doctest: +ELLIPSIS, +NORMALIZE_WHITESPACE
2228 Comparison of (4 pi |b_c|^2/100) and coherent
2229 13-C 4.81 5.38 -10.6%
2230 Sc 19.00 18.40 3.3%
2231 45-Sc 19.00 18.40 3.3%
2232 65-Cu 14.10 13.08 7.8%
2233 84-Sr 6.00 3.14 91.0%
2234 ...
2235
2236 """
2237 print("Comparison of (4 pi |b_c|^2/100) and coherent")
2238 def sigma_c(el):
2239 return 4*pi/100*abs(el.neutron.b_c_complex)**2
2240 compare(lambda el: el.neutron.coherent, sigma_c, table=table, tol=tol)
2241
2242 def total_comparison_table(table=None, tol=None):
2243 r"""
2244 Prints a table of neutron.total and sum coh,inc for each
2245 isotope where these exist. This is used to checking the integrity
2246 of the data and formula.
2247
2248 :Parameters:
2249 *table* \: PeriodicTable
2250 The default periodictable unless a specific table has been requested.
2251 *tol* = 0.01 \: float | barn
2252 Amount of difference to show. Use -tol to show elements within
2253 tolerance rather than those outside tolerance.
2254
2255 :Returns: None
2256
2257 Example
2258
2259 >>> total_comparison_table (tol=0.1)
2260 Comparison of total cross section to (coherent + incoherent)
2261 84-Kr 6.60 ----
2262 Xe 4.34 3.04 42.9%
2263 149-Sm 200.00 200.50 -0.2%
2264 Eu 9.20 9.07 1.4%
2265 Gd 180.00 180.30 -0.2%
2266 155-Gd 66.00 65.80 0.3%
2267 161-Dy 16.00 16.30 -1.8%
2268 180-Ta 7.00 6.70 4.5%
2269 187-Os 13.00 13.30 -2.3%
2270
2271 """
2272 print("Comparison of total cross section to (coherent + incoherent)")
2273 compare(lambda el: el.neutron.total,
2274 lambda el: el.neutron.coherent+el.neutron.incoherent,
2275 table=table, tol=tol)
2276
2277 def incoherent_comparison_table(table=None, tol=None):
2278 r"""
2279 Prints a table comparing total minus coherent with incoherent cross sections.
2280
2281 That is, check that σ_i = σ_s - σ_c where σ_c =σ_4π/100 \|b_c - σ_a/(2000 λ)i\|²
2282 for i = √-1 and λ = wavelength for the absorption cross section σ_a reported
2283 in the table.
2284
2285 :Parameters:
2286 *table* \: PeriodicTable
2287 The default periodictable unless a specific table has been requested.
2288 *tol* = 0.01 \: float | barn
2289 Amount of difference to show. Use -tol to show elements within
2290 tolerance rather than those outside tolerance.
2291
2292 :Returns: None
2293
2294 Example
2295
2296 >>> incoherent_comparison_table (tol=0.5) # doctest: +ELLIPSIS, +NORMALIZE_WHITESPACE
2297 Comparison of incoherent and (total - 4 pi |b_c|^2/100)
2298 13-C 0.02 -0.54 -104.1%
2299 Sc 4.50 5.10 -11.8%
2300 45-Sc 4.50 5.10 -11.8%
2301 65-Cu 0.40 1.42 -71.7%
2302 84-Sr 0.00 2.86 -100.0%
2303 ...
2304
2305 """
2306 print("Comparison of incoherent and (total - 4 pi |b_c|^2/100)")
2307 def sigma_c(el):
2308 return 4*pi/100*abs(el.neutron.b_c_complex)**2
2309 compare(lambda el: el.neutron.incoherent,
2310 lambda el: el.neutron.total - sigma_c(el),
2311 table=table, tol=tol)
2312
2313 def bp_bm_bc_comparison_table(table=None, tol=None):
2314 r"""
2315 Prints a table comparing b+ and b- with coherent.
2316
2317 The coherent scattering length for an isotope with spin I is computed as
2318 b_c = (I+1)/(2I+1) b_p + I/(2I+1) b_m.
2319
2320 :Parameters:
2321 *table* \: PeriodicTable
2322 The default periodictable unless a specific table has been requested.
2323 *tol* = 0.01 \: float | barn
2324 Amount of difference to show. Use -tol to show elements within
2325 tolerance rather than those outside tolerance.
2326
2327 :Returns: None
2328 """
2329 print("Comparison of b_c with b_c computed from b+ and b-")
2330 def b_coh(atom: Atom) -> float|None:
2331 if iselement(atom):
2332 return np.nan # should be excluded from the table
2333
2334 iso = cast(Isotope, atom)
2335 # print(f"Processing isotope {el}")
2336 # print(f" {el} {el.abundance} {el.nuclear_spin} b+={el.neutron.bp} b-={el.neutron.bm}")
2337 spinstr, bp, bm = iso.nuclear_spin, iso.neutron.bp, iso.neutron.bm
2338 if not spinstr or bp is None or bm is None:
2339 return np.nan
2340 spin = int(spinstr[:-2])/2 if spinstr.endswith('/2') else int(spinstr)
2341 b_coh = ((spin+1)*bp + spin*bm) / (2*spin+1)
2342 return b_coh
2343
2344 compare(lambda atom: atom.neutron.b_c, b_coh, table=table, tol=tol)
2345
2346 def bp_bm_bi_comparison_table(table=None, tol=None):
2347 r"""
2348 Prints a table comparing b+ and b- with incoherent.
2349
2350 Also calculates the incoherent scattering from the mixture of naturally occurring
2351 isotopes for each element using mean(b_i²) + var(b_c).
2352
2353 The incoherent scattering length for an isotope with spin I is computed as
2354 b_i = √I(I+1)]/(2I+1) (b_p - b_m). If b_p and b_m are not available, then guess
2355 b_i up to sign from the incoherent cross section σ_i.
2356
2357 :Parameters:
2358 *table* \: PeriodicTable
2359 The default periodictable unless a specific table has been requested.
2360 *tol* = 0.01 \: float | barn
2361 Amount of difference to show. Use -tol to show elements within
2362 tolerance rather than those outside tolerance.
2363
2364 :Returns: None
2365 """
2366 print("Comparison of σ_ι and 4 pi/100 var(b_c)")
2367 def sigma_i(atom: Atom) -> float|None:
2368 if iselement(atom):
2369 el = cast(Element, atom)
2370 # print(f"Processing element {el}")
2371 sum_b_coh = 0.
2372 sum_b_coh_sq = 0.
2373 sum_weight = 0.
2374 for iso in el:
2375 if not iso.neutron.has_sld():
2376 continue
2377
2378 bp, bm = iso.neutron.bp, iso.neutron.bm
2379 b_coh = iso.neutron.b_c
2380 # The following doesn't work in practice because b_inc may be negative.
2381 # Since this code is only for crosscheck and this only affects isotopes
2382 # that don't have b+ and b- defined we won't worry too much about
2383 # correctness. If you are trying to track down why some of the table
2384 # comparisons are so bad you may need to address them.
2385 # Looking at tables for Crystallography C(4):
2386 # b_i < 0: 79Br 141Pr 169Tm 181Ta 187Os
2387 # b_i complex: 149Sm 151Eu 155,157Gd 176Lu
2388 # b_i unknown: 95,97Mo 99Tc 99,101Ru 105Pd 111,113Cd 231Pa 237Np 243Am
2389 # The remaining missing entries have b_i > 0 so inversion should work.
2390 b_inc = np.sqrt(iso.neutron.incoherent/_4PI_100) if iso.neutron.incoherent else 0.
2391
2392 # # List the isotopes which don't have b+ defined.
2393 # if bp is None and b_inc != 0:
2394 # print(f"!!! {iso} missing b+,b- with {b_coh=} {b_inc=}")
2395
2396 # TODO: I don't know what to do with negative spin
2397 spinstr = iso.nuclear_spin
2398 spin = abs(int(spinstr[:-2])/2 if spinstr.endswith('/2') else int(spinstr))
2399 # # Check that odd isotopes have fractional spin and even isotops have integer spin
2400 # if iso.isotope%2 == 1 and not spinstr.endswith('/2'):
2401 # print(f"!!! {iso} with spin={spinstr} should have fractional spin")
2402 # if iso.isotope%2 == 0 and spinstr.endswith('/2'):
2403 # print(f"!!! {iso} with spin={spinstr} should have integer spin")
2404
2405 if iso.abundance:
2406 # Checking that all spin=0 have no incoherent scattering recorded
2407 # if spin == 0 and b_inc != 0:
2408 # print(f"!!! {iso} has spin {spin} and {b_inc=}")
2409 if bp is None or bm is None:
2410 # Using the b_coh and b_inc defined as:
2411 # b_c = ((I+1) b+ + I b-) / (2I+1)
2412 # b_i = √I(I+1)] (b+ - b-) / (2I+1)
2413 # and solving for b+, b- gives:
2414 # b+ = b_c + b_i I / √I(I+1)] = b_c + b_i √I/(I+1)]
2415 # b- = b_c - b_i (I+1) / √I(I+1)] = b_c - b_i √(I+1)/I]
2416 # Guard against division by I=0. In that case we will only
2417 # have b+ contributing to the sums, so it doesn't matter
2418 # what value we use for b-. I've arbitrarily set it
2419 # to b- = b_coh when spin is zero since b_inc is zero in those cases
2420 bp = b_coh + b_inc * np.sqrt(spin/(spin + 1))
2421 bm = b_coh - b_inc * np.sqrt((spin + 1)/spin) if spin != 0 else b_coh
2422 bp, bm = cast(float, bp), cast(float, bm)
2423
2424 # calc_bc = ((spin+1)*bp + spin*bm) / (2*spin + 1)
2425 # calc_bi = np.sqrt(spin*(spin+1)) * (bp - bm) / (2*spin + 1)
2426 # print(f" {iso} {iso.abundance} {spinstr} b+={bp} b-={bm} b_c={b_coh}:{calc_bc} b_i={b_inc}:{calc_bi}")
2427
2428
2429 # Instead treat bp and bm as separate isotopes when finding
2430 # the mean and variance. Use relative weighting of spin+1:spin
2431 # for b+ and b-, so normalize by (2*spin+1). There is no
2432 # independent incoherent contribution using this approach.
2433 weight = iso.abundance/100
2434 sum_weight += weight # in case abundance doesn't sum to 100%
2435 sum_b_coh += weight*((spin+1)*bp + spin*bm)/(2*spin+1)
2436 sum_b_coh_sq += weight*((spin+1)*bp**2 + spin*bm**2)/(2*spin+1)
2437
2438 if sum_weight == 0.0:
2439 # No naturally occurring isotopes; value is meaningless
2440 return np.nan
2441 # Normal expression across isotopes is the weighted mean of the isotope
2442 # incoherence plus the variance of the isotope coherence:
2443 # var(b_c) = Σ w (b_c - <b_c>)² / Σ w
2444 # mean(b_i²) = Σ w b_i² / Σ w
2445 # b_i² = mean(b_i²) + var(b_c)
2446 # Since we are using the different spin states as separate coherent
2447 # contributions we don't need mean(b_i²), just the coherent variance
2448 var_b_coh = sum_b_coh_sq/sum_weight - (sum_b_coh/sum_weight)**2
2449 sigma_i = _4PI_100 * var_b_coh
2450 # print(f" var<b_c> = {var_b_coh} -> σ_i = {sigma_i:.5f} compared to {el.neutron.incoherent:.5f}")
2451
2452 return sigma_i
2453
2454 # print(f"Processing isotope {el}")
2455 #print(f":: {el} {el.abundance} {el.nuclear_spin} b+={el.neutron.bp} b-={el.neutron.bm}")
2456 iso = cast(Isotope, atom)
2457 spinstr, bp, bm = iso.nuclear_spin, iso.neutron.bp, iso.neutron.bm
2458 if not spinstr or bp is None or bm is None:
2459 return np.nan # exclude from the table
2460 return iso.neutron.incoherent
2461 spin = int(spinstr[:-2])/2 if spinstr.endswith('/2') else int(spinstr)
2462 b_inc = np.sqrt(spin*(spin+1)) / (2*spin+1) * (bp - bm)
2463 sigma_i = _4PI_100 * abs(b_inc)**2
2464 #print(f" σ_i = {sigma_i:.5f} compared to {el.neutron.incoherent:.5f}")
2465 return sigma_i
2466
2467 compare(lambda el: el.neutron.incoherent, sigma_i, table=table, tol=tol)
2468
2469
2470 def print_scattering(compound, wavelength=ABSORPTION_WAVELENGTH):
2471 """
2472 Print the scattering for a single compound.
2473 """
2474 from . import formulas
2475 compound = formulas.formula(compound)
2476 density = compound.density if compound.density is not None else 1.0
2477 sld, xs, penetration = neutron_scattering(compound, wavelength=wavelength,
2478 density=density)
2479 print("%s at %g Ang (density=%g g/cm^3)"
2480 % (str(compound), wavelength, density))
2481 print(" sld: %g + %g j (%g incoherent) 1e-6/Ang^2"%sld)
2482 print(" Σ_c: %g Σ_a: %g Σ_i: %g 1/cm"%xs)
2483 print(" μ: %g 1/cm 1/e penetration: %g cm"%(1/penetration, penetration))
2484
2485 def main():
2486 """
2487 Simple command line interface, showing the predicted neutron scattering.
2488
2489 Usage::
2490
2491 python -m periodictable.nsf [-Lwavelength] compound@density compound@density ...
2492
2493 For example::
2494
2495 $ python -m periodictable.nsf [email protected]
2496 scattering for XeF6 at 1.798 Ang (density=3.56 g/cm^3)
2497 sld: 3.37503 + 0.000582313 j (0.402605 incoherent) 1e-6/Ang^2
2498 sigma_c: 3.37503 sigma_i: 0.000582313 sigma_a: 0.402605 1/cm
2499 1/e penetration: 2.23871 cm
2500
2501 To generate an updated cross section table use::
2502
2503 python -m periodictable.nsf --html path/filename.html
2504 """
2505
2506 import sys
2507 compounds = sys.argv[1:]
2508 if not compounds:
2509 print("usage: python -m periodictable.nsf [-Lwavelength] atom ...")
2510 sys.exit(1)
2511 if compounds[0] == '--html':
2512 scattering_table_html(path=compounds[1])
2513 return
2514
2515 if compounds[0].startswith('-L'):
2516 wavelength = float(compounds[0][2:])
2517 compounds = compounds[1:]
2518 else:
2519 wavelength = ABSORPTION_WAVELENGTH
2520 for c in compounds:
2521 print_scattering(c, wavelength)
2522
2523 if __name__ == "__main__":
2524 #sld_table()
2525 # tolerances are absolute, not relative
2526 #coherent_comparison_table(tol=0.1)
2527 #incoherent_comparison_table(tol=0.1)
2528 #absorption_comparison_table(tol=0.1)
2529 #total_comparison_table(tol=0.1)
2530 #bp_bm_bc_comparison_table(tol=0.1)
2531 #bp_bm_bi_comparison_table(tol=0.1)
2532 main() # command line scattering calculator for elements and isotopes