From 536301fddc81c7aeb14837b23b4222899af2fa74 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Ne=C4=8Dada?= Date: Tue, 25 Dec 2018 22:15:23 +0200 Subject: [PATCH 1/5] constants.py: unit conversions Former-commit-id: 61ecddf9bb1d4c4a0355bad5edcae435a160aeb2 --- qpms/constants.py | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 qpms/constants.py 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 + From cee14a69e3828531c1830d34109e3eac51039d48 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Ne=C4=8Dada?= Date: Tue, 25 Dec 2018 22:34:37 +0200 Subject: [PATCH 2/5] Some "declarations of intent" for new C code. Former-commit-id: 552279d756fc30f9138f8fc3a9fbc5f901466547 --- qpms/symmetries.h | 13 +++++++++++++ qpms/symmetries.py | 2 ++ qpms/tmatrices.h | 12 ++++++++++++ 3 files changed, 27 insertions(+) create mode 100644 qpms/symmetries.h create mode 100644 qpms/tmatrices.h diff --git a/qpms/symmetries.h b/qpms/symmetries.h new file mode 100644 index 0000000..c3bc69a --- /dev/null +++ b/qpms/symmetries.h @@ -0,0 +1,13 @@ +#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. + * + * Maybe (much later) also point and space group irrep + * functionality as in symmetries.py. + */ + +#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 From 7fb84d1d025b45248e2ab80b09d13d1384502e82 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Ne=C4=8Dada?= Date: Tue, 25 Dec 2018 22:43:57 +0200 Subject: [PATCH 3/5] Some more description of intent in symmetries.h Former-commit-id: c5d64a7a203e5e50d9faadf0a085e5b895cf7d78 --- qpms/symmetries.h | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/qpms/symmetries.h b/qpms/symmetries.h index c3bc69a..1b7207b 100644 --- a/qpms/symmetries.h +++ b/qpms/symmetries.h @@ -5,9 +5,19 @@ * 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 From cac8ee4dfda824b4f610294e64cb2e49750f3db8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Ne=C4=8Dada?= Date: Tue, 25 Dec 2018 23:50:39 +0200 Subject: [PATCH 4/5] Update forgotten struct name Former-commit-id: 77c8dcb871ccb11a37be416a0f3bf19b2ee65abb --- qpms/lattices.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 From cab66465baa078b1488af1da973145b8613a39ec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Ne=C4=8Dada?= Date: Wed, 26 Dec 2018 00:15:19 +0200 Subject: [PATCH 5/5] Some cpython extern declarations / typedefs. Towards accessing the ewald summation functions from python. Former-commit-id: e384cbf2194f2d51357266ac345bfeace7e02b9f --- qpms/qpms_c.pyx | 74 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 74 insertions(+) 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):