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

ModuleNotFoundError: No module named 'S4' #63

Open
99rbbt opened this issue Jan 22, 2024 · 3 comments
Open

ModuleNotFoundError: No module named 'S4' #63

99rbbt opened this issue Jan 22, 2024 · 3 comments

Comments

@99rbbt
Copy link

99rbbt commented Jan 22, 2024

I successfully installed both S4 and rayflare according to the documentation and I encountered this error when I tried to execute one of examples in the documentation.

Error:
Traceback (most recent call last): File "/home/jaehyeon/my_project/S4/examples/example.py", line 1, in <module> import S4 ModuleNotFoundError: No module named 'S4'

I used visual studio code with wsl, python extension.

@phoebe-p
Copy link
Member

Do you have multiple Python versions? That is usually the issue when you have installed something but cannot import it. You have to make sure that the Python version (the correct on in WSL) where you installed S4 is the same one that VSCode is trying to use.

As an additional point, relating to your email, if you are only trying to simulate thin-film layers (including thin-film layers on e.g. silicon pyramids), there is no reason to install or use S4/RCWA. In fact it will not be able to handle the thick bulk layers you mentioned correctly. So unless you are simulating a solar cell with a diffraction grating, or very small (compared to the wavelength) structures, you probably do not need to use S4.

@99rbbt
Copy link
Author

99rbbt commented Jan 23, 2024

Thank you for your response!

Unfortunately, the structure has bulk(μm scale) top layer and nm scale bottom layer.

Therefore, I checked python version as you said and it seemed to matching well.

python version:
jaehyeon@DESKTOP-40LV1SK:~/my_project/S4$ python --version Python 3.8.10

installed S4:
jaehyeon@DESKTOP-40LV1SK:~/my_project/S4$ pip show S4 Name: S4 Version: 1.1 Summary: Stanford Stratified Structure Solver (S4): Fourier Modal Method Home-page: UNKNOWN Author: UNKNOWN Author-email: UNKNOWN License: UNKNOWN Location: /home/jaehyeon/my_project/mainenv/lib/python3.8/site-packages Requires: Required-by:

installed rayflare:
jaehyeon@DESKTOP-40LV1SK:~/my_project/S4$ pip show rayflare Name: rayflare Version: 1.2.1 Summary: Python-based integrated optical modelling Home-page: https://github.com/qpv-research-group/rayflare Author: Phoebe Pearce Author-email: phoebe.pearce15@imperial.ac.uk License: GNU GPLv3 Location: /home/jaehyeon/my_project/mainenv/lib/python3.8/site-packages Requires: joblib, xarray, inkstone, matplotlib, seaborn, scipy, sparse, numpy, solcore Required-by:

VS code:
캡처

Also, when I run the example without S4 import - [https://rayflare.readthedocs.io/en/latest/Examples/perovskite_Si_rt.html], I met error message.

`SOPRA_DB :: ERROR :: Material not found in SOPRA_DB... Check materials list...
Similar Matches ::

Material ERROR: "MgF2_RdeM" is not in the semiconductors database or in the SOPRA database. Valid semiconductor materials are:`

@phoebe-p
Copy link
Member

It doesn’t matter how thick the layers are, the transfer matrix method will work as long as the layers are made of a single material. Does your structure have a diffraction grating or a photonic crystal? If not, really don’t think you need to use S4! It will actually give worse results for a structure with thick (10s of um) layers than the TMM solver with incoherent layers.

you can see that VSCode is not using the same Python as the one where S4 and RayFlare are installed: the path when you run pop show is /home/jaehyeon/my_project/mainenv/lib/python3.8, but in VSCode it is /bin/python3. This is probably why VSCode cannot find the packages.

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