Skip to content

Commit

Permalink
merge meep::quiet and fields::verbose into a single meep::verbosity (#…
Browse files Browse the repository at this point in the history
…994)

* merge meep::quiet and fields::verbose into a single meep::verbosity

* fix Python references to cvar.quiet
  • Loading branch information
stevengj authored Aug 23, 2019
1 parent a15d836 commit 4e0e80d
Show file tree
Hide file tree
Showing 37 changed files with 141 additions and 152 deletions.
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
Loading

0 comments on commit 4e0e80d

Please sign in to comment.