Note
Click here to download the full example code or to run this example in your browser via Binder
Tangent field#
import matplotlib.pyplot as plt
import nannos as nn
from nannos.formulations.tangent import get_tangent_field
We will generate a field tangent to the material interface
nh = 151
lattice = nn.Lattice(([1, 0], [0, 1]), discretization=2**9)
x, y = lattice.grid
circ = lattice.circle((0.3, 0.3), 0.25)
rect = lattice.rectangle((0.7, 0.7), (0.2, 0.5))
grid = lattice.ones() * (3 + 0.01j)
grid[circ] = 1
grid[rect] = 1
st = lattice.Layer("pat", thickness=1, epsilon=grid)
lays = [lattice.Layer("sup"), st, lattice.Layer("sub")]
pw = nn.PlaneWave(wavelength=1 / 1.2)
sim = nn.Simulation(lays, pw, nh)
FFT version:
Out:
/builds/nannos/nannos.gitlab.io/nannos/examples/basic/plot_tangent.py:60: UserWarning: FigureCanvasAgg is non-interactive, and thus cannot be shown
plt.show()
Optimized version
Out:
/builds/nannos/nannos.gitlab.io/nannos/examples/basic/plot_tangent.py:78: UserWarning: FigureCanvasAgg is non-interactive, and thus cannot be shown
plt.show()
Total running time of the script: ( 0 minutes 2.146 seconds)
Estimated memory usage: 520 MB