usnistgov / pySCATMECH

pySCATMECH is a Python interface to SCATMECH: Polarized Light Scattering C++ Class Library
https://pages.nist.gov/pySCATMECH/index.html
Other
30 stars 12 forks source link

Issue with materials #1

Closed OptoManishK closed 2 years ago

OptoManishK commented 3 years ago

Hi, I have pip installed pySCATMECH in windows 10 PC.

I am trying to run the test example code (https://github.com/usnistgov/pySCATMECH/blob/master/tests/testPySCATMECH.py) and it is getting stuck at various materials like silicon, aluminum, gold etc. Below is a copy of first error which I could resolve by downloading the silicon.txt file in the parent folder.

Is there a way to include other materials as well? How do I download/create these materials library?

`========================== Testing pySCATMECH.fresnel

Traceback (most recent call last): File "D:\Python\RCWA\test.py", line 243, in plt.plot(wavelengths, [silicon(w).real for w in wavelengths], label="Si n") File "D:\Python\RCWA\test.py", line 243, in plt.plot(wavelengths, [silicon(w).real for w in wavelengths], label="Si n") File "C:\Users\K-lab_manish\anaconda3\envs\test\lib\site-packages\pySCATMECH\fresnel.py", line 73, in call return SCATPY.GetOpticalConstant(wavelength,self.name) Exception: At GetOpticalConstant, SCATMECH: Cannot open file "silicon.txt"`

OptoManishK commented 2 years ago

I found out two approached to define a new material. Both approaches are presented in the pySCATMECH example files/website.

One way is to download RI info of a material in three column, tab-delimited text file. Here 1st column reads wavelength, 2nd one n and 3rd one k. Then remove the .txt extension from the filename. This file can now be identified by code as a material (provided the file exists in the current working directory).

The second approach is to make use of OpticalFunction from pySCATMECH.fresnel. Once imported in a python file, a new material can be defined by a mathematical expression e.g. FusedSilica = OpticalFunction(lambda L: 1.4580 + 0.00354/L**2, np.arange(0.2,1.5,0.05))