From 3fed9396a11747823b756f6303c128176ce624d3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Ne=C4=8Dada?= Date: Thu, 13 Feb 2020 19:05:11 +0200 Subject: [PATCH] support for TMatrixInterpolator in TMatrixGenerator Former-commit-id: ae3849483ca5d45d39ab51f9340d0c3c7a347865 --- qpms/cytmatrices.pyx | 5 ++++- qpms/qpms_c.pyx | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/qpms/cytmatrices.pyx b/qpms/cytmatrices.pyx index 940cd9e..f370dfe 100644 --- a/qpms/cytmatrices.pyx +++ b/qpms/cytmatrices.pyx @@ -266,7 +266,10 @@ cdef class TMatrixGenerator: self.holder = what self.g.function = qpms_tmatrix_generator_constant self.g.params = (self.holder).rawpointer() - # TODO INTERPOLATOR + elif isinstance(what, TMatrixInterpolator): + self.holder = what + self.g.function = qpms_tmatrix_generator_interpolator + self.g.params = (self.holder).rawpointer() else: raise TypeError("Can't construct TMatrixGenerator from that") diff --git a/qpms/qpms_c.pyx b/qpms/qpms_c.pyx index af16a8d..f99095f 100644 --- a/qpms/qpms_c.pyx +++ b/qpms/qpms_c.pyx @@ -12,7 +12,7 @@ from .cyquaternions cimport IRot3, CQuat from .cybspec cimport BaseSpec from .cycommon cimport make_c_string from .cycommon import string_c2py, PointGroupClass -from .cytmatrices cimport CTMatrix, TMatrixFunction, TMatrixGenerator +from .cytmatrices cimport CTMatrix, TMatrixFunction, TMatrixGenerator, TMatrixInterpolator from .cymaterials cimport EpsMuGenerator from libc.stdlib cimport malloc, free, calloc import warnings @@ -271,6 +271,9 @@ cdef class Particle: raise ValueError("Position argument has to contain 3 or 2 cartesian coordinates") if isinstance(t, CTMatrix): tgen = TMatrixGenerator(t) + elif isinstance(t, TMatrixInterpolator): + tgen = TMatrixGenerator(t) + warnings.warn("Initialising a particle with interpolated T-matrix values. Imaginary frequencies will be discarded and mode search algorithm will yield nonsense (just saying).") elif isinstance(t, TMatrixGenerator): tgen = t else: raise TypeError('t must be either CTMatrix or TMatrixGenerator, was %s' % str(type(t)))