from dataclasses import dataclass @dataclass class BaseUnits: distance: float charge: float voltage: float concentrationM: float @property def charge_density(self): return self.charge / (self.distance ** 2) @property def energy(self): return self.charge * self.voltage @property def concentration(self): return self.concentrationM * 6.02214076 * 1e23 / (10 * self.distance) ** 3 @dataclass class Constants: Boltzmann: float epsilon0: float e0: float base_units = {'distance': 1e-9, 'charge': 1.602176634 * 1e-19, 'voltage': 1, 'concentrationM': 1e-3} UNITS = BaseUnits(**base_units) # values of different constants in provided base units CONSTANTS = Constants(Boltzmann=1.380649 * 1e-23 / UNITS.energy, epsilon0=8.8541878128 * 1e-12 * UNITS.distance * UNITS.voltage / UNITS.charge, e0=1.602176634 * 1e-19 / UNITS.charge)