Merge branch 'master' of necada.org:~/repo/qpms

Former-commit-id: 02d05da51614f95e6aae4c80da62b6eab940ff62
This commit is contained in:
Marek Nečada 2018-12-25 22:17:49 +00:00
commit c5a82516eb
6 changed files with 145 additions and 1 deletions

33
qpms/constants.py Normal file
View File

@ -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

View File

@ -135,7 +135,7 @@ static const PGenSphReturnData PGenSphDoneVal = {PGEN_DONE, {0,0,0}};
static const PGenCart2ReturnData PGenCart2DoneVal = {PGEN_DONE, {0,0}}; static const PGenCart2ReturnData PGenCart2DoneVal = {PGEN_DONE, {0,0}};
static const PGenCart3ReturnData PGenCart3DoneVal = {PGEN_DONE, {0,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 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. 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 PGenPointFlags native_point_flags; // info about native coordinate system

View File

@ -8,6 +8,80 @@ from cython.parallel cimport parallel, prange
#cimport openmp #cimport openmp
#openmp.omp_set_dynamic(1) #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 ## Auxillary function for retrieving the "meshgrid-like" indices; inc. nmax
@cython.boundscheck(False) @cython.boundscheck(False)
def get_mn_y(int nmax): def get_mn_y(int nmax):

23
qpms/symmetries.h Normal file
View File

@ -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

View File

@ -395,6 +395,8 @@ point_group_info = { # representation info of some useful point groups
# permutation group generators # permutation group generators
(Permutation(0,1, size=6)(2,3), # x -> - x mirror operation (i.e. yz mirror plane) (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) 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) Permutation(4,5, size=6) # z -> - z mirror operation (i.e. xy mirror plane)
), ),
# dictionary with irrep generators # dictionary with irrep generators

12
qpms/tmatrices.h Normal file
View File

@ -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