pytalbot

This project's aim is to plot the formation of the Talbot effect in the near field of an infinite periodic diffraction grating of Fourier coefficients gn . This corresponds to the numeric part of the attached report.

https://github.com/gabri110/pytalbot

Science Score: 54.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
    Found CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
    Found .zenodo.json file
  • DOI references
  • Academic publication links
    Links to: arxiv.org
  • Academic email domains
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (11.6%) to scientific vocabulary

Keywords

physics-simulation talbot
Last synced: 4 months ago · JSON representation ·

Repository

This project's aim is to plot the formation of the Talbot effect in the near field of an infinite periodic diffraction grating of Fourier coefficients gn . This corresponds to the numeric part of the attached report.

Basic Info
  • Host: GitHub
  • Owner: Gabri110
  • License: mit
  • Language: Python
  • Default Branch: main
  • Homepage:
  • Size: 25 MB
Statistics
  • Stars: 0
  • Watchers: 1
  • Forks: 1
  • Open Issues: 0
  • Releases: 1
Topics
physics-simulation talbot
Created 11 months ago · Last pushed 4 months ago
Metadata Files
Readme License Citation

README.md

pyTalbot

This project's aim is to plot the formation of the Talbot effect in the near field of an infinite periodic diffraction grating of Fourier coefficients $g_n$. This corresponds to the numeric part of arXiv 2507.00820.

Requirements

With Docker

It is recommended to use Docker to install the dependencies and run the script. After having it installed, just create an image with the provided Dockerfile and run the script from the container. To compile the C libraries, run the following from the main folder, cd pyTalbot/src make

Without Docker

In order to get all the python required libraries, you may run from the main folder pip install -r requirements.txt

It is also necessary to compile the C libraries used for integration. For this you need GSL and OpenMPI. You may install them from the terminal in Ubundu and Debian through sudo apt install gsl and sudo apt install openmpi, and on macOS through brew install gsl and brew install openmpi.

To compile the libraries, run the following from the main folder, cd pyTalbot/src make

In order to be able to create the video, it is indispensable to have FFmpeg installed.

You may install it from the terminal in Ubundu and Debian through sudo apt install ffmpeg and on macOS through brew install ffmpeg.

The problem

This project plots the solution to the 2D wave equation

$$\partial{tt} u = \partial{xx} u + \partial{yy} u + \partial{zz} u$$

in the domain $0 \leq x <= d/2$, $z \geq 0$, $t \geq 0$ under the border conditions in $x$

$$\left.\partialx u\right\vert{x=0} = \left.\partialx u\right\vert{x=d/2} = 0,$$

the boundary conditions in $z$

$$u(t,x,0) = f(t,x) = \sin(\omega t)\theta(t)\, \chi(x/w),$$

and the initial conditions

$$u(t=0) = 0,\quad\text{and,}\quad \partial_t u(t=0) = 0.$$

All of this can be sumarised through the figure Alt text

The solution

The solution to this problem can be written in closed form:

$$u(t,x,z) = \sumn \hat{g}n\left( \sin\omega (t-z) - kn z \intz^{t} \dfrac{J1\left( kn\sqrt{\tau^2-z^2} \right)}{\sqrt{\tau^2-z^2}} \sin\omega(t-\tau) \,d\tau \right) \theta(t-z) \cos{k_n x},$$

which is what we plot. The RHS is mostly straightforward to compute, although certain approximations must be made: - The most obvious, we have to introduce an $N$ at which we truncate the series. We usually want to take $N \gg \frac{d}{ \lambda}$ to make sure that we take into account all the oscillatory behaviour. - We have to numerically approximate the integral. In order to do this, we use GSL's adaptative quadrature method, QAG. In case that QAG runs into problems, we use CQUAD, a doubly-adaptative method, instead.

After calculating $u(t,x,z)$ on a grid, we plot it and make an .mp4 video to showcase the transient behaviour of the Talbot effect.

There is also the possibility to plot the state of the field at the final time considering the stationary approximation (see section 5 of the notes) and to compare its result to the transient case.

Running on a cluster

We are including a SLURM file for those interested in running the simulation on a cluster. Furthermore, the code is compatible with both OpenMP and MPI to speed up the computations when available.

Aknowledgements

This project was developped by Gabriel María Ybarra Marcaida under the supervision of Luis Vega González during the authour's research internship at the Basque Centre for Applied Mathematics in between November 2024 and February 2025.

The authour would like to thank @miguelfrndz and @pcardenal5 with their help with programming issues throughout the development of the project.

Owner

  • Login: Gabri110
  • Kind: user

Citation (CITATION.cff)

# This CITATION.cff file was generated with cffinit.
# Visit https://bit.ly/cffinit to generate yours today!

cff-version: 1.2.0
title: pyTalbot
message: >-
  If you use this software, please cite it using the
  metadata from this file.
type: software
authors:
  - given-names: Gabriel
    family-names: Ybarra Marcaida
    email: gabriybarra@gmail.com
identifiers:
  - type: doi
    value: 10.5281/zenodo.14988572
    description: Zenodo repository
repository-code: 'https://github.com/Gabri110/pyTalbot'
repository: 'https://doi.org/10.5281/zenodo.14988572'
abstract: >-
  This project's aim is to simulate the formation of the
  Talbot effect in the near field of an infinite periodic
  diffraction grating of Fourier coefficients gn. This
  corresponds to the numeric part of the attached report.
keywords:
  - Talbot effect
  - Diffraction
  - Wave equation
license: MIT
commit: 96ec6d3
version: v0.1
date-released: '2025-03-07'

GitHub Events

Total
  • Watch event: 1
  • Push event: 47
  • Public event: 1
  • Pull request event: 1
  • Fork event: 1
  • Create event: 3
Last Year
  • Watch event: 1
  • Push event: 47
  • Public event: 1
  • Pull request event: 1
  • Fork event: 1
  • Create event: 3

Dependencies

Dockerfile docker
  • ubuntu 22.04 build
requirements.txt pypi
  • matplotlib >=3.9.2
  • mpi4py >=4.0.0
  • numpy >=1.26.4
  • tqdm >=4.66.5