Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-04-09 07:48:46

0001 #!/usr/bin/env python
0002 #
0003 # Copyright (c) 2019 Opticks Team. All Rights Reserved.
0004 #
0005 # This file is part of Opticks
0006 # (see https://bitbucket.org/simoncblyth/opticks).
0007 #
0008 # Licensed under the Apache License, Version 2.0 (the "License"); 
0009 # you may not use this file except in compliance with the License.  
0010 # You may obtain a copy of the License at
0011 #
0012 #   http://www.apache.org/licenses/LICENSE-2.0
0013 #
0014 # Unless required by applicable law or agreed to in writing, software 
0015 # distributed under the License is distributed on an "AS IS" BASIS, 
0016 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  
0017 # See the License for the specific language governing permissions and 
0018 # limitations under the License.
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