Skip to content

Units and tolerances

Units

AngleUnit

AngleUnit(value: int)

The units of a number representing an angle.

from brille import AngleUnit r = AngleUnit.radian

Members:

not_provided : unknown, will be inferred

radian : radian

degree : degree

pi : radian divided by pi

Attributes:

degree class-attribute

degree: AngleUnit

not_provided class-attribute

not_provided: AngleUnit

pi class-attribute

pi: AngleUnit

radian class-attribute

radian: AngleUnit

name property

name: str

value property

value: int

LengthUnit

LengthUnit(value: int)

The units of a number representing a length.

from brille import LengthUnit a = LengthUnit.angstrom

Members:

none : A default value, the used value may be inferred

angstrom : 10\ :sup:-10 meter

inverse_angstrom : 1 / angstrom

real_lattice : fractional coordinates of real lattice

reciprocal_lattice : fractional coordinates of reciprocal lattice

Attributes:

angstrom class-attribute

angstrom: LengthUnit

inverse_angstrom class-attribute

inverse_angstrom: LengthUnit

none class-attribute

none: LengthUnit

real_lattice class-attribute

real_lattice: LengthUnit

reciprocal_lattice class-attribute

reciprocal_lattice: LengthUnit

name property

name: str

value property

value: int

NodeType

NodeType(value: int)

An enumeration to differentiate between Node types of the brille._brille.BZTrellisQdd, brille._brille.BZTrellisQdc, and brille._brille.BZTrellisQcc, classes.

The return type of the methods, e.g., node_at_type, node_containing_type, and all_node_types.

from brill import NodeType nt = NodeType.polygon

Members:

assumed_null : Indicates a node which should be null but no explicit check was performed

found_null : A node which an explicit check found to be null

null : A null node

cube : A cube shaped node

polygon : A convex polygon shaped node

Attributes:

assumed_null class-attribute

assumed_null: NodeType

cube class-attribute

cube: NodeType

found_null class-attribute

found_null: NodeType

null class-attribute

null: NodeType

polygon class-attribute

polygon: NodeType

name property

name: str

value property

value: int

Floating point tolerance

brille decides the zone and mesh geometry with exact predicates (Shewchuk's robust predicates and exact expansion arithmetic), but compares user-provided lattices, symmetry operations and points with a floating point tolerance, to allow for rounding in the input and in calculations. Two numbers \(a\) and \(b\) are equal if \(|a - b| \le t + \epsilon\,|a + b|\), with \(t\) an absolute tolerance and \(\epsilon\) machine epsilon.

No one absolute tolerance suits all input: atom positions written as 32-bit floats, for example, are far less precise than the lattice vectors beside them. So real-space and reciprocal-space comparisons have separate tolerances.

The absolute tolerances are \(10^{-12}\) Å in real space and \(10^{-12}\) Å⁻¹ in reciprocal space. They can be changed for the whole module,

import brille
brille.real_space_tolerance(1e-10)
brille.reciprocal_space_tolerance(1e-14)

or for one call, with an ApproxConfig:

config = brille.ApproxConfig()
config.real_space_tolerance = 1e-10
config.reciprocal_space_tolerance = 1e-14

Note

Typical input should not need either. Changing them can cause surprising errors elsewhere.

ApproxConfig

ApproxConfig(digits: int = 1000, real_space_tolerance: float = 1e-10, reciprocal_space_tolerance: float = 1e-10)

A local set of approximate floating point comparison values

Attributes:

  • digits (int) –

    A multiplier on the machine epsilon, below which two floating point numbers are approximately the same.

  • real_space_tolerance (float) –

    An absolute real space floating point tolerance in angstrom

  • reciprocal_space_tolerance (float) –

    An absolute reciprocal space floating point tolerance in inverse angstrom

digits property writable

digits: int

A multiplier on the machine epsilon, below which two floating point numbers are approximately the same.

real_space_tolerance property writable

real_space_tolerance: float

An absolute real space floating point tolerance in angstrom

reciprocal_space_tolerance property writable

reciprocal_space_tolerance: float

An absolute reciprocal space floating point tolerance in inverse angstrom

real_space_tolerance

real_space_tolerance() -> float
real_space_tolerance(tolerance: float) -> None
real_space_tolerance() -> float

Return the module-global real space floating point tolerance in angstrom.

reciprocal_space_tolerance

reciprocal_space_tolerance() -> float
reciprocal_space_tolerance(tolerance: float) -> None
reciprocal_space_tolerance() -> float

Return the module-global reciprocal space floating point tolerance in inverse angstrom.