Expose single vswf functions to cython.

Former-commit-id: 7fd1183cdab2d6f60b446879a875dab4d673da73
This commit is contained in:
Marek Nečada 2019-08-14 11:04:42 +03:00
parent 1bf9c0b44e
commit 5a9219a4f6
7 changed files with 36 additions and 8 deletions

View File

@ -18,11 +18,12 @@ except ImportError as ex:
raise ex
from .qpms_p import *
from .cyquaternions import CQuat, IRot3
from .cybspec import VSWFNorm, BaseSpec
from .cybspec import VSWFNorm, BaseSpec, default_bspec
from .cytmatrices import CTMatrix, TMatrixInterpolator, TMatrixGenerator
from .cytranslations import trans_calculator
from .cymaterials import MaterialInterpolator, EpsMu, LorentzDrudeModel, lorentz_drude, EpsMuGenerator
from .cycommon import dbgmsg_enable, dbgmsg_disable, dbgmsg_active, BesselType
from .cycommon import dbgmsg_enable, dbgmsg_disable, dbgmsg_active, BesselType, VSWFType
from .cywaves import vswf_single
from .lattices2d import *
from .hexpoints import *
from .tmatrices import *

View File

@ -119,3 +119,4 @@ cdef class BaseSpec:
def __get__(self):
return VSWFNorm(self.s.norm)
default_bspec = BaseSpec(lMax=2)

20
qpms/cywaves.pyx Normal file
View File

@ -0,0 +1,20 @@
from qpms_cdefs cimport *
from .cybspec cimport BaseSpec
from .cybspec import VSWFNorm, default_bspec
from .cycommon import VSWFType, BesselType
def vswf_single(kr_csph, qpms_vswf_type_t t, qpms_l_t l, qpms_m_t m,
qpms_bessel_t btyp = QPMS_BESSEL_REGULAR, qpms_normalisation_t norm = default_bspec.norm):
cdef csph_t kr
kr.r, kr.theta, kr.phi = kr_csph
if t == QPMS_VSWF_ELECTRIC:
return qpms_vswf_single_el_csph(m, l, kr, btyp, norm)
elif t == QPMS_VSWF_MAGNETIC:
return qpms_vswf_single_mg_csph(m, l, kr, btyp, norm)
elif t == QPMS_VSWF_LONGITUDINAL:
raise NotImplementedError("Longitudinal single waves not yet implemented, sorry.")
else:
raise ValueError("Invalid wave type specified")

View File

@ -488,7 +488,7 @@ cdef class ScatteringMatrix:
qpms_scatsys_scatter_solve(&f_view[0], &a_view[0], self.lu)
return f
def pitau(double theta, qpms_l_t lMax, double csphase = 1):
def pitau(double theta, qpms_l_t lMax, double csphase = -1):
if(abs(csphase) != 1):
raise ValueError("csphase must be 1 or -1, is %g" % csphase)
cdef size_t nelem = qpms_lMax2nelem(lMax)

View File

@ -160,6 +160,8 @@ cdef extern from "vswf.h":
qpms_incfield_planewave_params_E E
qpms_errno_t qpms_incfield_planewave(cdouble target, const qpms_vswf_set_spec_t *bspec,
const cart3_t evalpoint, const void *args, bint add)
csphvec_t qpms_vswf_single_el_csph(qpms_m_t m, qpms_l_t n, csph_t kdlj, qpms_bessel_t btyp, qpms_normalisation_t norm)
csphvec_t qpms_vswf_single_mg_csph(qpms_m_t m, qpms_l_t n, csph_t kdlj, qpms_bessel_t btyp, qpms_normalisation_t norm)
cdef extern from "indexing.h":
qpms_y_t qpms_lMax2nelem(qpms_l_t lMax)

View File

@ -128,16 +128,16 @@ qpms_errno_t qpms_incfield_planewave(
// -----------------------------------------------------------------------
/// Electric wave N.
csphvec_t qpms_vswf_single_el(int m, int n, sph_t kdlj,
csphvec_t qpms_vswf_single_el(qpms_m_t m, qpms_l_t n, sph_t kdlj,
qpms_bessel_t btyp, qpms_normalisation_t norm);
/// Magnetic wave M.
csphvec_t qpms_vswf_single_mg(int m, int n, sph_t kdlj,
csphvec_t qpms_vswf_single_mg(qpms_m_t m, qpms_l_t n, sph_t kdlj,
qpms_bessel_t btyp, qpms_normalisation_t norm);
/// Electric wave N, complex wave number version.
csphvec_t qpms_vswf_single_el_csph(int m, int n, csph_t kdlj,
csphvec_t qpms_vswf_single_el_csph(qpms_m_t m, qpms_l_t n, csph_t kdlj,
qpms_bessel_t btyp, qpms_normalisation_t norm);
/// Magnetic wave M, complex wave number version..
csphvec_t qpms_vswf_single_mg_csph(int m, int n, csph_t kdlj,
csphvec_t qpms_vswf_single_mg_csph(qpms_m_t m, qpms_l_t n, csph_t kdlj,
qpms_bessel_t btyp, qpms_normalisation_t norm);
/// Set of electric and magnetic VSWF values in spherical coordinate basis.

View File

@ -92,6 +92,10 @@ cytmatrices = Extension('qpms.cytmatrices',
#extra_link_args=['qpms/libqpms.a', 'amos/libamos.a'],
libraries=['qpms', 'gsl', 'lapacke', 'blas', 'gslcblas', 'pthread',]
)
cywaves = Extension('qpms.cywaves',
sources = ['qpms/cywaves.pyx'],
libraries=['qpms', 'gsl', 'lapacke', 'blas', 'gslcblas', 'pthread',]
)
cytranslations = Extension('qpms.cytranslations',
sources = ['qpms/cytranslations.pyx',
'qpms/translations_python.c',
@ -140,7 +144,7 @@ setup(name='qpms',
#'quaternion','spherical_functions',
'scipy>=0.18.0', 'sympy>=1.2'],
#dependency_links=['https://github.com/moble/quaternion/archive/v2.0.tar.gz','https://github.com/moble/spherical_functions/archive/master.zip'],
ext_modules=cythonize([qpms_c, cytranslations, cytmatrices, cycommon, cyquaternions, cybspec, cymaterials], include_path=['qpms', 'amos'], gdb_debug=True),
ext_modules=cythonize([qpms_c, cywaves, cytranslations, cytmatrices, cycommon, cyquaternions, cybspec, cymaterials], include_path=['qpms', 'amos'], gdb_debug=True),
cmdclass = {'build_ext': build_ext},
zip_safe=False
)