| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Name | Name | Last commit date | ||
|---|---|---|---|---|
This is a pure Python implementation of the finite difference frequency domain (FDFD) method. It makes use of scipy, numpy, matplotlib, and the MKL Pardiso solver. fdfdpy currently supports 2D geometries
python setup.py install
See the ipython notebooks in notebooks.
Some basic tests are included in tests/
To run an example test, tests/test_nonlinear_solvers.py, either call
python -m unittest tests/test_nonlinear_solvers.py
or
python tests/test_nonlinear_solvers.py
The Simulation class is initialized as
from fdfdpy import Simulation simulation = Simulation(omega, eps_r, dl, NPML, pol, L0)
Creating a new Fdfd object solves for:
It also creates a relative permeability, mu_r, as numpy.ones(eps_r.shape) and a source src as numpy.zeros(eps_r.shape).
Sources can be added to the simulation either by manually editing the 2D src array inside of the simulation object,
simulation.src[10,20:30] = 1
or by adding modal sources, which are defined as planes within the 2D domain which launch a mode in their normal direction. Modal source definitions can be added to the simulation by
simulation.add_mode(neff, direction, center, width) simulation.setup_modes()
Note that simulation.setup_modes() must always be called after adding mode(s) in order to populate simulation.src.
Now, we have everything we need to solve the system for the electromagnetic fields, by running
fields = simulation.solve_fields(timing=False)
simulation.src is proportional to either the Jz or Mz source term, depending on whether pol is set to 'Ez' or 'Hz', respectively.
fields is a tuple containing (Ex, Ey, Hz) or (Hx, Hy, Ez) depending on the polarization.
If you want to change the permittivity distribution, reassigning eps_r
simulation.eps_r = eps_new
will automatically solve for a new system matrix with the new permittivity distribution. Note that simulation.setup_modes() should also be called if the permittivity changed within the plane of any of the modal sources. <- I'll make this happen automatically later -T
Primary fields (Hz/Ez) can be visualized using the included helper functions:
simulation.plt_re(outline=True, cbar=True) simulation.plt_abs(outline=True, cbar=True, vmax=None)
These optionally outline the permittivity with contours and can be supplied with a matplotlib axis handle to plot into.
| Back | FazBrowse Home | New Git URL |