How to insert glass material not in refractiveindex.info?
Hi Bryan, I want to transfer an optical model from another optical design program for testing. The lens is called "AFL12-15" from asphericon. I have the glass material as .csv and extracted the information:
['!Manufact ', 'Name ', 'EqName ', 'Code ', 'B1 ', 'B2 ', 'B3 ', 'C1 ', 'C2 ', 'C3 ', ' A7 ', ' A8 ', ' A9 ', 'EQ ', ' Lmin', ' Lmax ', 'Lv ', 'D0 ', 'D1 ', 'D2 ', 'E0 ', 'E1 ', 'LTK ', 'DNDT7 ', 'DNDT8 ', 'DNDT9 ', 'DNDT10', 'DNDT11', 'DNDT12', 'DRT ', ' 2500', ' 2325', ' 1970', ' 1530', ' 1060', ' 700', ' 660', ' 620', ' 580', ' 546', ' 500', ' 460', ' 436', ' 420', ' 404', ' 400', ' 390', ' 380', ' 370', ' 365', ' 350', ' 334', ' 320', ' 310', ' 300', ' 290', ' 280', ' 270', ' 260', ' 250', ' 240', ' 230', ' CC', ' al1 ', ' al2 ', ' rho ', 'price']
['SPECIAL ', 'HPFS7980 ', 'SILICA ', ' ', '0.683740494 ', ' 0.420323613 ', ' 0.585027480 ', ' 0.00460352869', ' 0.01339688560', ' 64.4932732 ', ' ', ' ', ' ', ' 1 ', ' 0.18 ', ' 2.30 ', ' ', ' 2.40E-5 ', ' 0.0 ', ' 0.0 ', ' 5.5E-7 ', ' 0.0 ', '0.10 ', ' ', ' ', ' ', ' ', ' ', ' ', '10.0', '0.9897', '0.9964', '0.9997', '0.9998', '0.9999', '0.9999', '0.9999', '0.9999', '0.9999', '0.9999', '0.9999', '0.9998', '0.9998', '0.9999', '0.9999', '0.9999', '0.9999', '0.9999', '0.9999', '0.9999', '0.9999', '0.9999', '0.9999', '0.9999', '0.9999', '0.9997', '0.9996', '0.9992', '0.9962', '0.9846', '0.9747', '0.9831', ' ', ' 0.52', ' ', ' 2.20', '']
How can I define a glass material "OpticalMaterial" in raypier by inserting Sellmeier coefficients "B1 ', 'B2 ', 'B3 ', 'C1 ', 'C2 ', 'C3"?
The equation is like eq. 10 in http://www.schott.com/shop/medias/tie-29-refractive-index-and-dispersion-eng.pdf?context=bWFzdGVyfHJvb3R8MTg4OTQ2NHxhcHBsaWNhdGlvbi9wZGZ8aDQ3L2hjYS84ODE3NDA5NTg5Mjc4LnBkZnxkMTc5MjMyYjI5YmRlZTAzZmFmYzIxZmVlNTMyMmE5NzBiNWI5OGJhODM3YWRjYmM5NmY1ZTczMjY1ZWM3NDdk
I saw you defined some Sellmeier equations here: https://github.com/bryancole/raypier_optics/blob/master/raypier/core/cmaterials.pyx used in "BaseDispersionCurve(object)".
Could you please provide me with an example how to enter the Sellmeier coefficients?
Best regards, Jonas
Ah I found this class here https://github.com/bryancole/raypier_optics/blob/79da3d45312f66bf9bf0833f0cdd76f17ba16610/raypier/dispersion.py:
class FusedSilica(BaseDispersionCurve): """ A Dispersion curve for fused silica. """ def init(self, absorption=0.0): formula_id=1 coefs = numpy.array([0.0, 0.6961663, 0.0684043, 0.4079426, 0.1162414, 0.8974794, 9.896161]) wavelen_min=0.21 wavelen_max=6.7 super(FusedSilica,self).init(formula_id, coefs, absorption, wavelen_min, wavelen_max )
Could it be done by adding a property "from_formula" to https://github.com/bryancole/raypier_optics/blob/79da3d45312f66bf9bf0833f0cdd76f17ba16610/raypier/materials.py :
class OpticalMaterial(HasStrictTraits): name = Str("Part A") from_database = Bool(True) refractive_index = Float(1.0) glass_name=Enum(GlassNames) absorption=Float(0.0)
dispersion_curve = Property(depends_on="glass_name, absorption, refractive_index, from_database")
traits_view = View(VGroup(
Item("from_database"),
Item("glass_name", style="simple", enabled_when="from_database"),
Item("refractive_index", editor=NumEditor, enabled_when="not from_database"),
Item("absorption", editor=NumEditor),
))
def __init__(self, *args, **kwds):
if "from_database" not in kwds:
if ("refractive_index" in kwds) and ("glass_name" not in kwds):
kwds['from_database'] = False
return super().__init__(*args, **kwds)
@cached_property
def _get_dispersion_curve(self):
if self.from_database:
return NamedDispersionCurve(self.glass_name, absorption=self.absorption)
else:
return NondispersiveCurve(refractive_index=self.refractive_index,
absorption=self.absorption)
?
Hi Jonas, Looks like you more-or-less found the answer. I've just pushed a changeset which adds a OpticalMaterialFromFormula class. The OpticalMaterial class was a very simple Traits wrapper roundthe BaseDispersiveMaterial object (not a Traits class) which actually evaluates the Sellmeier equation. I didn't want to add another parameter to OpticalMaterial; I think making a new subclass of the (newly added) BaseOpticalMaterial is cleaner. Note, for the Schott glass you mention, you need to use Formula_ID=2. Check against the formula definitions here: https://refractiveindex.info/database/doc/Dispersion%20formulas.pdf There are a couple other changesets I've pushed as well (stuff playing with implicit functions for modelling complex shaped optics) which, on reflection, I should have done on another branch. However, I don't think I've broken anything. Bryan On Fri, 2022-06-10 at 00:42 -0700, Jonas231 wrote:
Could it be done by adding a property "from_formula" to
https://github.com/bryancole/raypier_optics/blob/79da3d45312f66bf9bf0833f0cdd76f17ba16610/raypier/materials.py : class OpticalMaterial(HasStrictTraits):
name = Str("Part A")
from_database = Bool(True)
refractive_index = Float(1.0)
glass_name=Enum(GlassNames)
absorption=Float(0.0) dispersion_curve = Property(depends_on="glass_name, absorption, refractive_index, from_database") traits_view = View(VGroup( Item("from_database"), Item("glass_name", style="simple", enabled_when="from_database"), Item("refractive_index", editor=NumEditor, enabled_when="not from_database"), Item("absorption", editor=NumEditor), )) def init(self, *args, **kwds): if "from_database" not in kwds: if ("refractive_index" in kwds) and ("glass_name" not in kwds): kwds['from_database'] = False return super().init(*args, **kwds) @cached_propertydef _get_dispersion_curve(self): if self.from_database: return NamedDispersionCurve(self.glass_name, absorption=self.absorption) else: return NondispersiveCurve(refractive_index=self.refractive_index,
absorption=self.absorption) ?— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you are subscribed to this thread.Message ID: < @.***>
Hello Bryan, with your new version I get now this error:
~\Anaconda3\envs\myRaypier38\lib\site-packages\raypier-0.2.3-py3.8-win-amd64.egg\raypier\core\cfaces.pyx in init raypier.core.cfaces()
ModuleNotFoundError: No module named 'distribute_setup'
Regards, Jonas
Okay. I repeated the build of your new version. Now it works.
I used: "m1 = OpticalMaterialFromFormula(formula_id = 2, coefs = coeffs, wavelen_min = Lmin, wavelen_max = Lmax)"
Hi Bryan, I setup a new environment with myRaypier38.yml on another Windows PC and "pip install chaco=3.8.0". I used git clone https://github.com/bryancole/raypier_optics and used "python setup.py install".
Now I am getting the error "~\Anaconda3\envs\myRaypier38\lib\site-packages\raypier-0.2.3-py3.8-win-amd64.egg\raypier\core\cfaces.pyx in init raypier.core.cfaces()
ModuleNotFoundError: No module named 'distribute_setup' " again.
Full error message: " from raypier.api import OpticalMaterialFromFormula
File "C:\Users\Jonas.conda\envs\myRaypier38\lib\site-packages\raypier-0.2.3-py3.8-win-amd64.egg\raypier\api.py", line 5, in
File "C:\Users\Jonas.conda\envs\myRaypier38\lib\site-packages\raypier-0.2.3-py3.8-win-amd64.egg\raypier\general_optic.py", line 15, in
File "C:\Users\Jonas.conda\envs\myRaypier38\lib\site-packages\raypier-0.2.3-py3.8-win-amd64.egg\raypier\lenses.py", line 30, in
File "raypier\core\cfaces.pyx", line 11, in init raypier.core.cfaces
ModuleNotFoundError: No module named 'distribute_setup' "
Do you know why this error occurs?
Best regards, Jonas
This is the content of my .yml file:
name: myRaypier38 channels:
- spyder-ide
- dbanas
- anaconda
- conda-forge
- defaults dependencies:
- alabaster=0.7.12=py_0
- apptools=5.1.0=pyh44b312d_0
- argh=0.26.2=pyh9f0ad1d_1002
- argon2-cffi=20.1.0=py38he774522_1
- arrow=1.2.1=pyhd8ed1ab_0
- astroid=2.5.8=py38haa244fe_0
- async_generator=1.10=py_0
- atomicwrites=1.4.0=pyh9f0ad1d_0
- attrs=21.2.0=pyhd8ed1ab_0
- autopep8=1.6.0=pyhd8ed1ab_0
- babel=2.9.1=pyh44b312d_0
- backcall=0.2.0=pyh9f0ad1d_0
- backports=1.0=py_2
- backports.functools_lru_cache=1.6.4=pyhd8ed1ab_0
- bcrypt=3.2.0=py38h294d835_2
- binaryornot=0.4.4=py_1
- black=21.10b0=pyhd8ed1ab_0
- blas=1.0=mkl
- bleach=4.1.0=pyhd8ed1ab_0
- bottleneck=1.3.4=py38h080aedc_0
- brotli=1.0.9=ha925a31_2
- brotlipy=0.7.0=py38h294d835_1003
- bzip2=1.0.8=h8ffe710_4
- ca-certificates=2022.4.26=haa95532_0
- certifi=2022.5.18.1=py38haa95532_0
- cffi=1.15.0=py38hd8c33c5_0
- chardet=4.0.0=py38haa244fe_2
- charset-normalizer=2.0.0=pyhd8ed1ab_0
- click=8.0.3=py38haa244fe_1
- cloudpickle=2.0.0=pyhd8ed1ab_0
- colorama=0.4.4=pyh9f0ad1d_0
- configobj=5.0.6=py_0
- cookiecutter=1.6.0=py38_1000
- cryptography=35.0.0=py38hb7941b4_2
- curl=7.80.0=h789b8ee_0
- cycler=0.11.0=pyhd8ed1ab_0
- cython=0.29.24=py38h885f38d_1
- dataclasses=0.8=pyhc8e2a94_3
- debugpy=1.5.1=py38h885f38d_0
- decorator=5.1.0=pyhd8ed1ab_0
- defusedxml=0.7.1=pyhd8ed1ab_0
- diff-match-patch=20200713=pyh9f0ad1d_0
- docutils=0.15.2=py38haa244fe_2
- double-conversion=3.1.5=h0e60522_2
- eigen=3.4.0=h2d74725_0 #- enable=5.2.1=py38h4da3286_2
- entrypoints=0.3=pyhd8ed1ab_1003
- envisage=6.0.1=pyhd8ed1ab_0
- expat=2.4.1=h39d44d4_0
- ffmpeg=4.3.1=ha925a31_0
- flake8=3.9.2=pyhd8ed1ab_0
- fonttools=4.25.0=pyhd3eb1b0_0
- freetype=2.10.4=h546665d_1
- future=0.18.2=py38haa244fe_4
- gl2ps=1.4.2=h0597ee9_0
- glew=2.1.0=h39d44d4_2
- hdf4=4.2.15=h0e5069d_3
- hdf5=1.10.6=nompi_h5268f04_1114
- icc_rt=2019.0.0=h0cc432a_1
- icu=68.2=h0e60522_0
- idna=3.1=pyhd3deb0d_0
- imagesize=1.3.0=pyhd8ed1ab_0
- importlib-metadata=4.8.2=py38haa244fe_0
- importlib_metadata=4.8.2=hd8ed1ab_0
- importlib_resources=5.4.0=pyhd8ed1ab_0
- inflection=0.5.1=pyh9f0ad1d_0
- intel-openmp=2021.4.0=h57928b3_3556
- intervaltree=3.0.2=py_0
- ipykernel=6.5.0=py38h595d716_0
- ipython=7.29.0=py38h595d716_2
- ipython_genutils=0.2.0=py_1
- ipywidgets=7.5.1=py_1
- isort=5.10.1=pyhd8ed1ab_0
- jbig=2.1=h8d14728_2003
- jedi=0.18.0=py38haa244fe_3
- jinja2=3.0.3=pyhd8ed1ab_0
- jinja2-time=0.2.0=py_2
- jpeg=9d=h8ffe710_0
- jsoncpp=1.9.4=h2d74725_3
- jsonschema=4.2.1=pyhd8ed1ab_0
- jupyter=1.0.0=py38_7
- jupyter_client=6.1.12=pyhd8ed1ab_0
- jupyter_console=6.2.0=py_0
- jupyter_core=4.9.1=py38haa244fe_1
- jupyterlab_pygments=0.1.2=pyh9f0ad1d_0
- keyring=23.2.1=py38haa244fe_1
- kiwisolver=1.3.2=py38hbd9d945_1
- krb5=1.19.2=h20d022d_3
- lazy-object-proxy=1.6.0=py38h294d835_1
- lerc=3.0=h0e60522_0
- libclang=11.1.0=default_h5c34c98_1
- libcurl=7.80.0=h789b8ee_0
- libdeflate=1.8=h8ffe710_0
- libflang=5.0.0=h6538335_20180525
- libiconv=1.16=he774522_0
- libnetcdf=4.8.1=nompi_hf689e7d_100
- libogg=1.3.4=h8ffe710_1
- libpng=1.6.37=h1d00b33_2
- libsodium=1.0.18=h8d14728_1
- libspatialindex=1.9.3=h39d44d4_4
- libssh2=1.10.0=h680486a_2
- libtheora=1.1.1=h8d14728_1005
- libtiff=4.3.0=hd413186_2
- libwebp=1.2.0=h2bbff1b_0
- libxml2=2.9.12=hf5bbc77_1
- libzip=1.8.0=hfed4ece_1
- libzlib=1.2.11=h8ffe710_1013
- llvm-meta=5.0.0=0
- loguru=0.5.3=py38haa244fe_3
- lz4-c=1.9.3=h8ffe710_1
- m2w64-gcc-libgfortran=5.3.0=6
- m2w64-gcc-libs=5.3.0=7
- m2w64-gcc-libs-core=5.3.0=7
- m2w64-gmp=6.1.0=2
- m2w64-libwinpthread-git=5.0.0.4634.697f757=2
- markupsafe=2.0.1=py38h294d835_1
- matplotlib=3.5.0=py38haa244fe_0
- matplotlib-base=3.5.0=py38h1f000d6_0
- matplotlib-inline=0.1.3=pyhd8ed1ab_0
- mayavi=4.7.2=py38h0a81178_5
- mccabe=0.6.1=py_1
- mistune=0.8.4=py38h294d835_1005
- mkl=2021.4.0=haa95532_640
- mkl-service=2.4.0=py38h2bbff1b_0
- mkl_fft=1.3.1=py38h277e83a_0
- mkl_random=1.2.2=py38hf11a4ad_0
- mpmath=1.2.1=pyhd8ed1ab_0
- msys2-conda-epoch=20160418=1
- munkres=1.1.4=py_0
- mypy_extensions=0.4.3=py38haa244fe_4 #- nbclient=0.5.8=pyhd8ed1ab_0
- nbconvert=6.3.0=py38haa244fe_0
- nbformat=5.1.3=pyhd8ed1ab_0
- nest-asyncio=1.5.1=pyhd8ed1ab_0
- notebook=6.1.4=py38_0
- numexpr=2.8.1=py38hb80d3ca_0
- numpy=1.21.5=py38h7a0a035_2
- numpy-base=1.21.5=py38hca35cd5_2
- numpydoc=1.1.0=py_1
- olefile=0.46=pyhd3eb1b0_0
- openmp=5.0.0=vc14_1
- openssl=1.1.1o=h2bbff1b_0
- packaging=21.0=pyhd8ed1ab_0
- pandas=1.4.2=py38hd77b12b_0
- pandoc=2.16.1=h8ffe710_0
- pandocfilters=1.5.0=pyhd8ed1ab_0
- paramiko=2.8.0=pyhd8ed1ab_0
- parso=0.8.2=pyhd8ed1ab_0
- pathspec=0.9.0=pyhd8ed1ab_0
- pexpect=4.8.0=pyh9f0ad1d_2
- pickleshare=0.7.5=py_1003
- pillow=8.4.0=py38hd45dc43_0
- pip=21.0.1=py38haa95532_0
- platformdirs=2.3.0=pyhd8ed1ab_0
- pluggy=1.0.0=py38haa244fe_2
- poyo=0.5.0=py_0
- proj=8.2.0=h1cfcee9_0
- prometheus_client=0.8.0=py_0
- prompt-toolkit=3.0.8=py_0
- prompt_toolkit=3.0.8=0
- psutil=5.8.0=py38h294d835_2
- ptyprocess=0.7.0=pyhd3deb0d_0
- pugixml=1.11.4=h0e60522_0
- pycodestyle=2.7.0=pyhd8ed1ab_0
- pycparser=2.21=pyhd8ed1ab_0
- pydocstyle=6.1.1=pyhd8ed1ab_0
- pyface=7.3.0=pyh44b312d_1
- pyflakes=2.3.1=pyhd8ed1ab_0
- pygments=2.10.0=pyhd8ed1ab_0
- pylint=2.7.2=py38haa244fe_0
- pyls-spyder=0.4.0=pyhd8ed1ab_0
- pynacl=1.4.0=py38h31c79cd_3
- pyopenssl=21.0.0=pyhd8ed1ab_0
- pyparsing=3.0.6=pyhd8ed1ab_0
- pyqt=5.12.3=py38haa244fe_8
- pyqt-impl=5.12.3=py38h885f38d_8
- pyqt5-sip=4.19.18=py38h885f38d_8
- pyqtchart=5.12=py38h885f38d_8
- pyqtwebengine=5.12.1=py38h885f38d_8
- pyrsistent=0.18.0=py38h294d835_0
- pysocks=1.7.1=py38haa244fe_4
- python=3.8.12=h6244533_0
- python-dateutil=2.8.2=pyhd8ed1ab_0
- python-lsp-black=1.0.0=pyhd8ed1ab_0
- python-lsp-jsonrpc=1.0.0=pyhd8ed1ab_0
- python-lsp-server=1.2.4=pyhd8ed1ab_0
- python_abi=3.8=2_cp38
- pytz=2021.3=pyhd8ed1ab_0
- pywin32=302=py38h294d835_2
- pywin32-ctypes=0.2.0=py38haa244fe_1004
- pywinpty=0.5.7=py38_0
- pyyaml=6.0=py38h294d835_3
- pyzmq=22.3.0=py38h09162b1_1
- qdarkstyle=3.0.2=pyhd8ed1ab_0
- qstylizer=0.2.1=pyhd8ed1ab_0
- qt=5.12.9=h5909a2a_4
- qtawesome=1.1.0=pyhd8ed1ab_0
- qtconsole=5.1.1=pyhd3eb1b0_0
- qtpy=1.11.2=pyhd8ed1ab_0
- regex=2021.11.10=py38h294d835_0
- requests=2.26.0=pyhd8ed1ab_0
- rope=0.21.1=pyhd8ed1ab_0
- rtree=0.9.7=py38h8b54edf_2
- scipy=1.7.3=py38h0a974cb_0
- send2trash=1.5.0=py38_0
- setuptools=58.0.4=py38haa95532_0
- six=1.16.0=pyh6c4a22f_0
- snowballstemmer=2.1.0=pyhd8ed1ab_0
- sortedcontainers=2.4.0=pyhd8ed1ab_0
- sphinx=4.3.0=pyh6c4a22f_0
- sphinxcontrib-applehelp=1.0.2=py_0
- sphinxcontrib-devhelp=1.0.2=py_0
- sphinxcontrib-htmlhelp=2.0.0=pyhd8ed1ab_0
- sphinxcontrib-jsmath=1.0.1=py_0
- sphinxcontrib-qthelp=1.0.3=py_0
- sphinxcontrib-serializinghtml=1.1.5=pyhd8ed1ab_0
- spyder=5.1.5=py38haa244fe_1
- spyder-kernels=2.1.3=py38haa244fe_0
- spyder-notebook=0.1.4=py_0
- sqlite=3.36.0=h2bbff1b_0
- sympy=1.9=py38haa244fe_1
- tbb=2020.2=h2d74725_4
- tbb-devel=2020.2=h2d74725_4
- terminado=0.9.1=py38_0
- testpath=0.5.0=pyhd8ed1ab_0
- textdistance=4.2.2=pyhd8ed1ab_0
- three-merge=0.1.1=pyh9f0ad1d_0
- tinycss2=1.1.0=pyhd8ed1ab_0
- tk=8.6.11=h8ffe710_1
- toml=0.10.2=pyhd8ed1ab_0
- tomli=1.2.2=pyhd8ed1ab_0
- tornado=6.1=py38h294d835_2
- traitlets=5.1.1=pyhd8ed1ab_0
- traits=6.3.2=py38h294d835_0
- traitsui=7.2.0=pyhd8ed1ab_0
- typed-ast=1.5.0=py38h294d835_0
- typing_extensions=3.10.0.2=pyha770c72_0
- ujson=4.2.0=py38h885f38d_1
- urllib3=1.26.7=pyhd8ed1ab_0
- utfcpp=3.2.1=h57928b3_0
- vc=14.2=h21ff451_1
- vs2015_runtime=14.27.29016=h5e58377_2
- vtk=9.0.3=no_osmesa_py38hb83a64e_106
- watchdog=2.1.6=py38haa244fe_1
- wcwidth=0.2.5=pyh9f0ad1d_2
- webencodings=0.5.1=py_1
- wheel=0.37.0=pyhd3eb1b0_1
- whichcraft=0.6.1=py_0
- widgetsnbextension=3.5.1=py38_0
- win32_setctime=1.0.3=py_0
- win_inet_pton=1.1.0=py38haa244fe_3
- wincertstore=0.2=py38haa95532_2
- winpty=0.4.3=4
- wrapt=1.12.1=py38h294d835_3
- xz=5.2.5=h62dcd97_1
- yaml=0.2.5=he774522_0
- yapf=0.31.0=pyhd8ed1ab_0
- zeromq=4.3.4=h0e60522_1
- zipp=3.6.0=pyhd8ed1ab_0
- zlib=1.2.11=h8ffe710_1013
- zstd=1.5.0=h6255e5f_0
- pip:
- chaco==4.8.0
prefix: C:\Users\herbst\Anaconda3\envs\myRaypier38
Hi Jonas,
Sorry, my bad. Lines 11-13 in raypier\core\cfaces.pyx in the latest commit should not be there. This is my IDE (eclipse) adding random imports at the top of the file (as part of it's auto-fix 'feature') without me noticing. Very annoying. I need to figure out how to turn that off.
I've just pushed a fix.
Bryan