Ejemplo n.º 1
0
    name = 'scenario_1_input_' + calc_method
    input_file = name + '.json'
    output_file = name + '.sqlite'
    with open(input_file, 'w') as f:
        json.dump(scenario_1_input[calc_method], f)
    s = subprocess.check_output(['cyclus', '-o', output_file, input_file],
                                universal_newlines=True,
                                env=ENV)

    # Initialize dicts
    all_dict_fuel = {}
    agent_entry_dict = {}

    all_dict_fuel = tester.supply_demand_dict_driving(output_file, demand_eq,
                                                      'fuel')
    agent_entry_dict['fuel'] = tester.get_agent_dict(output_file, ['source'])
    plotter.plot_demand_supply_agent(all_dict_fuel, agent_entry_dict['fuel'],
                                     'fuel', name + '_fuel', True, False,
                                     False)

    metric_dict = tester.metrics(all_dict_fuel, metric_dict, calc_method,
                                 'fuel', True)

    df = pd.DataFrame(metric_dict)
    df.to_csv('scenario_1_output.csv')

##########################################################################

######################################SCENARIO 2##########################
# scenario 2, source -> reactor (cycle time = 1, refuel time = 0) -> sink
scenario_2_input = {}
    'lwrstorageout': ['lwrreprocessing'],
    'frstorageout': ['frreprocessing'],
    'moxstorageout': ['moxreprocessing'],
    'lwrout': ['lwrstorage'],
    'frout': ['frstorage'],
    'moxout': ['moxstorage'],
    'lwrtru': ['frmixer', 'moxmixer'],
    'frtru': ['frmixer', 'moxmixer'],
    'moxtru': ['frmixer', 'moxmixer'],
    'lwrreprocessingwaste': ['lwrsink'],
    'frreprocessingwaste': ['frsink'],
    'moxreprocessingwaste': ['moxsink']
}

for commod, facility in commod_dict.items():
    agent_entry_dict[commod] = tester.get_agent_dict(output_file, facility)

# get supply deamnd dict
all_dict['power'] = tester.supply_demand_dict_nond3ploy(
    output_file, 'power', demand_eq)

plotter.plot_demand_supply_nond3ploy(all_dict['power'],
                                     agent_entry_dict['power'], 'power',
                                     'eg01-eg30-flatpower-nond3ploy_power',
                                     True, True, 1)

front_commods = ['sourceout', 'enrichmentout']

back_commods = [
    'lwrstorageout', 'frstorageout', 'moxstorageout', 'lwrreprocessingwaste',
    'frreprocessingwaste', 'moxreprocessingwaste', 'lwrout', 'frout', 'moxout',
all_dict_power = tester.supply_demand_dict_driving(
    output_file, demand_eq, "power")
all_dict_fuel = tester.supply_demand_dict_nondriving(output_file, "fuel", True)
all_dict_spent_fuel = tester.supply_demand_dict_nondriving(
    output_file, "spent_fuel", False
)

agent_entry_dict["power"] = tester.get_agent_dict(
    output_file,
    [
        "reactor1",
        "reactor2",
        "reactor3",
        "reactor4",
        "reactor5",
        "reactor6",
        "reactor7",
        "reactor8",
        "reactor9",
        "reactor10",
        "newreactor",
    ],
)
agent_entry_dict["fuel"] = tester.get_agent_dict(
    output_file, ["source", "initialsource"]
)
agent_entry_dict["spent_fuel"] = tester.get_agent_dict(output_file, [
                                                       "sink"])
# plots demand, supply, calculated demand, calculated supply for the
# scenario for each calc method
plotter.plot_demand_supply_agent(
Ejemplo n.º 4
0
                                universal_newlines=True, env=ENV)
    # Initialize dicts
    all_dict = {}
    agent_entry_dict = {}
    all_dict['power'] = tester.supply_demand_dict_driving(
        output_file, demand_eq, 'power')
    all_dict['sourceoutput'] = tester.supply_demand_dict_nondriving(
        output_file, 'sourceoutput', True)
    all_dict['reactor1output'] = tester.supply_demand_dict_nondriving(
        output_file, 'reactor1output', False)
    all_dict['separations1Pu'] = tester.supply_demand_dict_nondriving(
        output_file, 'separations1Pu', False)
    all_dict['reactor2output'] = tester.supply_demand_dict_nondriving(
        output_file, 'reactor2output', False)

    agent_entry_dict['power'] = tester.get_agent_dict(
        output_file, ['reactor1', 'reactor2'])
    agent_entry_dict['sourceoutput'] = tester.get_agent_dict(output_file, [
                                                             'source'])
    agent_entry_dict['reactor1output'] = tester.get_agent_dict(output_file, [
                                                               'separations1'])
    agent_entry_dict['separations1Pu'] = tester.get_agent_dict(output_file, [
                                                               'mixer'])
    agent_entry_dict['reactor2output'] = tester.get_agent_dict(output_file, [
                                                               'separations2'])

    # plots demand, supply, calculated demand, calculated supply for the
    # scenario for each calc method
    name1 = "scenario_7_input_" + calc_method + "_power"
    plotter.plot_demand_supply_agent(
        all_dict['power'],
        agent_entry_dict['power'],
                                env=ENV)

    # Initialize dicts
    all_dict_power = {}
    all_dict_fuel = {}
    all_dict_spentfuel = {}
    agent_entry_dict = {}

    all_dict_power = tester.supply_demand_dict_driving(output_file, demand_eq,
                                                       'power')
    all_dict_fuel = tester.supply_demand_dict_nondriving(
        output_file, 'fuel', True)
    all_dict_spentfuel = tester.supply_demand_dict_nondriving(
        output_file, 'spentfuel', False)

    agent_entry_dict['power'] = tester.get_agent_dict(output_file, ['reactor'])
    agent_entry_dict['fuel'] = tester.get_agent_dict(output_file, ['source'])
    agent_entry_dict['spentfuel'] = tester.get_agent_dict(
        output_file, ['sink'])

    # plots demand, supply, calculated demand, calculated supply for the
    # scenario for each calc method
    plotter.plot_demand_supply_agent(all_dict_power, agent_entry_dict['power'],
                                     'power', name + "_power", True, False,
                                     False)
    plotter.plot_demand_supply_agent(all_dict_fuel, agent_entry_dict['fuel'],
                                     'fuel', name + "_fuel", True, False,
                                     False)
    plotter.plot_demand_supply_agent(all_dict_spentfuel,
                                     agent_entry_dict['spentfuel'],
                                     'spentfuel', name + "_spentfuel", False,
    input_file = name + ".json"
    output_file = name + ".sqlite"
    with open(input_file, 'w') as f:
        json.dump(scenario_7_input[calc_method], f)
    s = subprocess.check_output(['cyclus', '-o', output_file, input_file],
                                universal_newlines=True,
                                env=ENV)
    # Initialize dicts
    all_dict = {}
    agent_entry_dict = {}
    all_dict['power'] = tester.supply_demand_dict_driving(
        output_file, demand_eq, 'power')
    all_dict['sourceoutput'] = tester.supply_demand_dict_nondriving(
        output_file, 'sourceoutput', True)

    agent_entry_dict['power'] = tester.get_agent_dict(output_file,
                                                      ['reactor1', 'reactor2'])
    agent_entry_dict['sourceoutput'] = tester.get_agent_dict(
        output_file, ['source'])

    # plots demand, supply, calculated demand, calculated supply for the scenario for each calc method
    plotter.plot_demand_supply_agent(all_dict['power'],
                                     agent_entry_dict['power'], 'power', name,
                                     True)
    name2 = "scenario_7_input_" + calc_method + "_sourceoutput"
    plotter.plot_demand_supply_agent(all_dict['sourceoutput'],
                                     agent_entry_dict['sourceoutput'],
                                     'sourceoutput', name2, True)

    metric_dict = tester.metrics(all_dict['power'], metric_dict, calc_method,
                                 'power', True)
    metric_dict = tester.metrics(all_dict['sourceoutput'], metric_dict,
def format_agent_dict(output_file, simple=True):
    """
    This function takes the agent entry table from the transition scenario
    sqlite file and creates a time series dictionary of the entry the various
    facilities in the simulation. The output of this function is used as an
    input for the plot_agents function to generate nice deployment plots.
    INPUT
    output_file: sqlite file name (str)
    simple: boolean.
            True: EG01-23, EG01-24
            False: EG01-29, EG01-30
    OUTPUT
    agent_dict: time series dictionary of the entry the various
    facilities in the simulation (dict)
    """

    if simple:
        in_agent = [
            'lwr1', 'lwr2', 'lwr3', 'lwr4', 'lwr5', 'lwr6', 'lwr7', 'lwr8',
            'lwr9', 'lwr10', 'enrichment', 'source', 'lwrstorage',
            'lwrreprocessing', 'lwrmixer', 'lwrsink', 'fr', 'frstorage',
            'frreprocessing', 'frsink'
        ]
    else:
        in_agent = [
            'lwr1', 'lwr2', 'lwr3', 'lwr4', 'lwr5', 'lwr6', 'lwr7', 'lwr8',
            'lwr9', 'lwr10', 'enrichment', 'source', 'lwrstorage',
            'lwrreprocessing', 'lwrmixer', 'lwrsink', 'moxlwr', 'moxmixer',
            'frmixer', 'fr', 'moxstorage', 'frstorage', 'moxreprocessing',
            'frreprocessing', 'frsink', 'moxsink'
        ]
    agent_dict = tester.get_agent_dict(output_file, in_agent)
    if simple:
        prototypes = [
            'source', 'enrichment', 'lwr', 'lwrstorage', 'lwrreprocessing',
            'lwrmixer', 'lwrsink', 'fr', 'frstorage', 'frreprocessing',
            'frsink'
        ]
    else:
        prototypes = [
            'enrichment', 'source', 'lwrstorage', 'lwrreprocessing',
            'lwrmixer', 'lwrsink', 'moxlwr', 'moxmixer', 'frmixer', 'fr',
            'moxstorage', 'frstorage', 'moxreprocessing', 'frreprocessing',
            'frsink', 'moxsink'
        ]
    agent_dict['lwr'] = {}
    for x in range(10):
        name = 'lwr' + str(x + 1)
        if x == 0:
            agent_dict['lwr'] = Counter(agent_dict[name].copy())
        else:
            agent_dict['lwr'] += Counter(agent_dict[name])
        del agent_dict[name]
    t = list(agent_dict[prototypes[0]].keys())
    prototypes.reverse()
    for x in prototypes:
        if len(agent_dict[x]) < len(agent_dict[prototypes[0]]):
            for key in agent_dict[prototypes[0]]:
                if agent_dict[x].get(key) is None:
                    agent_dict[x][key] = 0
    return agent_dict