Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

error when running Appendix A.1 #26

Open
Jasonwi opened this issue Aug 1, 2024 · 1 comment
Open

error when running Appendix A.1 #26

Jasonwi opened this issue Aug 1, 2024 · 1 comment

Comments

@Jasonwi
Copy link

Jasonwi commented Aug 1, 2024

when running Appendix A.1 code

import tmm_fast as tmmf
import numpy as np
L = 12
d = np.random.uniform(20, 150, L)*1e-9 # thicknesses of the layers
d[0] = d[-1] = np.inf # set first and last layer as injection layer
n = np.random.uniform(1.2, 5, L) # random constant refractive index
n[-1] = 1 # outcoupling into air
wl = np.linspace(500, 900, 301)*1e-9
theta = np.deg2rad(np.linspace(0, 90, 301))
result = (tmmf.coh_tmm('s', n, d, theta, wl)['R']+ tmmf.coh_tmm('p', n, d, theta, wl)['R'])/2

get error

Traceback (most recent call last):
  File "d:\project\tmm_fast\appendix_01.py", line 10, in <module>
    result = (tmmf.coh_tmm('s', n, d, theta, wl)['R']+ tmmf.coh_tmm('p', n, d, theta, wl)['R'])/2
  File "d:\project\tmm_fast\tmm_fast\vectorized_tmm_dispersive_multistack.py", line 125, in coh_vec_tmm_disp_mstack
    check_inputs(N, T, lambda_vacuum, Theta)
  File "d:\project\tmm_fast\tmm_fast\vectorized_tmm_dispersive_multistack.py", line 498, in check_inputs
    assert N.ndim == 3, 'N is not of shape [S x L x W] (3d), as it is of dimension ' + str(N.ndim)
AssertionError: N is not of shape [S x L x W] (3d), as it is of dimension 2

tmm-fast version 0.2.1
os Windows 11
torch 2.4.0
numpy 2.0.1

@Nerrror
Copy link
Collaborator

Nerrror commented Aug 20, 2024

Hey, I think this is a problem with some api changes that we have done with the package. In the old version, if you would specifiy a range of wavelengths but a single value for the refractive index n, we automatically assume a dispersionless material and would tile the refractive index value to the same shape as the wavelength. Since most realistic materials have dispersion, we changed this and ask the user to specify the refractive index over wavelenght by himself - however, I agree that we should make this more clear in the error message.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants