def plotSphereSimulationSpectrum( rendezvous_file,
                                  estimator_id,
                                  entity_id,
                                  mcnp_file,
                                  mcnp_file_start,
                                  mcnp_file_end,
                                  is_a_current,
                                  top_ylims = None,
                                  bottom_ylims = None,
                                  legend_pos = None ):

    # Set the database path
    Collision.FilledGeometryModel.setDefaultDatabasePath( os.environ['DATABASE_PATH'] )
    
    # Reload the simulation
    manager = Manager.ParticleSimulationManagerFactory( rendezvous_file ).getManager()
    
    # Extract the estimator of interest
    estimator = manager.getEventHandler().getEstimator( estimator_id )

    entity_bin_data = estimator.getEntityBinProcessedData( entity_id )
    entity_bin_data["e_bins"] = estimator.getEnergyDiscretization()
    
    # Extract the mcnp data from the output file
    mcnp_file = open( mcnp_file, "r" )
    mcnp_file_lines = mcnp_file.readlines()
    
    mcnp_bin_data = {"e_up": [], "mean": [], "re": []}
    
    for i in range(mcnp_file_start,mcnp_file_end+1):
        split_line = mcnp_file_lines[i-1].split()
        
        mcnp_bin_data["e_up"].append( float(split_line[0]) )
        mcnp_bin_data["mean"].append( float(split_line[1]) )
        mcnp_bin_data["re"].append( float(split_line[2]) )
        
    output_file_name = "h1_sphere_"
    output_file_names = []

    if is_a_current:
        output_file_names.append( output_file_name + "current.eps" )
        output_file_names.append( output_file_name + "current.png" )
        data_type = "Current"
    else:
        output_file_names.append( output_file_name + "flux.eps" )
        output_file_names.append( output_file_name + "flux.png" )
        data_type = "Flux"
        
    # Plot the data
    plotSpectralDataWithErrors( "FRENSIE",
                                entity_bin_data,
                                "MCNP6",
                                mcnp_bin_data,
                                data_type,
                                True,
                                per_lethargy = is_a_current,
                                top_ylims = top_ylims,
                                bottom_ylims = bottom_ylims,
                                legend_pos = legend_pos,
                                output_plot_names = output_file_names )
def plotBroomstickSimulationSpectrumWHvsIA(wh_data_file_name,
                                           wh_data_name,
                                           ia_data_file_name,
                                           ia_data_name,
                                           is_a_current,
                                           top_ylims=None,
                                           bottom_ylims=None,
                                           xlims=None,
                                           legend_pos=None,
                                           dopp_data=False):

    # Load the wh data
    wh_data = loadDataFromDataFile(wh_data_file_name)
    print wh_data.keys()

    # Load the ia data
    ia_data = loadDataFromDataFile(ia_data_file_name)
    print ia_data.keys()

    output_file_name = "pb_broomstick_"
    output_file_names = []

    if is_a_current:
        output_file_names.append(output_file_name + "current.eps")
        output_file_names.append(output_file_name + "current.png")
        data_type = "Current"
    else:
        output_file_names.append(output_file_name + "flux.eps")
        output_file_names.append(output_file_name + "flux.png")
        data_type = "Flux"

    if dopp_data:
        wh_data_abrv = "F-Hybrid"
        ia_data_abrv = "F-Consistent"
    else:
        wh_data_abrv = "F-WH"
        ia_data_abrv = "F-IA"

    # Plot the data
    plotSpectralDataWithErrors(ia_data_name,
                               ia_data,
                               wh_data_name,
                               wh_data,
                               data_type,
                               log_spacing=False,
                               per_lethargy=False,
                               top_ylims=top_ylims,
                               bottom_ylims=bottom_ylims,
                               xlims=xlims,
                               legend_pos=legend_pos,
                               output_plot_names=output_file_names,
                               frensie_data_abrv=ia_data_abrv,
                               test_data_abrv=wh_data_abrv)
def plotExtractedContSoilSimulationData(data_file_name_1,
                                        data_name_1,
                                        data_name_abrv_1,
                                        data_file_name_2,
                                        data_name_2,
                                        data_name_abrv_2,
                                        top_ylims=None,
                                        bottom_ylims=None,
                                        xlims=None,
                                        legend_pos=None):

    # Load the first data
    data_1 = loadDataFromDataFile(data_file_name_1)

    # Load the second data
    data_2 = loadDataFromDataFile(data_file_name_2)

    # for i in range(0,len(data_2["mean"])):
    #     data_2["mean"][i] *= 0.51099891013;
    # for i in range(0,len(data_2["e_bins"])-1):
    #     #data_2["mean"][i] *= 0.51099891013

    #     if data_2["e_bins"][i] > 0.0718705616632476:
    #         data_2["mean"][i] /= 2

    output_file_name = "cont_soil_effective_dose_rate"
    output_file_names = []
    output_file_names.append(output_file_name + ".eps")
    output_file_names.append(output_file_name + ".png")

    # Plot the data
    plotSpectralDataWithErrors(data_name_2,
                               data_2,
                               data_name_1,
                               data_1,
                               "Effective Dose Rate",
                               log_spacing=False,
                               per_lethargy=False,
                               top_ylims=top_ylims,
                               bottom_ylims=bottom_ylims,
                               xlims=xlims,
                               legend_pos=legend_pos,
                               output_plot_names=output_file_names,
                               frensie_data_abrv=data_name_abrv_2,
                               test_data_abrv=data_name_abrv_1,
                               y_log_spacing=True)
def plotBroomstickSimulationSpectrum(rendezvous_file,
                                     estimator_id,
                                     entity_id,
                                     mcnp_file,
                                     mcnp_file_start,
                                     mcnp_file_end,
                                     is_a_current,
                                     top_ylims=None,
                                     bottom_ylims=None,
                                     xlims=None,
                                     legend_pos=None):

    # Activate just-in-time initialization to prevent automatic loading of the
    # geometry and data tables
    Utility.activateJustInTimeInitialization()

    # Set the database path
    Collision.FilledGeometryModel.setDefaultDatabasePath(
        os.environ['DATABASE_PATH'])

    # Reload the simulation
    manager = Manager.ParticleSimulationManagerFactory(
        rendezvous_file).getManager()

    # Extract the estimator of interest
    estimator = manager.getEventHandler().getEstimator(estimator_id)

    full_entity_bin_data = estimator.getEntityBinProcessedData(entity_id)

    start_index = estimator.getNumberOfBins(Event.OBSERVER_ENERGY_DIMENSION)
    end_index = 2 * start_index

    entity_bin_data = {"mean": [], "re": [], "e_bins": []}

    for i in range(start_index, end_index):
        entity_bin_data["mean"].append(full_entity_bin_data["mean"][i])
        entity_bin_data["re"].append(full_entity_bin_data["re"][i])

    entity_bin_data["e_bins"] = list(estimator.getEnergyDiscretization())

    # Extract the mcnp data from the output file
    mcnp_file = open(mcnp_file, "r")
    mcnp_file_lines = mcnp_file.readlines()

    mcnp_bin_data = {"e_up": [], "mean": [], "re": []}

    for i in range(mcnp_file_start, mcnp_file_end + 1):
        split_line = mcnp_file_lines[i - 1].split()

        mean_value = float(split_line[1])

        mcnp_bin_data["e_up"].append(float(split_line[0]))
        mcnp_bin_data["mean"].append(mean_value)
        mcnp_bin_data["re"].append(float(split_line[2]))

    output_file_name = "pb_broomstick_"
    output_file_names = []

    if is_a_current:
        output_file_names.append(output_file_name + "current.eps")
        output_file_names.append(output_file_name + "current.png")
        data_type = "Current"
    else:
        output_file_names.append(output_file_name + "flux.eps")
        output_file_names.append(output_file_name + "flux.png")
        data_type = "Flux"

    # Plot the data
    plotSpectralDataWithErrors("FRENSIE",
                               entity_bin_data,
                               "MCNP6",
                               mcnp_bin_data,
                               data_type,
                               log_spacing=False,
                               per_lethargy=False,
                               top_ylims=top_ylims,
                               bottom_ylims=bottom_ylims,
                               xlims=xlims,
                               legend_pos=legend_pos,
                               output_plot_names=output_file_names)
Ejemplo n.º 5
0
def plotContSoilSimulationSpectrum(rendezvous_file,
                                   estimator_id,
                                   entity_id,
                                   mcnp_file,
                                   mcnp_file_start,
                                   mcnp_file_end,
                                   is_a_current,
                                   is_forward,
                                   col_bin=None,
                                   top_ylims=None,
                                   bottom_ylims=None,
                                   xlims=None,
                                   legend_pos=None):

    # Activate just-in-time initialization to prevent automatic loading of the
    # geometry and data tables
    Utility.activateJustInTimeInitialization()

    # Set the database path
    Collision.FilledGeometryModel.setDefaultDatabasePath(
        os.environ['DATABASE_PATH'])

    # Reload the simulation
    manager = Manager.ParticleSimulationManagerFactory(
        rendezvous_file).getManager()

    # Print the leakage current
    # estimator = manager.getEventHandler().getEstimator( 2 )
    # print estimator.getEntityTotalProcessedData( 20 )
    # print estimator.getEntityTotalProcessedData( 21 )
    # print estimator.getEntityTotalProcessedData( 22 )
    # print estimator.getEntityTotalProcessedData( 23 )
    # print estimator.getEntityTotalProcessedData( 24 )
    # print estimator.getEntityTotalProcessedData( 25 )

    # Extract the estimator of interest
    estimator = manager.getEventHandler().getEstimator(estimator_id)

    full_entity_bin_data = estimator.getEntityBinProcessedData(entity_id)

    num_energy_bins = 0

    if is_forward:
        num_energy_bins = estimator.getNumberOfBins(
            Event.OBSERVER_ENERGY_DIMENSION)
    else:
        num_energy_bins = estimator.getNumberOfBins(
            Event.OBSERVER_SOURCE_ENERGY_DIMENSION)

    start_index = 0
    end_index = num_energy_bins

    if not col_bin is None:
        num_col_bins = estimator.getNumberOfBins(
            Event.OBSERVER_COLLISION_NUMBER_DIMENSION)

        if col_bin >= num_col_bins:
            print "There are only", num_col_bins, "collision number bins!"
            sys.exit(1)

        start_index = col_bin * num_energy_bins
        end_index = start_index + num_energy_bins

    entity_bin_data = {
        "mean": [],
        "re": [],
        "e_bins": [],
        "vov": [],
        "fom": []
    }

    for i in range(start_index, end_index):
        entity_bin_data["mean"].append(full_entity_bin_data["mean"][i])
        entity_bin_data["re"].append(full_entity_bin_data["re"][i])
        #entity_bin_data["vov"].append( full_entity_bin_data["vov"][i] )
        entity_bin_data["fom"].append(full_entity_bin_data["fom"][i])

    if is_forward:
        entity_bin_data["e_bins"] = list(estimator.getEnergyDiscretization())
    else:
        entity_bin_data["e_bins"] = list(
            estimator.getSourceEnergyDiscretization())

    # Extract the mcnp data from the output file
    mcnp_file = open(mcnp_file, "r")
    mcnp_file_lines = mcnp_file.readlines()

    mcnp_bin_data = {"e_up": [], "mean": [], "re": []}

    mcnp_first_nonzero_index = 0
    first_nonzero_value_found = False

    for i in range(mcnp_file_start, mcnp_file_end + 1):
        split_line = mcnp_file_lines[i - 1].split()

        mean_value = float(split_line[1])

        mcnp_bin_data["e_up"].append(float(split_line[0]))
        mcnp_bin_data["mean"].append(mean_value)
        mcnp_bin_data["re"].append(float(split_line[2]))

    for i in range(0, len(mcnp_bin_data["e_up"])):
        print i, mcnp_bin_data["e_up"][i], entity_bin_data["e_bins"][
            i + 1], mcnp_bin_data["mean"][i], entity_bin_data["mean"][
                i], entity_bin_data["re"][i]
        #print i, entity_bin_data["e_bins"][i], entity_bin_data["e_bins"][i+1], entity_bin_data["mean"][i], entity_bin_data["re"][i], entity_bin_data["vov"][i], entity_bin_data["fom"][i]

    output_file_name = "h_infinite_medium_"
    output_file_names = []

    if is_a_current:
        output_file_names.append(output_file_name + "current.eps")
        output_file_names.append(output_file_name + "current.png")
        data_type = "Current"
    else:
        output_file_names.append(output_file_name + "flux.eps")
        output_file_names.append(output_file_name + "flux.png")
        data_type = "Flux"

    # Plot the data
    plotSpectralDataWithErrors("FRENSIE",
                               entity_bin_data,
                               "MCNP6",
                               mcnp_bin_data,
                               data_type,
                               log_spacing=False,
                               per_lethargy=False,
                               top_ylims=top_ylims,
                               bottom_ylims=bottom_ylims,
                               xlims=xlims,
                               legend_pos=legend_pos,
                               output_plot_names=output_file_names)