Ejemplo n.º 1
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 bright
    import tables

    from fcparams import fr_params
    from fcparams import Quiet

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

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

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


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

    def run_P_NL(temp_pnl):
        FR.P_NL = temp_pnl

        #Calculate output
        FR.ms_feed = InStream
        FR.fold_mass_weights()
        FR.BUd_bisection_method()


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

    pnl_b = 0.7
    run_P_NL(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_P_NL(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.calc_ms_prod()
    FR.write()

    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.tru_cr))
Ejemplo n.º 2
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 bright
    import tables

    from fcparams import lwr_params
    from fcparams import Quiet

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


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

    if name == "LWR_NEA":
        #NEA
        U234 = bright.MassStream({922340: 1.0}, 0.00032, "U234")
        U235 = bright.MassStream({922350: 1.0}, 0.03600, "U235")
        U236 = bright.MassStream({922350: 1.0}, 0.00016, "U235")
        U238 = bright.MassStream({922380: 1.0}, 0.96352, "U238")
    elif name == "LWR_VIS51":
        #VISION
        U234 = bright.MassStream({922340: 1.0}, 3.439849E-04, "U234")
        U235 = bright.MassStream({922350: 1.0}, 4.299811E-02, "U235")
        U236 = bright.MassStream({922350: 1.0}, 0.000000E+00, "U235")
        U238 = bright.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 = bright.LightWaterReactor1G("../LWR.h5", lwr_params, name)

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

    def run_P_NL(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.batch_average_k(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.batch_average_k(lwr_params.BUt)
            n = n+1
            if not Quiet:
                print k, 
        if not Quiet:
            print
            print

        #Calculate and write output
        LWR.BUd_bisection_method()
        LWR.calc_ms_prod()
        LWR.write()

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

        LWR.ms_feed = LWR_CoreInput

        print(LWR.ms_feed)

        LWR.calibrate_P_NL_to_BUd()

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

        print
        run_P_NL(LWR.P_NL)

        with open(name + "_pnl.txt", 'w') as f:
            f.write(str(LWR.P_NL))
    else:
        print
        run_P_NL(0.98)
Ejemplo n.º 3
0
print("Empty Fuel Cycle Component")
printFCComp(fc0)
print("")

print(bright.track_isos())
bright.track_isos( [922350, 942390, 10010] )
print(bright.track_isos())



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

bright.verbosity(1)
print(bright.verbosity())

fc2 = bright.FCComp("Isotope track with name!")
printFCComp(fc2)
print("")

bright.verbosity(100)
print(bright.verbosity())

ptrack = ["My first Param", "Another Param"]
fc3 = bright.FCComp(ptrack)
print("Full track with no name...")
printFCComp(fc3)
print("")