question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Defining a 3D Plane Source

See original GitHub issue

I’m trying to define a plane source such that it outputs a plane wave, but I’m getting some odd-looking outputs. The following code seems to produce some pretty heavy fringes of some sort. Any thoughts? Ideally it would produce a smooth plane wave. Thanks! plane_source


import matplotlib.pyplot as plt

import fdtd
import fdtd.backend as bd
import numpy as np
import torch
import torch.autograd
import torch.nn
fdtd.set_backend("torch.cuda")


WAVELENGTH = 1550e-9
SPEED_LIGHT: float = 299_792_458.0  # [m/s] speed of light


grid = fdtd.Grid(
    (2.5e-5, 2.5e-5, 1.5e-5),
    # (161,161,97),
    grid_spacing=0.1 * WAVELENGTH,
    permittivity=1.0,
    permeability=1.0,
    # courant_number=0.3
)

grid[0, :, :] = fdtd.PeriodicBoundary(name="xbounds")
# grid[0:10, :, :] = fdtd.PML(name="pml_xlow")
# grid[-10:, :, :] = fdtd.PML(name="pml_xhigh")
grid[:, :, 0:10] = fdtd.PML(name="pml_zlow")
grid[:, :, -10:] = fdtd.PML(name="pml_zhigh")
grid[:, 0, :] = fdtd.PeriodicBoundary(name="ybounds")

grid[2:160,2:160,30:31] = fdtd.PlaneSource(
    period=WAVELENGTH / SPEED_LIGHT, name="linesource"
)
grid.run(300)
grid.visualize(z=80,show=True)

Issue Analytics

  • State:open
  • Created 2 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
CharlesDovecommented, Jul 29, 2021

Figured it out. A plane source at z=N outputs the wrong polarization, which doesn’t propagate. Changing it to something transverse solves the problem. Also there should probably be GaussianPlaneSource and UniformPlaneSource methods to reduce ambiguity. For line sources as well. I’ll see if I can knock together a PR. 😃

0reactions
flaportcommented, Oct 9, 2021

@CharlesDove , If you have the time, would you be willing to create a PR with your fix?

Read more comments on GitHub >

github_iconTop Results From Across the Web

3D Coordinate Geometry - Equation of a Plane - Brilliant
A plane in 3D coordinate space is determined by a point and a vector that is perpendicular to the plane. This wiki page...
Read more >
Plane Equation - Song Ho Ahn
The equation of a plane in 3D space is defined with normal vector (perpendicular to the plane) and a known point on the...
Read more >
1.4: Equations of Planes in 3d - Mathematics LibreTexts
Specifying one point (x0,y0,z0) on a plane and a vector d parallel to the plane does not uniquely determine the plane, because it...
Read more >
Equations of Planes in 3d
Section 1.4 Equations of Planes in 3d. Specifying one point \((x_0,y_0,z_0)\) on a plane and a vector \(\vd\) parallel to the plane does...
Read more >
Lines & Planes in 3D-Space: Definition, Formula & Examples
Lines and planes both exist in three-dimensional spaces calculated using vector equations. Explore several examples of how these two ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found