{'attribute' : 'powerpack_thermal_simulator.analysis.grid_0', 'operator' : 'gt', 'bound' : 0}, {'attribute' : 'powerpack_thermal_simulator.analysis.grid_1', 'operator' : 'gt', 'bound' : 0}, {'attribute' : 'powerpack_thermal_simulator.analysis.grid_2', 'operator' : 'gt', 'bound' : 0}, ] filter_sort_gbo = wf.Filter(filters) blocks.extend([block_gbo, optimize_gbo, attribute_selection_gbo, filter_sort_gbo]) pipes.extend([wf.Pipe(attribute_selection_qtbo.outputs[0], block_gbo.inputs[8]), wf.Pipe(block_gbo.outputs[0], optimize_gbo.inputs[0]), wf.Pipe(optimize_gbo.outputs[1], attribute_selection_gbo.inputs[0]), wf.Pipe(attribute_selection_gbo.outputs[0], filter_sort_gbo.inputs[0]) ]) workflow_complete_battery = wf.Workflow(blocks, pipes, filter_sort_gbo.outputs[0]) input_values = {workflow_complete_battery.index(block_ebo.inputs[0]): Cell2, workflow_complete_battery.index(block_ebo.inputs[1]): limits_voltage_module, workflow_complete_battery.index(block_ebo.inputs[2]): limits_current_module, workflow_complete_battery.index(block_ebo.inputs[3]): limits_voltage_battery, workflow_complete_battery.index(block_ebo.inputs[4]): limits_current_battery, workflow_complete_battery.index(block_ebo.inputs[5]): [6, 50], workflow_complete_battery.index(block_ebo.inputs[6]): [25, 50], workflow_complete_battery.index(block_ebo.inputs[7]): [comb_profile_load, comb_profile_wltp, comb_profile_end], workflow_complete_battery.index(optimize_ebo.inputs[1]): 20, workflow_complete_battery.index(optimize_ebo.inputs[2]): [420, 500]} input_values.update({workflow_complete_battery.index(block_qtbo.inputs[1]): catalog1,
}, { 'attribute': 'bms.battery.number_cells', 'operator': 'gt', 'bound': 700 }] filter_sort = wf.Filter(filters, 'Filters EBO') blocks.extend([block_ebo, optimize_ebo, attribute_selection_ebo, filter_sort]) pipes = [ wf.Pipe(block_ebo.outputs[0], optimize_ebo.inputs[0]), wf.Pipe(optimize_ebo.outputs[1], attribute_selection_ebo.inputs[0]), wf.Pipe(attribute_selection_ebo.outputs[0], filter_sort.inputs[0]) ] workflow = wf.Workflow(blocks, pipes, filter_sort.outputs[0]) input_values = { 0: cells.CELL1_2RC, 1: limits_voltage_module, 2: limits_current_module, 3: limits_voltage_battery, 4: limits_current_battery, 5: [33, 34], 6: [24, 25], 7: [comb_profile_load, comb_profile_wltp, comb_profile_end], 12: 5 } #workflow_run = workflow.run(input_values) #d = workflow_run.to_dict() #w = wf.WorkflowRun.dict_to_object(d) #methods_jsonschemas = workflow._method_jsonschemas
display = wf.Display(name='Display') block_workflow = [ block_generator, block_generate, block_gearbox, block_engine, block_efficiencymap, block_cluster, display ] pipe_workflow = [ wf.Pipe(block_generator.outputs[0], block_generate.inputs[0]), wf.Pipe(block_gearbox.outputs[0], block_generator.inputs[0]), wf.Pipe(block_engine.outputs[0], block_gearbox.inputs[0]), wf.Pipe(block_efficiencymap.outputs[0], block_engine.inputs[0]), wf.Pipe(block_generate.outputs[0], block_cluster.inputs[0]), wf.Pipe(block_cluster.outputs[0], display.inputs[0]) ] workflow = wf.Workflow(block_workflow, pipe_workflow, block_generate.outputs[0]) workflow.plot() engine_speeds = list(np.linspace(500, 6000, num=12)) #Engine speed in rpm engine_speeds = [float(i) * (np.pi / 30) for i in engine_speeds] # in rad/s engine_torques = [ 15.6, 31.2, 46.8, 62.4, 78, 93.6, 109.2, 124.8, 140.4, 156, 171.6 ] #engine torque in N*m mass_flow_rate = [[ 0.1389, 0.2009, 0.2524, 0.3006, 0.3471, 0.4264, 0.4803, 0.5881, 0.5881, 0.6535, 0.7188 ], [ 0.2777, 0.3659, 0.4582, 0.5587, 0.6453, 0.7792, 0.8977, 1.0325, 1.1762, 1.3069, 1.4376 ],
wf.Pipe(import_csv.outputs[1], filtered_catalog1.inputs[1]), wf.Pipe(instantiate_pareto.outputs[0], filtered_catalog1.inputs[2]), wf.Pipe(filtered_catalog1.outputs[0], catalogs.inputs[0]), wf.Pipe(filter2.outputs[0], filtered_catalog2.inputs[0]), wf.Pipe(import_csv.outputs[1], filtered_catalog2.inputs[1]), wf.Pipe(instantiate_pareto.outputs[0], filtered_catalog2.inputs[2]), wf.Pipe(filtered_catalog2.outputs[0], catalogs.inputs[1]), wf.Pipe(catalogs.outputs[0], concatenate.inputs[0]), wf.Pipe(import_csv.outputs[1], concatenate.inputs[3]), wf.Pipe(concatenate.outputs[0], display.inputs[0]), wf.Pipe(concatenate.outputs[0], array_attribute.inputs[0]) ] # Workflow workflow = wf.Workflow(blocks=blocks, pipes=pipes, output=catalogs.outputs[0], name='Cars workflow') # workflow.plot_jointjs() # # Input values input_values = { workflow.index(import_csv.inputs[0]): 'cars.csv', workflow.index(instantiate_pareto.inputs[0]): minimized_attributes, workflow.index(instantiate_pareto.inputs[1]): True, workflow.index(catalog1.inputs[4]): choice_args, workflow.index(catalog1.inputs[5]): 'Cars 1', workflow.index(filter1.inputs[1]): filter_min, workflow.index(filtered_catalog1.inputs[4]): choice_args, workflow.index(filtered_catalog1.inputs[5]): 'Filtered Cars 1', workflow.index(catalog2.inputs[4]): choice_args, workflow.index(catalog2.inputs[5]): 'Cars 2',
wf.Pipe(import_csv.outputs[0], instantiate_catalog.inputs[0]), wf.Pipe(import_csv.outputs[1], instantiate_catalog.inputs[1]), wf.Pipe(instantiate_pareto.outputs[0], instantiate_catalog.inputs[2]), wf.Pipe(instantiate_catalog.outputs[0], display.inputs[0]), # wf.Pipe(instantiate_catalog.outputs[0], objectives_method.inputs[0]), wf.Pipe(instantiate_catalog.outputs[0], filter_method.inputs[0]), wf.Pipe(filter_method.outputs[0], filtered_catalog.inputs[0]), wf.Pipe(import_csv.outputs[1], filtered_catalog.inputs[1]), wf.Pipe(filtered_catalog.outputs[0], filtered.inputs[0]), wf.Pipe(instantiate_pareto.outputs[0], filtered_catalog.inputs[2]) # wf.Pipe(objectives_method.outputs[1], objectives_attributes.inputs[0]) ] # Workflow workflow = wf.Workflow(blocks=blocks, pipes=pipes, output=filter_method.outputs[0], name='Cars workflow') # workflow.plot_jointjs() # # Input values input_values = { workflow.index(import_csv.inputs[0]): 'cars.csv', workflow.index(instantiate_pareto.inputs[0]): minimized_attributes, workflow.index(instantiate_pareto.inputs[1]): True, workflow.index(instantiate_catalog.inputs[4]): choice_args, workflow.index(instantiate_catalog.inputs[3]): [], workflow.index(instantiate_catalog.inputs[5]): 'Cars', workflow.index(filter_method.inputs[1]): filters, workflow.index(filtered_catalog.inputs[4]): choice_args, workflow.index(filtered_catalog.inputs[3]): [], workflow.index(filtered_catalog.inputs[5]): 'Filtered Cars',
block_efficiencymap = wf.InstanciateModel(objects.EfficiencyMap, name= 'Efficiency Map') block_wltpcycle = wf.InstanciateModel(objects.WLTPCycle, name = 'WLTP Cycle') list_attribute = ['average_fuel_consumption', 'average_engine_speed', 'average_engine_torque', 'ratio_min', 'ratio_max', 'average_ratio'] display = wf.MultiPlot(list_attribute, order = 1, name= 'Display') block_workflow = [block_optimizer, method_optimize, block_gearbox, block_engine, block_efficiencymap, block_wltpcycle, display] pipe_workflow = [wf.Pipe(block_optimizer.outputs[0], method_optimize.inputs[0]), wf.Pipe(block_gearbox.outputs[0], block_optimizer.inputs[0]), wf.Pipe(block_wltpcycle.outputs[0], block_optimizer.inputs[1]), wf.Pipe(block_engine.outputs[0], block_gearbox.inputs[0]), wf.Pipe(block_efficiencymap.outputs[0], block_engine.inputs[0]), wf.Pipe(method_optimize.outputs[0], display.inputs[0])] workflow = wf.Workflow(block_workflow, pipe_workflow, method_optimize.outputs[0]) engine_speeds = list(np.linspace(500, 6000, num = 12)) #Engine speed in rpm engine_speeds = [float(i)*(np.pi/30) for i in engine_speeds] # in rad/s engine_torques = [15.6,31.2, 46.8, 62.4, 78, 93.6, 109.2, 124.8, 140.4, 156, 171.6] #engine torque in N*m mass_flow_rate = [[0.1389, 0.2009, 0.2524, 0.3006, 0.3471, 0.4264, 0.4803, 0.5881, 0.5881, 0.6535, 0.7188], [0.2777, 0.3659, 0.4582, 0.5587, 0.6453, 0.7792, 0.8977, 1.0325, 1.1762, 1.3069, 1.4376], [0.4166, 0.5538, 0.7057, 0.8332, 0.9557, 1.0733, 1.2127, 1.3428, 1.5438, 1.9604, 2.1564], [0.5391, 0.7188, 0.9116, 1.0913, 1.2497, 1.4115, 1.5552, 1.7774, 2.0290, 2.3851, 2.8752], [0.6330, 0.8658, 1.0904, 1.2906, 1.5111, 1.6786, 1.9440, 2.2217, 2.4995, 2.8997, 3.5940], [0.7106, 0.9949, 1.2718, 1.5193, 1.7888, 2.0878, 2.3671, 2.6661, 2.9993, 3.5286, 4.3128], [0.7433, 1.0806, 1.3722, 1.7839, 2.2013, 2.5490, 2.8817, 3.1562, 3.5507, 4.1739, 5.0316], [0.9475, 1.2938, 1.7290, 2.2087, 2.5648, 2.9993, 3.3391, 3.6855, 4.2932, 4.8355, 5.7504],
instanciate_optimizer = wf.InstanciateModel(model_class=Optimizer, name='Instantiate Optimizer') optimization = wf.ModelMethod(model_class=Optimizer, method_name='optimize', name='Optimization') model_fetcher = wf.ModelAttribute(attribute_name='model_to_optimize', name='Model Fetcher') pipe1_opt = wf.Pipe(input_variable=instanciate_optimizer.outputs[0], output_variable=optimization.inputs[0]) pipe2_opt = wf.Pipe(input_variable=optimization.outputs[1], output_variable=model_fetcher.inputs[0]) optimization_blocks = [instanciate_optimizer, optimization, model_fetcher] optimization_pipes = [pipe1_opt, pipe2_opt] optimization_workflow = wf.Workflow(blocks=optimization_blocks, pipes=optimization_pipes, output=model_fetcher.outputs[0], name='Optimization Workflow') optimization_workflow_block = wf.WorkflowBlock(workflow=optimization_workflow, name='Workflow Block') parallel_optimization = wf.ForEach( workflow_block=optimization_workflow_block, workflow_iterable_input=optimization_workflow_block.inputs[0], name='ForEach') unpacker = wf.Unpacker(indices=[0, 3, -1], name='Unpacker') sequence = wf.Sequence(number_arguments=2, name='Sequence') filters = [{ 'attribute': 'value',
'number_main_area', 'number_area', 'last_revenue', 'strategy_txt', 'revenue_txt']) blocks = [] blocks.extend([block_generator, method_generate, block_optimizer, method_minimize, method_sort, parallel_plot_block]) pipes = [wf.Pipe(block_generator.outputs[0], method_generate.inputs[0]), wf.Pipe(method_generate.outputs[0], method_minimize.inputs[1]), wf.Pipe(block_optimizer.outputs[0], method_minimize.inputs[0]), wf.Pipe(method_minimize.outputs[0], method_sort.inputs[1]), wf.Pipe(block_optimizer.outputs[0], method_sort.inputs[0]), wf.Pipe(method_sort.outputs[0], parallel_plot_block.inputs[0])] workflow = wf.Workflow(blocks, pipes, method_sort.outputs[0], name='Generation') workflow.plot_jointjs() input_values = {workflow.index(block_generator.inputs[0]): [France, Germany, Italy, USA, Canada, China, Japan], workflow.index(method_generate.inputs[1]): 2020, workflow.index(method_generate.inputs[2]): 2022, workflow.index(method_minimize.inputs[2]): 1e6, workflow.index(method_minimize.inputs[3]): 5, workflow.index(method_minimize.inputs[4]): 0.01, workflow.index(method_minimize.inputs[5]): 1, workflow.index(method_minimize.inputs[6]): 2e8, workflow.index(method_minimize.inputs[7]): 5e6, workflow.index(method_sort.inputs[2]): 50, }
list_attribute1 = ['mass_reductor', 'number_solution'] display_reductor = wf.MultiPlot(list_attribute1, 1, name='Display Reductor') block_workflow = [block_optimizer, block_optimize, block_instanciate_reductor, block_instanciate, block_motor, display_reductor] pipe_worflow = [wf.Pipe(block_optimizer.outputs[0], block_optimize.inputs[0]), wf.Pipe(block_instanciate_reductor.outputs[0], block_instanciate.inputs[0]), wf.Pipe(block_motor.outputs[0], block_instanciate_reductor.inputs[0]), wf.Pipe(block_instanciate.outputs[0], block_optimizer.inputs[0]), wf.Pipe(block_optimize.outputs[0], display_reductor.inputs[0])] workflow = wf.Workflow(block_workflow, pipe_worflow, block_optimize.outputs[0]) input_values = {workflow.index(block_optimizer.inputs[1]): 500, workflow.index(block_optimizer.inputs[2]): [-1, 1], workflow.index(block_optimizer.inputs[3]): [-1, 1], workflow.index(block_instanciate_reductor.inputs[1]): 0.01, workflow.index(block_motor.inputs[0]): 0.1, workflow.index(block_motor.inputs[1]): 0.2, workflow.index(block_motor.inputs[2]): 150 } workflow_generator_run = workflow.run(input_values)
method_type_optimize = MethodType(tuto.Optimizer, 'optimize') block_optimize = wf.ModelMethod(method_type_optimize, name='optimize') list_attribute1 = [ 'length', 'min_radius', 'max_radius', 'distance_input', 'straight_line' ] display_reductor = wf.ParallelPlot(list_attribute1, 1, name='Display') block_workflow = [block_optimizer, block_optimize, display_reductor] pipe_worflow = [ wf.Pipe(block_optimizer.outputs[0], block_optimize.inputs[0]), wf.Pipe(block_optimize.outputs[0], display_reductor.inputs[0]) ] workflow = wf.Workflow(block_workflow, pipe_worflow, block_optimize.outputs[0], name="workflowpipe") input_values = { workflow.index(block_optimize.inputs[1]): assemblies, workflow.index(block_optimize.inputs[2]): 1, } workflow_run = workflow.run(input_values) # c = Client(api_url='https://api.platform-dev.dessia.tech') # r = c.create_object_from_python_object(workflow_run)
population_instanciator = workflow.ClassMethod(interior.Population, 'random_population') mark_cockpit = workflow.ModelMethod(interior.Population, 'mark_cockpit') extremas = workflow.ModelMethod(interior.SeatErgonomyAnalysis, 'extremas') interior_instanciator = workflow.InstanciateModel( interior.CarInterior) #cockpit: 0 cockpit_pipe1 = workflow.Pipe(cockpit, mark_cockpit.inputs[1]) cockpit_pipe2 = workflow.Pipe(cockpit, interior_instanciator.inputs[0]) population_pipe = workflow.Pipe(population_instanciator.outputs[0], mark_cockpit.inputs[0]) marks_pipe = workflow.Pipe(mark_cockpit.outputs[0], extremas.inputs[0]) passenger_pipe = workflow.Pipe(extremas.outputs[0], interior_instanciator.inputs[4]) simple_analysis = workflow.Workflow([population_instanciator, mark_cockpit], [population_pipe], mark_cockpit.outputs[0], name='Simple analysis') seat_analysis_workflow = workflow.Workflow( [population_instanciator, mark_cockpit, interior_instanciator, extremas], [ population_pipe, marks_pipe, passenger_pipe, cockpit_pipe1, cockpit_pipe2 ], interior_instanciator.outputs[0], )
block_generator = wf.InstanciateModel(hd.Generator, name='Generator') methode_generate = wf.ModelMethod(hd.Generator, 'generate', name='generate') list_attribute = [ 'rivet_diameter', 'rivet_length', 'head_diameter', 'head_length', 'price', 'mass' ] display = wf.ParallelPlot(list_attribute, 1, name='Display') block_workflow = [block_generator, methode_generate, display] pipe_worflow = [ wf.Pipe(block_generator.outputs[0], methode_generate.inputs[0]), wf.Pipe(methode_generate.outputs[0], display.inputs[0]) ] workflow = wf.Workflow(block_workflow, pipe_worflow, methode_generate.outputs[0]) workflow_block = wf.WorkflowBlock(workflow=workflow, name='Workflow') final_pipe_workflow = pipe_worflow + [ wf.Pipe(methode_generate.outputs[1], workflow_block.inputs[0]) ] final_block_workflow = block_workflow + [workflow_block] final_workflow = wf.Workflow(final_block_workflow, final_pipe_workflow, methode_generate.outputs[0], name="") # final_workflow.plot_jointjs() # # rivets_definition = [[0.01, 0.05, 0.012, 0.005], # [0.012, 0.05, 0.013, 0.0055], # [0.0125, 0.05, 0.014, 0.0057],