def step1(): config = ConfigParser.ConfigParser() config.read(config_filename) structured = config.getboolean("general", "structured") sub_voxel = config.getboolean("general", "sub_voxel") meshtal = config.get("step1", "meshtal") tally_num = config.getint("step1", "tally_num") flux_tag = config.get("step1", "flux_tag") decay_times = config.get("step2", "decay_times").split(",") geom = config.get("step1", "geom") reverse = config.getboolean("step1", "reverse") num_rays = config.getint("step1", "num_rays") grid = config.getboolean("step1", "grid") load(geom) # get meshtal info from meshtal file flux_mesh = resolve_mesh(meshtal, tally_num, flux_tag) # create the cell_fracs array before irradiation_steup if flux_mesh.structured: cell_fracs = discretize_geom(flux_mesh, num_rays=num_rays, grid=grid) # tag cell fracs for both default and subvoxel r2s modes flux_mesh.tag_cell_fracs(cell_fracs) else: cell_fracs = discretize_geom(flux_mesh) cell_mats = cell_materials(geom) irradiation_setup( flux_mesh, cell_mats, cell_fracs, alara_params_filename, tally_num, num_rays=num_rays, grid=grid, reverse=reverse, flux_tag=flux_tag, decay_times=decay_times, sub_voxel=sub_voxel, ) # create a blank mesh for step 2: ves = list(flux_mesh.iter_ve()) tags_keep = ( "cell_number", "cell_fracs", "cell_largest_frac_number", "cell_largest_frac", ) for tag in flux_mesh.get_all_tags(): if tag.name not in tags_keep and isinstance(tag, NativeMeshTag): tag.delete() flux_mesh.write_hdf5("blank_mesh.h5m") print("The file blank_mesh.h5m has been saved to disk.") print("Do not delete this file; it is needed by r2s.py step2.\n") print("R2S step1 complete, run ALARA with the command:") print(">> alara alara_inp > output.txt")
def step1(): config = ConfigParser.ConfigParser() config.read(config_filename) structured = config.getboolean("general", "structured") meshtal = config.get("step1", "meshtal") tally_num = config.getint("step1", "tally_num") flux_tag = config.get("step1", "flux_tag") decay_times = config.get("step2", "decay_times").split(",") geom = config.get("step1", "geom") reverse = config.getboolean("step1", "reverse") num_rays = config.getint("step1", "num_rays") grid = config.getboolean("step1", "grid") responses = config.get("general", "responses").split(",") wdr_file = config.get("general", "wdr_file") load(geom) # get meshtal info from meshtal file flux_mesh = resolve_mesh(meshtal, tally_num, flux_tag) # create the cell_fracs array before irradiation_steup if flux_mesh.structured: cell_fracs = discretize_geom(flux_mesh, num_rays=num_rays, grid=grid) else: cell_fracs = discretize_geom(flux_mesh) cell_mats = cell_materials(geom) irradiation_setup( flux_mesh, cell_mats, cell_fracs, alara_params_filename, tally_num, num_rays=num_rays, grid=grid, reverse=reverse, output_mesh="activation_responses_step1.h5m", flux_tag=flux_tag, decay_times=decay_times, sub_voxel=False, responses=responses, wdr_file=wdr_file, ) # create a blank mesh for step 2: ves = list(flux_mesh.iter_ve()) for tag in flux_mesh.get_all_tags(): tag.delete() flux_mesh.write_hdf5("blank_mesh.h5m") print("The file blank_mesh.h5m has been saved to disk.") print( "Do not delete this file; it is needed by activation_responses.py step2.\n" ) print("Decay_heat step1 complete, run ALARA with the command:") print(">> alara alara_inp > output.txt")
def step1(): config = ConfigParser.ConfigParser() config.read(config_filename) structured = config.getboolean('general', 'structured') meshtal = config.get('step1', 'meshtal') tally_num = config.getint('step1', 'tally_num') flux_tag = config.get('step1', 'flux_tag') decay_times = config.get('step2', 'decay_times').split(',') geom = config.get('step1', 'geom') reverse = config.getboolean('step1', 'reverse') num_rays = config.getint('step1', 'num_rays') grid = config.getboolean('step1', 'grid') responses = config.get('general', 'responses').split(',') wdr_file = config.get('general', 'wdr_file') load(geom) # get meshtal info from meshtal file flux_mesh = resolve_mesh(meshtal, tally_num, flux_tag) # create the cell_fracs array before irradiation_steup if flux_mesh.structured: cell_fracs = discretize_geom(flux_mesh, num_rays=num_rays, grid=grid) else: cell_fracs = discretize_geom(flux_mesh) cell_mats = cell_materials(geom) irradiation_setup(flux_mesh, cell_mats, cell_fracs, alara_params_filename, tally_num, num_rays=num_rays, grid=grid, reverse=reverse, output_mesh="activation_responses_step1.h5m", flux_tag=flux_tag, decay_times=decay_times, sub_voxel=False, responses=responses, wdr_file=wdr_file) # create a blank mesh for step 2: ves = list(flux_mesh.iter_ve()) for tag in flux_mesh.get_all_tags(): tag.delete() flux_mesh.write_hdf5('blank_mesh.h5m') print('The file blank_mesh.h5m has been saved to disk.') print( 'Do not delete this file; it is needed by activation_responses.py step2.\n' ) print('Decay_heat step1 complete, run ALARA with the command:') print('>> alara alara_inp > output.txt')
def step1(): config = ConfigParser.ConfigParser() config.read(config_filename) structured = config.getboolean('general', 'structured') sub_voxel = config.getboolean('general', 'sub_voxel') meshtal = config.get('step1', 'meshtal') tally_num = config.getint('step1', 'tally_num') flux_tag = config.get('step1', 'flux_tag') decay_times = config.get('step2', 'decay_times').split(',') geom = config.get('step1', 'geom') reverse = config.getboolean('step1', 'reverse') num_rays = config.getint('step1', 'num_rays') grid = config.getboolean('step1', 'grid') load(geom) # get meshtal info from meshtal file flux_mesh = resolve_mesh(meshtal, tally_num, flux_tag) # create the cell_fracs array before irradiation_steup if flux_mesh.structured: cell_fracs = discretize_geom(flux_mesh, num_rays=num_rays, grid=grid) # tag cell fracs for both default and subvoxel r2s modes flux_mesh.tag_cell_fracs(cell_fracs) else: cell_fracs = discretize_geom(flux_mesh) cell_mats = cell_materials(geom) irradiation_setup(flux_mesh, cell_mats, cell_fracs, alara_params_filename, tally_num, num_rays=num_rays, grid=grid, reverse=reverse, flux_tag=flux_tag, decay_times=decay_times, sub_voxel=sub_voxel) # create a blank mesh for step 2: ves = list(flux_mesh.iter_ve()) tags_keep = ("cell_number", "cell_fracs", "cell_largest_frac_number", "cell_largest_frac") for tag in flux_mesh.get_all_tags(): if tag.name not in tags_keep and isinstance(tag, NativeMeshTag): tag.delete() flux_mesh.write_hdf5('blank_mesh.h5m') print('The file blank_mesh.h5m has been saved to disk.') print('Do not delete this file; it is needed by r2s.py step2.\n') print('R2S step1 complete, run ALARA with the command:') print('>> alara alara_inp > output.txt')
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.')
def cell_materials(): from pyne import dagmc path = os.path.join(os.path.dirname(__file__), 'files_test_dagmc', 'three_blocks.h5m') c = dagmc.cell_materials(path) r = [] r.append(c[1].comp == {10010000: 1.0}) r.append(c[1].density == 1.0) r.append(c[1].metadata['name'] == 'mat:m1/rho:1.0') r.append(c[2].comp == {20040000: 1.0}) r.append(c[2].density == 2.0) r.append(c[2].metadata['name'] == 'mat:m2') r.append(c[3].comp == {20040000: 1.0}) r.append(c[3].density == 3.0) r.append(c[3].metadata['name'] == 'mat:m2/rho:3.0') r.append(c[6].comp == {}) r.append(c[6].density == 0) r.append(c[6].metadata['name'] == 'void') return np.all(r)
def cell_materials(): from pyne import dagmc path = os.path.join(os.path.dirname(__file__), "files_test_dagmc", "three_blocks.h5m") c = dagmc.cell_materials(path) r = [] r.append(c[1].comp == {10010000: 1.0}) r.append(c[1].density == 1.0) r.append(c[1].metadata["name"] == "mat:m1/rho:1.0") r.append(c[2].comp == {20040000: 1.0}) r.append(c[2].density == 2.0) r.append(c[2].metadata["name"] == "mat:m2") r.append(c[3].comp == {20040000: 1.0}) r.append(c[3].density == 3.0) r.append(c[3].metadata["name"] == "mat:m2/rho:3.0") r.append(c[6].comp == {}) r.append(c[6].density == 0) r.append(c[6].metadata["name"] == "void") return np.all(r)