Replace scipy.constants with own constants module.

This commit is contained in:
Marek Nečada 2022-06-07 05:53:48 +03:00
parent 87c2fd24fe
commit 1aac5de903
4 changed files with 27 additions and 8 deletions

View File

@ -1,7 +1,26 @@
# unit conversions, mostly for standalone usage """
# TODO avoid importing the "heavy" qpms parts Constants and unit conversion, mostly for standalode usage.
from scipy.constants import epsilon_0 as ε_0, c, pi as π, e as eV, hbar, hbar as , mu_0 as μ_0
pi = π 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 μm = 1e-6
nm = 1e-9 nm = 1e-9
# "SCUFF FREQUENCY UNIT" # "SCUFF FREQUENCY UNIT"

View File

@ -9,7 +9,7 @@ cimport cython
import enum import enum
import warnings import warnings
import os 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 from libc.stdlib cimport malloc, free, calloc, abort
class EpsMuGeneratorType(enum.Enum): class EpsMuGeneratorType(enum.Enum):

View File

@ -6,7 +6,7 @@ import numpy as np
from .qpms_c import * from .qpms_c import *
ň = np.newaxis ň = np.newaxis
import scipy 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 eV = e
from scipy.special import lpmn, lpmv, spherical_jn, spherical_yn, poch, gammaln, factorial from scipy.special import lpmn, lpmv, spherical_jn, spherical_yn, poch, gammaln, factorial
import math import math

View File

@ -12,8 +12,7 @@ except ImportError:
use_moble_quaternion = False use_moble_quaternion = False
import re import re
from scipy import interpolate from .constants import hbar, eV, pi, c
from scipy.constants import hbar, e as eV, pi, c
from .cycommon import get_mn_y, get_nelem from .cycommon import get_mn_y, get_nelem
from .cyquaternions import CQuat from .cyquaternions import CQuat
ň = np.newaxis ň = np.newaxis
@ -440,6 +439,7 @@ class TMatrix(TMatrixSpec):
TODO support for different/multiple interpolators TODO support for different/multiple interpolators
''' '''
def __init__(self, tmatrix_spec): def __init__(self, tmatrix_spec):
from scipy import interpolate
#self.specification = tmatrix_spec #self.specification = tmatrix_spec
self.lMax_override = tmatrix_spec.lMax_override self.lMax_override = tmatrix_spec.lMax_override
self.tmatrix_path = tmatrix_spec.tmatrix_path self.tmatrix_path = tmatrix_spec.tmatrix_path