File indexing completed on 2026-04-09 07:48:46
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021 """
0022 boundary.py : inner/outer materials and surfaces
0023 ==================================================
0024
0025 Boundaries are composed of four parts:
0026
0027 * outer material
0028 * outer surface, relevant to incoming photons
0029 * inner surface, relevant to outgoing photons
0030 * inner material
0031
0032 Boundaries are created from a specification string of form "omat/osur/isur/imat"
0033 where outer and inner materials are required but surfaces are optional.
0034 For example:
0035
0036 .. code-block:: py
0037
0038 In [2]: b1 = Boundary("Vacuum///GlassSchottF2")
0039
0040 In [3]: wl = np.linspace(100.,730.,10, dtype=np.float32)
0041
0042 In [4]: ri = b1.imat.refractive_index(wl)
0043
0044 In [8]: al = b1.imat.absorption_length(wl)
0045
0046 In [9]: sl = b1.imat.scattering_length(wl)
0047
0048 In [10]: rp = b1.imat.reemission_prob(wl)
0049
0050 In [11]: np.dstack([wl,ri,al,sl,rp])
0051 Out[11]:
0052 array([[[ 100. , 1.685, 1000000. , 1000000. , 0. ],
0053 [ 170. , 1.685, 1000000. , 1000000. , 0. ],
0054 [ 240. , 1.685, 1000000. , 1000000. , 0. ],
0055 [ 310. , 1.685, 1000000. , 1000000. , 0. ],
0056 [ 380. , 1.658, 1000000. , 1000000. , 0. ],
0057 [ 450. , 1.638, 1000000. , 1000000. , 0. ],
0058 [ 520. , 1.626, 1000000. , 1000000. , 0. ],
0059 [ 590. , 1.619, 1000000. , 1000000. , 0. ],
0060 [ 660. , 1.614, 1000000. , 1000000. , 0. ],
0061 [ 730. , 1.611, 1000000. , 1000000. , 0. ]]])
0062
0063
0064 """
0065 import os, logging, numpy as np
0066 log = logging.getLogger(__name__)
0067
0068 from opticks.ana.base import opticks_environment
0069 from opticks.ana.proplib import PropLib
0070 from opticks.ana.material import Material
0071
0072
0073 class Boundary(object):
0074 def __init__(self, spec):
0075 self.spec = spec
0076
0077 elem = spec.split("/")
0078 assert len(elem) == 4
0079 omat, osur, isur, imat = elem
0080
0081 self.omat = Material(omat)
0082 self.osur = osur
0083 self.isur = isur
0084 self.imat = Material(imat)
0085
0086
0087 def title(self):
0088 return self.spec
0089
0090 def __repr__(self):
0091 return "%s %s " % ( self.__class__.__name__ , self.spec )
0092
0093
0094
0095 if __name__ == '__main__':
0096
0097 logging.basicConfig(level=logging.INFO)
0098 opticks_environment()
0099
0100
0101 wl = np.linspace(100.,730.,10)
0102
0103 boundary = Boundary("Vacuum///GlassSchottF2")
0104
0105 print "imat",boundary.imat.refractive_index(wl)
0106 print "omat",boundary.omat.refractive_index(wl)
0107
0108
0109
0110