def test_phtn_src_energy_bounds(): input_file = os.path.join(thisdir, "files_test_alara", "alara_other_blocks.txt") e_bounds = phtn_src_energy_bounds(input_file) expected_e_bounds = [ 0, 1.00e4, 2.00e4, 5.00e4, 1.00e5, 2.00e5, 3.00e5, 4.00e5, 6.00e5, 8.00e5, 1.00e6, 1.22e6, 1.44e6, 1.66e6, 2.00e6, 2.50e6, 3.00e6, 4.00e6, 5.00e6, 6.50e6, 8.00e6, 1.00e7, 1.20e7, 1.40e7, 2.00e7, ] assert_array_equal(e_bounds, expected_e_bounds)
def step2(): config = ConfigParser.ConfigParser() config.read(config_filename) structured = config.getboolean("general", "structured") sub_voxel = config.getboolean("general", "sub_voxel") decay_times = config.get("step2", "decay_times").split(",") output = config.get("step2", "output") tot_phtn_src_intensities = config.get("step2", "tot_phtn_src_intensities") tag_name = "source_density" if sub_voxel: geom = config.get("step1", "geom") load(geom) cell_mats = cell_materials(geom) else: cell_mats = None h5_file = "phtn_src.h5" if not isfile(h5_file): photon_source_to_hdf5(filename="phtn_src", nucs="total") intensities = "Total photon source intensities (p/s)\n" e_bounds = phtn_src_energy_bounds("alara_inp") for i in range(len(e_bounds)): e_bounds[i] /= 1.0e6 # convert unit from eV to MeV for i, dt in enumerate(decay_times): print("Writing source for decay time: {0} to mesh".format(dt)) mesh = Mesh(structured=structured, mesh="blank_mesh.h5m") tags = {("TOTAL", dt): tag_name} photon_source_hdf5_to_mesh(mesh, h5_file, tags, sub_voxel=sub_voxel, cell_mats=cell_mats) p_src_filename = "{0}_{1}.h5m".format(output, i + 1) intensity = total_photon_source_intensity(mesh, tag_name, sub_voxel=sub_voxel) mesh = tag_e_bounds(mesh, e_bounds) mesh = tag_source_intensity(mesh, intensity) # get and tag decay time decay_time = to_sec(float(dt.split()[0]), dt.split()[1]) mesh = tag_decay_time(mesh, decay_time) # set version manually when changing the information of source.h5m mesh = tag_version(mesh) mesh.write_hdf5("{0}_{1}.h5m".format(output, i + 1)) intensities += "{0}: {1}\n".format(dt, intensity) with open(tot_phtn_src_intensities, "w") as f: f.write(intensities) print("R2S step2 complete.")
def step2(): config = ConfigParser.ConfigParser() config.read(config_filename) structured = config.getboolean('general', 'structured') sub_voxel = config.getboolean('general', 'sub_voxel') decay_times = config.get('step2', 'decay_times').split(',') output = config.get('step2', 'output') tot_phtn_src_intensities = config.get('step2', 'tot_phtn_src_intensities') tag_name = "source_density" if sub_voxel: geom = config.get('step1', 'geom') load(geom) cell_mats = cell_materials(geom) else: cell_mats = None h5_file = 'phtn_src.h5' if not isfile(h5_file): photon_source_to_hdf5('phtn_src') intensities = "Total photon source intensities (p/s)\n" for i, dc in enumerate(decay_times): print('Writing source for decay time: {0}'.format(dc)) mesh = Mesh(structured=structured, mesh='blank_mesh.h5m') tags = {('TOTAL', dc): tag_name} photon_source_hdf5_to_mesh(mesh, h5_file, tags, sub_voxel=sub_voxel, cell_mats=cell_mats) mesh.write_hdf5('{0}_{1}.h5m'.format(output, i + 1)) intensity = total_photon_source_intensity(mesh, tag_name, sub_voxel=sub_voxel) intensities += "{0}: {1}\n".format(dc, intensity) with open(tot_phtn_src_intensities, 'w') as f: f.write(intensities) e_bounds = phtn_src_energy_bounds("alara_inp") e_bounds_str = "" for e in e_bounds: e = e / 1e6 # convert unit to MeV e_bounds_str += "{0}\n".format(e) with open("e_bounds", 'w') as f: f.write(e_bounds_str) print('R2S step2 complete.')
def step2(): config = ConfigParser.ConfigParser() config.read(config_filename) structured = config.getboolean('general', 'structured') sub_voxel = config.getboolean('general', 'sub_voxel') decay_times = config.get('step2', 'decay_times').split(',') output = config.get('step2', 'output') tot_phtn_src_intensities = config.get('step2', 'tot_phtn_src_intensities') tag_name = "source_density" if sub_voxel: geom = config.get('step1', 'geom') load(geom) cell_mats = cell_materials(geom) else: cell_mats = None h5_file = 'phtn_src.h5' if not isfile(h5_file): photon_source_to_hdf5(filename='phtn_src', nucs='total') intensities = "Total photon source intensities (p/s)\n" e_bounds = phtn_src_energy_bounds("alara_inp") for i in range(len(e_bounds)): e_bounds[i] /= 1.0e6 # convert unit from eV to MeV for i, dt in enumerate(decay_times): print('Writing source for decay time: {0} to mesh'.format(dt)) mesh = Mesh(structured=structured, mesh='blank_mesh.h5m') tags = {('TOTAL', dt): tag_name} photon_source_hdf5_to_mesh(mesh, h5_file, tags, sub_voxel=sub_voxel, cell_mats=cell_mats) intensity = total_photon_source_intensity(mesh, tag_name, sub_voxel=sub_voxel) mesh = tag_e_bounds(mesh, e_bounds) mesh = tag_source_intensity(mesh, intensity) # get and tag decay time decay_time = to_sec(float(dt.split()[0]), dt.split()[1]) mesh = tag_decay_time(mesh, decay_time) # set version manually when changing the information of source.h5m mesh = tag_version(mesh) mesh.write_hdf5('{0}_{1}.h5m'.format(output, i+1)) intensities += "{0}: {1}\n".format(dt, intensity) with open(tot_phtn_src_intensities, 'w') as f: f.write(intensities) print('R2S step2 complete.')