Element
Module for static information about chemical elements.
Element
Storage class for information about a chemical element.
!!! examples
>>> h = Element.from_string("H")
>>> c = Element.from_string("C")
>>> n = Element.from_atomic_number(7)
>>> f = Element.from_string("F")
Element implements an ordering for sorting in e.g.
molecular formulae where carbon and hydrogen come first,
otherwise elements are sorted in order of atomic number.
>>> sorted([h, f, f, c, n])
[C, H, N, F, F]
ball_stick_radius: float
property
readonly
The radius of this element in a ball and stick representation.
color
property
readonly
The color RGBA color of this element.
covalent_radius: float
property
readonly
The covalent radius in angstroms.
vdw_radius: float
property
readonly
The van der Waals radius in angstroms.
__eq__(self, other)
special
Check if two Elements have the same atomic number.
Source code in chmpy/core/element.py
391 392 393 394 395 |
|
__ge__(self, other, NotImplemented=NotImplemented)
special
Return a >= b. Computed by @total_ordering from (not a < b).
Source code in chmpy/core/element.py
100 101 102 103 104 105 |
|
__gt__(self, other, NotImplemented=NotImplemented)
special
Return a > b. Computed by @total_ordering from (not a < b) and (a != b).
Source code in chmpy/core/element.py
88 89 90 91 92 93 |
|
__hash__(self)
special
Hash of this element (its atomic number).
Source code in chmpy/core/element.py
384 385 386 |
|
__init__(self, atomic_number, name, symbol, cov, vdw, mass)
special
Initialize an Element from its chemical data.
Source code in chmpy/core/element.py
270 271 272 273 274 275 276 277 |
|
__le__(self, other, NotImplemented=NotImplemented)
special
Return a <= b. Computed by @total_ordering from (a < b) or (a == b).
Source code in chmpy/core/element.py
95 96 97 98 |
|
__lt__(self, other)
special
Check which element comes before the other in chemical formulae (C first, then order of atomic number).
Source code in chmpy/core/element.py
397 398 399 400 401 402 403 404 405 406 407 408 409 |
|
__repr__(self)
special
Represent this element as a string for REPL.
Source code in chmpy/core/element.py
380 381 382 |
|
from_atomic_number(n)
staticmethod
Create an element from a given atomic number.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
n |
int |
the atomic number of the element |
required |
Returns:
Type | Description |
---|---|
Element |
Element: an Element object if atomic number was valid, otherwise an exception is raised |
Examples:
1 2 3 4 |
|
Source code in chmpy/core/element.py
340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 |
|
from_label(label)
staticmethod
Create an element from a label e.g. 'C1', 'H2_F2___i' etc.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
l |
str |
a string representation of an element in the periodic table |
required |
Returns:
Type | Description |
---|---|
Element |
Element: an Element object if the conversion was successful, otherwise an exception is raised |
Examples:
1 2 3 4 5 6 |
|
An ambiguous case, will make this Calcium not Carbon
1 2 |
|
Source code in chmpy/core/element.py
310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 |
|
from_string(s)
staticmethod
Create an element from a given element symbol.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
s |
str |
a string representation of an element in the periodic table |
required |
Returns:
Type | Description |
---|---|
Element |
Element: an Element object if the conversion was successful, otherwise an exception is raised |
Examples:
1 2 3 4 5 6 |
|
Source code in chmpy/core/element.py
279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 |
|
chemical_formula(elements, subscript=False)
Calculate the chemical formula for the given list of elements.
Examples:
1 2 3 4 |
|
Parameters:
Name | Type | Description | Default |
---|---|---|---|
elements |
List[Element or str] |
a list of elements or element symbols. Note that if a list of strings are provided the order of chemical symbols may not match convention. |
required |
subscript |
bool, optoinal |
toggle to use unicode subscripts for the chemical formula string |
False |
Returns:
Type | Description |
---|---|
str |
the chemical formula |
Source code in chmpy/core/element.py
412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 |
|
cov_radii(atomic_numbers)
Return the covalent radii for the given atomic numbers.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
atomic_numbers |
array_like |
the (N,) length integer array of atomic numbers |
required |
Returns:
Type | Description |
---|---|
np.ndarray |
(N,) array of floats representing covalent radii |
Source code in chmpy/core/element.py
444 445 446 447 448 449 450 451 452 453 454 455 |
|
element_names(atomic_numbers)
Return the element names for the given atomic numbers.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
atomic_numbers |
array_like |
the (N,) length integer array of atomic numbers |
required |
Returns:
Type | Description |
---|---|
List[str] |
(N,) list of strings representing element names |
Source code in chmpy/core/element.py
472 473 474 475 476 477 478 479 480 481 482 483 |
|
element_symbols(atomic_numbers)
Return the element symbols for the given atomic numbers.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
atomic_numbers |
array_like |
the (N,) length integer array of atomic numbers |
required |
Returns:
Type | Description |
---|---|
List[str] |
(N,) list of strings representing element symbols |
Source code in chmpy/core/element.py
486 487 488 489 490 491 492 493 494 495 496 497 |
|
vdw_radii(atomic_numbers)
Return the van der Waals radii for the given atomic numbers.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
atomic_numbers |
array_like |
the (N,) length integer array of atomic numbers |
required |
Returns:
Type | Description |
---|---|
np.ndarray |
(N,) array of floats representing van der Waals radii |
Source code in chmpy/core/element.py
458 459 460 461 462 463 464 465 466 467 468 469 |
|