Git Product home page Git Product logo

pytmm's Introduction

PyTMM

Transfer Matrix Method implementation & RefractiveIndex.info database (2015-05-24) browser

Citations: DOI

RefractiveIndex.info module as a separate package:

https://github.com/toftul/refractiveindex

Documentation

Extended documentation can be found at kitchenknif.github.io/PyTMM

Installation & Basic Usage

By default the RefractiveIndex module thinks that the RefractiveIndex.info database is installed in your home folder. If this is okay, the database can be used as follows:

catalog = RefractiveIndex()
mat = catalog.getMaterial('main', 'Si', 'Aspnes')
# wavelength in nanometers
n = mat.getRefractiveIndex(500))
n = mat.getExtinctionCoefficient(500))

If you want to have the database in a different folder, you just need to specify the path to the RefractiveIndex database:

catalog = RefractiveIndex("./path/to/folder/with/RefractiveIndex/database")
mat = catalog.getMaterial('main', 'Si', 'Aspnes')
n = mat.getRefractiveIndex(500))  # wavelength in nanometers

By default, the database is downloaded automatically on first use. If you do not want that, use RefractiveIndex(auto_download=False).

Examples of using the transferMatrix module can be found in

.
+-- _PyTMM
|   +-- examples

Dependencies

  • numpy
  • scipy
  • pyyaml
  • matplotlib (for plotting)

pytmm's People

Contributors

kitchenknif avatar woutdenolf avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

pytmm's Issues

Incorrect handling of lossy materials

@MK8J
Let's move this over to the relevant project :)

BTW - The files did not get attached for some reason.
Pavel

Hey Mikhail,

Everything looks great. Thanks for the efforts!

On the scripts you have attached to the github, I think,
https://github.com/kitchenknif/PyTMM, might not properly take into account
the extinction coefficient. There is an implementation that does here
https://pypi.python.org/pypi/tmm.

Mattias

Hi Mattias,
Hmm.
I wasn't sure if the way I had implemented complex refractive indices in PyTMM was correct, but couldn't think of any quick way of checking... If you have an example that definitely shows incorrect behaviour, I would really appreciate it.

That being said,
https://github.com/kitchenknif/PyATMM
Should handle complex refractive indices correctly, and can also work with anisotropic (uniaxial) materials, but is a bit more complex.

Hey Pavel,

I wouldn't rule at user error yet . See below is my attempt at comparing 3
TMM implementations.

I compared a stack of a-Si [272 nm] and Si [infinite], optical constants
shown below. So layers without k, I got good agreement between all
models.
Zip below containing everything required.

i did simulations at 0 deg, so polarization doesn't matter.

pyTMM seems to do some where stuff, giving over 100% transmission.

Yeah I has a look at pyATMM, and put it in the to hard basket for now. I'm
only dealing with isotropic materials.

Mattias

Mutation of input numpy array.

Hi @kitchenknif,

thank you for the very useful project!

I just wanted to point out a behaviour that I think is problematic or at least counterintuitive. When inputing a numpy array in the getRefractiveIndex functions, the array is changed during function execution. See below

import PyTMM.refractiveIndex as RI
import numpy as np
cat = RI.RefractiveIndex()
Wmat = cat.getMaterial('main','W','Werner')

lamspace = np.linspace(200,850)
lamspace
#array([200.        , 213.26530612, 226.53061224, 239.79591837, ... ])
n = Wmat.getRefractiveIndex(lamspace)
lamspace
#array([0.2       , 0.21326531, 0.22653061, 0.23979592, ... ])

This is due to this

wavelength /= 1000.0

if your replace it with wavelength2 = wavelength/1000 and proceed with the new variable, or re-multiply wavelength before returning the function it should be fixed. There are also other lines of code where this is an issue (for interpolated refractive indices and the two extinction coefficient).

Just letting you know, I gladly help if needed

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.