From 4bbdfbfbfc847aae1704a5e224bf7d60047639c5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Ne=C4=8Dada?= Date: Thu, 15 Aug 2019 14:20:47 +0300 Subject: [PATCH] Convenience methods in cymaterials Former-commit-id: dc27285f1d23c0cda3c9d80fe073aafc86f77277 --- qpms/cymaterials.pyx | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/qpms/cymaterials.pyx b/qpms/cymaterials.pyx index fdbf9c2..3b1b7f3 100644 --- a/qpms/cymaterials.pyx +++ b/qpms/cymaterials.pyx @@ -9,7 +9,7 @@ cimport cython import enum import warnings import os -from scipy.constants import e as eV, hbar +from scipy.constants import e as eV, hbar, c from libc.stdlib cimport malloc, free, calloc, abort class EpsMuGeneratorType(enum.Enum): @@ -35,6 +35,15 @@ cdef class EpsMu: def __repr__(self): return 'EpsMu(' + repr(self.em.eps) + ', ' + repr(self.em.mu) + ')' + def k(self, omega): + return self.n * omega / c + property n: + def __get__(self): + return (self.em.eps * self.em.mu)**.5 + property Z: + def __get__(self): + return (self.em.mu / self.em.eps)**.5 + cdef class LorentzDrudeModel: def __cinit__(self, eps_inf, omega_p, f_arr, omega_arr, gamma_arr): cdef size_t n = len(omega_arr) @@ -129,6 +138,13 @@ cdef class EpsMuGenerator: em = self.g.function(omega, self.g.params) return EpsMu(em.eps, em.mu) + def n(self, omega): + return self(omega).n + def Z(self, omega): + return self(omega).Z + def k(self, omega): + return self(omega).k(omega) + cdef qpms_epsmu_generator_t raw(self): return self.g