-
Notifications
You must be signed in to change notification settings - Fork 0
/
relations.py
59 lines (45 loc) · 1.53 KB
/
relations.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# -*- coding: utf-8 -*-
"""
Various kinds of relations and conversions
"""
import numpy as np
from scipy.constants import physical_constants
"""
Unit conversion
"""
class NotImplemented(Exception):
def __init__(self, value):
self.value = value
def __str__(self):
return repr(self.value)
availableEnergyUnits = ('eV', 'cm-1', 'THz', 'nm')
def xtoeV(x, unitX):
if unitX == 'nm' : return 1239.0/x
elif unitX == 'um' : return 1239.0/(1e3*x)
elif unitX == 'THz' : return x/(physical_constants['electron volt-hertz relationship'][0]/10**12)
elif unitX == 'cm-1': return x/(physical_constants['electron volt-inverse meter relationship'][0]/100)
elif unitX == 'eV' : return x
else: raise NotImplemented("Conversion not implemented")
def eVtox(x, unitX):
if unitX == 'nm' : return 1239.0/x
elif unitX == 'um' : return 1239.0/(1e3*x)
elif unitX == 'THz' : return x*(physical_constants['electron volt-hertz relationship'][0]/10**12)
elif unitX == 'cm-1': return x*(physical_constants['electron volt-inverse meter relationship'][0]/100)
elif unitX == 'eV' : return x
else: raise NotImplemented("Conversion not implemented")
"""
Optical relations
"""
def identity(epsilon):
return epsilon
def reflectivity(epsilon, theta=0.0, polarization='s'):
#TODO Fresnel
n = refractive_index(epsilon)
R = np.abs((n-1)/(n+1))**2
return R
def refractive_index(epsilon):
n = np.sqrt(epsilon)
return n
def conductivity(x, epsilon):
s = 0.0 + 0.0j
return s