diff --git a/qpms/constants.py b/qpms/constants.py index bbdcec6..7874890 100644 --- a/qpms/constants.py +++ b/qpms/constants.py @@ -1,7 +1,26 @@ -# unit conversions, mostly for standalone usage -# TODO avoid importing the "heavy" qpms parts -from scipy.constants import epsilon_0 as ε_0, c, pi as π, e as eV, hbar, hbar as ℏ, mu_0 as μ_0 -pi = π +""" +Constants and unit conversion, mostly for standalode usage. + +Previously, QPMS used scipy.constants in the python parts. +Now the relevant ones are set explicitly here in order +to avoid dependency on the whole scipy (which needs a fortran +compiler to build. + +The values are taken from scipy / "2018 CODATA recommended values". +They slightly differ from the constants in GSL that are used +in the C code. It would be desirable to use the same source, +hence the values here might be subject to change in future versions. +""" + +epsilon_0 = ε_0 = 8.8541878128e-12 # ± 0.0000000013e-12 F m^-1 +c = speed_of_light = 299792458. +eV = e = elementary_charge = 1.602176487e-19 # ± 0000000040e-19 C +hbar = ℏ = 1.054571800e-34 # ± 0.000000013e-34 J s +mu_0 = μ_0 = 1.25663706212e-6 # ± 0.00000000019 e-6 N A^-2 + +from math import pi +π = pi + μm = 1e-6 nm = 1e-9 # "SCUFF FREQUENCY UNIT" diff --git a/qpms/cymaterials.pyx b/qpms/cymaterials.pyx index 1e3915b..330c8ba 100644 --- a/qpms/cymaterials.pyx +++ b/qpms/cymaterials.pyx @@ -9,7 +9,7 @@ cimport cython import enum import warnings import os -from scipy.constants import e as eV, hbar, c +from .constants import e as eV, hbar, c from libc.stdlib cimport malloc, free, calloc, abort class EpsMuGeneratorType(enum.Enum): diff --git a/qpms/qpms_p.py b/qpms/qpms_p.py index f1a0202..0b39711 100644 --- a/qpms/qpms_p.py +++ b/qpms/qpms_p.py @@ -6,7 +6,7 @@ import numpy as np from .qpms_c import * ň = np.newaxis import scipy -from scipy.constants import epsilon_0 as ε_0, c, pi as π, e, hbar as ℏ, mu_0 as μ_0 +from .constants import ε_0, c, pi, π, e, ℏ, μ_0 eV = e from scipy.special import lpmn, lpmv, spherical_jn, spherical_yn, poch, gammaln, factorial import math diff --git a/qpms/tmatrices.py b/qpms/tmatrices.py index 1c9064c..a74a41f 100644 --- a/qpms/tmatrices.py +++ b/qpms/tmatrices.py @@ -12,8 +12,7 @@ except ImportError: use_moble_quaternion = False import re -from scipy import interpolate -from scipy.constants import hbar, e as eV, pi, c +from .constants import hbar, eV, pi, c from .cycommon import get_mn_y, get_nelem from .cyquaternions import CQuat ň = np.newaxis @@ -440,6 +439,7 @@ class TMatrix(TMatrixSpec): TODO support for different/multiple interpolators ''' def __init__(self, tmatrix_spec): + from scipy import interpolate #self.specification = tmatrix_spec self.lMax_override = tmatrix_spec.lMax_override self.tmatrix_path = tmatrix_spec.tmatrix_path