Skip to content

This is an educational project developed with Streamlit that brings together a collection of interactive simulators to study and visualize light diffraction phenomena

Notifications You must be signed in to change notification settings

Rypsor/Virtual-Optics-Laboratory

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Virtual Optics Laboratory

Welcome to the Virtual Optics Laboratory! This is an educational project developed with Streamlit that brings together a collection of interactive simulators to study and visualize light diffraction phenomena. The application is designed for students, educators, and physics enthusiasts who wish to explore the Fresnel (near-field) and Fraunhofer (far-field) diffraction regimes in an intuitive and visual way.

Streamlit link: https://virtual-optics-laboratory-plcbvaadq4hdtm6zv75c2h.streamlit.app/

📜 Description

This laboratory contains different tools that allow for the simulation of diffraction patterns for various apertures. Each simulator offers interactive controls to modify key physical parameters such as aperture geometry, light wavelength, and observation distances, enabling a deep understanding of how these elements influence the final result.


🔬 Laboratory Modules

The laboratory consists of the following simulators:

1. General Diffraction Simulator via FFT (Fraunhofer)

  • File: pages/2_Simulador_Difraccion.py
  • Allows you to upload any black and white image to be used as an arbitrary aperture.
  • Calculates the Fraunhofer diffraction pattern using the Fast Fourier Transform (FFT), which numerically models the physical phenomenon.
  • Provides controls to scale, rotate, and invert the aperture, as well as adjust padding to improve the resolution of the resulting pattern.

2. Cross Aperture Simulator (Fraunhofer)

  • File: pages/1_Simulador_Cruz.py
  • Simulates the Fraunhofer diffraction pattern for an asymmetrical cross-shaped aperture.
  • Uses the analytical solution derived from the Fourier transform to calculate the intensity with high precision.
  • Includes a far-field condition validator to ensure that the chosen parameters are consistent with the Fraunhofer approximation.

3. Fresnel to Fraunhofer Evolution (Single Slit)

  • File: pages/3_Simulador_Rendija_Fresnel.py
  • Shows the continuous transition of the diffraction pattern from the Fresnel to the Fraunhofer regime as the distance D between the slit and the screen changes.
  • Graphically compares both patterns for a given distance and calculates the Fresnel Number (NF).
  • Includes a heatmap that visualizes the evolution of intensity along the propagation axis.

4. Edge and Slit Simulator (Fresnel)

  • File: pages/4_Simulador_Borde_Fresnel.py
  • Focuses specifically on Fresnel diffraction for simple geometries.
  • Allows simulating the pattern generated by a semi-infinite edge or by a slit (by enabling a second edge).
  • Calculates intensity patterns using the Fresnel integrals from the SciPy library.

🛠️ Technologies Used


🚀 Installation and Usage

To run this laboratory on your local machine, follow these steps:

  1. Clone the repository:

    git clone [https://github.com/Rypsor/optica.git](https://github.com/Rypsor/optica.git)
    cd optica
  2. Create and activate a virtual environment (recommended):

    python -m venv venv
    # On Windows
    venv\Scripts\activate
    # On macOS/Linux
    source venv/bin/activate
  3. Create a requirements.txt file with the following content:

    streamlit
    numpy
    scipy
    matplotlib
    Pillow
  4. Install the dependencies:

    pip install -r requirements.txt
  5. Run the Streamlit application:

    streamlit run app.py
  6. Open your web browser and go to the local URL provided by the terminal (usually http://localhost:8501).


🖼️ Screenshots

(You can add screenshots of each simulator here to show what they look like)

Example: Cross Aperture Simulator Cross Simulator

Example: Fresnel to Fraunhofer Evolution Evolution Simulator


📄 License

This project is licensed under the MIT License. See the LICENSE file for more details.

About

This is an educational project developed with Streamlit that brings together a collection of interactive simulators to study and visualize light diffraction phenomena

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages