Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

merge meep::quiet and fields::verbose into a single meep::verbosity #994

Merged
merged 2 commits into from
Aug 23, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 12 additions & 9 deletions python/simulation.py
Original file line number Diff line number Diff line change
Expand Up @@ -1008,7 +1008,7 @@ def _compute_fragment_stats(self, gv):
return stats

def _init_structure(self, k=False):
if not mp.cvar.quiet:
if mp.cvar.verbosity > 0:
print('-' * 11)
print('Initializing structure...')

Expand All @@ -1031,7 +1031,7 @@ def _init_structure(self, k=False):
if self.collect_stats and isinstance(self.default_material, mp.Medium):
self.fragment_stats = self._compute_fragment_stats(gv)

if self._output_stats and isinstance(self.default_material, mp.Medium) and not mp.cvar.quiet:
if self._output_stats and isinstance(self.default_material, mp.Medium) and mp.cvar.verbosity > 0:
stats = self._compute_fragment_stats(gv)
print("STATS: aniso_eps: {}".format(stats.num_anisotropic_eps_pixels))
print("STATS: anis_mu: {}".format(stats.num_anisotropic_mu_pixels))
Expand Down Expand Up @@ -1158,7 +1158,7 @@ def init_sim(self):
self.fields.require_component(mp.Hz)

if self.verbose:
self.fields.verbose()
verbosity(2)

def use_real(self):
cond1 = self.is_cylindrical and self.m != 0
Expand All @@ -1170,7 +1170,7 @@ def use_real(self):

if use_real(self):
self.fields.use_real_fields()
elif not mp.cvar.quiet:
elif mp.cvar.verbosity > 0:
print("Meep: using complex fields.")

if self.k_point:
Expand Down Expand Up @@ -1295,7 +1295,7 @@ def use_output_directory(self, dname=''):
closure = {'trashed': False}

def hook():
if not mp.cvar.quiet:
if mp.cvar.verbosity > 0:
print("Meep: using output directory '{}'".format(dname))
self.fields.set_output_directory(dname)
if not closure['trashed']:
Expand Down Expand Up @@ -1347,7 +1347,7 @@ def stop_cond(sim):
for func in step_funcs:
_eval_step_func(self, func, 'finish')

if not mp.cvar.quiet:
if mp.cvar.verbosity > 0:
print("run {} finished at t = {} ({} timesteps)".format(self.run_index, self.meep_time(), self.fields.t))
self.run_index += 1

Expand Down Expand Up @@ -2480,7 +2480,7 @@ def _stop(sim):
closure['cur_max'] = 0
closure['t0'] = sim.round_time()
closure['max_abs'] = max(closure['max_abs'], old_cur)
if closure['max_abs'] != 0 and not mp.cvar.quiet:
if closure['max_abs'] != 0 and mp.cvar.verbosity > 0:
fmt = "field decay(t = {}): {} / {} = {}"
print(fmt.format(sim.meep_time(), old_cur, closure['max_abs'], old_cur / closure['max_abs']))
return old_cur <= closure['max_abs'] * decay_by
Expand Down Expand Up @@ -2551,7 +2551,7 @@ def display_progress(t0, t, dt):

def _disp(sim):
t1 = mp.wall_time()
if t1 - closure['tlast'] >= dt and not mp.cvar.quiet:
if t1 - closure['tlast'] >= dt and mp.cvar.verbosity > 0:
msg_fmt = "Meep progress: {}/{} = {:.1f}% done in {:.1f}s, {:.1f}s to go"
val1 = sim.meep_time() - t0
val2 = val1 / (0.01 * t)
Expand Down Expand Up @@ -2924,4 +2924,7 @@ def complexarray(re, im):


def quiet(quietval=True):
mp.cvar.quiet = quietval
mp.cvar.verbose = int(not quietval)

def verbosity(verbose_val):
mp.cvar.verbose = verbose_val
Copy link
Collaborator

@oskooi oskooi Aug 24, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be mp.cvar.verbosity = verbose_val. Nevermind, this was also fixed by 55a67ae. However, the error persists even with this commit.

Loading