def run(self, commands, iterations, initial_sample=None): errors = [] samples = [] if initial_sample: samples.append(initial_sample) for i in reversed(range(iterations)): self.setup_files["input.deck"] = util.decks.input_deck(solver=self.solver, num_cells_x=32*2**i, num_cells_y=32*2**i, t_final=0.33, init_cond="smooth") util.bullet(self.log_path, "dx / %d" % 2**i, indent=2) with util.ResetFile(self.current_path, self.initial_path): super(ConvergenceTest, self).run(commands) samples.append(self.parser(self.current_path)) if len(samples) > 1: errors.append(samples[-1] - samples[0]) if len(errors) > 1: util.result(self.log_path, "%f" % math.log(abs(errors[-1]) / abs(errors[-2]), 2)) else: util.result(self.log_path, "") return samples
def convergence_test(target, source, env): try: util.tee(str(target[0]), "convergence tests:") for s in SOLVER: if s == "kinetic": util.bullet(str(target[0]), "%s" % s, wait=False) KineticConvergenceTest(str(target[0])).run([os.path.abspath(str(source[0]))], 5) elif s == "moment": for f in MOMENT_FILTER: util.bullet(str(target[0]), "%s(%s)" % (s, f), wait=False) MomentConvergenceTest(str(target[0]), f).run([os.path.abspath(str(source[0]))], 5) elif s == "momopt": for t in MOMOPT_TYPE: util.bullet(str(target[0]), "%s(%s)" % (s, t), wait=False) MomoptConvergenceTest(str(target[0]), t).run([os.path.abspath(str(source[0]))], 5) except: try: os.unlink(str(target[0])) except: pass raise
def regression_test(target, source, env): try: util.tee(str(target[0]), "regression tests:") for p in [str(x) for x in source]: if p.startswith("solver_mpi"): commands = [["mpirun", "-np", "4", p]] composite = True else: commands = [os.path.abspath(p)] composite = False for s in SOLVER: for i in INITCOND: if s == "kinetic": util.bullet(str(target[0]), "%s,%s,%s" % (p, s, i), wait=False) if composite: KineticCompositeRegressionTest(str(target[0]), i).run(commands) else: KineticRegressionTest(str(target[0]), i).run(commands) elif s == "moment": for f in MOMENT_FILTER: util.bullet(str(target[0]), "%s,%s,%s(%s)" % (p, s, i, f), wait=False) if composite: MomentCompositeRegressionTest(str(target[0]), f, i).run(commands) else: MomentRegressionTest(str(target[0]), f, i).run(commands) elif s == "momopt": for t in MOMOPT_TYPE: util.bullet(str(target[0]), "%s,%s,%s(%s)" % (p, s, i, t), wait=False) if composite: MomoptCompositeRegressionTest(str(target[0]), t, i).run(commands) else: MomoptRegressionTest(str(target[0]), t, i).run(commands) except: try: os.unlink(str(target[0])) except: pass raise