User Tools

Site Tools


optimization

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
optimization [2018/09/18 10:28]
mark.naves
optimization [2022/01/12 13:41] (current)
jan.dejong
Line 1: Line 1:
 ===== Example: Shape optimization of cross-hinge ===== ===== Example: Shape optimization of cross-hinge =====
  
-This example provides a shape optimization of a single cross flexure by using matlab's ''fmincon'' function. For this optimization a crosshinge is considered with a mass and inertia connected to node 3. Furthermore, the optimization objective is to maximize the first parasitic frequency of the system (note: rotation of the cross-hinge is prescribed to de desired rotation angle. Therefore, the first parasitic frequency of the system is given by the first eigenfrequency).+This example provides a shape optimization of a single cross flexure by using matlab's ''fmincon'' function. For this optimization a crosshinge is considered with a mass and inertia connected to node 3. Furthermore, the optimization objective is to maximize the first parasitic frequency of the system (note: rotation of the cross-hinge is prescribed to de desired rotation angle. Therefore, the first parasitic frequency of the system is given by the first eigenfrequency). A rotation of 0.5rad, a maximum stress of 300MPa and and a maximum actuation force of 2.5Nm is considered.
  
 The cost function of the optimization is defined by the inverse of the first eigenfrequency. Additionally, a limit on the maximum stress and actuation force is implemented by applying a penalty on the value of the cost function. The matlab function which calls spacarlight and computes the cost function is defined by: The cost function of the optimization is defined by the inverse of the first eigenfrequency. Additionally, a limit on the maximum stress and actuation force is implemented by applying a penalty on the value of the cost function. The matlab function which calls spacarlight and computes the cost function is defined by:
  
 <code matlab run_sim.m> <code matlab run_sim.m>
-function cost = run_sim(P, Silent)% EXAMPLE SCRIPT FOR RUNNING SPACAR LIGHT +function [cost, out] = run_sim(P, Silent)% EXAMPLE SCRIPT FOR RUNNING SPACAR LIGHT
-% This example simulates a simple cross flexure rotating due to an applied moment+
 if nargin == 1 if nargin == 1
     Silent = true; %run in silent mode when called by optimizer     Silent = true; %run in silent mode when called by optimizer
Line 21: Line 20:
 stressmax = 300e6; %Max stress [MPa] stressmax = 300e6; %Max stress [MPa]
 Mmax = 2.5; %Max actuation moment [Nm] Mmax = 2.5; %Max actuation moment [Nm]
-Stroke = 0.5; %Max stroke+Stroke = 0.5; %Max stroke [Rad]
  
  
 %% NODE POSITIONS %% NODE POSITIONS
 %           x y z %           x y z
-nodes = [   0 0 0;      %node 1  +nodes = [   0 0 0;    %node 1  
             0 H 0;    %node 2               0 H 0;    %node 2  
-            B H 0;  %node 3+            B H 0;    %node 3
             B 0 0];   %node 4             B 0 0];   %node 4
  
Line 61: Line 60:
 eprops(1).orien    = [0 0 1];          %Orientation of the cross-section as a vector pointing along "width-direction" eprops(1).orien    = [0 0 1];          %Orientation of the cross-section as a vector pointing along "width-direction"
 eprops(1).nbeams   = 2;                %Number of beams used to model this element  eprops(1).nbeams   = 2;                %Number of beams used to model this element 
-eprops(1).flex     = 1:6;            %Model out-of-plane bending (modes 3 and 4) as flexible+eprops(1).flex     = 1:6;              %Consider all deformation modes (1 to 6) as flexible
 eprops(1).color    = 'grey';           %Color eprops(1).color    = 'grey';           %Color
 eprops(1).opacity  = 0.7;              %Opacity eprops(1).opacity  = 0.7;              %Opacity
Line 99: Line 98:
 end end
 </code> </code>
 +
 +An example to conduct the optimization is provided below, taking into account additional boundary conditions on the design parameters of the cross-hinge. See matlab's documentation on ''fmincon'' for more information.
 +
 +<code matlab optimization.m>
 +%filename
 +simulation = @run_sim;
 +
 +%starting point
 +x0 = [0.1;  0.1;  50e-3; 0.2e-3];
 +
 +%constraints
 +b1 = [0.05; 0.05; 25e-3; 0.1e-3];   % Lower bound (b1 < x)
 +b2 = [0.2;  0.2;  75e-3; 1e-3  ];       % Upper bound (x < b2)
 +
 +A = [-eye(4); eye(4)];
 +b = [-b1;b2];
 +
 +%optimization
 +x_opt = fmincon(simulation, x0, A, b);
 +
 +%show results
 +[cost, out] = run_sim(x_opt,false);
 +</code>
 +//Note: prescribing input rotation is only supported for SPACAR light version 1.27 or higher.//
optimization.1537259300.txt.gz · Last modified: 2018/09/18 10:28 by mark.naves