def get_undersupply_timesteps(output_file, commod, driving_commod=False, demand_eq='0', demand_driving=True): """ This function returns timeseries dictionaries for existence undersupply of a commodity and the absolute value of this undersupply. INPUT output_file: sqlite file (str) commod: commodity name (str) driving_commod: Boolean, True: driving commod, False: not driving commod demand_eq: demand equation (str), only used if driving_commod is True demand_driving: Boolean. True: demand-driven commodities False: supply-driven commodities OUTPUT dict_dots: timeseries dictionary with 1 and 0 depending if there is undersupply at a specific time step. diff_dict_drop: timeseries dictionary with absolute difference between supply and demand, if supply < demand. """ if driving_commod: all_dict = tester.supply_demand_dict_driving(output_file, demand_eq, commod) else: if demand_driving: all_dict = tester.supply_demand_dict_nondriving(output_file, commod, True, calc=False) else: all_dict = tester.supply_demand_dict_nondriving(output_file, commod, False, calc=False) diff_dict = supplydemanddiff(all_dict) dict_dots = {} diff_dict_drop = {} for key in diff_dict: if demand_driving: if diff_dict[key] < 0: dict_dots[key] = 1 diff_dict_drop[key] = diff_dict[key] else: if diff_dict[key] > 0: dict_dots[key] = 1 diff_dict_drop[key] = diff_dict[key] return dict_dots, diff_dict_drop
'power': ['lwr', 'fr'], 'lwrstorageout': ['lwrreprocessing'], 'frstorageout': ['frreprocessing'], 'lwrout': ['lwrstorage'], 'frout': ['frstorage'], 'lwrtru': ['pumixerlwr'], 'frtru': ['pumixerfr'], 'lwrreprocessingwaste': ['lwrsink'], 'frreprocessingwaste': ['frsink'] } 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_driving(output_file, demand_eq, 'power') plotter.plot_demand_supply_agent(all_dict['power'], agent_entry_dict['power'], 'power', 'eg01-eg24-flatpower-d3ploy_power', True, True, False, 1) front_commods = ['sourceout', 'enrichmentout'] back_commods = [ 'lwrstorageout', 'frstorageout', 'lwrout', 'frout', 'lwrreprocessingwaste', 'frreprocessingwaste', 'frtru', 'lwrtru' ] for commod in front_commods: all_dict[commod] = tester.supply_demand_dict_nondriving( output_file, commod, True) name = 'B2000-' + commod
metric_dict = {} for calc_method in calc_methods: 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 = {} all_dict_fuel = tester.supply_demand_dict_driving(output_file, demand_eq, 'fuel') plotter.plot_demand_supply( all_dict_fuel, 'fuel', name,True) 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 = {} demand_eq = "1000*t"
indx = input_path.rfind("d3ploy/") input = input_path.replace( input_path[indx + len(find):], "input/%s_transition.xml" % transition_type ) s = subprocess.check_output( ["cyclus", "-o", output_file, input], universal_newlines=True, env=ENV ) # Initialize dicts all_dict_power = {} all_dict_fuel = {} all_dict_spent_fuel = {} agent_entry_dict = {} metric_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_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",