Skip to content

Commit

Permalink
Merge pull request #12 from fancompute/pythonic
Browse files Browse the repository at this point in the history
Pythonic
  • Loading branch information
twhughes committed Sep 21, 2018
2 parents 15bc317 + 552a680 commit b691709
Show file tree
Hide file tree
Showing 27 changed files with 1,305 additions and 1,455 deletions.
7 changes: 7 additions & 0 deletions .gitignore
Expand Up @@ -38,6 +38,7 @@ pip-delete-this-directory.txt
# Unit test / coverage reports
htmlcov/
.tox/
.nox/
.coverage
.coverage.*
.cache
Expand Down Expand Up @@ -72,6 +73,10 @@ target/
# Jupyter Notebook
.ipynb_checkpoints

# IPython
profile_default/
ipython_config.py

# pyenv
.python-version

Expand Down Expand Up @@ -102,3 +107,5 @@ venv.bak/

# mypy
.mypy_cache/
.dmypy.json
dmypy.json
3 changes: 0 additions & 3 deletions .gitmodules

This file was deleted.

File renamed without changes.
33 changes: 27 additions & 6 deletions README.md
Expand Up @@ -4,13 +4,34 @@

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

## Installation

python setup.py install

## Examples

See the ipython notebooks in `notebooks`.

## Unit Tests

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

## Structure

### Initialization

The `Fdfd` class is initialized as
The `Simulation` class is initialized as

simulation = Fdfd(omega, eps_r, dl, NPML, pol, L0)
from fdfdpy import Simulation
simulation = Simulation(omega, eps_r, dl, NPML, pol, L0)

- `omega` : the angular frequency in units of` 2 pi / seconds`
- `eps_r` : a numpy array specifying the relative permittivity distribution
Expand Down Expand Up @@ -58,11 +79,11 @@ Now, we have everything we need to solve the system for the electromagnetic fiel

### Setting a new permittivity

If you want to change the permittivity distribution, you may run
If you want to change the permittivity distribution, reassigning `eps_r`

simulation.reset_eps(new_eps)
simulation.eps_r = eps_new

And this will reconstruct the system matrix and store it in `FDFD`. Note that `simulation.setup_modes()` should also be called if the permittivity changed within the plane of any of the modal sources.
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

### Plotting

Expand Down Expand Up @@ -93,4 +114,4 @@ To load the MKL solver:
- [ ] Add ability to run local jupyter notebooks running FDFD on parallel from hera.
- [ ] Save the factorization of `A` in the `Fdfd` object to be reused later if one has the same `A` but a different `b`.
- [ ] Allow the source term to have `(Jx, Jy, Jz, Mx, My, Mz)`, which would be useful for adjoint stuff where the source is not necessarily along the `z` direction.
- [ ] Clean up imports (e.g. `import numpy as np` to `from numpy import abs, zeros, ...`)
- [x] Clean up imports (e.g. `import numpy as np` to `from numpy import abs, zeros, ...`)
292 changes: 0 additions & 292 deletions fdfdpy/Fdfd.py

This file was deleted.

6 changes: 6 additions & 0 deletions fdfdpy/__init__.py
@@ -0,0 +1,6 @@
# This line makes it possible to load Simulation object directly as
# `from fdfdpy import Simulation`
from .simulation import Simulation

# used for setup.py
name = "fdfdpy"
2 changes: 1 addition & 1 deletion fdfdpy/constants.py
Expand Up @@ -7,4 +7,4 @@

DEFAULT_MATRIX_FORMAT = 'csr'
DEFAULT_SOLVER = 'pardiso'
DEFAULT_LENGTH_SCALE = 1e-6 # microns
DEFAULT_LENGTH_SCALE = 1e-6 # microns

0 comments on commit b691709

Please sign in to comment.