Difference between revisions of "LoadControl Custom Task"

From OSUPDOCS
Jump to navigation Jump to search
Line 64: Line 64:


=== Choosing PID Gain Parameters ===
=== Choosing PID Gain Parameters ===
== Prior Documentation ==
The following is for old version for PID Control
A <tt>LoadControl</tt> custom task needs either [[MPM Global Archiving Options|global contact]] or [[MPM Global Archiving Options|global reaction]] for the specified [[Rigid Material|Rigid material]] depending on if contact for that material is enabled. This task will not work if rigid materials have a velocity function assigned, because these functions over-ride the load control velocity.
== Theory ==
This custom task tries to dynamically estimate the relationship between load and displacement of the rigid material using the following equation:
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<math>A_t = \text{arg}\min_{A}  \left[ (1-\alpha) \frac{(L-Ax)^2}{0.5(L^2+(A_{t-1}x)^2)}+\alpha\frac{(A-A_{t-1})^2}{A_{t-1}^2}\right]</math>
where <math>A_t</math> is the  estimate the relationship between load and displacement (or the stiffness) at time ''t'', ''x'' is the displacement, ''L'' is the recorded load and <math>\alpha</math> is the <tt>smooth</tt> parameter. The minimization problem has the analytical solution:
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<math>A_t =\frac{\lambda L x + \gamma A_{t-1}}{\lambda x^2 +\gamma}</math>  &nbsp;&nbsp;where&nbsp;&nbsp;  <math>\lambda =\frac{2(1-\alpha)}{L^2+(A_{t-1}x)^2}</math>  &nbsp;&nbsp;and&nbsp;&nbsp;  <math>\gamma =\frac{\alpha}{A_{t-1}^2}</math>.
The smoothing provides an interpolation between <math>A_t=L/x</math> and <math>A_t=A_{t-1}</math> as <math>\alpha</math> goes from 0 to 1 or to interpolate between current stiffness or no change in stiffness, which controls how fast the stiffness can change. Next, the error between requested load ''L(t)'' and recorded load ''L'' is smoothed and converted to velocity as:
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<math>e_t =(1-\alpha)\frac{L(t)-L}{A_t}+\alpha e_{t-1}</math>
The integrated error is calculated as:
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<math>Ie_t =\frac{L(t)-L}{A_t}+ Ie_{t-1}</math>
The derivative error is calculated with Brown's double exponential smoothing as:
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<math> e{\scriptstyle 2}_t =(1-\alpha)e_t+ \alpha e{\scriptstyle 2}_{t-1}</math>
and
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<math> De_t = \frac{1-\alpha}{\alpha}(e_t-e{\scriptstyle 2}_t) </math>
then finally the velocity is set using the PID algorithm:
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<math>V_t  = K_p e_t + K_i Ie_t + K_d De_t</math>
Note: If the velocity has a magnitude larger than <tt>MaxVelocity</tt> than it is given that magnitude and the integrated error for that time step is not accrued.


== Task Scheduling ==
== Task Scheduling ==
Line 115: Line 70:


  CustomTask LoadControl
  CustomTask LoadControl
Parameter velocity,(number)
Parameter material,(int)
Parameter direction,(int)
Parameter MaxVelocity,(number)
  Parameter Load,(function)
  Parameter Load,(function)
  Parameter Kp,(number)
  ... all remaining parameters with similar command
Parameter Ki,(number)
Parameter Kd,(number)
Parameter smooth,(number)
Parameter UpdateTime,(number)
Parameter Archive,(file_name)


In <tt>XML</tt> files, these task options are scheduled using <tt><Schedule></tt> elements, which must be within the single <tt><CustomTasks></tt> block:
In <tt>XML</tt> files, these task options are scheduled using a <tt><Schedule></tt> element, which must be within the single <tt><CustomTasks></tt> block:


  <Schedule name='LoadControl'>
  <Schedule name='LoadControl'>
    <Parameter name='velocity'>(number)</Parameter>
    <Parameter name='material'>(int)</Parameter>
    <Parameter name='direction'>(int)</Parameter>
    <Parameter name='MaxVelocity'>(number)</Parameter>
     <Parameter name='Load'>(function)</Parameter>
     <Parameter name='Load'>(function)</Parameter>
     <Parameter name='Kp'>(number)</Parameter>
     ... all remaining parameters with similar elements
    <Parameter name='Ki'>(number)</Parameter>
    <Parameter name='Kd'>(number)</Parameter>
    <Parameter name='smooth'>(number)</Parameter>
    <Parameter name='UpdateTime'>(number)</Parameter>
    <Parameter name='Archive'>(file_name)</Parameter>
  </Schedule>
  </Schedule>


These are the parameters that this custom task needs to operate:
* <tt>velocity</tt> - This is the starting velocity of the simulation for the specified  [[Rigid Material|Rigid material]] in [[ConsistentUnits Command#Legacy and Consistent Units|velocity units]]. The sign of this parameter is probably more important than its value, as long as it is something reasonable. It is needed for initializing the load control.
* <tt>material</tt> - The material number of the [[Rigid Material|Rigid material]] to be controlled (must be entered by number).
* <tt>direction</tt> - An integer (1, 2, or 3) to choose the direction (x, y, or z) to contrtol for velocity and load.
* <tt>MaxVelocity</tt> - A positive number that limits the magnitude of the velocity of the controlled material (default is 1000 in [[ConsistentUnits Command#Legacy and Consistent Units|velocity units]]).
* <tt>Load</tt> - A [[User Defined Functions|user defined function]] that gives the desired load (in [[ConsistentUnits Command#Legacy and Consistent Units|force-time units]]). This task doesn't work well with discontinuous functions.
* <tt>UpdateTime</tt> - The time interval between runs of the load control algorithm (in [[ConsistentUnits Command#Legacy and Consistent Units|alt time units]]). Should be equal to or greater than the [[MPM Global Archiving Options#InputCommands|global archive time]]. To run control algorithm on every time step, set [[MPM Global Archiving Options#InputCommands|global archive time]] to zero and omit this parameter.
* <tt>Archive</tt> - This command gives a file name (with extension) such as "_PID_data.txt". When used, control calculations for A<sub>t</sub>, error, integrated error, derivative of error, and final velocity will be written to a plain text file. Plotting the results can help choose control parameters.
These following parameters are for the control algorithm. The provided default parameters don't seem to really work. Try increasing <tt>Kp</tt> until it overshoots the target, then increase <tt>Ki</tt> to lessen the overshoot.
* <tt>Kp</tt> - Proportional gain factor for PID algorithm (default 0.1).
* <tt>Ki</tt> - Integral gain factors for PID algorithm (default 0.001).
* <tt>Kd</tt> - Derivative gain factors for PID algorithm (default: <tt>Kd = 0.25Ki</tt>).
* <tt>smooth</tt> - Exponential smoothing parameter in the range (0,1). Controls how fast the dynamic relationship between distance and load is updated and also how much smoothing is done on the load values (default 0.95).
== To be developed ==
Contact forces are corrupted with fat tail noise. A median filter would help reduce the effect of this noise.
Self-tuning parameters.


== References ==
== References ==
<references/>
<references/>

Revision as of 10:15, 22 January 2023

A custom task run a load control simulation based on calculations contact or reaction forces. .

Introduction

This CustomTask tries to achieve the load requested from a provided user defined function by adjusting the velocity of a block of rigid material points. The control is done using a non-linear PID control algorithm.[1]

Specifying the Force

A LoadControl custom task is based on a block of RigidBC or RigidContact particles. These particle are typically placed on the edge of the specimen. The following steps are used to setup all simulations with load control. First pick a direction as 1, 2, or 3 for x, y, or z direction. Load control is limited to be along grid axes. Next create rigid particles to apply the load:

  1. Define a RigidBC to control velocity is the specified direction or define a RigidContact material type. Do not use any setting functions in the rigid material definition.
  2. Place a block of those material points using that defined rigid material on the edge to be loaded.
  3. Include displacement of the defined rigid material in the global archive using dispx, dispy, or dispz for the chosen direction.
  4. When using RigidBC particles, include reaction force for the defined rigid material in the global archive using reactionx, reactiony, or reactionz for the chosen direction.
  5. When using RigidContact particles, include contact force for the defined rigid material in the global archive using contactx, contacty, or contactz for the chosen direction.
  6. Choose global archiving time to provide stable load control

Start the custom task and define following force defining parameters

CustomTask LoadControl
Parameter direction,(loaddir)
Parameter material,(matnum)
Parameter load,(loadfunction)

where

Non-Linear PID Control

The control loop starts by estimating the error in current displacement using

      [math]\displaystyle{ e = \frac{F - L(t)}{A_t} }[/math]

where [math]\displaystyle{ F }[/math] is the rigid material force in the global archive, [math]\displaystyle{ L(t) }[/math] is the desired load from the Load parameter function, and [math]\displaystyle{ A_t }[/math] is the tangent stiffness for rigid material force (in force units) per unit displacement (in displacement units). If [math]\displaystyle{ A-t }[/math] is constant, the control is a linear PID. But for many simulations, such as those with plasticity, damage, or non-linear elasticity, [math]\displaystyle{ A_t }[/math] will evolve during the simulation leading to non-linear PID. The PID algorithim changes the rigid material points velocity in the control direction to

      [math]\displaystyle{ v = \frac{1}{t_g}\left(K_pe + \frac{K_i}{t_g}\int_0^t e\thinspace d\tau + K_dt_g\frac{de}{dt}\right) }[/math]

where [math]\displaystyle{ K_p }[/math], [math]\displaystyle{ K_i }[/math], and [math]\displaystyle{ K_d }[/math] are dimensionless gain factors for proportional (P), integral (I), and derivative (D) errors and [math]\displaystyle{ t_g }[/math] is the simulation's global archiving time.

Selecting PID Control Parameters

Load control depends on global archiving time [math]\displaystyle{ t_g }[/math], [math]\displaystyle{ A_t }[/math] (and how it evolves), [math]\displaystyle{ K_p }[/math], [math]\displaystyle{ K_i }[/math], and [math]\displaystyle{ K_d }[/math]. In addition, reaction and contact forces on rigid materials are typically noisy meaning that some of the control variables will require smoothing for stable control. All relevant parameters are set with the following commands:

Parameter velocity,(initvelocity)
Parameter startupTime,(inittime)
Parameter At,(initAt)
Parameter smoothF,(smoothF)
Parameter smoothA,(smoothA)
Parameter smoothErr,(smoothErr)
Parameter Kp,(Kp)
Parameter Ki,(Kp)
Parameter Kd,(Kp)

Methods to choose these parameters are in the following sections

Choosing Start Up Conditions

Choosing Smoothing Parameters

Choosing PID Gain Parameters

Task Scheduling

In scripted files, a LoadControl custom task is scheduled with the following block:

CustomTask LoadControl
Parameter Load,(function)
... all remaining parameters with similar command

In XML files, these task options are scheduled using a <Schedule> element, which must be within the single <CustomTasks> block:

<Schedule name='LoadControl'>
   <Parameter name='Load'>(function)</Parameter>
   ... all remaining parameters with similar elements
</Schedule>


References