diff --git a/qpms/constants.py b/qpms/constants.py new file mode 100644 index 0000000..21280dc --- /dev/null +++ b/qpms/constants.py @@ -0,0 +1,33 @@ +# 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 as ℏ, mu_0 as μ_0 +pi = π +μm = 1e-6 +nm = 1e-9 +# "SCUFF FREQUENCY UNIT" +SU = 3e14 +SCUFF_OMEGAUNIT = SU + +#freqs = freqs_weirdunits * c / μm + +def nm2eV(lambda_nm, n = 1): + return 2*π*c/(n * lambda_nm * nm) / (eV / ℏ) + +def eV2nm(e_eV, n = 1): + return 2*π*c/(n * e_eV * (eV/ℏ)) / nm + +def SU2eV(e_SU): + ''' + Scuff frequency units to eV. + ''' + return e_SU * SU / (eV / ℏ) + +def eV2SU(e_eV): + return e_eV * (eV / ℏ) / SU + +def SU2nm(e_SU, n = 1): + return 2*π*c/(n * e_SU * SU) / nm + +def nm2SU(lambda_nm, n = 1): + return 2*π*c/(n * lambda_nm * nm) / SU + diff --git a/qpms/lattices.h b/qpms/lattices.h index 578655f..79f9f6c 100644 --- a/qpms/lattices.h +++ b/qpms/lattices.h @@ -135,7 +135,7 @@ static const PGenSphReturnData PGenSphDoneVal = {PGEN_DONE, {0,0,0}}; static const PGenCart2ReturnData PGenCart2DoneVal = {PGEN_DONE, {0,0}}; static const PGenCart3ReturnData PGenCart3DoneVal = {PGEN_DONE, {0,0,0}}; -typedef struct PGenSphClassInfo { // static PGenSph info +typedef struct PGenClassInfo { // static PGenSph info char * const name; // mainly for debugging purposes int dimensionality; // lower-dimensional can be converted to higher-D, not vice versa; bit redundant with the following, whatever. PGenPointFlags native_point_flags; // info about native coordinate system diff --git a/qpms/qpms_c.pyx b/qpms/qpms_c.pyx index 58af70c..12db927 100644 --- a/qpms/qpms_c.pyx +++ b/qpms/qpms_c.pyx @@ -8,6 +8,80 @@ from cython.parallel cimport parallel, prange #cimport openmp #openmp.omp_set_dynamic(1) +#cdef extern from "stdbool.h": + +# TODO put the declarations / cdef extern parts to a .pxd file + +cdef extern from "qpms_types.h": + cdef struct cart3_t: + double x + double y + double z + cdef struct cart2_t: + double x + double y + cdef struct sph_t: + double r + double theta + double phi + cdef struct pol_t: + double r + double phi + cdef union anycoord_point_t: + double z + cart3_t cart3 + cart2_t cart2 + pol_t pol + ctypedef enum qpms_normalisation_t: + QPMS_NORMALISATION_XU + QPMS_NORMALISATION_XU_CS + QPMS_NORMALISATION_NONE + QPMS_NORMALISATION_NONE_CS + QPMS_NORMALISATION_KRISTENSSON + QPMS_NORMALISATION_KRISTENSSON_CS + QPMS_NORMALISATION_POWER + QPMS_NORMALISATION_POWER_CS + QPMS_NORMALISATION_TAYLOR + QPMS_NORMALISATION_TAYLOR_CS + QPMS_NORMALISATION_SPHARM + QPMS_NORMALISATION_SPHARM_CS + QPMS_NORMALISATION_UNDEF + # maybe more if needed + +# Point generators from lattices.h +cdef extern from "lattices.h": + ctypedef enum PGenPointFlags: + pass + struct PGenReturnData: + pass + struct PGenZReturnData: + pass + struct PGenPolReturnData: + pass + struct PGenSphReturnData: + pass + struct PGenCart2ReturnData: + pass + struct PGenCart3ReturnData: + pass + struct PGenClassInfo: # maybe important + pass + struct PGen: # probably important + PGenClassInfo* c + void *statedata + void PGen_destroy(PGen *g) + + # now the individual PGen implementations: + # FIXME Is bint always guaranteed to be equivalent to _Bool? (I dont't think so.) + PGen PGen_xyWeb_new(cart2_t b1, cart2_t b2, double rtol, cart2_t offset, + double minR, bint inc_minR, double maxR, bint inc_maxR) + ctypedef enum PGen_1D_incrementDirection: + PGEN_1D_INC_FROM_ORIGIN + PGEN_1D_INC_TOWARDS_ORIGIN + PGen PGen_1D_new_minMaxR(double period, double offset, double minR, bint inc_minR, + double maxR, bint inc_maxR, PGen_1D_incrementDirection incdir) + + ## Auxillary function for retrieving the "meshgrid-like" indices; inc. nmax @cython.boundscheck(False) def get_mn_y(int nmax): diff --git a/qpms/symmetries.h b/qpms/symmetries.h new file mode 100644 index 0000000..1b7207b --- /dev/null +++ b/qpms/symmetries.h @@ -0,0 +1,23 @@ +#ifndef SYMMETRIES_H +#define SYMMETRIES_H +/* TODO. + * + * Here will be functions providing point group operations + * operating on translation operators and T-matrices + * as in tmatrices.py. + * + * At least I want: + * - Wigner D matrices + * - Basic mirror operations for T-matrices + * - Inversion operation for the translation matrices + * + * Maybe (much later) also point and space group irrep + * functionality as in symmetries.py. + * However, I think that the group structures can be simply + * hard-coded/generated by a python script, then there is + * no need to check the group consistency etc. at runtime. + * + * + */ + +#endif // SYMMETRIES_H diff --git a/qpms/symmetries.py b/qpms/symmetries.py index edd4d75..c8ccb9c 100644 --- a/qpms/symmetries.py +++ b/qpms/symmetries.py @@ -395,6 +395,8 @@ point_group_info = { # representation info of some useful point groups # permutation group generators (Permutation(0,1, size=6)(2,3), # x -> - x mirror operation (i.e. yz mirror plane) Permutation(0,3, size=6)(1,2), # y -> - y mirror operation (i.e. xz mirror plane) + # ^^^ btw, I guess that Permutation(0,1, size=6) and Permutation(2,3, size=6) would + # do exactly the same job (they should; CHECK) Permutation(4,5, size=6) # z -> - z mirror operation (i.e. xy mirror plane) ), # dictionary with irrep generators diff --git a/qpms/tmatrices.h b/qpms/tmatrices.h new file mode 100644 index 0000000..305c3e1 --- /dev/null +++ b/qpms/tmatrices.h @@ -0,0 +1,12 @@ +#ifndef TMATRICES_H +#define TMATRICES_H +/* TODO + * This file will contain declarations of functions providing + * a) Mie T-matrix for spherical particle + * i) using Drude model + * ii) using interpolated material data + * b) T-matrix from scuff-tmatrix output, using interpolation + */ + + +#endif //TMATRICES_H