WIP fixes, cython interface
Former-commit-id: 8a97ee8adf11b21c6fbaf2d0afe6c6d2e81a8d69
This commit is contained in:
parent
7d19bed4cd
commit
b62f1dadc5
|
@ -422,8 +422,8 @@ cdef class ScatteringSystem:
|
|||
orig.p[pi].pos = p.cval().pos
|
||||
orig.p[pi].tmatrix_id = tmindices[tm_derived_key]
|
||||
ssw = qpms_scatsys_apply_symmetry(&orig, sym.rawpointer(), omega, &QPMS_TOLERANCE_DEFAULT)
|
||||
qpms_ss_create_translation_cache(ss, caching_mode)
|
||||
ss = ssw[0].ss
|
||||
qpms_ss_create_translation_cache(ss, caching_mode)
|
||||
finally:
|
||||
free(orig.tmg)
|
||||
free(orig.tm)
|
||||
|
@ -606,6 +606,11 @@ cdef class ScatteringSystem:
|
|||
self.s, qpms_incfield_planewave, <void *>&p, 0)
|
||||
return target_np
|
||||
|
||||
property has_translation_cache:
|
||||
def __get__(self):
|
||||
self.check_s()
|
||||
return True if qpms_scatsys_has_translation_cache(self.s) else False
|
||||
|
||||
def find_modes(self, cdouble omega_centre, double omega_rr, double omega_ri, iri = None,
|
||||
size_t contour_points = 20, double rank_tol = 1e-4, size_t rank_min_sel=1,
|
||||
double res_tol = 0):
|
||||
|
@ -633,6 +638,8 @@ cdef class ScatteringSystem:
|
|||
cdef np.ndarray[double, ndim=1] ranktest_SV = np.empty((vlen), dtype=np.double)
|
||||
cdef double[::1] ranktest_SV_v = ranktest_SV
|
||||
|
||||
cdef size_t i, j
|
||||
|
||||
for i in range(neig):
|
||||
eigval_v[i] = res[0].eigval[i]
|
||||
eigval_err_v[i] = res[0].eigval_err[i]
|
||||
|
@ -705,6 +712,10 @@ cdef class _ScatteringSystemAtOmega:
|
|||
def __get__(self): return self.ss_pyref.irrep_names
|
||||
property nirreps:
|
||||
def __get__(self): return self.ss_pyref.nirreps
|
||||
property has_translation_cache:
|
||||
def __get__(self):
|
||||
self.check()
|
||||
return True if qpms_scatsysw_has_translation_cache(self.ssw) else False
|
||||
|
||||
def add_translation_cache(self):
|
||||
'''
|
||||
|
@ -715,6 +726,7 @@ cdef class _ScatteringSystemAtOmega:
|
|||
'''
|
||||
self.check()
|
||||
qpms_ssw_create_translation_cache(self.ssw)
|
||||
return self.has_translation_cache
|
||||
|
||||
def modeproblem_matrix_full(self):
|
||||
self.check()
|
||||
|
|
|
@ -609,6 +609,8 @@ cdef extern from "scatsystem.h":
|
|||
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,
|
||||
double rank_tol, size_t rank_sel_min, double res_tol)
|
||||
bint qpms_scatsysw_has_translation_cache(const qpms_scatsys_at_omega_t *ssw)
|
||||
bint qpms_scatsys_has_translation_cache(const qpms_scatsys_t *ss)
|
||||
|
||||
cdef extern from "ewald.h":
|
||||
struct qpms_csf_result:
|
||||
|
|
|
@ -210,6 +210,7 @@ qpms_scatsys_at_omega_t *qpms_scatsys_apply_symmetry(const qpms_scatsys_t *orig,
|
|||
QPMS_CRASHING_MALLOC(ssw, sizeof(*ssw)); // returned
|
||||
ssw->ss = ss;
|
||||
ssw->omega = omega;
|
||||
ssw->translation_cache = NULL;
|
||||
ssw->medium = qpms_epsmu_generator_eval(ss->medium, omega);
|
||||
ssw->wavenumber = qpms_wavenumber(omega, ssw->medium);
|
||||
// we will be using ss->tm_capacity also for ssw->tm
|
||||
|
|
|
@ -193,6 +193,11 @@ typedef struct qpms_scatsys_t {
|
|||
|
||||
} qpms_scatsys_t;
|
||||
|
||||
/// Returns true if ss has the translation caching metadata populated.
|
||||
static inline _Bool qpms_scatsys_has_translation_cache(const qpms_scatsys_t *ss) {
|
||||
return ss->tbooster != NULL;
|
||||
}
|
||||
|
||||
/// Retrieve the bspec of \a tmi'th element of \a ss->tm.
|
||||
static inline const qpms_vswf_set_spec_t *qpms_ss_bspec_tmi(const qpms_scatsys_t *ss, qpms_ss_tmi_t tmi) {
|
||||
return ss->tmg[ss->tm[tmi].tmgi].spec;
|
||||
|
@ -217,7 +222,7 @@ typedef struct qpms_scatsys_at_omega_t {
|
|||
qpms_epsmu_t medium; ///< Background medium optical properties at the given frequency
|
||||
complex double wavenumber; ///< Background medium wavenumber
|
||||
|
||||
struct qpms_scatsysw_translation_booster *translation_cache; ///< (private) cache to speedup tranlations
|
||||
struct qpms_scatsysw_translation_booster *translation_cache; ///< (private) cache to speedup translations
|
||||
} qpms_scatsys_at_omega_t;
|
||||
|
||||
|
||||
|
@ -283,6 +288,11 @@ typedef enum qpms_ss_caching_mode {
|
|||
QPMS_SS_CACHE_DEFAULT = QPMS_SS_CACHE_AUTO
|
||||
} qpms_ss_caching_mode_t;
|
||||
|
||||
/// Returns true if ssw has the translation operator cache populated.
|
||||
static inline _Bool qpms_scatsysw_has_translation_cache(const qpms_scatsys_at_omega_t *ssw) {
|
||||
return ssw->translation_cache != NULL;
|
||||
}
|
||||
|
||||
/// Creates some data structures for speeding up translation operator calculations.
|
||||
/** This is mostly useful for "finite lattices", where many pairs of nanoparticles
|
||||
* share the same relative positions.
|
||||
|
|
Loading…
Reference in New Issue