From ad748afbfe9eea62e38c181134c9162760abcd1b Mon Sep 17 00:00:00 2001 From: Christopher Hogan Date: Mon, 15 Jan 2018 19:50:05 -0600 Subject: [PATCH] Adjust Simulation constructor (#170) * Adjust Simulation constructor * Make sure all "input variables" from the scheme docs can be passed into the constructor. * Organize arguments into a column for readability. * Update docs --- doc/docs/Python_User_Interface.md | 12 +++++++- python/simulation.py | 51 ++++++++++++++++++++++--------- 2 files changed, 48 insertions(+), 15 deletions(-) diff --git a/doc/docs/Python_User_Interface.md b/doc/docs/Python_User_Interface.md index 6ad9b37a1..6d17fefdc 100644 --- a/doc/docs/Python_User_Interface.md +++ b/doc/docs/Python_User_Interface.md @@ -33,7 +33,17 @@ class Simulation(object): extra_materials=[], material_function=None, epsilon_func=None, - epsilon_input_file=''): + epsilon_input_file='', + progress_interval=4, + subpixel_tol=1e-4, + subpixel_maxeval=100000, + ensure_periodicity=False, + num_chunks=0, + courant=0.5, + accurate_fields_near_cylorigin=False, + filename_prefix='', + output_volume=None, + output_single_precision=False): ``` All `Simulation` attributes are described in further detail here. In brackets after each variable is the type of value that it should hold. The classes, complex datatypes like `GeometricObject`, are described in a later subsection. The basic datatypes, like `integer`, `boolean`, `complex`, and `string` are defined by Python. `Vector3` is a `meep` class. diff --git a/python/simulation.py b/python/simulation.py index d23c00d68..a47d409a3 100644 --- a/python/simulation.py +++ b/python/simulation.py @@ -231,10 +231,34 @@ def _harm(sim): class Simulation(object): - def __init__(self, cell_size, resolution, geometry=[], sources=[], eps_averaging=True, - dimensions=2, boundary_layers=[], symmetries=[], verbose=False, - force_complex_fields=False, default_material=mp.Medium(), m=0, k_point=False, - extra_materials=[], material_function=None, epsilon_func=None, epsilon_input_file=''): + def __init__(self, + cell_size, + resolution, + geometry=[], + sources=[], + eps_averaging=True, + dimensions=2, + boundary_layers=[], + symmetries=[], + verbose=False, + force_complex_fields=False, + default_material=mp.Medium(), + m=0, + k_point=False, + extra_materials=[], + material_function=None, + epsilon_func=None, + epsilon_input_file='', + progress_interval=4, + subpixel_tol=1e-4, + subpixel_maxeval=100000, + ensure_periodicity=False, + num_chunks=0, + courant=0.5, + accurate_fields_near_cylorigin=False, + filename_prefix='', + output_volume=None, + output_single_precision=False): self.cell_size = cell_size self.geometry = geometry @@ -245,32 +269,31 @@ def __init__(self, cell_size, resolution, geometry=[], sources=[], eps_averaging self.symmetries = symmetries self.geometry_center = Vector3() self.eps_averaging = eps_averaging - self.subpixel_tol = 1e-4 - self.subpixel_maxeval = 100000 - self.ensure_periodicity = False + self.subpixel_tol = subpixel_tol + self.subpixel_maxeval = subpixel_maxeval + self.ensure_periodicity = ensure_periodicity self.extra_materials = extra_materials self.default_material = default_material self.epsilon_input_file = epsilon_input_file - self.num_chunks = 0 - self.courant = 0.5 + self.num_chunks = num_chunks + self.courant = courant self.global_d_conductivity = 0 self.global_b_conductivity = 0 self.special_kz = False self.k_point = k_point self.fields = None self.structure = None - self.accurate_fields_near_cylorigin = False + self.accurate_fields_near_cylorigin = accurate_fields_near_cylorigin self.m = m self.force_complex_fields = force_complex_fields self.verbose = verbose - self.progress_interval = 4 + self.progress_interval = progress_interval self.init_fields_hooks = [] - self.progress_interval = 4 self.run_index = 0 self.filename_prefix = '' self.output_append_h5 = None - self.output_single_precision = False - self.output_volume = None + self.output_single_precision = output_single_precision + self.output_volume = output_volume self.last_eps_filename = '' self.output_h5_hook = lambda fname: False self.interactive = False