def test_init_reasonable_sim_w_components(): t0 = 0*units.seconds tf = 10*units.seconds t_feedback = 1.*units.seconds dt = 0.1*units.seconds ti = Timer(t0=t0, tf=tf, t_feedback=t_feedback, dt=dt) iso = "u235" spectrum = "thermal" npg = 6 ndg = 11 kappa = 0.06 tester = th_component.THComponent() c = [tester, tester, tester] kappa = 0.0 testfile = 'testfile.py' open(testfile, 'w+') info = si.SimInfo(timer=ti, components=c, iso=iso, e=spectrum, n_precursors=npg, n_decay=ndg, kappa=kappa, infile=testfile, db=database.Database(mode='w')) assert_equal(t0, info.timer.t0) assert_equal(tf, info.timer.tf) assert_equal(dt, info.timer.dt) assert_equal(info.timer.timesteps(), 101) info.db.close_db() info.db.delete_db()
def main(args, curr_dir): np.set_printoptions(precision=5, threshold=np.inf) logger.set_up_pyrklog(args.logfile) infile = load_infile(args.infile) out_db = database.Database(filepath=args.outfile) if not hasattr(infile, 'n_ref'): n_ref = 0 else: n_ref = infile.n_ref si = sim_info.SimInfo(timer=infile.ti, components=infile.components, iso=infile.fission_iso, e=infile.spectrum, n_precursors=infile.n_pg, n_decay=infile.n_dg, n_fic=n_ref, kappa=infile.kappa, feedback=infile.feedback, rho_ext=infile.rho_ext, plotdir=args.plotdir, infile=args.infile, db=out_db) # TODO: think about weather to add n_ref to all input files, or put n_ref # in database files print_logo(curr_dir) sol = solve(si=si, y=si.y, infile=infile) log_results(si) out_db.close_db() print(si.plotdir) plotter.plot(sol, si) pyrklog.critical("\nSimulation succeeded.\n")
def __init__(self, timer=Timer(), components=None, iso="u235", e="thermal", n_precursors=6, n_decay=11, n_fic=0, kappa=0.0, rho_ext=None, feedback=False, plotdir='images', infile=None, sim_id=None, db=None): """This class holds information about a reactor kinetics simulation :param timer: the Timer object for the simulation :type timer: Timer :param components: the components making up the reactor :type components: dictionary :param iso: the main fissioning isotope, decides precursor data :type iso: only a few values are supported. see PrecursorData class :param e: spectrum ("fast", "thermal", etc.) :type e: string :param n_precursors: number of delayed precursor groups :type n_precursors: int :param n_decay: number of decay groups :type n_decay: int :param n_fic: number of fictitious neutron groups for multi point kinetics :type n_fic: int :param kappa: the value for kappa, a decay heat parameter :type kappa: float :param rho_ext: external reactivity :type rho_ext: a ReactivityInsertion object or None :param feedback: is reactivity feedback present in the simulation :type feedback: bool :param plotdir: the directory where the plots will be placed :type plotdir: string """ self.timer = timer self.components = components if components else {} self.iso = iso self.e = e self.n_pg = n_precursors + n_fic self.n_dg = n_decay self.rho_ext = self.init_rho_ext(rho_ext) self.feedback = feedback self.ne = self.init_ne() self.kappa = kappa self.th = th_system.THSystem(kappa=kappa, components=components) self.y = np.zeros(shape=(timer.timesteps(), self.n_entries()), dtype=float) self.plotdir = plotdir self.infile = infile if sim_id is not None: self.sim_id = sim_id else: self.sim_id = self.generate_sim_id() if db is not None: self.db = db else: self.db = database.Database() self.register_recorders()
def setUp(self): "set up test fixtures" self.a = d.Database(mode='w') self.custom = d.Database(filepath='testfile.h5', mode='w')