diff --git a/doc/docs/Python_User_Interface.md b/doc/docs/Python_User_Interface.md
index 84371fce6..4cc513a75 100644
--- a/doc/docs/Python_User_Interface.md
+++ b/doc/docs/Python_User_Interface.md
@@ -87,40 +87,40 @@ control various parameters of the Meep computation.
```python
def __init__(self,
- cell_size,
- resolution,
- geometry=None,
- sources=None,
- eps_averaging=True,
- dimensions=3,
- boundary_layers=None,
- symmetries=None,
- force_complex_fields=False,
- default_material=Medium(),
- m=0,
- k_point=False,
- kz_2d='complex',
- extra_materials=None,
- material_function=None,
- epsilon_func=None,
- epsilon_input_file='',
- progress_interval=4,
- subpixel_tol=0.0001,
- subpixel_maxeval=100000,
- loop_tile_base_db=0,
- loop_tile_base_eh=0,
- ensure_periodicity=True,
- num_chunks=0,
- Courant=0.5,
- accurate_fields_near_cylorigin=False,
- filename_prefix=None,
- output_volume=None,
- output_single_precision=False,
- geometry_center=Vector3<0.0, 0.0, 0.0>,
- force_all_components=False,
- split_chunks_evenly=True,
+ cell_size: Union[meep.geom.Vector3, Tuple[float, ...], Tuple[int, ...], NoneType] = None,
+ resolution: float = None,
+ geometry: Optional[List[meep.geom.GeometricObject]] = None,
+ sources: Optional[List[meep.source.Source]] = None,
+ eps_averaging: bool = True,
+ dimensions: int = 3,
+ boundary_layers: Optional[List[meep.simulation.PML]] = None,
+ symmetries: Optional[List[meep.simulation.Symmetry]] = None,
+ force_complex_fields: bool = False,
+ default_material: meep.geom.Medium = Medium(),
+ m: float = 0,
+ k_point: Union[meep.geom.Vector3, Tuple[float, ...], Tuple[int, ...], bool] = False,
+ kz_2d: str = 'complex',
+ extra_materials: Optional[List[meep.geom.Medium]] = None,
+ material_function: Optional[Callable[[Union[meep.geom.Vector3, Tuple[float, ...], Tuple[int, ...]]], meep.geom.Medium]] = None,
+ epsilon_func: Optional[Callable[[Union[meep.geom.Vector3, Tuple[float, ...], Tuple[int, ...]]], float]] = None,
+ epsilon_input_file: str = '',
+ progress_interval: float = 4,
+ subpixel_tol: float = 0.0001,
+ subpixel_maxeval: int = 100000,
+ loop_tile_base_db: int = 0,
+ loop_tile_base_eh: int = 0,
+ ensure_periodicity: bool = True,
+ num_chunks: int = 0,
+ Courant: float = 0.5,
+ accurate_fields_near_cylorigin: bool = False,
+ filename_prefix: Optional[str] = None,
+ output_volume: Optional[meep.simulation.Volume] = None,
+ output_single_precision: bool = False,
+ geometry_center: Union[meep.geom.Vector3, Tuple[float, ...], Tuple[int, ...]] = Vector3<0.0, 0.0, 0.0>,
+ force_all_components: bool = False,
+ split_chunks_evenly: bool = True,
chunk_layout=None,
- collect_stats=False):
+ collect_stats: bool = False):
```
@@ -152,7 +152,7 @@ Python. `Vector3` is a `meep` class.
+ **`boundary_layers` [ list of `PML` class ]** — Specifies the
[PML](Perfectly_Matched_Layer.md) absorbing boundary layers to use. Defaults to
- none.
+ none (empty list).
+ **`cell_size` [ `Vector3` ]** — Specifies the size of the cell which is centered
on the origin of the coordinate system. Any sizes of 0 imply a
diff --git a/python/simulation.py b/python/simulation.py
index 9ed5c6338..126f05db2 100644
--- a/python/simulation.py
+++ b/python/simulation.py
@@ -1,6 +1,8 @@
# -*- coding: utf-8 -*-
from __future__ import division, print_function
+from typing import Callable, List, Tuple, Union, Optional
+
import functools
import math
import numbers
@@ -21,8 +23,8 @@
import numpy as np
import meep as mp
-from meep.geom import Vector3, init_do_averaging
-from meep.source import EigenModeSource, GaussianBeamSource, IndexedSource, check_positive
+from meep.geom import Vector3, init_do_averaging, GeometricObject, Medium
+from meep.source import Source, EigenModeSource, GaussianBeamSource, IndexedSource, check_positive
import meep.visualization as vis
from meep.verbosity_mgr import Verbosity
@@ -168,6 +170,7 @@ def p(self):
return self._p
DefaultPMLProfile = lambda u: u * u
+Vector3Type = Union[Vector3, Tuple[float, ...], Tuple[int, ...]]
class PML(object):
"""
@@ -933,40 +936,40 @@ class Simulation(object):
control various parameters of the Meep computation.
"""
def __init__(self,
- cell_size,
- resolution,
- geometry=None,
- sources=None,
- eps_averaging=True,
- dimensions=3,
- boundary_layers=None,
- symmetries=None,
- force_complex_fields=False,
- default_material=mp.Medium(),
- m=0,
- k_point=False,
- kz_2d="complex",
- extra_materials=None,
- material_function=None,
- epsilon_func=None,
- epsilon_input_file='',
- progress_interval=4,
- subpixel_tol=1e-4,
- subpixel_maxeval=100000,
- loop_tile_base_db=0,
- loop_tile_base_eh=0,
- ensure_periodicity=True,
- num_chunks=0,
- Courant=0.5,
- accurate_fields_near_cylorigin=False,
- filename_prefix=None,
- output_volume=None,
- output_single_precision=False,
- geometry_center=mp.Vector3(),
- force_all_components=False,
- split_chunks_evenly=True,
- chunk_layout=None,
- collect_stats=False):
+ cell_size: Optional[Vector3Type] = None,
+ resolution: float = None,
+ geometry: Optional[List[GeometricObject]] = None,
+ sources: Optional[List[Source]] = None,
+ eps_averaging: bool = True,
+ dimensions: int = 3,
+ boundary_layers: Optional[List[PML]] = None,
+ symmetries: Optional[List[Symmetry]] = None,
+ force_complex_fields: bool = False,
+ default_material: Medium = mp.Medium(),
+ m: float = 0,
+ k_point: Union[Vector3Type, bool] = False,
+ kz_2d: str = "complex",
+ extra_materials: Optional[List[Medium]] = None,
+ material_function: Optional[Callable[[Vector3Type], Medium]] = None,
+ epsilon_func: Optional[Callable[[Vector3Type], float]] = None,
+ epsilon_input_file: str = '',
+ progress_interval: float = 4,
+ subpixel_tol: float = 1e-4,
+ subpixel_maxeval: int = 100000,
+ loop_tile_base_db: int = 0,
+ loop_tile_base_eh: int = 0,
+ ensure_periodicity: bool = True,
+ num_chunks: int = 0,
+ Courant: float = 0.5,
+ accurate_fields_near_cylorigin: bool = False,
+ filename_prefix: Optional[str] = None,
+ output_volume: Optional[Volume] = None,
+ output_single_precision: bool = False,
+ geometry_center: Vector3Type = Vector3(),
+ force_all_components: bool = False,
+ split_chunks_evenly: bool = True,
+ chunk_layout = None,
+ collect_stats: bool = False):
"""
All `Simulation` attributes are described in further detail below. In brackets
after each variable is the type of value that it should hold. The classes, complex
@@ -995,7 +998,7 @@ def __init__(self,
+ **`boundary_layers` [ list of `PML` class ]** — Specifies the
[PML](Perfectly_Matched_Layer.md) absorbing boundary layers to use. Defaults to
- none.
+ none (empty list).
+ **`cell_size` [ `Vector3` ]** — Specifies the size of the cell which is centered
on the origin of the coordinate system. Any sizes of 0 imply a