Script MotorDesign

download Script MotorDesign

of 5

Transcript of Script MotorDesign

  • 8/10/2019 Script MotorDesign

    1/5

    Script for DC Motor Design Optimization

    Open the script Demo3_optimMotorDesign.m. This will walk you through the demo.

    Note1: Ive used the AEG cluster with 16 workers for this example, you will have tochange this script file, and reference the cluster you plan to use.

    Note2: There is a eigs function in motorDesign.m (at the bottom) that you can use themake the problem more/less expensive to run if your resources are different.

    This script contains the MATLAB commands Im going to use to show how to perform a multi-level optimization problem.

    The first cell defines the Motor design parameters in d, and a scaling dscale thatIll use to scale the optimization problem to have similar magnitudes in the design

    variables. Execute cell This next cell defines the operating parameters of the motor, recall these arecoupled to the control design function. Execute cell

    Next Ill define the constants used in the problem. Execute cell And well start by solving for the optimal design with the operating conditions

    given in b. Execute cell This gives a good starting point to use when we solve both the design and control

    problems together. This next cell defines the initial parameters for the PID control design. Note that

    the input to the function motorController, v, is an output from the motorDesignfunction. Execute cell

    The plot shows the how the control design performs. We now want to optimize both the motor design and the PID design simultaneously. This next cell calls themotorSystem function which couples the motorDesign function to themotorController function. Execute cell

  • 8/10/2019 Script MotorDesign

    2/5

    And if when we run the optimization problem on a single worker we get anexecution time of around 6 seconds. Execute cell

    Execute cell Running the same problem with 4 workers reduces the time to

    Now let s run multiple optimization problems to map the Pareto front. This nextcell will run the problem over 10 different values for the weight, alpha, on asingle worker.

    Execute cell. This will take about 5 minutes .So have something to talkabout.Go back to the slides and explain whats going o n with the tasks

    flowchart

  • 8/10/2019 Script MotorDesign

    3/5

    You can see the result in the figure window that shows the trade off. As the

    motor gets heavier, larger armature winding, the response time (or performanceindex), is relatively cons tant. As the motor gets lighter (smaller armaturewinding), the controller performance degrades (becomes limited by the electrical

    power supplied to meet performance goals).

    Lets simply rerun this using parfor in place of the for loop and 4 workers (thenumber of optimization problems).

  • 8/10/2019 Script MotorDesign

    4/5

    Notice that I have a parfor loop, and the optimization option useParallel is set to

    never. Inside the optimization solver, it is using a parfor loop to accelerate thegradient estimation step when this is set to always . I cant have a nested parforloop, so even if I enabled useParallel it would only use the first parfor statement,this loop you see here.

    The reason why nested parfor loops arent allowed is that there is no automatedway to determine how each loop should allocate workers. But we can do thismanually using creatematlabpooljob and parfor (or useParallel option).

    Now lets run this in parall el using jobs/tasks and the built in useParallel option inthe optimization solver.

    This next cell defines the job and creates the tasks, which are to solve theoptimization problem as a task.

    Open motorOptimizationTask.m And the task itself is opening a m atlabpool with nLabs (well use 4). Now well create the job and task. You can see its in the queue.

    And use submit to run the job and wait for results.

  • 8/10/2019 Script MotorDesign

    5/5

    You can see that the additional benefit is diminishing. But keep in mind that thisexample isnt that computationally expensive, and if your problems take longer,or have more dimensions, you could see even greater speed up.

    Return to slides