def test_isotropic_vol_source(): """Test isotropic volumetric source generation from DAGMC geometry. """ try: from pyne import dagmc except: raise SkipTest if not HAVE_PYMOAB: raise SkipTest sc = np.linspace(-25, 25, 6) m = Mesh(structured=True, structured_coords=[sc, sc, sc]) cells = [14, 15] spectra = [[0.1, 0.1, 0.1, 0.7], [0.3, 0.3, 0.3, 0.1]] intensities = [1, 2] dg, s = partisn.isotropic_vol_source("files_test_partisn/source_boxes.h5m", m, cells, spectra, intensities, num_rays=4, tag_name="src", grid=True) m.src = NativeMeshTag(4, float) data = m.src[:] # setup expected result, confirmed by hand calcs and inspection exp = np.zeros(shape=((len(sc) - 1)**3, len(spectra[0]))) exp[22, :] = [0.025, 0.025, 0.025, 0.175] exp[62, :] = [0.075, 0.075, 0.075, 0.025] exp[63, :] = [0.075, 0.075, 0.075, 0.025] exp[87, :] = [0.075, 0.075, 0.075, 0.025] exp[88, :] = [0.075, 0.075, 0.075, 0.025] assert(np.allclose(data, exp))
def step1(cfg): """This function writes the PARTISN input file for the adjoint photon transport Parameters ---------- cfg : dictionary User input for step 1 from the config.yml file """ # Get user-input from config file geom = cfg["geom_file"] cells = [cfg["src_cell"]] src_vol = [float(cfg["src_vol"])] try: origin_x, origin_y, origin_z = cfg["origin"].split(" ") except: print("Too few entries in origin location") xmesh = cfg["xmesh"] xints = cfg["xints"] ymesh = cfg["ymesh"] yints = cfg["yints"] zmesh = cfg["zmesh"] zints = cfg["zints"] # Create structured mesh sc = [ np.linspace(float(origin_x), float(xmesh), float(xints) + 1), np.linspace(float(origin_y), float(ymesh), float(yints) + 1), np.linspace(float(origin_z), float(zmesh), float(zints) + 1), ] m = Mesh(structured=True, structured_coords=sc) m.write_hdf5("blank_mesh.h5m") # Generate 42 photon energy bins [eV] # First bin has been replaced with 1 for log interpolation photon_bins = np.array( [ 1e-6, 0.01, 0.02, 0.03, 0.045, 0.06, 0.07, 0.075, 0.1, 0.15, 0.2, 0.3, 0.4, 0.45, 0.51, 0.512, 0.6, 0.7, 0.8, 1, 1.33, 1.34, 1.5, 1.66, 2, 2.5, 3, 3.5, 4, 4.5, 5, 5.5, 6, 6.5, 7, 7.5, 8, 10, 12, 14, 20, 30, 50, ] ) # ICRP 74 flux-to-dose conversion factors in pico-Sv/s per photon flux de = np.array( [ 0.01, 0.015, 0.02, 0.03, 0.04, 0.05, 0.06, 0.07, 0.08, 0.1, 0.15, 0.2, 0.3, 0.4, 0.5, 0.6, 0.8, 1, 2, 4, 6, 8, 10, ] ) df = np.array( [ 0.0485, 0.1254, 0.205, 0.2999, 0.3381, 0.3572, 0.378, 0.4066, 0.4399, 0.5172, 0.7523, 1.0041, 1.5083, 1.9958, 2.4657, 2.9082, 3.7269, 4.4834, 7.4896, 12.0153, 15.9873, 19.9191, 23.76, ] ) # Convert to Sv/s per photon FLUX pico = 1.0e-12 df = df * pico # Convert pointwise data to group data for log interpolation photon_spectrum = pointwise_collapse(photon_bins, de, df, logx=True, logy=True) # Anything below 0.01 MeV should be assigned the DF value of 0.01 MeV photon_spectrum[0] = df[0] # Total number of groups is 217 (42 photon + 175 neutron) spectra = [np.append(photon_spectrum, np.zeros(175))] # The spectrum is normalized by PyNE, so we need to mutliply by the sum of # intensities in the spectrum. # Additionally, we divide by the volume of the source cell in order to get # source density. intensities = [np.sum(spectra) / src_vol] # Load geometry into DAGMC load(geom) # Generate isotropic photon volume source source, dg = isotropic_vol_source(geom, m, cells, spectra, intensities) # PARTISN input ngroup = 217 # total number of energy groups cards = _cards(source) # block 1, 3, 5 input values names_dict = _names_dict() # dictionary of isotopes (PyNE nucids to bxslib names) write_partisn_input( m, geom, ngroup, cards=cards, dg=dg, names_dict=names_dict, data_hdf5path="/materials", nuc_hdf5path="/nucid", fine_per_coarse=1, )