### Run Optimization with Gyptis
Source: https://context7.com/gyptis/gyptis/llms.txt
This snippet demonstrates how to run an optimization process using the Gyptis optimizer. It initializes the starting point for the optimization and then calls the minimize function to find the optimal solution and the corresponding objective function value. The optimized objective value is then printed.
```python
import numpy as np
# Assuming 'optimizer' is an initialized optimizer object from Gyptis
# and 'optimizer.nvar' is the number of variables.
x0 = 0.5 * np.ones(optimizer.nvar) # initial density
xopt, fopt = optimizer.minimize(x0)
print(f"Optimized objective: {fopt}")
```
--------------------------------
### Waveguide - Guided Mode Calculation
Source: https://context7.com/gyptis/gyptis/llms.txt
Determines propagation constants and mode profiles for an optical waveguide with PML boundary conditions. It solves the eigenvalue problem for a specified wavenumber and prints the effective refractive indices.
```python
wg = gy.Waveguide(
geom, epsilon, mu,
wavenumber=k0,
degree=(2, 2),
)
solution = wg.eigensolve(n_eig=6, target=k0 * n_core)
for i, kz in enumerate(solution["eigenvalues"]):
neff = kz.real / k0
print(f" Mode {i}: kz = {kz:.4f}, n_eff = {neff:.4f}")
```
--------------------------------
### Table of Gallery Execution Times and Memory Usage
Source: https://gitlab.com/gyptis/gyptis/-/blob/master/docs/sg_execution_times.rst
This is a list-table directive used to present the execution time and memory usage for different example files. Each row corresponds to an example, showing its name, total execution time, and memory consumed in MB.
```rst
.. list-table::
:header-rows: 1
:class: table table-striped sg-datatable
* - Example
- Time
- Mem (MB)
* - :ref:`sphx_glr_examples_homogenization_plot_high_contrast.py` (``../examples/homogenization/plot_high_contrast.py``)
- 01:48.419
- 487.6
* - :ref:`sphx_glr_examples_diffraction_plot_2d_to_3d_grating.py` (``../examples/diffraction/plot_2d_to_3d_grating.py``)
- 00:00.000
- 0.0
* - :ref:`sphx_glr_examples_diffraction_plot_anisotropic_grating.py` (``../examples/diffraction/plot_anisotropic_grating.py``)
- 00:00.000
- 0.0
* - :ref:`sphx_glr_examples_diffraction_plot_dielectric_grating.py` (``../examples/diffraction/plot_dielectric_grating.py``)
- 00:00.000
- 0.0
* - :ref:`sphx_glr_examples_diffraction_plot_pec_grating.py` (``../examples/diffraction/plot_pec_grating.py``)
- 00:00.000
- 0.0
* - :ref:`sphx_glr_examples_diffraction_plot_silver_core_shell_grating.py` (``../examples/diffraction/plot_silver_core_shell_grating.py``)
- 00:00.000
- 0.0
* - :ref:`sphx_glr_examples_homogenization_plot_four_phase.py` (``../examples/homogenization/plot_four_phase.py``)
- 00:00.000
- 0.0
* - :ref:`sphx_glr_examples_homogenization_plot_homogenization.py` (``../examples/homogenization/plot_homogenization.py``)
- 00:00.000
- 0.0
* - :ref:`sphx_glr_examples_modal_plot_phc2D.py` (``../examples/modal/plot_phc2D.py``)
- 00:00.000
- 0.0
* - :ref:`sphx_glr_examples_modal_plot_qnm.py` (``../examples/modal/plot_qnm.py``)
- 00:00.000
- 0.0
* - :ref:`sphx_glr_examples_scattering_plot_cylinder.py` (``../examples/scattering/plot_cylinder.py``)
- 00:00.000
- 0.0
* - :ref:`sphx_glr_examples_scattering_plot_ldos.py` (``../examples/scattering/plot_ldos.py``)
- 00:00.000
- 0.0
* - :ref:`sphx_glr_examples_scattering_plot_nanorods.py` (``../examples/scattering/plot_nanorods.py``)
- 00:00.000
- 0.0
* - :ref:`sphx_glr_examples_scattering_plot_pec_cylinder.py` (``../examples/scattering/plot_pec_cylinder.py``)
- 00:00.000
- 0.0
* - :ref:`sphx_glr_examples_scattering_plot_silver_core_shell.py` (``../examples/scattering/plot_silver_core_shell.py``)
- 00:00.000
- 0.0
* - :ref:`sphx_glr_examples_sources_plot_sources.py` (``../examples/sources/plot_sources.py``)
- 00:00.000
- 0.0
* - :ref:`sphx_glr_examples_waveguides_plot_anisotropic_waveguide.py` (``../examples/waveguides/plot_anisotropic_waveguide.py``)
- 00:00.000
- 0.0
* - :ref:`sphx_glr_examples_waveguides_plot_lithium_niobate_waveguide.py` (``../examples/waveguides/plot_lithium_niobate_waveguide.py``)
- 00:00.000
- 0.0
* - :ref:`sphx_glr_tutorials_plot_basic.py` (``../tutorials/plot_basic.py``)
- 00:00.000
- 0.0
* - :ref:`sphx_glr_tutorials_plot_optim.py` (``../tutorials/plot_optim.py``)
- 00:00.000
- 0.0
```
--------------------------------
### BibTeX Citation for Computational Photonics Paper
Source: https://gitlab.com/gyptis/gyptis/-/blob/master/docs/cite.rst
This BibTeX entry can be used to cite the paper that explains the numerical method and provides examples for Gyptis. It includes title, authors, year, journal, volume, number, pages, publisher, ISSN, DOI, and keywords.
```bibtex
@article{vial2022,
title = {Open-{{Source Computational Photonics}} with {{Auto Differentiable Topology Optimization}}},
author = {Vial, Benjamin and Hao, Yang},
year = {2022},
month = jan,
journal = {Mathematics},
volume = {10},
number = {20},
pages = {3912},
publisher = {Multidisciplinary Digital Publishing Institute},
issn = {2227-7390},
doi = {10.3390/math10203912},
copyright = {http://creativecommons.org/licenses/by/3.0/},
keywords = {computational photonics,topology optimization}
}
```
--------------------------------
### Simulate 2D Diffraction Grating
Source: https://context7.com/gyptis/gyptis/llms.txt
Simulates diffraction gratings and calculates diffraction efficiencies. Requires geometry parameters, material properties, and a source. Outputs reflection, transmission, absorption, and energy balance, and allows plotting of field and geometry.
```python
import gyptis as gy
from collections import OrderedDict
import numpy as np
# Geometry parameters
period = 800 # nm
wavelength = 600
n_rod = 1.4
ax, ay = 300, 200 # ellipse semi-axes
# Create layered geometry
thicknesses = OrderedDict({
"substrate": wavelength,
"groove": 2 * ay * 1.5,
"superstrate": wavelength,
})
geom = gy.Layered(dim=2, period=period, thicknesses=thicknesses,
pml_thickness=(wavelength, wavelength))
# Add rod to groove layer
groove = geom.layers["groove"]
y0 = geom.y_position["groove"] + thicknesses["groove"] / 2
rod = geom.add_ellipse(0, y0, 0, ax, ay)
groove, rod = geom.fragment(groove, rod)
geom.add_physical(rod, "rod")
geom.add_physical(groove, "groove")
geom.set_mesh_size({"substrate": 60, "groove": 60, "rod": 30, "superstrate": 60})
geom.build()
# Materialsepsilon = {d: 1 for d in geom.subdomains["surfaces"]}epsilon["rod"] = n_rod**2
mu = {d: 1 for d in geom.subdomains["surfaces"]}
# Plane wave at 20 degrees
angle = np.radians(20)
pw = gy.PlaneWave(wavelength, angle, dim=2)
# Solve grating problem
grating = gy.Grating(
geom, epsilon, mu,
source=pw,
polarization="TM", # or "TE"
degree=2,
)
grating.solve()
# Calculate diffraction efficiencies
effs = grating.diffraction_efficiencies(N_order=2, orders=True, verbose=True)
print(f"Reflection: {effs['R']}")
print(f"Transmission: {effs['T']}")
print(f"Absorption: {effs['Q']}")
print(f"Energy balance: {effs['B']:.6f}")
# Plot field with multiple periods
grating.plot_field(nper=3, type="real", field="total")
grating.plot_geometry(nper=3)
```
--------------------------------
### Create Layered Domain for Diffraction Gratings using Layered
Source: https://context7.com/gyptis/gyptis/llms.txt
Constructs a 2D geometry for diffraction grating simulations with periodic boundary conditions. It defines layers with specified thicknesses, adds grating features like elliptical rods, fragments geometries, assigns physical domains, and sets mesh sizes. Requires 'gyptis' and 'collections.OrderedDict'.
```python
import gyptis as gy
from collections import OrderedDict
# Define layer thicknesses from bottom to top
period = 800 # nm
thicknesses = OrderedDict({
"substrate": 600,
"groove": 400,
"superstrate": 600,
})
# Create 2D grating geometry
geom = gy.Layered(
dim=2,
period=period,
thicknesses=thicknesses,
pml_thickness=(600, 600)
)
# Add grating features (e.g., elliptical rod)
groove = geom.layers["groove"]
y_center = geom.y_position["groove"] + thicknesses["groove"] / 2
rod = geom.add_ellipse(0, y_center, 0, 150, 100) # x, y, z, ax, ay
# Fragment and assign physical domains
groove, rod = geom.fragment(groove, rod)
geom.add_physical(rod, "rod")
geom.add_physical(groove, "groove")
# Set mesh sizes
geom.set_mesh_size({"substrate": 60, "groove": 60, "rod": 30, "superstrate": 60})
geom.build()
```
--------------------------------
### Create 2D Point Source using LineSource
Source: https://context7.com/gyptis/gyptis/llms.txt
Defines a 2D line source, equivalent to a 2D Green's function, for local density of states calculations. Specifies wavelength, position, amplitude, phase, and degree. Requires the 'gyptis' package.
```python
import gyptis as gy
wavelength = 0.5
position = (0.1, 0.2) # (x, y) coordinates
line_source = gy.LineSource(
wavelength=wavelength,
position=position,
dim=2,
amplitude=1.0,
phase=0,
degree=2,
)
```
--------------------------------
### Create Incident Plane Wave using PlaneWave
Source: https://context7.com/gyptis/gyptis/llms.txt
Generates an incident plane wave excitation for scattering and diffraction simulations in 2D or 3D. Allows specification of wavelength, angle of incidence, amplitude, phase, and polarization for both 2D and 3D cases. Requires 'gyptis' and 'numpy'.
```python
import gyptis as gy
import numpy as np
# 2D plane wave
wavelength = 600 # nm
angle = np.radians(20) # angle of incidence
pw_2d = gy.PlaneWave(
wavelength=wavelength,
angle=angle,
dim=2,
amplitude=1.0,
phase=0,
degree=2,
)
# 3D plane wave with polarization
theta = np.radians(30) # polar angle
phi = np.radians(45) # azimuthal angle
psi = np.radians(0) # polarization angle
pw_3d = gy.PlaneWave(
wavelength=wavelength,
angle=(theta, phi, psi),
dim=3,
amplitude=1.0,
)
```
--------------------------------
### TopologyOptimizer - Inverse Design
Source: https://context7.com/gyptis/gyptis/llms.txt
Performs gradient-based topology optimization to maximize scattering of a photonic structure. It utilizes automatic differentiation and a filter-based optimization approach to refine the permittivity distribution within a design domain.
```python
gy.use_adjoint(True)
def objective(epsilon_design):
epsilon = {"box": 1.0, "design": epsilon_design}
mu = {"box": 1.0, "design": 1.0}
pw = gy.PlaneWave(wavelength, 0, dim=2, degree=2)
scatt = gy.Scattering(geom, epsilon, mu, source=pw, degree=2)
scatt.solve()
cs = scatt.get_cross_sections()
return -cs["scattering"]
optimizer = gy.optimize.TopologyOptimizer(
fun=objective,
geometry=geom,
design="design",
eps_bounds=(1.0, 12.0),
rfilt=0.1,
threshold=(0, 6),
maxiter=50,
verbose=True,
)
```
--------------------------------
### Create 2D Scattering Domain with PML using BoxPML
Source: https://context7.com/gyptis/gyptis/llms.txt
Generates a 2D computational domain with Perfectly Matched Layers (PMLs) for simulating wave scattering. It defines the scattering box, adds a circular scatterer, assigns physical domains, and sets mesh sizes based on the wavelength. Dependencies include the 'gyptis' package.
```python
import gyptis as gy
# Create 2D scattering domain with PML
wavelength = 0.5
pml_width = wavelength
box_size = (3.0, 3.0)
geom = gy.BoxPML(
dim=2,
box_size=box_size,
pml_width=(pml_width, pml_width),
Rcalc=1.0, # Radius for cross-section calculation
)
# Add a circular scatterer
box = geom.box
cylinder = geom.add_circle(0, 0, 0, 0.3) # x, y, z, radius
out = geom.fragment(cylinder, box)
cylinder, box = out[0], out[1:3]
# Define physical domains
geom.add_physical(box, "box")
geom.add_physical(cylinder, "scatterer")
# Set mesh sizes
geom.set_size("box", wavelength / 10)
geom.set_size("scatterer", wavelength / 20)
[geom.set_size(pml, wavelength / 8) for pml in geom.pmls]
# Build the geometry and mesh
geom.build()
```
--------------------------------
### Create Electric Dipole Source
Source: https://context7.com/gyptis/gyptis/llms.txt
Creates an electric dipole source suitable for near-field calculations and Purcell enhancement. Requires wavelength, position, and orientation angle. Outputs a Dipole object.
```python
import gyptis as gy
import numpy as np
wavelength = 0.5
position = (0.1, 0.2)
orientation_angle = np.radians(90) # dipole orientation
dipole = gy.Dipole(
wavelength=wavelength,
position=position,
angle=orientation_angle,
dim=2,
amplitude=1.0,
degree=2,
)
```
--------------------------------
### Create Gaussian Beam Source
Source: https://context7.com/gyptis/gyptis/llms.txt
Generates a Gaussian beam modeled as a superposition of plane waves. Requires wavelength, propagation angle, beam waist, and position. Outputs a GaussianBeam object.
```python
import gyptis as gy
import numpy as np
wavelength = 0.5
angle = np.radians(0) # propagation direction
waist = 2.0 # beam waist (minimum size)
position = (0, 1) # beam center position
guassian = gy.GaussianBeam(
wavelength=wavelength,
angle=angle,
waist=waist,
position=position,
dim=2,
Npw=101, # number of plane waves for approximation
degree=2,
)
```
--------------------------------
### Homogenization2D - Effective Material Parameters
Source: https://context7.com/gyptis/gyptis/llms.txt
Calculates the effective permittivity and permeability tensors for a 2D metamaterial unit cell. It uses two-scale homogenization and provides visualization of the cell problem solutions.
```python
hom = gy.Homogenization2D(lattice, epsilon, mu, degree=2)
eps_eff = hom.get_effective_permittivity()
mu_eff = hom.get_effective_permeability()
fig, ax = plt.subplots(1, 2, figsize=(8, 3))
gy.plot(hom.solution["epsilon"]["x"].real, geometry=lattice, ax=ax[0])
gy.plot(hom.solution["epsilon"]["y"].real, geometry=lattice, ax=ax[1])
plt.show()
```
--------------------------------
### Define Photonic Crystal Unit Cell using Lattice
Source: https://context7.com/gyptis/gyptis/llms.txt
Creates a unit cell for photonic crystal band structure calculations with bi-periodic boundary conditions. It defines the lattice vectors, adds inclusions (e.g., circles), fragments geometries, assigns physical domains, and sets mesh sizes. Requires the 'gyptis' package.
```python
import gyptis as gy
# Define square lattice
a = 1.0 # lattice constant
vectors = ((a, 0), (0, a))
lattice = gy.Lattice(dim=2, vectors=vectors)
# Add cylindrical inclusion
R = 0.2 * a
circle = lattice.add_circle(a/2, a/2, 0, R)
circle, cell = lattice.fragment(circle, lattice.cell)
# Define physical domains
lattice.add_physical(cell, "background")
lattice.add_physical(circle, "inclusion")
# Set mesh sizes
lattice.set_size("background", a / 10)
lattice.set_size("inclusion", R / 10)
lattice.build()
```
--------------------------------
### Material Handling with Gyptis Coefficient Class
Source: https://context7.com/gyptis/gyptis/llms.txt
This snippet illustrates how to define and utilize materials, including scalar isotropic and anisotropic tensor materials, using Gyptis. It showcases the use of the `Coefficient` class for advanced material handling, incorporating Perfect Matched Layers (PMLs). The code demonstrates creating a `Coefficient` object with scalar material properties, geometry, PML definitions, and then converting it into subdomain representations or property dictionaries suitable for finite element methods.
```python
import gyptis as gy
import numpy as np
from gyptis.materials import Coefficient, PML
# Assuming 'geom' is a defined geometry object.
# Scalar isotropic materials
epsilon_scalar = {"air": 1.0, "glass": 2.25, "silver": -15 + 0.5j}
# Anisotropic tensor materials (3x3 matrix)
eps_aniso = np.array([
[2.0, 0.1, 0],
[0.1, 3.0, 0],
[0, 0, 4.0]
])
epsilon_tensor = {"background": 1.0, "crystal": eps_aniso}
# Create coefficient with PML
pml = PML(direction="x", stretch=1 - 1j, matched_domain="air", applied_domain="pml_air")
coeff = Coefficient(
epsilon_scalar, # Can also use epsilon_tensor or a mix
geometry=geom,
pmls=[pml],
degree=2
)
# Get subdomain representation for FEM
eps_subdomain = coeff.as_subdomain()
# Get property dictionary
eps_property = coeff.as_property()
```
--------------------------------
### Solve 2D/3D Scattering Problem
Source: https://context7.com/gyptis/gyptis/llms.txt
Solves electromagnetic scattering by arbitrary objects and calculates cross-sections. Requires geometry definition, material properties (permittivity and permeability), and a source. Outputs cross-section values and allows field plotting.
```python
import gyptis as gy
import numpy as np
# Create geometry
wavelength = 0.452
R = 0.5
eps_rod = -6.15 - 0.73j # silver permittivity
geom = gy.BoxPML(
dim=2,
box_size=(3, 3),
pml_width=(wavelength, wavelength),
Rcalc=1.2 * R,
)
box = geom.box
cyl = geom.add_circle(0, 0, 0, R)
out = geom.fragment(cyl, box)
geom.add_physical(out[1:3], "box")
geom.add_physical(out[0], "rod")
geom.set_size("box", wavelength / 10)
geom.set_size("rod", wavelength / 20)
geom.build()
# Define materialsepsilon = {"box": 1.0, "rod": eps_rod}
mu = {"box": 1.0, "rod": 1.0}
# Create plane wave source
pw = gy.PlaneWave(wavelength=wavelength, angle=0, dim=2, degree=2)
# Setup and solve scattering problem
scatt = gy.Scattering(
geom,
epsilon,
mu,
source=pw,
degree=2,
polarization="TE", # or "TM"
pml_stretch=1 - 1j,
)
scatt.solve()
# Get cross sections
cs = scatt.get_cross_sections()
print(f"Scattering: {cs['scattering']:.4f}")
print(f"Absorption: {cs['absorption']:.4f}")
print(f"Extinction: {cs['extinction']:.4f}")
# Verify optical theorem
assert np.allclose(cs['extinction'], cs['scattering'] + cs['absorption'], rtol=1e-3)
# Plot field distribution
scatt.plot_field(field="total", type="real")
```
--------------------------------
### Compute Photonic Crystal Band Structure
Source: https://context7.com/gyptis/gyptis/llms.txt
Computes band diagrams of photonic crystals using eigenvalue analysis. Requires lattice definition, geometry of inclusions, material properties, and high-symmetry points for the Brillouin zone. Outputs band structure data and can be visualized.
```python
import gyptis as gy
from gyptis import pi
from gyptis.utils import bands
import numpy as np
import matplotlib.pyplot as plt
# Create square lattice
a = 1.0
vectors = ((a, 0), (0, a))
R = 0.2 * a
lattice = gy.Lattice(dim=2, vectors=vectors)
circ = lattice.add_circle(a/2, a/2, 0, R)
circ, cell = lattice.fragment(circ, lattice.cell)
lattice.add_physical(cell, "background")
lattice.add_physical(circ, "inclusion")
lattice.set_size("background", a / 10)
lattice.set_size("inclusion", R / 10)
lattice.build()
# Materialsepsilon = {"background": 1, "inclusion": 8.9}
mu = {"background": 1, "inclusion": 1}
# Define high-symmetry points
Gamma = (0, 0)
X = (pi, 0)
M = (pi, pi)
sym_points = (Gamma, X, M, Gamma)
nband = 21
ks = bands.init_bands(sym_points, nband)
```
--------------------------------
### JavaScript: Configure MathJax for Equation Numbering and Fonts
Source: https://gitlab.com/gyptis/gyptis/-/blob/master/docs/_templates/layout.html
This JavaScript code configures MathJax, a library for rendering mathematical notation in web browsers. It enables automatic numbering for equations and specifies a list of preferred fonts, prioritizing 'STIX-Web'.
```javascript
MathJax.Hub.Config({
TeX: {
equationNumbers: { autoNumber: "all" }
},
"HTML-CSS": {
availableFonts: ["TeX", "STIX-Web", "Asana-Math", "Neo-Euler", "Gyre-Pagella", "Gyre-Termes", "Latin-Modern"],
preferredFont: "STIX-Web",
webFont: "STIX-Web",
matchFontHeight: true,
},
});
```
--------------------------------
### Calculate Band Diagram for Photonic Crystals
Source: https://context7.com/gyptis/gyptis/llms.txt
Computes the band structure for TE and TM polarizations by solving the eigenvalue problem across a range of propagation vectors. It outputs normalized frequencies and visualizes the band diagram using matplotlib.
```python
band_diag = {}
for polarization in ["TE", "TM"]:
evs = []
for k in ks:
phc = gy.PhotonicCrystal(
lattice, epsilon, mu,
propagation_vector=k,
polarization=polarization,
degree=2,
)
phc.eigensolve(n_eig=6, target=0.1)
ev_norma = phc.solution["eigenvalues"].real * a / (2 * pi)
evs.append(ev_norma)
band_diag[polarization] = evs
klabels = [r"$\Gamma$", r"$X$", r"$M$", r"$\Gamma$"]
plt.figure(figsize=(4, 3))
bands.plot_bands(sym_points, nband, band_diag["TM"], xtickslabels=klabels, color="blue")
bands.plot_bands(sym_points, nband, band_diag["TE"], xtickslabels=klabels, color="red")
plt.ylabel(r"Frequency $\omega a/2\pi c$")
plt.tight_layout()
plt.show()
```
--------------------------------
### HTML: Jinja Template Inheritance and Block Inclusion
Source: https://gitlab.com/gyptis/gyptis/-/blob/master/docs/_templates/layout.html
This Jinja template code demonstrates extending a base HTML layout and including a footer template. It utilizes Jinja's block system to override or add content to specific sections of the parent template.
```html
{% extends "!layout.html" %}
{% block extrahead %} {% endblock %}
{%- block footer %} {% include 'footer.html' %} {%- endblock %}
```
--------------------------------
### Plotting Fields and Geometry with Gyptis and Matplotlib
Source: https://context7.com/gyptis/gyptis/llms.txt
This code visualizes electromagnetic field distributions (real, imaginary, and absolute parts) and overlays geometry information using Gyptis and Matplotlib. It requires a solved simulation object (e.g., 'scatt') and a geometry object (e.g., 'geom'). The function generates a figure with multiple subplots for different field components and allows customization of colormaps and titles. It also includes functionality to create an animation of the time-harmonic field.
```python
import gyptis as gy
import matplotlib.pyplot as plt
# Assuming 'scatt' is a solved simulation object and 'geom' is a geometry object.
# Plot field distribution
fig, axes = plt.subplots(1, 3, figsize=(12, 4))
# Real part of total field
scatt.plot_field(ax=axes[0], field="total", type="real", cmap="RdBu_r")
axes[0].set_title("Re(E)")
# Imaginary part
scatt.plot_field(ax=axes[1], field="total", type="imag", cmap="RdBu_r")
axes[1].set_title("Im(E)")
# Absolute value
scatt.plot_field(ax=axes[2], field="total", type="abs", cmap="hot")
axes[2].set_title("|E|")
# Overlay geometry
for ax in axes:
geom.plot_subdomains(ax=ax, c="white", lw=0.5)
ax.set_aspect("equal")
plt.tight_layout()
plt.show()
# Create animation of time-harmonic field
scatt.animate_field(n=20, filename="field_animation.gif", type="real")
```
--------------------------------
### JavaScript: Clear and Set Local Storage for Theme and Mode
Source: https://gitlab.com/gyptis/gyptis/-/blob/master/docs/_templates/layout.html
This JavaScript code clears 'mode' and 'theme' from local storage and then sets the document's data attributes for 'mode' and 'theme' to 'light'. This is typically used to reset or enforce a light theme for the user interface.
```javascript
localStorage.removeItem('mode');
localStorage.removeItem('theme');
document.documentElement.dataset.mode = 'light';
document.documentElement.dataset.theme = 'light';
```
--------------------------------
### Displaying Gallery Execution Times with JavaScript and DataTables
Source: https://gitlab.com/gyptis/gyptis/-/blob/master/docs/sg_execution_times.rst
This snippet demonstrates how to use JavaScript with the DataTables library to display a table of gallery execution times and memory usage. It includes CSS for styling and JavaScript for initializing the DataTables plugin with sorting capabilities.
```html
```
--------------------------------
### BibTeX Citation for Gyptis Software
Source: https://gitlab.com/gyptis/gyptis/-/blob/master/docs/cite.rst
This BibTeX entry can be used to cite the Gyptis software in academic publications. It includes author, title, year, and DOI.
```bibtex
@misc{gyptis,
author = {Vial, Benjamin},
title = {Gyptis: {C}omputational {P}hotonics in {P}ython.},
year = 2020,
doi = {10.5281/zenodo.4667805},
}
```
=== COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.