Пример #1
0
comb_profile_load = electrical.CombinationPowerProfile([load_bat], name='load_profil')
comb_profile_end = electrical.CombinationPowerProfile([end_bat], name='end_soc_profil')

# =============================================================================
# Electrical Optimizer
# =============================================================================

input_values = {}
blocks = []
block_ebo = wf.InstanciateModel(eo.ElecBatteryOptimizer, name='ElecBatteryOptimizer')
optimize_ebo = wf.ModelMethod(eo.ElecBatteryOptimizer, 'Optimize',  name='Optimize-ElecBatteryOptimizer')
attribute_selection_ebo = wf.ModelAttribute('powerpack_electric_simulators')


blocks.extend([block_ebo, optimize_ebo, attribute_selection_ebo])
pipes = [wf.Pipe(block_ebo.outputs[0], optimize_ebo.inputs[0]),
         wf.Pipe(optimize_ebo.outputs[1], attribute_selection_ebo.inputs[0])
         ]

# =============================================================================
# Thermal specs
# =============================================================================
altitude = 0.1
evol_power1 = electrical.Evolution(evolution = list(npy.linspace(0, 5., 10)))
evol_power2 = electrical.Evolution(evolution = list(npy.linspace(0, 6., 10)))
evol_h_min1 = electrical.Evolution(evolution = [0 + 0.3*1e1*p/(p + 0.1)/2. for p in npy.linspace(0, 1, 10)])
evol_h_max2 = electrical.Evolution(evolution = [altitude + 0.3*1e1*p/(p + 0.1)/2. for p in npy.linspace(0, 1, 10)])

ce_cooling1_min = electrical.CombinationEvolution(evolution1 = [evol_power1],
        evolution2 = [evol_h_min1], name='Min', title1='power', title2='h')
ce_cooling1_max = electrical.CombinationEvolution(evolution1 = [evol_power2],
    'bound': 750
}, {
    'attribute': 'bms.number_cells',
    'operator': 'lte',
    'bound': 800
}, {
    '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
Пример #3
0
                                           name='generate'),
                                name='Generate')
block_efficiencymap = wf.InstanciateModel(objects.EfficiencyMap,
                                          name='Efficiency Map')
block_engine = wf.InstanciateModel(objects.Engine, name='Engine')
block_gearbox = wf.InstanciateModel(objects.GearBox, name='Gearbox')
block_cluster = wf.InstanciateModel(objects.Clustering, name='Clustering')

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
Пример #4
0
concatenate = wf.ClassMethod(class_=Catalog,
                             method_name='concatenate',
                             name='Concatenate')
display = wf.Display(order=0)

array_attribute = wf.ModelAttribute(attribute_name='array', name='Array')

blocks = [
    import_csv, instantiate_pareto, catalog1, filter1, filtered_catalog1,
    catalog2, filter2, filtered_catalog2, catalogs, concatenate, display,
    array_attribute
]

# Pipes
pipes = [
    wf.Pipe(import_csv.outputs[0], catalog1.inputs[0]),
    wf.Pipe(import_csv.outputs[1], catalog1.inputs[1]),
    wf.Pipe(instantiate_pareto.outputs[0], catalog1.inputs[2]),
    wf.Pipe(import_csv.outputs[0], catalog2.inputs[0]),
    wf.Pipe(import_csv.outputs[1], catalog2.inputs[1]),
    wf.Pipe(instantiate_pareto.outputs[0], catalog2.inputs[2]),
    wf.Pipe(catalog1.outputs[0], filter1.inputs[0]),
    wf.Pipe(catalog2.outputs[0], filter2.inputs[0]),
    wf.Pipe(filter1.outputs[0], filtered_catalog1.inputs[0]),
    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]),
# filtered = wf.MultiPlot(choice_args, 1, name='Filtered')
# objectives_method = wf.ModelMethod(model_class=Catalog,
#                                    method_name='find_best_objective',
#                                    name="Find best objectives")
# objectives_attributes = wf.ModelAttribute(attribute_name='objectives',
#                                           name='Objectives')

blocks = [
    import_csv, instantiate_pareto, instantiate_catalog, filter_method,
    filtered_catalog, display, filtered
]
# , objectives_method, objectives_attributes]

# Pipes
pipes = [
    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,
generator_generate = wf.ModelMethod(model_class=Generator,
                                    method_name='generate',
                                    name='Generator Generate')
attribute_selection = wf.ModelAttribute(attribute_name='models',
                                        name='Attribute Selection')

# Subworkflow of model optimization
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='Pattern Generator')
block_generate = wf.ModelMethod(MethodType(class_=patterns.PatternGenerator,
                                           name='generate'),
                                name='Generate')

list_attribute = [
    'minor_axis_size_in_mm', 'excentricity', 'clearence', 'piece_diameter'
]
display = wf.MultiPlot(list_attribute, order=1, name='Display')

# display = wf.Display(name='Display')

block_workflow = [block_generator, block_generate]

pipe_workflow = [
    wf.Pipe(block_generator.outputs[0], block_generate.inputs[0]),
    wf.Pipe(block_generate.outputs[0], display.inputs[0])
]

workflow = wf.Workflow(block_workflow, pipe_workflow,
                       block_generate.outputs[0])

list_diameters = [0.1, 0.125, 0.15, 0.175, 0.2, 0.225, 0.25, 0.275, 0.3]
excentricity_min_max = (0.6, 0.9)
diameter_percetage_clearence_min_max = (0.1, 0.6)
MINOR_AXIS_SIZE_IN_MM = 1

input_values = {
    workflow.input_index(block_generator.inputs[0]):
    MINOR_AXIS_SIZE_IN_MM,
    workflow.input_index(block_generator.inputs[1]):
Пример #8
0
block_generator = wf.InstanciateModel(bp.MainRevenueGenerator, name='MainRevenueGenerator')
method_generate = wf.ModelMethod(bp.MainRevenueGenerator, 'decision_tree', name='generate')
block_optimizer = wf.InstanciateModel(bp.MainRevenueOptimizer, name='MainRevenueOptimizer')
method_minimize = wf.ModelMethod(bp.MainRevenueOptimizer, 'minimize', name='minimize')
method_sort = wf.ModelMethod(bp.MainRevenueOptimizer, 'sort_solutions', name='sort')

parallel_plot_block = wf.ParallelPlot(['last_margin', 'cumulative_cost', 'cumulative_revenue',
                                       '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,
from dessia_common.typings import MethodType

block_optimizer = wf.InstanciateModel(objects.GearBoxOptimizer, name='Gearbox Optimizer')
method_optimize = wf.ModelMethod(MethodType(class_ =objects.GearBoxOptimizer,name= 'optimize'), name='Optimize')

block_gearbox = wf.InstanciateModel(objects.GearBox, name='Gearbox')
block_engine = wf.InstanciateModel(objects.Engine, name= 'Engine')

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],
Пример #10
0
block_optimize = wf.ModelMethod(method_type=method_type, name='Optimize')
block_instanciate_reductor = wf.InstantiateModel(objects.InstanciateReductor,
                                                 name='Instanciate Reductor')
method_type = MethodType(class_=objects.InstanciateReductor,
                         name='instanciate')
block_instanciate = wf.ModelMethod(method_type=method_type, name='Instanciate')

block_motor = wf.InstantiateModel(objects.Motor, name='Motor')

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,
Пример #11
0
# solutions = opti1.optimize(assemblies=[assembly1], number_solution_per_assembly=2)

block_optimizer = wf.InstanciateModel(tuto.Optimizer, name='Optimizer')

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)
Пример #12
0
from dessia_common import workflow
import automotive.interior as interior

cockpit = workflow.TypedVariable(interior.Cockpit, name='Cockpit')

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,
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
A simple workflow composed of functions
"""

import math
import dessia_common.workflow as workflow


def sinus_f(x: float) -> float:
    return math.sin(x)


def asin_f(x: float) -> float:
    return math.asin(x)


sinus = workflow.Function(sinus_f)
arcsin = workflow.Function(asin_f)

pipe1 = workflow.Pipe(sinus.outputs[0], arcsin.inputs[0])

workflow = workflow.WorkFlow([sinus, arcsin], [pipe1])

workflow.plot_graph()

workflow_run = workflow.run([math.pi / 3])
Пример #14
0
import hello_dessia as hd
import dessia_common.workflow as wf
from dessia_api_client import Client

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()