def test_constants(): assert pc.to_float(c.m_e / u.g) == approx(9.1 * 1e-28, abs=1e-30) assert pc.to_float(c.q_e / u.coulomb) == approx(1.60217662 * 1e-19, rel=1e-7) assert pc.to_float(c.mu_b / (u.eV / u.tesla)) == approx(5.788382 * 1e-5, rel=1e-6) assert pc.to_float(c.q_e ** 2 / c.hbar / c.c / c.epsilon0 / 4.0 / c.pi) == approx( 1.0 / 137.0, abs=1e-4 )
def __setitem__(self, key, value): if key in self.energy_quantities: scaled_value = to_float( value / self.energyUnit) # if is an energy quantity, scale it else: scaled_value = value # otherwise just pass self.properties[key] = scaled_value
def __init__(self, name, properties, eunit=None): self.name = name self.properties = dict(properties) if eunit is None: self.energyUnit = units.meV else: self.energyUnit = to_float(units.meV / parse_unit(eunit)) # Tuple of key values that have energy units: self.energy_quantities = ( "workFunction", "fermiEnergy", "electronAffinity", "directBandGap", "valenceBandOffset", "chargeNeutralityLevel", "interbandMatrixElement", "spinOrbitSplitting", )
def reference_level(self, eunit=None): if eunit is None: eunit = units.meV else: eunit = to_float(units.meV / parse_unit(eunit)) return -self.matDict["InSb"]["electronAffinity"] * eunit