| 1 |
# This program is public domain |
| 2 |
# Author: Paul Kienzle |
| 3 |
r""" |
| 4 |
|
| 5 |
The following properties are added: |
| 6 |
|
| 7 |
* density, density_units (|g/cm^3|) |
| 8 |
Densities for solids and liquids are given as specific |
| 9 |
gravities at 20\ |deg| C unless other wise indicated by |
| 10 |
*density_caveat*. Densities for gaseous elements |
| 11 |
are given for the liquids at their boiling points. |
| 12 |
Missing data are represented by *None*. |
| 13 |
* density_caveat |
| 14 |
Comments on the density, if not taken in standard conditions. |
| 15 |
* interatomic_distance, interatomic_distance_units (|Ang|) |
| 16 |
Interatomic distance estimated from element density. |
| 17 |
* number_density, number_density_units (|1/cm^3|) |
| 18 |
Number density estimated from mass and density. |
| 19 |
|
| 20 |
Density for the isotope is computed assuming that the atomic spacing |
| 21 |
is the same as that for the element in the natural abundance. |
| 22 |
|
| 23 |
.. doctest:: |
| 24 |
|
| 25 |
>>> from periodictable import D, H |
| 26 |
>>> print("H: %.4f, D: %.4f"%(H.density, D.density)) |
| 27 |
H: 0.0708, D: 0.1415 |
| 28 |
>>> print(f"{(D.density/H.density) / (D.mass/H.mass):.4f}") |
| 29 |
1.0000 |
| 30 |
|
| 31 |
The following plot shows density for all elements: |
| 32 |
|
| 33 |
.. plot:: plots/density_plot.py |
| 34 |
|
| 35 |
From the X-ray data book: http://xdb.lbl.gov/Section5/Sec_5-2.html |
| 36 |
|
| 37 |
Data were taken mostly from [#Lide1999]_. These values are reproduced in [#ILL]_. |
| 38 |
|
| 39 |
.. [#Lide1999] Lide. D. R., Ed., CRC Handbook of Chemistry and Physics, 80th ed. |
| 40 |
(CRC Press, Boca Raton, Florida, 1999) |
| 41 |
.. [#ILL] The ILL Neutron Data Booklet, Second Edition. |
| 42 |
""" |
| 43 |
|
| 44 |
from typing import cast |
| 45 |
|
| 46 |
from .core import Element, Isotope, Atom, PeriodicTable, isisotope, ision |
| 47 |
from .constants import avogadro_number |
| 48 |
|
| 49 |
def density(atom: Atom) -> float: |
| 50 |
|
| 51 |
""" |
| 52 |
Element density for natural abundance. For isotopes, return |
| 53 |
the equivalent density assuming identical inter-atomic spacing as the |
| 54 |
naturally occuring material. |
| 55 |
|
| 56 |
:Parameters: |
| 57 |
*iso_el* : isotope or element |
| 58 |
Name of the element or isotope. |
| 59 |
|
| 60 |
:Returns: |
| 61 |
*density* : float | |g/cm^3| |
| 62 |
|
| 63 |
Reference: |
| 64 |
*ILL Neutron Data Booklet, original values from CRC Handbook of Chemistry and Physics, |
| 65 |
80th ed. (1999).* |
| 66 |
|
| 67 |
""" |
| 68 |
# Note: materials with pure isotopes are adjusted by the natural mass ratio. |
| 69 |
if isisotope(atom): |
| 70 |
iso = cast(Isotope, atom) |
| 71 |
return iso.element._density * (iso.mass/iso.element.mass) |
| 72 |
return cast(Element, atom)._density |
| 73 |
|
| 74 |
def interatomic_distance(element: Element) -> float|None: |
| 75 |
r""" |
| 76 |
Estimated interatomic distance from atomic weight and density. The |
| 77 |
distance between isotopes is assumed to match that between atoms in |
| 78 |
the natural abundance. |
| 79 |
|
| 80 |
:Parameters: |
| 81 |
*element* : Element |
| 82 |
The element whose interatomic distance is to be calculated. |
| 83 |
|
| 84 |
:Returns: |
| 85 |
*distance* : float | |Ang| |
| 86 |
Estimated interatomic distance. |
| 87 |
|
| 88 |
Interatomic distance is computed using: |
| 89 |
|
| 90 |
.. math:: |
| 91 |
|
| 92 |
d = (m/(\rho_m N_A 10^{-24}))^{1/3} |
| 93 |
|
| 94 |
with units: |
| 95 |
|
| 96 |
.. math:: |
| 97 |
|
| 98 |
(\rm (g\cdot mol^{-1}) |
| 99 |
/ ( (g\cdot cm^{-3}) |
| 100 |
(atoms\cdot mol^{-1}) |
| 101 |
(10^{-8} cm\cdot \AA^{-1})^3))^{1/3} = \AA |
| 102 |
|
| 103 |
""" |
| 104 |
# Note: don't need to check for Ion or Isotope because these delegate to Element |
| 105 |
if element.density is None or element.mass is None: |
| 106 |
return None |
| 107 |
return (element.mass/(element.density*avogadro_number*1e-24))**(1./3.) |
| 108 |
|
| 109 |
def number_density(element: Element) -> float: |
| 110 |
r""" |
| 111 |
Estimate the number density from atomic weight and density. The density |
| 112 |
for isotopes is assumed to match that of between atoms in natural abundance. |
| 113 |
|
| 114 |
:Parameters: |
| 115 |
*element* : element |
| 116 |
Name of the element whose number density needs to be calculated. |
| 117 |
|
| 118 |
:Returns: |
| 119 |
*Nb* : float | |1/cm^3| |
| 120 |
Number density of a element. |
| 121 |
|
| 122 |
Number density is computed using: |
| 123 |
|
| 124 |
.. math:: |
| 125 |
|
| 126 |
d = N_A \frac{\rho}{m} |
| 127 |
|
| 128 |
with units: |
| 129 |
|
| 130 |
.. math:: |
| 131 |
|
| 132 |
\rm (atoms\cdot mol^{-1}) (g\cdot cm^{-3}) / (g\cdot mol^{-1}) |
| 133 |
= atoms\cdot cm^{-3} |
| 134 |
|
| 135 |
""" |
| 136 |
# Note: don't need to check for Ion or Isotope because these delegate to Element |
| 137 |
if element.density is None or element.mass is None: |
| 138 |
return None |
| 139 |
return (element.density/element.mass)*avogadro_number |
| 140 |
|
| 141 |
def init(table: PeriodicTable, reload: bool=False) -> None: |
| 142 |
if 'density' in table.properties and not reload: |
| 143 |
return |
| 144 |
table.properties.append('density') |
| 145 |
Isotope.density \ |
| 146 |
= property(density, doc="density using inter-atomic spacing from naturally occurring form") # type: ignore[assignment] |
| 147 |
Element.density \ |
| 148 |
= property(density, doc="density using inter-atomic spacing from naturally occurring form") # type: ignore[assignment] |
| 149 |
Element.density_units = "g/cm^3" |
| 150 |
|
| 151 |
Element.interatomic_distance \ |
| 152 |
= property(interatomic_distance, |
| 153 |
doc="interatomic distance estimated from density") # type: ignore[assignment] |
| 154 |
Element.interatomic_distance_units = "angstrom" |
| 155 |
Element.number_density \ |
| 156 |
= property(number_density, |
| 157 |
doc="number density estimated from mass and density") # type: ignore[assignment] |
| 158 |
Element.number_density_units = "1/cm^3" |
| 159 |
|
| 160 |
for k, v in element_densities.items(): |
| 161 |
el = getattr(table, k) |
| 162 |
if isinstance(v, tuple): |
| 163 |
el._density = v[0] |
| 164 |
el.density_caveat = v[1] |
| 165 |
elif v is None: |
| 166 |
el._density = None |
| 167 |
el.density_caveat = "unavailable" |
| 168 |
else: |
| 169 |
el._density = v |
| 170 |
el.density_caveat = "" |
| 171 |
|
| 172 |
element_densities = dict( |
| 173 |
n=None, # No longer using element 0 for a bare neutron |
| 174 |
H=(0.0708, "T=-252.87"), |
| 175 |
He=(0.122, "T=-268.93"), |
| 176 |
Li=0.534, |
| 177 |
Be=1.848, |
| 178 |
B=2.34, |
| 179 |
C=(2.2, "1.9-2.3 (graphite); CXRO, RSC and CRC use 2.2; NIST Xray tables use 2.26"), |
| 180 |
N=(0.808, "T=-195.79"), |
| 181 |
O=(1.14, "T=-182.95"), |
| 182 |
F=(1.50, "T=-188.12"), |
| 183 |
Ne=(1.207, "T=-246.08"), |
| 184 |
Na=0.971, |
| 185 |
Mg=1.738, |
| 186 |
Al=2.6989, |
| 187 |
Si=(2.33, "T=25"), |
| 188 |
P=1.82, |
| 189 |
S=2.07, |
| 190 |
Cl=(1.56, "T=-33.6, 0.44 C above boiling point"), |
| 191 |
Ar=(1.40, "T=-185.85"), |
| 192 |
K=0.862, |
| 193 |
Ca=1.55, |
| 194 |
Sc=(2.989, "T=25"), |
| 195 |
Ti=4.54, |
| 196 |
V=(6.11, "T=18.7"), |
| 197 |
Cr=(7.19, "7.18-7.20"), |
| 198 |
Mn=(7.33, "7.21-7.44"), |
| 199 |
Fe=7.874, |
| 200 |
Co=8.9, |
| 201 |
Ni=(8.902, "T=25"), |
| 202 |
Cu=8.96, |
| 203 |
Zn=(7.133, "T=25"), |
| 204 |
Ga=(5.904, "T=29.6"), |
| 205 |
Ge=(5.323, "T=25"), |
| 206 |
As=5.73, |
| 207 |
Se=4.79, |
| 208 |
Br=3.12, |
| 209 |
Kr=(2.16, "T=-153.22"), |
| 210 |
Rb=1.532, |
| 211 |
Sr=2.54, |
| 212 |
Y=(4.469, "T=25"), |
| 213 |
Zr=6.506, |
| 214 |
Nb=8.57, |
| 215 |
Mo=10.22, |
| 216 |
Tc=(11.50, "calculated"), |
| 217 |
Ru=12.41, |
| 218 |
Rh=12.41, |
| 219 |
Pd=12.02, |
| 220 |
Ag=10.50, |
| 221 |
Cd=8.65, |
| 222 |
In=7.31, |
| 223 |
Sn=7.31, |
| 224 |
Sb=6.691, |
| 225 |
Te=6.24, |
| 226 |
I=4.93, |
| 227 |
Xe=(3.52, "T=-108.12"), |
| 228 |
Cs=1.873, |
| 229 |
Ba=3.5, |
| 230 |
La=(6.145, "T=25"), |
| 231 |
Ce=(6.770, "T=25"), |
| 232 |
Pr=6.773, |
| 233 |
Nd=(7.008, "T=25"), |
| 234 |
Pm=(7.264, "T=25"), |
| 235 |
Sm=(7.520, "T=25"), |
| 236 |
Eu=(5.244, "T=25"), |
| 237 |
Gd=(7.901, "T=25"), |
| 238 |
Tb=8.230, |
| 239 |
Dy=(8.551, "T=25"), |
| 240 |
Ho=(8.795, "T=25"), |
| 241 |
Er=(9.066, "T=25"), |
| 242 |
Tm=(9.321, "T=25"), |
| 243 |
Yb=6.966, |
| 244 |
Lu=(9.841, "T=25"), |
| 245 |
Hf=13.31, |
| 246 |
Ta=16.654, |
| 247 |
W=19.3, |
| 248 |
Re=21.02, |
| 249 |
Os=22.57, |
| 250 |
Ir=(22.42, "T=17"), |
| 251 |
Pt=21.45, |
| 252 |
Au=(19.3, "approximate"), |
| 253 |
Hg=13.546, |
| 254 |
Tl=11.85, |
| 255 |
Pb=11.35, |
| 256 |
Bi=9.747, |
| 257 |
Po=9.32, |
| 258 |
At=None, |
| 259 |
Rn=None, |
| 260 |
Fr=None, |
| 261 |
Ra=None, |
| 262 |
Ac=None, |
| 263 |
Th=11.72, |
| 264 |
Pa=(15.37, "calculated"), |
| 265 |
U=(18.95, "approximate"), |
| 266 |
Np=20.25, |
| 267 |
Pu=(19.84, "T=25"), |
| 268 |
Am=13.67, |
| 269 |
Cm=(13.51, "calculated"), |
| 270 |
Bk=(14, "estimated"), |
| 271 |
Cf=None, |
| 272 |
Es=None, |
| 273 |
Fm=None, |
| 274 |
Md=None, |
| 275 |
No=None, |
| 276 |
Lr=None, |
| 277 |
Rf=None, |
| 278 |
Db=None, |
| 279 |
Sg=None, |
| 280 |
Bh=None, |
| 281 |
Hs=None, |
| 282 |
Mt=None, |
| 283 |
Ds=None, |
| 284 |
Rg=None, |
| 285 |
Cn=None, |
| 286 |
Nh=None, |
| 287 |
Fl=None, |
| 288 |
Mc=None, |
| 289 |
Lv=None, |
| 290 |
Ts=None, |
| 291 |
Og=None, |
| 292 |
) |