Beispiel #1
0
 def test_doCalc_3(self):
     BriPy.isos2track([922350, 922380, 942390])
     s = Storage()
     s.IsosIn = MassStream({942390: 1.0})
     s.doCalc(24110*365.25*24*3600)
     assert(s.IsosOut.mass < 1.0)
     assert_almost_equal(s.IsosOut.comp[942390], 0.5, 3) 
Beispiel #2
0
 def test_setParams(self):
     BriPy.isos2track([922350, 922380, 942390])
     r = Reprocess({"U235": 0.9, "922380": 0.999, "94239": 0.99})
     r.doCalc(MassStream({942390: 1.0}))
     r.setParams()
     assert_equal(r.ParamsIn["Mass"], 1.00)
     assert_equal(r.ParamsOut["Mass"], 0.99)
Beispiel #3
0
 def test_setParams(self):
     BriPy.isos2track([922350, 922380, 942390])
     s = Storage()
     s.doCalc(MassStream({942390: 1.0}), 24110*365.25*24*3600)
     s.setParams()
     assert_equal(s.ParamsIn["Mass"],  1.00)
     assert(0.5 < s.ParamsOut["Mass"] < 1.0)
Beispiel #4
0
 def test_doCalc_2(self):
     BriPy.isos2track([922350, 922380, 942390])
     s = Storage()
     s.decay_time = 0.0
     s.doCalc(MassStream({942390: 1.0}))
     assert_equal(s.IsosOut.mass, 1.0)
     assert_equal(s.IsosOut.comp[942390], 1.0) 
Beispiel #5
0
 def test_initialize_3(self):
     BriPy.isos2track([922350, 922380, 942390])
     r = Reprocess({"U235": 0.9, "922380": 0.999, "PU2390": 0.99})
     r.initialize({92: 0.99})
     assert_almost_equal(r.sepeff[922350], 0.99)
     assert_almost_equal(r.sepeff[922380], 0.99)
     assert_almost_equal(r.sepeff[942390], 1.0)
Beispiel #6
0
 def test_doCalc_1(self):
     BriPy.isos2track([922350, 922380, 942390])
     r = Reprocess({"U235": 0.9, "922380": 0.999, "94239": 0.99})
     r.IsosIn = MassStream({942390: 1.0})
     r.doCalc()
     assert_equal(r.IsosOut.mass, 0.99)
     assert_equal(r.IsosOut.comp[942390], 1.0)  # Recall ms.comp is normalized
Beispiel #7
0
 def test_writeout_1(self):
     """Text only."""
     BriPy.isos2track([922350])
     fcc = FCComp(["Mass"])
     fcc.IsosIn  = MassStream({922350: 1.0})
     fcc.IsosOut = MassStream({922350: 0.5})
     fcc.writeout()
Beispiel #8
0
 def test_writeText(self):
     BriPy.isos2track([922350])
     fcc = FCComp(["Mass"])
     fcc.IsosIn  = MassStream({922350: 1.0})
     fcc.IsosOut = MassStream({922350: 0.5})
     fcc.setParams()
     fcc.writeText()
Beispiel #9
0
 def test_initialize_1(self):
     BriPy.isos2track([922350, 922380, 942390])
     r = Reprocess()
     assert_equal(r.sepeff, {})
     r.initialize({92: 0.99, 942390: 0.9})
     assert_almost_equal(r.sepeff[922350], 0.99)
     assert_almost_equal(r.sepeff[922380], 0.99)
     assert_almost_equal(r.sepeff[942390], 0.9)
Beispiel #10
0
 def test_Reprocess_2(self):
     BriPy.isos2track([922350, 922380, 942390])
     r = Reprocess({"U235": 0.9, "922380": 0.999, "94239": 0.99})
     assert_equal(r.name, "")
     assert_almost_equal(r.sepeff[922350], 0.9)
     assert_almost_equal(r.sepeff[922380], 0.999)
     assert_almost_equal(r.sepeff[942390], 0.99)
     assert_equal(r.params2track, ["Mass"])
Beispiel #11
0
 def test_writeHDF5_1(self):
     BriPy.isos2track([922350])
     BriPy.write_hdf5(True)
     fcc = FCComp([], 'fcc')
     fcc.IsosIn  = MassStream({922350: 1.0})
     fcc.IsosOut = MassStream({922350: 0.5})
     fcc.PassNum = 1
     fcc.writeHDF5()
     os.remove('fcc.h5')
Beispiel #12
0
 def test_writeout_3(self):
     """HDF5 & Text output."""
     BriPy.isos2track([922350])
     BriPy.write_hdf5(True)
     BriPy.write_text(True)
     fcc = FCComp(["Mass"], 'fcc')
     fcc.IsosIn  = MassStream({922350: 1.0})
     fcc.IsosOut = MassStream({922350: 0.5})
     fcc.writeout()
     os.remove('fcc.h5')
Beispiel #13
0
    print("ParamsOut: " + str(fc.ParamsOut))
    print("Pass Number: " + str(fc.PassNum))
    print("Do Calc Empty: " + str( fc.doCalc() ))
    testCD = {922350: 10.0, 10010: 1.0}
    print("Do Calc Dictonary: " + str( fc.doCalc(testCD) ))
    testMS = BriPy.MassStream({942390: 10.0, 80160: 20.0})
    print("Do Calc MassStream: " + str( fc.doCalc(testMS) ))
    return

rp0 = BriPy.Reprocess()
print("Empty Reprocessing Cycle Component")
printFCComp(rp0)
print("")

SE1 = {92: 0.99, 94: 0.9}
BriPy.isos2track([922350, 942390, 10010])

rp1 = BriPy.Reprocess({})
rp1.initialize(SE1)
print("SE with no name...")
printFCComp(rp1)
print("")

SE2 = {922350: 0.99, 942390: 0.9}
rp2 = BriPy.Reprocess({}, "SE with name!")
rp2.initialize(SE2)
printFCComp(rp2)
print("")

SE3 = {"U": 0.99, "PU239": 0.9}
rp3 = BriPy.Reprocess(SE3)
Beispiel #14
0
 def test_load_isos2track_hdf5_4(self):
     old_isos = BriPy.isos2track()
     BriPy.isos2track([80160])
     BriPy.load_isos2track_hdf5('isos.h5', '/NotIsos', True)
     assert_equal(BriPy.isos2track(), [10010, 922350, 922380])
     BriPy.isos2track(old_isos)
Beispiel #15
0
 def test_isos2track(self):
     old_isolist = BriPy.isos2track()
     new_isolist = BriPy.mixed_2_zzaaam_List([92235, "H1"])
     BriPy.isos2track(new_isolist)
     assert_equal(BriPy.isos2track(), [10010, 922350])
     BriPy.isos2track(old_isolist)
Beispiel #16
0
def main():
    parser = OptionParser()
    parser.add_option("-c", "--case", dest="case", help="Benchmark case to run.")
    parser.add_option("-p", "--calibrate", action="store_true", dest="calibrate", default=False, help="Calibrate non-leakage probability.")
    parser.add_option("-v", "--verbose", action="store_true", dest="verbose", default=False, help="Prints extra information.")
    options, args = parser.parse_args()

    if options.case == "LWR_NEA":
        name = options.case
    elif options.case == "LWR_VIS51":
        name = options.case
    else:
        print "Case not valid, please pick from: LWR_NEA, or LWR_VIS51."
        raise SystemExit

    shutil.copy(name + "_fcparams.py", "fcparams.py")

    import BriPy
    import tables

    from fcparams import lwr_params
    from fcparams import Quiet

    #Various Variables
    snf_need = []
    if (not Quiet) or (options.verbose):
        BriPy.verbosity(100)


    #redefine isotrak
    trackfile = tables.openFile("../LWR.h5", 'r')
    itrack = trackfile.root.ToIso_zz.read()
    trackfile.close()
    BriPy.isos2track(itrack)

    if name == "LWR_NEA":
        #NEA
        U234 = BriPy.MassStream({922340: 1.0}, 0.00032, "U234")
        U235 = BriPy.MassStream({922350: 1.0}, 0.03600, "U235")
        U236 = BriPy.MassStream({922350: 1.0}, 0.00016, "U235")
        U238 = BriPy.MassStream({922380: 1.0}, 0.96352, "U238")
    elif name == "LWR_VIS51":
        #VISION
        U234 = BriPy.MassStream({922340: 1.0}, 3.439849E-04, "U234")
        U235 = BriPy.MassStream({922350: 1.0}, 4.299811E-02, "U235")
        U236 = BriPy.MassStream({922350: 1.0}, 0.000000E+00, "U235")
        U238 = BriPy.MassStream({922380: 1.0}, 9.566579E-01, "U238")
    else:
        print "Case not valid, please pick from: LWR_NEA, or LWR_VIS51."
        raise SystemExit

    #######################
    ### LWR Computation ###
    #######################

    #Fuel Cycle Components
    LWR = BriPy.LightWaterReactor1G("../LWR.h5", lwr_params, name)

    def LWR_delR_BU_(ms):
        "Calculates the delta Reaction Rates at the target burnup."
        LWR.IsosIn = ms
        LWR.foldMassWeights()
        dR = LWR.batchAve(lwr_params.BUt, "p") - LWR.batchAve(lwr_params.BUt, "d")
        return dR

    def Run_PNL(temp_pnl):
        LWR.P_NL = temp_pnl

        delR_U235 = LWR_delR_BU_(U235)
        delR_U238 = LWR_delR_BU_(U238)

        #Calculate delta R for the Guess
        LWR_CoreInput = U238 + U235 + U234 + U236
        LWR_CoreInput.name = "LWR_CoreInput"
        LWR_CoreInput.Normalize()
        LWR_delR_Guess = LWR_delR_BU_(LWR_CoreInput)

        k = LWR.batchAveK(lwr_params.BUt)
        n = 0
        if not Quiet:
            print str(1) + ")",  k, 

        while 0.001 < abs(1.0 - k) and n < 10:
            #Adjust Masses based on pertubation guess.
            LWR_DeltaM_U238 = - LWR_delR_Guess / (delR_U238 - delR_U235)
            U238.mass = U238.mass + LWR_DeltaM_U238
            U235.mass = U235.mass - LWR_DeltaM_U238

            #Recalculate core parameters for new masses guess
            LWR_CoreInput = U238 + U235 + U234 + U236
            LWR_CoreInput.name = "LWR_CoreInput"
            LWR_delR_Guess = LWR_delR_BU_(LWR_CoreInput)
            k = LWR.batchAveK(lwr_params.BUt)
            n = n+1
            if not Quiet:
                print k, 
        if not Quiet:
            print
            print

        #Calculate and write output
        LWR.BUd_BisectionMethod()
        LWR.calcOutIso()
        LWR.writeout()

    if options.calibrate:
        LWR_CoreInput = U238 + U235 + U234 + U236
        LWR_CoreInput.name = "LWR_CoreInput"
        LWR_CoreInput.Normalize()

        LWR.IsosIn = LWR_CoreInput

        print(LWR.IsosIn)

        LWR.Calibrate_PNL_2_BUd()

        print
        print "Non-Leakage Probability = ", LWR.P_NL

        print
        Run_PNL(LWR.P_NL)

        with open(name + "_pnl.txt", 'w') as f:
            f.write(str(LWR.P_NL))
    else:
        print
        Run_PNL(0.98)
Beispiel #17
0
 def test_writeIsoPass(self):
     BriPy.isos2track([922350])
     fcc = FCComp()
     fcc.IsosIn  = MassStream({922350: 1.0})
     fcc.IsosOut = MassStream({922350: 0.5})
     fcc.writeIsoPass()
Beispiel #18
0
 def test_Reprocess_4(self):
     BriPy.isos2track([922350])
     r = Reprocess({"U235": 0.9, "922380": 0.999}, "r")
     assert_equal(r.name, "r")
     assert_equal(r.sepeff, {922350: 0.9})
     assert_equal(r.params2track, ["Mass"])
Beispiel #19
0
def main():
    parser = OptionParser()
    parser.add_option("-c", "--case", dest="case", help="Benchmark case to run.")
    parser.add_option("-v", "--verbose", action="store_true", dest="verbose", default=False, help="Prints extra information.")
    options, args = parser.parse_args()

    if options.case == "FR_NEA":
        name = options.case
        bud_t = 27.3969072997
    elif options.case == "FR_VISp1":
        name = options.case
        bud_t = 176.6
    elif options.case == "FR_VISp5":
        name = options.case
        bud_t = 176.6
    else:
        print "Case not valid, please pick from: FR_NEA, FR_VISp1, or FR_VISp5."
        raise SystemExit

    shutil.copy(name + "_fcparams.py", "fcparams.py")

    import BriPy
    import tables

    from fcparams import fr_params
    from fcparams import Quiet

    #Various Variables
    snf_need = []
    if (not Quiet) or (options.verbose):
        BriPy.verbosity(100)

    #redefine isotrak
    trackfile = tables.openFile("../FR.h5", 'r')
    itrack = trackfile.root.ToIso_zz.read()
    trackfile.close()
    BriPy.isos2track(itrack)

    ######################
    ### FR Computation ###
    ######################
    InStream = BriPy.MassStream(name + '_Benchmark_In.txt', 1.0, "InStream")


    #Fuel Cycle Components
    FR = BriPy.FastReactor1G("../FR.h5", fr_params, name)

    def Run_PNL(temp_pnl):
        FR.P_NL = temp_pnl

        #Calculate output
        FR.IsosIn = InStream
        FR.foldMassWeights()
        FR.BUd_BisectionMethod()


    #Calibration proceeds by bisection method...
    pnl_a = 0.6
    Run_PNL(pnl_a)
    bud_a = FR.BUd
    sign_a = (bud_a - bud_t) / abs(bud_a - bud_t)

    pnl_b = 0.7
    Run_PNL(pnl_b)
    bud_b = FR.BUd
    sign_b = (bud_b - bud_t) / abs(bud_b - bud_t)

    DoA = 10.0**(-15)        #Degree of accuracy to carry out calculations to.
    q = 0
    while (DoA < abs(pnl_a - pnl_b)) and (DoA < abs(bud_a - bud_b)) and q < 100:
        pnl_c = (pnl_a + pnl_b) / 2.0
        Run_PNL(pnl_c)
        bud_c = FR.BUd
        sign_c = (bud_c - bud_t) / abs(bud_c - bud_t)

        q = q + 1

        if (sign_a == sign_c) and not (sign_b == sign_c):
            pnl_a = pnl_c 
            bud_a = bud_c
            sign_a = sign_c
        elif (sign_b == sign_c) and not (sign_a == sign_c):
            pnl_b = pnl_c 
            bud_b = bud_c
            sign_b = sign_c
        else:
            if not Quiet:
                print
                print "SOMEWHERE WHILE FINDING k SOMETHING WENT WRONG!!!"
                print "Here is some information that might help you debug ^_^"
                print "pnl_%(ltr)s = %(pnl)f\tBUd_%(ltr)s = %(bud)f\tsign_%(ltr)s = %(sign)f"%{'ltr': 'a', 'pnl': pnl_a, 'bud': bud_a, 'sign': sign_a}
                print "pnl_%(ltr)s = %(pnl)f\tBUd_%(ltr)s = %(bud)f\tsign_%(ltr)s = %(sign)f"%{'ltr': 'b', 'pnl': pnl_b, 'bud': bud_b, 'sign': sign_b}
                print "pnl_%(ltr)s = %(pnl)f\tBUd_%(ltr)s = %(bud)f\tsign_%(ltr)s = %(sign)f"%{'ltr': 'c', 'pnl': pnl_c, 'bud': bud_c, 'sign': sign_c}
                print

    if not Quiet:
        print
        print "Final Result of Burnup Bisection Method Calculation:"
        print "q = ", q
        print "pnl_%(ltr)s = %(pnl).16f\tBUd_%(ltr)s = %(bud)f\tsign_%(ltr)s = %(sign)f"%{'ltr': 'a', 'pnl': pnl_a, 'bud': bud_a, 'sign': sign_a}
        print "pnl_%(ltr)s = %(pnl).16f\tBUd_%(ltr)s = %(bud)f\tsign_%(ltr)s = %(sign)f"%{'ltr': 'b', 'pnl': pnl_b, 'bud': bud_b, 'sign': sign_b}
        print "pnl_%(ltr)s = %(pnl).16f\tBUd_%(ltr)s = %(bud)f\tsign_%(ltr)s = %(sign)f"%{'ltr': 'c', 'pnl': pnl_c, 'bud': bud_c, 'sign': sign_c}

    #Write output
    FR.calcOutIso()
    FR.writeout()

    with open(name + "_pnl.txt", 'w') as f:
        f.write(str(FR.P_NL))

    with open(name + "_trucr.txt", 'w') as f:
        f.write(str(FR.TruCR))
Beispiel #20
0
 def test_load_isos2track_text_2(self):
     old_isos = BriPy.isos2track()
     BriPy.isos2track([80160])
     BriPy.load_isos2track_text('isos.txt', True)
     assert_equal(BriPy.isos2track(), [10010, 922350, 922380])
     BriPy.isos2track(old_isos)
Beispiel #21
0
    print("ParamsOut: " + str(fc.ParamsOut))
    print("Pass Number: " + str(fc.PassNum))
    print("Do Calc Empty: " + str(fc.doCalc()))
    testCD = {922350: 10.0, 10010: 1.0}
    print("Do Calc Dictonary: " + str(fc.doCalc(testCD)))
    testMS = BriPy.MassStream({942390: 10.0, 80160: 20.0})
    print("Do Calc MassStream: " + str(fc.doCalc(testMS)))
    return


fc0 = BriPy.FCComp()
print("Empty Fuel Cycle Component")
printFCComp(fc0)
print("")

print(BriPy.isos2track())
BriPy.isos2track([922350, 942390, 10010])
print(BriPy.isos2track())


fc1 = BriPy.FCComp()
print("Isotope track with no name...")
printFCComp(fc1)
print("")

BriPy.verbosity(1)
print(BriPy.verbosity())

fc2 = BriPy.FCComp("Isotope track with name!")
printFCComp(fc2)
print("")
Beispiel #22
0
 def test_load_isos2track_hdf5_1(self):
     old_isos = BriPy.isos2track()
     BriPy.isos2track([80160])
     BriPy.load_isos2track_hdf5('isos.h5')
     assert_equal(BriPy.isos2track(), [10010, 80160, 922350, 922380])
     BriPy.isos2track(old_isos)
Beispiel #23
0
 def test_Tij_F_(self):
     Tij_F_ = self.r1g.Tij_F_
     jsos   = BriPy.isos2track()
     for i in Tij_F_.keys():
         for j in jsos:
             assert_equal(len(self.r1g.F), len(Tij_F_[i][j]))
Beispiel #24
0
def printFCComp(fc):
    print("Name: " + fc.name)
    print("Params2Track: " + str(fc.params2track))
    print("IsosIn: " + str(fc.IsosIn))
    print("IsosOut: " + str(fc.IsosOut))
    print("ParamsIn: " + str(fc.ParamsIn))
    print("ParamsOut: " + str(fc.ParamsOut))
    print("Pass Number: " + str(fc.PassNum))
    return

st0 = BriPy.Storage()
print("Empty Storage Component")
printFCComp(st0)
print("")

BriPy.isos2track([922350, 942390, 10010])
cd = {922350: 10.0, 10010: 1.0}
ms = BriPy.MassStream("MassStreamtry02.txt")

st1 = BriPy.Storage()
print("Storage No Name...")
printFCComp(st1)
print("")

BriPy.isos2track(ms.comp.keys())
st2 = BriPy.Storage("Storage With Name!")
printFCComp(st2)
print("")

print("ST1 Decay Time: " + str(st1.decay_time))
st1.decay_time = 3600 * 24 * 10
Beispiel #25
0
lwr_data = data_dir + "/LWR.h5"
bp.load_isos2track_hdf5(lwr_data)

# We are going to capture the output, so don't write it out automatically.
bp.write_text(False)
bp.write_hdf5(False)

# Generate a used fuel table description
UsedFuel = {
    'assembly_id': tb.StringCol(itemsize=15, pos=0), 
    'discharge_k': tb.Float64Col(pos=1),
    'mass':        tb.Float64Col(pos=2),
    }

nbuf = len(UsedFuel)
i2t = bp.isos2track()

for i in xrange(len(i2t)):
    UsedFuel[bp.isoname.zzaaam_2_LLAAAM(i2t[i])] = tb.Float64Col(pos=nbuf + i)

# Init the LWR object, only need one!
lwrd = bp.LWRDefaults()
lwrd.batches = 1
lwr = bp.LightWaterReactor1G(lwr_data, lwrd, "LWR")

# Init the storage object, we only need one
stor = bp.Storage("Storage")
t_now = time.time()  # Use the same time 'now' value for all runs.

############################
### Fuel Cycle Functions ###