WIP cython support for periodic lattices

Former-commit-id: f679f63941ec8dd597a5ccd140682de889e21807
This commit is contained in:
Marek Nečada 2020-02-29 01:35:12 +02:00
parent dd391747bf
commit 213853e407
3 changed files with 42 additions and 2 deletions

View File

@ -244,6 +244,16 @@ cdef class FinitePointGroup:
self.G = <qpms_finite_group_t *>0 self.G = <qpms_finite_group_t *>0
self.owns_data = False self.owns_data = False
property order: # LPTODO might instead be __len__() if iterable at some point
def __get__(self):
return self.G[0].order
@staticmethod
def TRIVIAL(): # quite ugly
from .symmetries import point_group_info
return FinitePointGroup(point_group_info['trivial_g'])
cdef class FinitePointGroupElement: cdef class FinitePointGroupElement:
'''TODO''' '''TODO'''
cdef readonly FinitePointGroup G cdef readonly FinitePointGroup G
@ -360,7 +370,12 @@ cdef class ScatteringSystem:
#TODO is there a way to disable the constructor outside this module? #TODO is there a way to disable the constructor outside this module?
@staticmethod # We don't have any "standard" constructor for this right now @staticmethod # We don't have any "standard" constructor for this right now
def create(particles, medium, FinitePointGroup sym, cdouble omega): # TODO tolerances def create(particles, medium, cdouble omega, FinitePointGroup sym = FinitePointGroup.TRIVIAL(),
latticebasis = None): # TODO tolerances
if latticebasis is not None and sym.order != 1:
raise NotImplementedError("Periodic systems don't currently support nontrivial point group symmetries")
# These we are going to construct # These we are going to construct
cdef ScatteringSystem self cdef ScatteringSystem self
cdef _ScatteringSystemAtOmega pyssw cdef _ScatteringSystemAtOmega pyssw
@ -419,6 +434,12 @@ cdef class ScatteringSystem:
tm_derived_key = (tmg_key, None) # TODO unique representation of p.p.op instead of None tm_derived_key = (tmg_key, None) # TODO unique representation of p.p.op instead of None
orig.p[pi].pos = p.cval().pos orig.p[pi].pos = p.cval().pos
orig.p[pi].tmatrix_id = tmindices[tm_derived_key] orig.p[pi].tmatrix_id = tmindices[tm_derived_key]
if latticebasis is not None: # periodic system
assert(len(latticebasis) <= 3 and len(latticebasis) > 0)
orig.lattice_dimension = len(latticebasis)
for d in range(len(latticebasis)):
orig.per.lattice_basis[d] = {'x' : latticebasis[d][0], 'y' : latticebasis[d][1], 'z' : latticebasis[d][2]}
else: orig.lattice_dimension = 0
ssw = qpms_scatsys_apply_symmetry(&orig, sym.rawpointer(), omega, &QPMS_TOLERANCE_DEFAULT) ssw = qpms_scatsys_apply_symmetry(&orig, sym.rawpointer(), omega, &QPMS_TOLERANCE_DEFAULT)
ss = ssw[0].ss ss = ssw[0].ss
finally: finally:

View File

@ -529,7 +529,11 @@ cdef extern from "scatsystem.h":
struct qpms_ss_derived_tmatrix_t: struct qpms_ss_derived_tmatrix_t:
qpms_ss_tmgi_t tmgi qpms_ss_tmgi_t tmgi
qpms_tmatrix_operation_t op qpms_tmatrix_operation_t op
struct qpms_scatsys_periodic_info_t:
cart3_t lattice_basis[3]
#etc.
struct qpms_scatsys_t: struct qpms_scatsys_t:
int lattice_dimension
qpms_epsmu_generator_t medium qpms_epsmu_generator_t medium
qpms_tmatrix_function_t *tmg qpms_tmatrix_function_t *tmg
qpms_ss_tmgi_t tmg_count qpms_ss_tmgi_t tmg_count
@ -541,6 +545,9 @@ cdef extern from "scatsystem.h":
size_t fecv_size size_t fecv_size
size_t *saecv_sizes size_t *saecv_sizes
const qpms_finite_group_t *sym const qpms_finite_group_t *sym
qpms_scatsys_periodic_info_t per
# per[] and other stuff not currently needed in cython
void qpms_scatsys_free(qpms_scatsys_t *s) void qpms_scatsys_free(qpms_scatsys_t *s)
qpms_errno_t qpms_scatsys_dump(qpms_scatsys_t *ss, char *path) #NI qpms_errno_t qpms_scatsys_dump(qpms_scatsys_t *ss, char *path) #NI
qpms_scatsys_t *qpms_scatsys_load(char *path) #NI qpms_scatsys_t *qpms_scatsys_load(char *path) #NI
@ -583,6 +590,7 @@ cdef extern from "scatsystem.h":
const qpms_scatsys_at_omega_t *ssw) const qpms_scatsys_at_omega_t *ssw)
struct qpms_ss_LU: struct qpms_ss_LU:
const qpms_scatsys_at_omega_t *ssw const qpms_scatsys_at_omega_t *ssw
const qpms_scatsys_at_omega_k_t *sswk
bint full bint full
qpms_iri_t iri qpms_iri_t iri
cdouble *a cdouble *a
@ -602,6 +610,17 @@ cdef extern from "scatsystem.h":
beyn_result_t *qpms_scatsys_finite_find_eigenmodes(const qpms_scatsys_t *ss, qpms_iri_t iri, beyn_result_t *qpms_scatsys_finite_find_eigenmodes(const qpms_scatsys_t *ss, qpms_iri_t iri,
cdouble omega_centre, double omega_rr, double omega_ri, size_t contour_npoints, cdouble omega_centre, double omega_rr, double omega_ri, size_t contour_npoints,
double rank_tol, size_t rank_sel_min, double res_tol) double rank_tol, size_t rank_sel_min, double res_tol)
# periodic-related funs
struct qpms_scatsys_at_omega_k_t:
const qpms_scatsys_at_omega_t *ssw
double k[3]
cdouble *qpms_scatsyswk_build_modeproblem_motrix_full(cdouble *target, const qpms_scatsys_at_omega_k_t *sswk)
cdouble *qpms_scatsys_periodic_build_translation_matrix_full(cdouble *target, const qpms_scatsys_t *ss, cdouble wavenumber, const cart3_t *wavevector)
cdouble *qpms_scatsyswk_build_translation_matrix_full(cdouble *target, const qpms_scatsys_at_omega_k_t *sswk)
qpms_ss_LU qpms_scatsyswk_build_modeproblem_matrix_full_LU(cdouble *target, int *target_piv, const qpms_scatsys_at_omega_t *sswk)
beyn_result_t *qpms_scatsys_periodic_find_eigenmodes(const qpms_scatsys_t *ss, const double *k,
cdouble omega_centre, double omega_rr, double omega_ri, size_t contour_npoints,
double rank_tol, size_t rank_sel_min, double res_tol)
cdef extern from "ewald.h": cdef extern from "ewald.h":
struct qpms_csf_result: struct qpms_csf_result:

View File

@ -158,7 +158,7 @@ struct qpms_epsmu_generator_t;
/// Common "class" for system of scatterers, both periodic and non-periodic. /// Common "class" for system of scatterers, both periodic and non-periodic.
/** /**
* Infinite periodic structures (those with \a lattice_dimension > 0) * Infinite periodic structures (those with \a lattice_dimension > 0)
* have the \a per element allocated and filled. * have the \a per filled.
* These are ignored for finite systems (lattice_dimension == 0). * These are ignored for finite systems (lattice_dimension == 0).
*/ */
typedef struct qpms_scatsys_t { typedef struct qpms_scatsys_t {