From a16cea4dca892b5803774f86eb060a6676443acd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Ne=C4=8Dada?= Date: Thu, 16 Jan 2020 08:51:05 +0200 Subject: [PATCH] Set medium generators Former-commit-id: 4eceb154349587fdb363a3e46073f065aa70fe61 --- qpms/qpms_c.pyx | 10 +++++++--- qpms/scatsystem.c | 1 + qpms/scatsystem.h | 2 +- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/qpms/qpms_c.pyx b/qpms/qpms_c.pyx index 6f99173..ec88dbe 100644 --- a/qpms/qpms_c.pyx +++ b/qpms/qpms_c.pyx @@ -13,6 +13,7 @@ from .cybspec cimport BaseSpec from .cycommon cimport make_c_string from .cycommon import string_c2py, PointGroupClass from .cytmatrices cimport CTMatrix, TMatrixFunction, TMatrixGenerator +from .cymaterials cimport EpsMuGenerator from libc.stdlib cimport malloc, free, calloc import warnings @@ -337,6 +338,7 @@ cdef class ScatteringSystem: ''' cdef list tmgobjs # here we keep the references to occuring TMatrixFunctions (and hence BaseSpecs and TMatrixGenerators) #cdef list Tmatrices # Here we keep the references to occuring T-matrices + cdef EpsMuGenerator medium_holder # Here we keep the reference to medium generator cdef qpms_scatsys_t *s def check_s(self): # cdef instead? @@ -345,7 +347,7 @@ cdef class ScatteringSystem: #TODO is there a way to disable the constructor outside this module? @staticmethod # We don't have any "standard" constructor for this right now - def create(particles, FinitePointGroup sym, cdouble omega): # TODO tolerances + def create(particles, medium, FinitePointGroup sym, cdouble omega): # TODO tolerances # These we are going to construct cdef ScatteringSystem self cdef _ScatteringSystemAtOmega pyssw @@ -378,7 +380,8 @@ cdef class ScatteringSystem: tmindices[tm_derived_key] = tm_count tmlist.append(tm_derived_key) tm_count += 1 - + cdef EpsMuGenerator mediumgen = EpsMuGenerator(medium) + orig.medium = mediumgen.g orig.tmg_count = tmg_count orig.tm_count = tm_count orig.p_count = p_count @@ -393,7 +396,7 @@ cdef class ScatteringSystem: orig.tmg[tmgi] = (tmgobjs[tmgi]).raw() for tmi in range(tm_count): tm_derived_key = tmlist[tmi] - tmgi = tmgindices[tmg_key[0]] + tmgi = tmgindices[tm_derived_key[0]] orig.tm[tmi].tmgi = tmgi orig.tm[tmi].op = qpms_tmatrix_operation_noop # TODO adjust when notrivial operations allowed for pi in range(p_count): @@ -409,6 +412,7 @@ cdef class ScatteringSystem: free(orig.tm) free(orig.p) self = ScatteringSystem() + self.medium_holder = mediumgen self.s = ss self.tmgobjs = tmgobjs pyssw = _ScatteringSystemAtOmega() diff --git a/qpms/scatsystem.c b/qpms/scatsystem.c index 1af486f..805c5ea 100644 --- a/qpms/scatsystem.c +++ b/qpms/scatsystem.c @@ -180,6 +180,7 @@ qpms_scatsys_at_omega_t *qpms_scatsys_apply_symmetry(const qpms_scatsys_t *orig, QPMS_CRASHING_MALLOC(ss, sizeof(qpms_scatsys_t)); ss->lenscale = lenscale; ss->sym = sym; + ss->medium = orig->medium; // Copy the qpms_tmatrix_fuction_t from orig ss->tmg_count = orig->tmg_count; diff --git a/qpms/scatsystem.h b/qpms/scatsystem.h index db9f807..721fb69 100644 --- a/qpms/scatsystem.h +++ b/qpms/scatsystem.h @@ -217,7 +217,7 @@ typedef struct qpms_scatsys_at_omega_t { * so keep them alive until scatsys is destroyed. * * The following fields must be filled in the "proto- scattering system" \a orig: - * * orig->medium – The pointer is copied to the new qpms_scatsys_t instance; + * * orig->medium – The pointers are copied to the new qpms_scatsys_t instance; * the target qpms_abstract_tmatrix_t objects must be kept alive before all the resulting * qpms_scatsys_t instances are properly destroyed. * * orig->tmg – The pointers are copied to the new qpms_scatsys_t instance;