光散射矩阵库
scatteringmatrix的Python项目详细描述
光散射矩阵库
这实现了一个简单的一维散射矩阵算法,用于计算光学薄膜和滤光片的反射、透射和吸收。它是传输矩阵算法的一种替代方法,并且以不太容易出现高吸收膜的问题而闻名。
开始
这些说明将为您提供项目的副本并在本地计算机上运行。
先决条件
这个库大量使用numpy和scipy库。你应该有:
- python版本>;3.x
- numpy版本>;x.y
- scipy版本>;x.y
(正在测试版本兼容性)
安装
最好的安装方式是通过pip。这是python3库,因此建议安装
pip install scatteringmatrix
或
pip3 install scatteringmatrix
示例
现在examples目录中只有一个示例文件。它与下面的代码完全相同。
"""This file implements finding the transmission and reflection for variouswavelengths for a single index lyaer on a glass substrate."""importscatteringmatrixassmimportnumpyasnp'''Declare Structure'''#Defining index functions. Any function that returns a complex value given#a specific wavelength (in meters) can be used. Here, we declare functions that#always return the same index, regardless of wavelengthindex_air=sm.single_index_function(1.0)index_glass=sm.single_index_function(1.5)index_Si3N4=sm.single_index_function(2.0)#A 1D optical structure is a list of layers. We declare two of the layers herefilm=sm.SingleLayer(index_Si3N4,60.0*sm.Units.NANOMETERS)substrate=sm.SingleLayer(index_glass,1.1*sm.Units.MILLIMETERS)#Here we declare the actual list and append the layers.structure=sm.LayerList()structure.append(sm.SingleLayer(index_air,sm.Units.MICROMETERS))structure.append(film)structure.append(substrate)structure.append(sm.SingleLayer(index_air,sm.Units.MICROMETERS))'''Calculate transmission and reflection at 0 degrees'''wavelengths=np.linspace(300.0,1200.0,91)*sm.Units.NANOMETERS#Data is returned in an array of arrays.results=sm.scattering_matrix_calculation(structure,wavelengths)print("Selected Wavelength Data")print("----------------------------")print("Incident Angle:",results[4])print("Mode:",results[5])print("Wavelengths (nm):",'{0:.1f}'.format(results[3][30]/sm.Units.NANOMETERS),",",'{0:.1f}'.format(results[3][60]/sm.Units.NANOMETERS))print("Transmission @ 600 nm, 900 nm:",'{0:.6f}'.format(results[0][30]),",",'{0:.6f}'.format(results[0][60]))print("Reflection @ 600 nm, 900 nm:",'{0:.6f}'.format(results[1][30]),",",'{0:.6f}'.format(results[1][60]))print("Absorption @ 600 nm, 900 nm:",'{0:.6f}'.format(results[2][30]),",",'{0:.6f}'.format(results[2][60]))
运行此文件将导致输出:
Selected Wavelength Data
----------------------------
Incident Angle: 0.0
Mode: TE
Wavelengths (nm): 600.0 , 900.0
Transmission @ 600 nm, 900 nm: 0.662785 , 0.964672
Reflection @ 600 nm, 900 nm: 0.337215 , 0.035328
Absorption @ 600 nm, 900 nm: 0.000000 , 0.000000
运行单元测试
进入安装库以运行基本单元测试的目录。这可以通过命令行使用
python3 -m unittest
其结果应该类似于:
Ran 80 tests in 0.026s
OK
展开
这仅仅是一个python模块,因此不需要特殊的部署步骤。
贡献
如果你想加入这个项目,请联系主要作者andrew.flood@mail.utoronto.ca。
版本
到目前为止,我们只有开发版和alpha版,所以暂时仍保持在0.1.0。
作者
- andrew flood-initial work和current project lead
许可证
此项目在麻省理工学院许可下获得许可-有关详细信息,请参见license.txt文件