Beispiel #1
0
def test_fluka_tally_proton():
    tally = Tally("Flux", "Proton", 12, "Volume", "Reg12",
                  "Proton Flux in Cell 12", -1.0)
    fluka_string = '* Proton Flux in Cell 12\n'+\
                   'USRTRACK         1.0    PROTON     -21.0     Reg12       1.0     1000.Proton F\n'+\
                   'USRTRACK       10.E1     1.E-3                                               &'
    assert_equal(fluka_string, tally.fluka("-21.0"))
Beispiel #2
0
def test_fluka_tally_muonp():
    tally = Tally("Flux", "Muon", 12, "Volume", "Reg12",
                  "Muon Flux in Cell 12", -1.0)
    fluka_string = '* Muon Flux in Cell 12\n'+\
                   'USRTRACK         1.0     MUON+     -21.0     Reg12       1.0     1000.Muon Flu\n'+\
                   'USRTRACK       10.E1     1.E-3                                               &'
    assert_equal(fluka_string, tally.fluka("-21.0"))
Beispiel #3
0
def test_tally20():
    clean(["test_tally.h5"])
    tally = Tally("Flux","Photon",12,"Volume","Volume 12","Photon Flux in Cell 12",35.0,123.0)
    write_photon("test_tally.h5")

    new_tally = Tally()
    new_tally.from_hdf5("test_tally.h5","tally",0)
    assert_equal(tally.tally_name,new_tally.tally_name)
Beispiel #4
0
def test_mcnp6_tally_vol_proton_volume_set():
    tally = Tally(
        "Flux", "Proton", 12, "Volume", "Volume 12", "Proton Flux in Cell 12", 100.0
    )
    assert_equal(
        "C Proton Flux in Cell 12\n" + "F14:h 12\n" + "SD14 100.000000\n",
        tally.mcnp(1, "mcnp6"),
    )
Beispiel #5
0
def test_tally36():
    clean(["test_tally.h5"])
    write_arb_n("test_tally.h5","bob_geldof")
    tally = Tally("Current","Neutron",14,"Surface","Surface 14","Neutron Current Across surface 14",100.0)
    
    new_tally = Tally()
    new_tally.from_hdf5("test_tally.h5","bob_geldof",0)
    assert_equal(tally.tally_type,new_tally.tally_type)
Beispiel #6
0
def test_tally20():
    clean(["test_tally.h5"])
    tally = Tally("Flux", "Photon", 12, "Volume", "Volume 12",
                  "Photon Flux in Cell 12", 35.0, 123.0)
    write_photon("test_tally.h5")

    new_tally = Tally()
    new_tally.from_hdf5("test_tally.h5", "tally", 0)
    assert_equal(tally.tally_name, new_tally.tally_name)
Beispiel #7
0
def test_tally21a():
    clean(["test_tally_21.h5"])
    tally = Tally("Flux","Photon",12,"Volume","Volume 12","Photon Flux in Cell 12",35.0,123.0)
    write_photon("test_tally_21.h5")

    new_tally = Tally()
    new_tally.from_hdf5("test_tally_21.h5","/tally",0)

    assert_equal(tally.normalization,new_tally.normalization)
Beispiel #8
0
def test_tally36():
    clean(["test_tally.h5"])
    write_arb_n("test_tally.h5", "bob_geldof")
    tally = Tally("Current", "Neutron", 14, "Surface", "Surface 14",
                  "Neutron Current Across surface 14", 100.0)

    new_tally = Tally()
    new_tally.from_hdf5("test_tally.h5", "bob_geldof", 0)
    assert_equal(tally.tally_type, new_tally.tally_type)
Beispiel #9
0
def test_tally37():
    clean(["test_tally.h5"])
    write_arb_n("test_tally.h5","bob_geldof")
    write_arb_p("test_tally.h5","bob_geldof")

    tally = Tally("Flux","Photon",12,"Volume","Volume 12","Photon Flux in Cell 12",35.0)
    
    new_tally = Tally()
    new_tally.from_hdf5("test_tally.h5","bob_geldof",1)
    assert_equal(tally.tally_type,new_tally.tally_type)
Beispiel #10
0
def test_tally35():
    clean(["test_tally.h5"])
    write_photon("test_tally.h5")
    write_neutron("test_tally.h5")

    tally = Tally("Current","Neutron",14,"Surface","Surface 14","Neutron Current Across surface 14",100.0)
    new_tally = Tally()
    new_tally.from_hdf5("test_tally.h5","tally",0)

    assert_not_equal(tally.entity_size,new_tally.entity_size)
Beispiel #11
0
def test_tally21a():
    clean(["test_tally_21.h5"])
    tally = Tally("Flux", "Photon", 12, "Volume", "Volume 12",
                  "Photon Flux in Cell 12", 35.0, 123.0)
    write_photon("test_tally_21.h5")

    new_tally = Tally()
    new_tally.from_hdf5("test_tally_21.h5", "/tally", 0)

    assert_equal(tally.normalization, new_tally.normalization)
Beispiel #12
0
def test_fluka_tally():
    tally = Tally(
        "Flux", "Gamma", 12, "Volume", "Reg12", "Photon Flux in Cell 12", -1.0
    )
    fluka_string = (
        "* Photon Flux in Cell 12\n"
        + "USRTRACK         1.0    PHOTON     -21.0     Reg12       1.0     1000.Photon F\n"
        + "USRTRACK       10.E1     1.E-3                                               &"
    )
    assert_equal(fluka_string, tally.fluka("-21.0"))
Beispiel #13
0
def test_tally22():
    clean(["test_tally.h5"])
    write_photon("test_tally.h5")
    write_neutron("test_tally.h5")

    # there are now two tallies in the h5 file
    tally = Tally("Current","Neutron",14,"Surface","Surface 14","Neutron Current Across surface 14",100.0) 
    new_tally = Tally()
    new_tally.from_hdf5("test_tally.h5","tally",1)
    assert_equal(tally.tally_type,new_tally.tally_type)
Beispiel #14
0
def test_tally35():
    clean(["test_tally.h5"])
    write_photon("test_tally.h5")
    write_neutron("test_tally.h5")

    tally = Tally("Current", "Neutron", 14, "Surface", "Surface 14",
                  "Neutron Current Across surface 14", 100.0)
    new_tally = Tally()
    new_tally.from_hdf5("test_tally.h5", "tally", 0)

    assert_not_equal(tally.entity_size, new_tally.entity_size)
Beispiel #15
0
def test_tally22():
    clean(["test_tally.h5"])
    write_photon("test_tally.h5")
    write_neutron("test_tally.h5")

    # there are now two tallies in the h5 file
    tally = Tally("Current", "Neutron", 14, "Surface", "Surface 14",
                  "Neutron Current Across surface 14", 100.0)
    new_tally = Tally()
    new_tally.from_hdf5("test_tally.h5", "tally", 1)
    assert_equal(tally.tally_type, new_tally.tally_type)
Beispiel #16
0
def test_mcnp5_tally_surf_flux():
    tally = Tally(
        "Flux",
        "Neutron",
        12,
        "Surface",
        "Surface 12",
        "Neutron Flux across surface 12",
        -1.0,
    )
    assert_equal("C Neutron Flux across surface 12\nF12:n 12\n", tally.mcnp(1, "mcnp5"))
Beispiel #17
0
def write_arb_n(file_name, path):
    tally = Tally(
        "Current",
        "Neutron",
        14,
        "Surface",
        "Surface 14",
        "Neutron Current Across surface 14",
        100.0,
    )
    tally.write_hdf5(file_name, path)
Beispiel #18
0
def test_tally37():
    clean(["test_tally.h5"])
    write_arb_n("test_tally.h5", "bob_geldof")
    write_arb_p("test_tally.h5", "bob_geldof")

    tally = Tally("Flux", "Photon", 12, "Volume", "Volume 12",
                  "Photon Flux in Cell 12", 35.0)

    new_tally = Tally()
    new_tally.from_hdf5("test_tally.h5", "bob_geldof", 1)
    assert_equal(tally.tally_type, new_tally.tally_type)
Beispiel #19
0
def write_photon(file_name):
    tally = Tally(
        "Flux",
        "Photon",
        12,
        "Volume",
        "Volume 12",
        "Photon Flux in Cell 12",
        35.0,
        123.0,
    )
    tally.write_hdf5(file_name, "tally")
Beispiel #20
0
def test_mcnp5_tally_surf_current():
    tally = Tally(
        "Current",
        "Neutron",
        12,
        "Surface",
        "Surface 12",
        "Neutron Current across surface 12",
        -1.0,
    )
    assert_equal(
        "C Neutron Current across surface 12\nF11:n 12\n", tally.mcnp(1, "mcnp5")
    )
Beispiel #21
0
def test_mcnp6_tally_vol_norm():
    tally = Tally(
        "Flux",
        "Gamma",
        12,
        "Volume",
        "Volume 12",
        "Photon Flux in Cell 12",
        -1.0,
        1.0e13,
    )
    assert_equal(
        "C Photon Flux in Cell 12\nF14:p 12\nFM14 1.000000e+13\n",
        tally.mcnp(1, "mcnp6"),
    )
Beispiel #22
0
def test_mcnp5_tally_surf_flux_norm():
    tally = Tally(
        "Flux",
        "Neutron",
        12,
        "Surface",
        "Surface 12",
        "Neutron Flux across surface 12",
        -1.0,
        1.0e13,
    )
    assert_equal(
        "C Neutron Flux across surface 12\nF12:n 12\nFM12 1.000000e+13\n",
        tally.mcnp(1, "mcnp5"),
    )
Beispiel #23
0
def test_mcnp5_tally_surf_current_norm():
    tally = Tally(
        "Current",
        "Neutron",
        12,
        "Surface",
        "Surface 12",
        "Neutron Current across surface 12",
        -1.0,
        1.0e13,
    )
    assert_equal(
        "C Neutron Current across surface 12\nF11:n 12\nFM11 1.000000e+13\n",
        tally.mcnp(1, "mcnp5"),
    )
Beispiel #24
0
def test_mcnp_mesh_tally_cyl():
    particle = "Neutron"
    geometry = "Cylinder"
    origin = [1, 2, 3]
    i_mesh = [5, 10, 20, 25]
    j_mesh = [2, 12]
    k_mesh = [45]
    i_ints = [1, 2, 3, 1]
    j_ints = [1]
    k_ints = [1]
    e = [0, 10, 100]
    e_ints = [1, 1, 2]
    tal_name = "Mesh Tally XYZ Neutron"
    vec = [-1, 4, -2]
    axs = [12, -2, 5]

    tally = Tally(
        particle,
        geometry,
        origin,
        i_mesh,
        j_mesh,
        k_mesh,
        i_ints,
        j_ints,
        k_ints,
        e,
        e_ints,
        tal_name=tal_name,
        axs=axs,
        vec=vec,
    )
    mcnp_tally = (
        "C Mesh Tally XYZ Neutron\n"
        + "FMESH14:n GEOM=CYL\n"
        + "          AXS=-1.000000 4.000000 -2.000000\n"
        + "          VEC=12.000000 -2.000000 5.000000\n"
        + "          ORIGIN=1.000000 2.000000 3.000000\n"
        + "          IMESH=5.000000 10.000000 20.000000 25.000000 IINTS=1 2 3 1\n"
        + "          JMESH=2.000000 12.000000 JINTS=1\n"
        + "          KMESH=45.000000 KINTS=1\n"
        + "          EMESH=0.000000 10.000000 100.000000\n"
        + "          EINTS=1 1 2"
    )
    assert_equal(mcnp_tally, tally.mcnp(1, "mcnp6"))
Beispiel #25
0
def test_tally30():
    clean(["test_tally.h5"])
    write_photon("test_tally.h5")
    write_neutron("test_tally.h5")

    tally = Tally(
        "Current",
        "Neutron",
        14,
        "Surface",
        "Surface 14",
        "Neutron Current Across surface 14",
        100.0,
    )
    new_tally = Tally()
    new_tally.from_hdf5("test_tally.h5", "tally", 0)

    assert_not_equal(tally.particle_names, new_tally.particle_names)
Beispiel #26
0
def test_tally38():
    clean(["test_tally.h5"])

    tally = Tally("Current", ["Neutron", "Proton"], 14, "Surface",
                  "Surface 14", "Neutron Current Across surface 14", 100.0)
    tally.write_hdf5("test_tally.h5", "tally")

    new_tally = Tally()
    new_tally.from_hdf5("test_tally.h5", "tally")

    assert_not_equal(tally.particle_names, new_tally.particle_names)
Beispiel #27
0
def write_tally_h5m(tally_list, filename):
    """
    Function that writes tally objects to ouptut .h5m file
    -------
    tally_list: list of volume id tally pairs of PyNE Material Objects
    filename: filename to write the objects to
    """
    # tally list contains elements of the form ('photon', ('current', ['Surface:4', 'Volume:1']))
    # loop over list
    for tally in tally_list:
        particle_name = tally[0].capitalize()
        tally_type = tally[1][0]
        for k in range(len(tally[1][1])):
            tally_object = tally[1][1][k].split(':')[0]
            object_id = tally[1][1][k].split(':')[1]
            tally_name = particle_name[
                0:2].upper() + tally_type[0: 7 - len(object_id)] + str(object_id)
            new_tally = Tally(tally_type, particle_name,
                              int(object_id), tally_object, str(object_id), tally_name, 0.0, 1.0)
            new_tally.write_hdf5(filename, "/tally")
Beispiel #28
0
def test_mcnp_mesh_tally_xyz():
    particle = "Neutron"
    geometry = "Cartesian"
    origin = [1, 2, 3]
    i_mesh = [5, 10, 20, 25]
    j_mesh = [2, 12]
    k_mesh = [45]
    i_ints = [1, 2, 3, 1]
    j_ints = [1]
    k_ints = [1]
    e = [0, 10, 100]
    e_ints = [1, 1, 2]
    tal_name = "Mesh Tally XYZ Neutron"
    out = "IJ"

    tally = Tally(
        particle,
        geometry,
        origin,
        i_mesh,
        j_mesh,
        k_mesh,
        i_ints,
        j_ints,
        k_ints,
        e,
        e_ints,
        tal_name=tal_name,
    )
    mcnp_tally = (
        "C Mesh Tally XYZ Neutron\n"
        + "FMESH14:n GEOM=XYZ\n"
        + "          ORIGIN=1.000000 2.000000 3.000000\n"
        + "          IMESH=5.000000 10.000000 20.000000 25.000000 IINTS=1 2 3 1\n"
        + "          JMESH=2.000000 12.000000 JINTS=1\n"
        + "          KMESH=45.000000 KINTS=1\n"
        + "          EMESH=0.000000 10.000000 100.000000\n"
        + "          EINTS=1 1 2\n"
        + "          OUT=IJ"
    )
    assert_equal(mcnp_tally, tally.mcnp(1, "mcnp6", out))
Beispiel #29
0
def test_tally14a():
    tally = Tally(
        "Flux",
        "Photon",
        12,
        "Volume",
        "Volume 12",
        "Photon Flux in Cell 12",
        35.0,
        1.0e20,
    )
    assert_equal(tally.normalization, 1.0e20)
Beispiel #30
0
def write_arb_p(file_name,path):
    tally = Tally("Flux","Photon",12,"Volume","Volume 12","Photon Flux in Cell 12",35.0)
    tally.write_hdf5(file_name,path)
Beispiel #31
0
def test_mcnp6_tally_vol():
    tally = Tally(
        "Flux", "Gamma", 12, "Volume", "Volume 12", "Photon Flux in Cell 12", -1.0
    )
    assert_equal("C Photon Flux in Cell 12\nF14:p 12\n", tally.mcnp(1, "mcnp6"))
Beispiel #32
0
def write_arb_p(file_name, path):
    tally = Tally(
        "Flux", "Photon", 12, "Volume", "Volume 12", "Photon Flux in Cell 12", 35.0
    )
    tally.write_hdf5(file_name, path)
Beispiel #33
0
def test_fluka_tally_muonp():
    tally = Tally("Flux","Muon",12,"Volume","Reg12","Muon Flux in Cell 12",-1.0)
    fluka_string = '* Muon Flux in Cell 12\n'+\
                   'USRTRACK         1.0     MUON+     -21.0     Reg12       1.0     1000.Muon Flu\n'+\
                   'USRTRACK       10.E1     1.E-3                                               &'
    assert_equal(fluka_string,tally.fluka("-21.0"))
Beispiel #34
0
def test_tally2():
    tally = Tally()
    assert_equal(tally.particle_names, [])
Beispiel #35
0
def test_tally1():
    tally = Tally()
    assert_equal(tally.tally_type, "")
Beispiel #36
0
def test_mcnp6_tally_vol_norm():
    tally = Tally("Flux","Gamma",12,"Volume","Volume 12","Photon Flux in Cell 12",-1.0,1.0e13)
    assert_equal("C Photon Flux in Cell 12\nF14:P 12\nFM14 1.000000e+13\n",tally.mcnp(1,"mcnp6"))
Beispiel #37
0
def test_mcnp6_tally_vol_proton():
    tally = Tally("Flux","Proton",12,"Volume","Volume 12","Proton Flux in Cell 12",-1.0)
    assert_equal("C Proton Flux in Cell 12\nF14:H 12\n",tally.mcnp(1,"mcnp6"))
Beispiel #38
0
def test_mcnp6_tally_vol_proton_volume_set():
    tally = Tally("Flux","Proton",12,"Volume","Volume 12","Proton Flux in Cell 12",100.0)
    assert_equal("C Proton Flux in Cell 12\n"+\
                 "F14:H 12\n"+\
                 "SD14 100.000000\n",tally.mcnp(1,"mcnp6"))
Beispiel #39
0
def test_tally14():
    tally = Tally(
        "Flux", "Photon", 12, "Volume", "Volume 12", "Photon Flux in Cell 12", 35.0
    )
    assert_equal(tally.entity_size, 35.0)
Beispiel #40
0
def test_tally13():
    tally = Tally(
        "Flux", "Photon", 12, "Volume", "Volume 12", "Photon Flux in Cell 12", 35.0
    )
    assert_equal(tally.tally_name, "Photon Flux in Cell 12")
Beispiel #41
0
def test_fluka_tally_proton():
    tally = Tally("Flux","Proton",12,"Volume","Reg12","Proton Flux in Cell 12",-1.0)
    fluka_string = '* Proton Flux in Cell 12\n'+\
                   'USRTRACK         1.0    PROTON     -21.0     Reg12       1.0     1000.Proton F\n'+\
                   'USRTRACK       10.E1     1.E-3                                               &'
    assert_equal(fluka_string,tally.fluka("-21.0"))
Beispiel #42
0
def test_mcnp6_tally_vol_proton():
    tally = Tally(
        "Flux", "Proton", 12, "Volume", "Volume 12", "Proton Flux in Cell 12", -1.0
    )
    assert_equal("C Proton Flux in Cell 12\nF14:h 12\n", tally.mcnp(1, "mcnp6"))
Beispiel #43
0
def test_mcnp5_tally_surf_current():
    tally = Tally("Current","Neutron",12,"Surface","Surface 12","Neutron Current across surface 12",-1.0)
    assert_equal("C Neutron Current across surface 12\nF11:N 12\n",tally.mcnp(1,"mcnp5"))
Beispiel #44
0
def test_mcnp6_tally_vol():
    tally = Tally("Flux","Gamma",12,"Volume","Volume 12","Photon Flux in Cell 12",-1.0)
    assert_equal("C Photon Flux in Cell 12\nF14:P 12\n",tally.mcnp(1,"mcnp6"))
Beispiel #45
0
def write_arb_n(file_name,path):
    tally = Tally("Current","Neutron",14,"Surface","Surface 14","Neutron Current Across surface 14",100.0)
    tally.write_hdf5(file_name,path)
Beispiel #46
0
def test_mcnp5_tally_surf_flux_norm():
    tally = Tally("Flux","Neutron",12,"Surface","Surface 12","Neutron Flux across surface 12",-1.0,1.0e13)
    assert_equal("C Neutron Flux across surface 12\nF12:N 12\nFM12 1.000000e+13\n",tally.mcnp(1,"mcnp5"))
Beispiel #47
0
def write_photon(file_name):
    tally = Tally("Flux","Photon",12,"Volume","Volume 12","Photon Flux in Cell 12",35.0,123.0)
    tally.write_hdf5(file_name,"/tally")
Beispiel #48
0
def test_mcnp5_tally_surf_flux():
    tally = Tally("Flux","Neutron",12,"Surface","Surface 12","Neutron Flux across surface 12",-1.0)
    assert_equal("C Neutron Flux across surface 12\nF12:N 12\n",tally.mcnp(1,"mcnp5"))
Beispiel #49
0
def test_tally3():
    tally = Tally()
    assert_equal(tally.entity_type, "")
Beispiel #50
0
def test_mcnp5_tally_surf_current_norm():
    tally = Tally("Current","Neutron",12,"Surface","Surface 12","Neutron Current across surface 12",-1.0,1.0e13)
    assert_equal("C Neutron Current across surface 12\nF11:N 12\nFM11 1.000000e+13\n",tally.mcnp(1,"mcnp5"))