Exemplo n.º 1
0
 def test_get_cooling_step_name3(self):
     """Verify passing non-zero cooling step
     """
     (coolingstep, numergbins) = read_alara_phtn.get_cooling_step_name( \
             5, self.fr)
     self.assertEqual(coolingstep, '1 y')
     self.assertEqual(numergbins, 42)
Exemplo n.º 2
0
 def test_get_cooling_step_name1(self):
     """Verify passing 0 as cooling step
     """
     (coolingstep, numergbins) = read_alara_phtn.get_cooling_step_name( \
             0, self.fr)
     self.assertEqual(coolingstep, 'shutdown')
     self.assertEqual(numergbins, 42)
Exemplo n.º 3
0
###########################
# Do step 2

print "Loading step one data file '{0}'".format(datafile)
smesh = ScdMesh.fromFile(datafile)

# Tagging mesh
print "Reading ALARA photon source '{0}'".format(phtn_src)
read_alara_phtn.read_to_h5m(phtn_src, smesh, isotope=opt_isotope, \
        coolingstep=opt_cooling, retag=True, totals=True)

print "Saving photon source information to '{0}'".format(datafile)
smesh.imesh.save(datafile)

fr = open(phtn_src, 'r')
coolingstepstring = read_alara_phtn.get_cooling_step_name(opt_cooling, fr)[0]
fr.close()

print "Writing gammas file"
write_gammas.gen_gammas_file_from_h5m(smesh, sampling=opt_sampling, \
        do_bias=opt_bias, cumulative=opt_cumulative, cust_ergbins=opt_ergs, \
        coolingstep=coolingstepstring, isotope=opt_isotope)

# Create photon MCNP input file from neutron input if it doesn't exist already
if mcnp_p_problem:

    if os.path.exists(mcnp_p_problem):
        print "MCNP photon transport input file '{0}' already exists and will" \
                " not be recreated.".format(mcnp_p_problem)

    else:
Exemplo n.º 4
0
def handle_phtn_data(datafile, phtn_src, opt_isotope, opt_cooling,  \
        opt_sampling, opt_bias, opt_cumulative, cust_ergbins, 
        resample, uni_resamp_all, gammas="gammas"):
    """Loads phtn_src data, tags this to mesh, and generates 'gammas' file.

    Parameters
    ----------
    datafile : string
        Path to structured mesh file (e.g. .h5m file)
    phtn_src : string
        Path to phtn_src file
    opt_isotope : string
        The isotope identifier as listed in phtn_src file
    opt_cooling : int or string
        The cooling step, either as a numeric index (from 0) or a string
        identifier as listed in phtn_src file
    opt_sampling : ['v', 'u']
        Type of sampling to generate the 'gammas' file for; v=voxel; u=uniform
    opt_bias : boolean
        If true, look for bias values on the mesh and include them in 'gammas'
    opt_cumulative : boolean
        If true, write energy bins' relative probabilities cumulatively
    cust_ergbins : boolean
        If true, look for custom energy bins on the mesh and include them in
        'gammas'
    resample : boolean
        If true, 'r' flag is added to gammas, and resampling of particles 
        starting in void regions of voxels is enabled.
    uni_resamp_all : boolean
        If true, 'a' flag is added to gammas, and particles starting in void
        regions of voxels, during uniform sampling, are resampled over the
        entire problem, rather than resampling just the voxel.  This has the
        potential to result in an unfair game.
    gammas : string (optional)
        File name for 'gammas' file. Defaults to 'gammas'.

    Returns
    -------
    mesh : ScdMesh object or iMesh.Mesh object
        MOAB mesh object

    Notes
    -----
    Only creates gammas file if mesh is an ScdMesh.
    """
    print "Loading step one data file '{0}'".format(datafile)
    try:
        mesh = ScdMesh.fromFile(datafile)
    except ScdMeshError:
        mesh = iMesh.Mesh()
        mesh.load(datafile)

    # Tagging mesh
    print "Reading ALARA photon source '{0}'".format(phtn_src)
    read_alara_phtn.read_to_h5m(phtn_src, mesh, isotope=opt_isotope, \
            coolingstep=opt_cooling, retag=True, totals=True)

    print "Saving photon source information to '{0}'".format(datafile)
    if isinstance(mesh, ScdMesh):
        mesh.imesh.save(datafile)

        with open(phtn_src, 'r') as fr:
            try:
                coolingstepstring = read_alara_phtn.get_cooling_step_name( \
                    opt_cooling, fr)[0]
            except ValueError:
                coolingstepstring = opt_cooling

        print "Writing gammas file"
        write_gammas.gen_gammas_file_from_h5m(mesh, outfile=gammas, \
                sampling=opt_sampling, do_bias=opt_bias, \
                cumulative=opt_cumulative, cust_ergbins=cust_ergbins, \
                coolingstep=coolingstepstring, isotope=opt_isotope, \
                resample=resample, uni_resamp_all=uni_resamp_all)
    else:
        mesh.save(datafile)

    return mesh