All Projects → rafael-fuente → diffractsim

rafael-fuente / diffractsim

Licence: other
✨ A diffraction simulator for exploring and visualizing physical optics.

Programming Languages

python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to diffractsim

odak
🔬 Scientific computing library for optics 🔭, computer graphics 💻 and visual perception 👀
Stars: ✭ 99 (-58.58%)
Mutual labels:  holography, wave-optics
FastExpm.jl
Implementation of a fast exponential matrix for large matrices (full and sparse)
Stars: ✭ 22 (-90.79%)
Mutual labels:  physics, physics-simulations
image-to-box2d-body
proof-of-concept game build pipeline for converting an image to a Box2D body
Stars: ✭ 24 (-89.96%)
Mutual labels:  physics
03-Unstable-Rotation
The code for my Game Physics course: https://www.udemy.com/gamephysics
Stars: ✭ 21 (-91.21%)
Mutual labels:  physics
Legion-Engine
Rythe is a data-oriented C++17 game engine built to make optimal use of modern hardware.
Stars: ✭ 502 (+110.04%)
Mutual labels:  physics
creative-coding-notebooks
🎨 An authorial collection of fundamental recipes on Creative Coding and Recreational Programming.
Stars: ✭ 17 (-92.89%)
Mutual labels:  physics
SymbolicTensors.jl
Manipulate tensors symbolically in Julia! Currently needs a SymPy dependency, but work is ongoing to change the backend to SymbolicUtils.jl
Stars: ✭ 26 (-89.12%)
Mutual labels:  physics
ux-animate
A simple but powerful tweening, spring physics, animation library for Rust
Stars: ✭ 19 (-92.05%)
Mutual labels:  physics
physics-learning-path
This is my physics learning path. Best courses I've found to learn physics online.
Stars: ✭ 37 (-84.52%)
Mutual labels:  physics
GDCustomRaycastVehicle
A simple custom raycast vehicle implementation
Stars: ✭ 36 (-84.94%)
Mutual labels:  physics
diepssect
A public repo for hacky diep stuff - networking protocol, WebAssembly, memory editing, & physics
Stars: ✭ 26 (-89.12%)
Mutual labels:  physics
cas
Cellular Automata Simulator
Stars: ✭ 22 (-90.79%)
Mutual labels:  physics
moac
Generate passwords and analyze their strength given physical limits to computation
Stars: ✭ 16 (-93.31%)
Mutual labels:  physics
fdtd3d
fdtd3d is an open source 1D, 2D, 3D FDTD electromagnetics solver with MPI, OpenMP and CUDA support for x86, arm, arm64 architectures
Stars: ✭ 77 (-67.78%)
Mutual labels:  physics
phoebe
A high-performance framework for solving phonon and electron Boltzmann equations
Stars: ✭ 33 (-86.19%)
Mutual labels:  physics
MachineLearning Physics
This is to facilitate the “Machine Learning in Physics” course that I am teaching at Sharif University of Technology for winter-19 semester. For more information, see the course page at
Stars: ✭ 26 (-89.12%)
Mutual labels:  physics
billiards
billiards physics
Stars: ✭ 37 (-84.52%)
Mutual labels:  physics
plottr
A flexible plotting and data analysis tool.
Stars: ✭ 32 (-86.61%)
Mutual labels:  physics
Libbulletjme
A JNI interface to Bullet Physics and V-HACD
Stars: ✭ 55 (-76.99%)
Mutual labels:  physics
vankampen-stochastic
Exercises and notes for N.G. Van Kampen's Stochastic Processes in Physics and Chemistry
Stars: ✭ 19 (-92.05%)
Mutual labels:  physics

Diffractsim: A diffraction simulator for exploring and visualizing physical optics

animation

Flexible, and easy-to-use Python diffraction simulator that focuses on visualizing physical optics phenomena. The simulator uses mainly scalar diffraction techniques for light propagation, provides a nice interface for simulation set up, and includes several plotting options, counting with CIE Color matching functions for accurate color reproduction.

The basic use of this simulator using the angular spectrum method is described in this article. Take a look to the videos to see the animated simulations!

Features

  • Arbitrary apertures and light spectrums
  • Full-path optical propagation and arbitrary zoom in the region of interest
  • Lenses
  • Phase holograms generation and reconstruction
  • GPU acceleration
  • Incoherent Light (coming soon)

Installation

pip install diffractsim

Alternatively, to download the examples and the apertures as well, you can also build from source by cloning the repository and running from the main folder project on the command prompt:

python setup.py install

Examples

To perform the simulations, just run from the examples subdirectory the corresponding Python scripts on the command prompt. To compute your own diffraction pattern, you'll need to specify in the script the aperture as an image and input its size.

python hexagon_monochromatic.py

N|Solid

python hexagon_polychromatic.py

N|Solid

python rectangular_grating_small.py

N|Solid

python rectangular_grating_big.py

N|Solid

python bahtinov_mask.py

N|Solid

python rings.py

N|Solid

python hexagonal_grating.py

N|Solid

python diffraction_text.py

N|Solid

The examples from the video about diffraction with lenses can be found here.

GPU acceleration requires having CuPy installed and CUDA in your computer. To use GPU acceleration in your simulations, after import diffractsim add the line:

diffractsim.set_backend("CUDA")

Cupy and CUDA aren't required to install and use this package, but they can offer a significant speed boost.

The first GPU accelerated run can be slow because Python is caching the required functions. The next time it can be about 10x and 100x faster than a CPU backend depending on your GPU. The speed boost raises as the grid gets larger.

Diffractsim can also be used to compute and visualize longitudinal profiles. Since the computation of each propagation distance is independent, it can be fully parallelized, and therefore GPU use is highly recommended.

python lens_longitudinal_profile.py

N|Solid

python axicon_longitudinal_profile.py

N|Solid

The problem of phase retrieval is a classic one in optics and arises when one is interested in retrieving the wavefront from two intensity measurements acquired in two different planes. Diffractsim provides a simple implementation of this problem.

In the following example, the GitHub logo is recovered at the Fourier plane from a coherently illuminated square-shaped aperture. The script generates a phase mask, which is stored as an image using an HSV colormap and then placed on the aperture to reconstruct the desired image.

python phase_hologram_github_logo_generation_and_reconstruction.py

animation

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].