Convenience methods in cymaterials

Former-commit-id: dc27285f1d23c0cda3c9d80fe073aafc86f77277
This commit is contained in:
Marek Nečada 2019-08-15 14:20:47 +03:00
parent 5a9219a4f6
commit 4bbdfbfbfc
1 changed files with 17 additions and 1 deletions

View File

@ -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