Difference between revisions of "LoadControl Custom Task"

From OSUPDOCS
Jump to navigation Jump to search
m
 
(154 intermediate revisions by the same user not shown)
Line 1: Line 1:
A [[MPM Input Files#Custom Tasks|custom task]] run a load control simulation based on calculations contact or reaction forces. .
A [[MPM Input Files#Custom Tasks|custom task]] to run a load control simulation based on calculations of contact or reaction forces.
__TOC__
__TOC__
== Introduction ==
== Introduction ==


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.
This CustomTask tries to apply a target load requested from a provided [[User Defined Functions|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.<ref name="pidwiki"/>


This CustomTask tries to achieve the load requested from a provided [[User Defined Functions|user defined function]] by adjusting the velocity of that material. It does that by dynamically estimating the relationship between the displacement and load and then uses a PID control algorithm to adjust the velocity.
== Specifying the Force ==


== Theory ==
A <tt>LoadControl</tt> custom task is based on a block of [[Rigid Material|RigidBC or RigidContact]] particles. These particles 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 one grid axis. Next create rigid particles to apply the load:


This custom task tries to dynamically estimate the relationship between load and displacement of the rigid material using the following equation:
# Define a [[Rigid Material|RigidBC material]] to control velocity in the specified direction or define a [[Rigid Material|RigidContact material]]. Do not use any setting functions in the rigid material definition.
# Place a block of material points using that defined rigid material on the edge to be loaded.
# Include displacement of the defined rigid material in the global archive using [[MPM Global Archiving Options|<tt>dispx</tt>, <tt>dispy</tt>, or <tt>dispz</tt>]] for the chosen <tt>direction</tt>.
# When using [[Rigid Material|RigidBC]] particles, include reaction force for the defined rigid material in the global archive using [[MPM Global Archiving Options|<tt>reactionx</tt>, <tt>reactiony</tt>, or <tt>reactionz</tt>]] for the chosen <tt>direction</tt>.
# When using [[Rigid Material|RigidContact]] particles, include contact force for the defined rigid material in the global archive using [[MPM Global Archiving Options|<tt>contactx</tt>, <tt>contacty</tt>, or <tt>contactz</tt>]] for the chosen <tt>direction</tt>.
# Set the [[MPM Global Archiving Options|global archiving time]] to sampling rate for load control (the ideal sample rate will depend on the target load function and other simulation parameters).


&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
Start the custom task and define the following force defining parameters (note: parameters in this documentation assume using a scripted file; see [[#Task Scheduling|below]] for how to enter them in <tt>XML</tt> input files):
<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>
 
CustomTask LoadControl
Parameter direction,(loaddir)
  Parameter material,(matID)
Parameter matname,(matname)
Parameter Load,(loadfunction)
 
where
 
* <tt>(loaddir)</tt> is 1, 2, or 3 for x, y, or z direction loading.
* <tt>(matID)</tt> or <tt>(matname)</tt> is the defined rigid material [[Material Command Block#Referencing Materials in XML Files|by number or name]].
* <tt>(loadfunction)</tt> is a [[User Defined Functions|user defined function]] that defines desired load (in [[ConsistentUnits Command#Legacy and Consistent Units|force units]]) as a function of time (in [[ConsistentUnits Command#Legacy and Consistent Units|alt time units]])


where <math>A_t</math> is the  estimate the relationship between load and displacement at time ''t'', ''x'' is the displacement, ''L'' is the recorded load and <math>\alpha</math> is the <tt>smooth</tt> parameter.
== Non-Linear PID Control ==


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


&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&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>.
<math>e = \frac{F - L(t)}{A_t}</math>


Then the error between requested load ''L(t)'' and recorded load ''L'' is smoothed and converted to velocity as:
where <math>F</math> is the rigid material reaction or contact force in the global archive, <math>L(t)</math> is the desired load from the <tt>Load</tt> parameter function, and <math>A_t</math> is the tangent stiffness for rigid material force (in [[ConsistentUnits Command#Legacy and Consistent Units|force units]]) per unit displacement (in [[ConsistentUnits Command#Legacy and Consistent Units|displacement units]]). If <math>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>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


&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<math>e_t =(1-\alpha)\frac{L(t)-L}{A_t}+\alpha e_{t-1}</math>
<math>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>K_p</math>, <math>K_i</math>, and <math>K_d</math> are dimensionless gain factors for proportional (P), integral (I), and derivative (D) errors and <math>t_g</math> is the simulation's [[MPM Global Archiving Options|global archiving time]].
 
== Selecting PID Control Parameters ==
 
Load control depends on [[MPM Global Archiving Options|global archiving time]] <math>t_g</math>, <math>A_t</math> (and how it evolves), <math>K_p</math>, <math>K_i</math>, and <math>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 minVelocity,(minvelocity)
Parameter startupTime,(inittime)
Parameter At,(initAt)
Parameter smoothF,(smoothF)
Parameter smoothA,(smoothA)
Parameter smoothErr,(smoothErr)
Parameter Archive,(stubwext)
Parameter Kp,(Kp)
Parameter Ki,(Ki)
Parameter Kd,(Kd)
 
Methods to choose these parameters are in the following sections.


The integrated error is calculated as:
=== Choosing Start Up Conditions ===
 
To get started, a load control task needs an initial velocity and an initial stiffness <math>A_t</math> (which is required to calculate control error). Furthermore, reaction and contact forces in dynamic calculations take a while to settle into reasonable values (such as when loading at constant velocity). A load control task thus normally needs a <tt>(inittime)</tt>, which is a time over which the rigid particles move at constant <tt>(initvelocity)</tt> without imposing any control. Once the start up time has passed, the load control begins using an initial <math>A_t</math> that can be determined one of two methods:
 
# If you do not want to (or not able to) calculate an initial <math>A_t</math>, specify a positive <tt>(inittime)</tt>. The initial <math>A_t</math> will be found by least squares slope for force <i>vs.</i> displacement up to <tt>(inittime)</tt>. Any provided <tt>(initAt)</tt> will be ignored. Note that this method cannot be used if <tt>(initvelocity)</tt> is zero.
# Specified <math>A_t</math>: If you can calculate initial stiffness for the simulation, you can enter it in <tt>(initAt)</tt> parameter and then set <tt>(inittime)</tt> to minus the desired start up time. Once the time is passed, control will start with the provided <math>A_t</math>.
 
Finding <math>A_t</math> from slope of force <i>vs.</i> displacement requires that <tt>(inittime)</tt> be 10-20 multiples of <math>t_g</math> to have enough points to fit a line. The start up time must also be long enough that the calculation is not adversely affected by dynamic start-up artifacts. Even when specifying <math>A_t</math> with negative start up time, the time should be long enough to bypass dynamic start-up artifacts. If control is started too soon, those artifacts may lead to unstable results.
 
During control steps, the value of <math>A_t</math> is continually adjusted to the current tangent modulus that is given by


&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<math>Ie_t =\frac{L(t)-L}{A_t}+ Ie_{t-1}</math>
<math>A_t = \frac{F_t - F_{t-1}}{v t_g}</math>
 
If the velocity gets too low (which is expected if control is seeking constant force or reversing direction), this calculation will become unreliable (the denominator will be too small). To avoid unreliable updates to <math>A_t</math>, this calculation can be limited to control steps for which velocity magnitude is greater than absolute value of input <tt>(minVelocity)</tt> (if no minimum input is provided, the default is to use 5% of <tt>(initVelocity)</tt>).
 
=== Choosing Smoothing Parameters ===
 
[[MPM Global Archiving Options|Reaction and contact forces]] recorded in global archives are typcially noisy. To avoid this noise from adversely affecting load control calculations, it is usually necessary to smooth some load control parameters. All smoothing is done by exponential smoothing<ref name="eswiki"/> with smoothing parameters from 0 for no smoothing to 1 for complete smoothing (<i>i.e.</i>, the result remains fixed at initial value). The three smoothing options are
 
# <tt>smoothF</tt> - smooth recorded [[MPM Global Archiving Options|reaction or contact force]]. This smoothing is probably always required. If no input value is provided, the default value is 0.9. This smoothing is limited to the interval [0,1) (<i>i.e.</i>, 1 is not allowed).
# <tt>smoothA</tt> - if [[#Choosing Start Up Conditions|dyanamic updates to <math>A_t</math>]] are noisy, the updates can be smoothed. This parameter can use the entire iterval [0,1]. A value of 1 means <math>A_t</math> will remain fixed at its initial value. Note that a fixed <math>A_t</math> turns this task in a linear PID control algorithm. That approach, however, may not work well for problems where stiffness changes do to effects such as plasticity, damage, or non-linear elasticity. Such problems require non-linear PID with evolving <math>A_t</math> otherwise control parameters based on linear PID may become unstable.
# <tt>smoothErr</tt> - smooths the [[#Non-Linear PID Control|<tt>e(t)</tt> calculation]]. The default value is zero. This smoothing is limited to the interval [0,1).
 
=== Archiving Load Control Details ===
 
When using load control, especially when selecting parameters as explained in sections below, it is useful to archive load control results. To include archived results for a simulation, use the <tt>Archive</tt> parameter and set <tt>(stubwext)</tt> to a partial name with extension, such as "LC.txt". When this parameter is used, load control results will saved to a file with <tt>(stubwext)</tt> appended to the [[MPM Archiving Options|root path name]] defined for the simulation. The file will be a tab-delimited file with time in the first column and the remaining columns having
 
&nbsp;&nbsp;&nbsp;&nbsp;
<math>A_t, \quad e, \quad \frac{1}{t_g}\int_0^t e\thinspace d\tau, \quad t_g \frac{de}{dt},</math>
 
velocity set by the control algorithm, and smoothed force used in calculations. The file will begin with comment lines (lines starting in "#") that describe the load control parameters being used.
 
=== Choosing PID Gain Parameters - An Example ===
 
The final, and most challenging step, is to choose the PID gain factors. Furthermore, the optimal values for these parameters might depend on the above [[#Choosing Start Up Conditions|start up parameters]] and [[#Choosing Smoothing Parameters|smoothing parameters]]. This section provides one example of choosing parameters. Other guidance can be found in two references.<ref name="pidwiki"/><ref name="pidphd"/>
 
The example is loading a 20 mm long rectangular bar with width and thickness of 5 mm. The bar is clamped on its right edge and pulled in the negative x direction on the left edge. The material is a [[Mooney Material]] with E = 1000 MPa and nu = 0.3. The goal is to linearly increase the load using [[Rigid Material|RigidBC]] particles on the left edge. Thus <tt>(direction)=1</tt> and global archiving must include [[MPM Global Archiving Options|<tt>dispx</tt> and <tt>reactionx</tt>]] for the defined [[Rigid Material|RigidBC material]]. This simple example could alternatively be done with [[Particle-Based Boundary Conditions|traction boundary conditions]], but this example provides a sample of using load control that could be applied to problems where traction boundary conditions are not acceptable.
 
==== Start Up and Smoothing Settings ====
 
For start up conditions, the initial <math>A_t</math> is easily calculated from low-strain modulus as
 
&nbsp;&nbsp;&nbsp;&nbsp;
<math>{\tt (initAt)} = A_t = \frac{EA}{L} = 1250\ {\rm N/mm}</math>
 
The sample was loaded to about 30% strain using an initial velocity of about 0.2% as estimated using the material's low-strain modulus. Simple calculations led to
 
(initvelocity) = -1961.1613 mm/sec
(load) = -2451.4516*t
 
to pull in the negative x direction. The load rate was estimated assuming a linear elastic material. For the nonlinear [[Mooney Material]], which softens in tension, the final strain based on this loading rate and time will exceed the 30% strain used for start up calculations. Other startup parameters used were
 
[[MPM Global Archiving Options|Global archiving time]] set to have 500 samples over the estimate loading time
(minVelocity) = 20% of (initvelocity)
(inittime) = -(10% of estimated loading time)
(smoothA) = 1
 
The <tt>(inittime)</tt> is negative to tell the load control to use the provided <math>A_t</math> value once it starts. The entered value defines the start up time as the time to reach about 3% strain. The <tt>(smoothA)=1</tt> is to use a fixed <math>A_t</math> value throughout the simulations. Using a fixed <math>A_t</math> is often a good way to choose PID gain factors. Once those value of found, however, the <tt>(smoothA)</tt> should be reduced to allow non-linear PID load control that tracks changes in stiffness expected for the non-linear [[Mooney Material]].


The derivative error is calculated with Brown's double exponential smoothing as:
==== Choose <math>K_p</math> ====


&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
The first step is to set <tt>(Ki)=(Kd)=0</tt> and vary just <tt>(Kp)</tt>. With an accurate <math>A_t</math>, this value is typically about 0.1. If it is too low, the applied force will not reach the desired force. If it is too high, the simulation will become stable. A good method is to increase <tt>(Kp)</tt> until unstable and then reduce to well within the stable regime. For this sample problem <tt>(Kp)=0.1</tt> worked well.
<math> e{\scriptstyle 2}_t =(1-\alpha)e_t+ \alpha e{\scriptstyle 2}_{t-1}</math>
 
The following figure plots target and actual smoothed force for this simulation. The actual force lags behind the target force, but may actually be sufficient for this simulation. In other words, using just proportional control may be sufficient for many simulations. For other simulations, adding "I" and "D" may be needed. Two examples are if the lag expected in proportional control in unacceptable or if activation of evolving <math>A_t</math> causes proportional control to deteriorate from well-controlled simulations.
 
[[File:KpAlone.png|400px|center|Kp alone]]
 
==== Choose <math>K_i</math> ====
 
When actual force lags the target force in proportional control, the integrated error will increase. Adding gain related to integrated error can penalize that increase such that the lag is reduced. The next step is to keep <tt>(Kd)=0</tt> but now increase <tt>(Ki)</tt> to reduce the integrated error. As <tt>(Ki)</tt> is increased, the integrated error will get smaller. As <tt>(Ki)</tt> gets larger, the control will likely to start to oscillate near the target force. If <tt>(Ki)</tt> is too large the oscillations will grow in magnitude and the simulation will be come unstable. If <tt>(Ki)</tt> is about right, the oscillations will remain small and may even decay with time. A good choice seems to be to select <tt>(Ki)</tt> below the region where oscillations grow in magnitude.
 
The following plot shows the integrated error (from archive file of results) for several values of <tt>(Ki)</tt> while keeping <tt>(Kp)=0.1</tt>. For <tt>(Ki)=0</tt>, the integrated error is large and continues to grow (plot is truncated at -10). As <tt>(Ki)</tt> increases, the integrated error gets smaller. When <tt>(Ki)=0.0075</tt>, some oscillations appear, but they die out with time. For <tt>(Ki)=0.01</tt>, the oscillations get larger, but do not grow with time. For larger <tt>(Ki)</tt> (not shown), the oscillations grow and the simulation becomes unstable. For this example, <tt>(Ki)=0.01</tt> was selected because it remains stable and it minimized the mean integrate error. Although oscillations are created, the goal of the next section is to remove them.
 
[[File:KpandKi.png|400px|center|Kp and Ki control]]
 
==== Choose <math>K_d</math> ====
 
The addition of <tt>(Ki)</tt> reduced the lag, but caused force to oscillate around the target force. By adding gain related to error derivative, PID contral can suppress the oscillations. Again, increasing <tt>(Kd)</tt> damps the oscillations, but if it gets too high the simulation becomes unstable. Here using <tt>(Kd)=1</tt> worked well.


and
The following plot compares smoothed force to target force (dashed black line) for PI control alone (in red) and for PID control (in blue). The PI control oscillates around the target force. The PID control is very close to target force with no oscillations.


&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
[[File:ForcePID.png|400px|center|PID control]]
<math> De_t = \frac{1-\alpha}{\alpha}(e_t-e{\scriptstyle 2}_t) </math>


then finally the velocity is set using the PID algorithm:
==== Choose Final Smoothing ====


&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
In most interesting simulations, <math>A_t</math> will change. To continue PID control under such conditions, this task tries to re-evaluate <math>A_t</math> each control step. Because incremental calculations of <math>A_t</math> can be noisy, it is usually necessary to smooth the calcution. The following two plots show results of PID control (using parameters determined above) but with <tt>(smoothA)</tt> reduced to below 1 to allow evolution of <math>A_t</math>. The first plots shows the dynanmic <math>A_t</math> calculated in the load control for <tt>(smoothA)=0.95</tt> and <tt>(smoothA)=0.99</tt> compared to theoretical expectation for a [[Mooney Material]]. The load control <math>A_t</math> oscillates but tracks the proper decrease with strain. A high value of <tt>(smoothA)</tt> is needed to avoid large osciallations. The second plot compares globally archived reaction force for a simulation under constant velocity and a simulation under PID control. The constant velocity simulation has persistent ringing. The PID simulation starts with some noise, but then settles to very stable reaction force.
<math>V_t  = K_p e_t + K_i Ie_t + 0.25K_i 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.
<center>
[[File:DynamicAt.png|400px]]
[[File:FinalForce.png|400px]]
</center>


== Task Scheduling ==
== Task Scheduling ==
Line 53: Line 160:


  CustomTask LoadControl
  CustomTask LoadControl
  Parameter velocity,(velocity)
  Parameter Load,(loadfunction)
  Parameter material,(int)
  ... all remaining parameters with similar commands
Parameter direction,(int)
Parameter MaxVelocity,(number)
Parameter "Load_Function (user-inputted function)"
Parameter Kp,(number)
Parameter Ki,(number)
Parameter smooth,(number)
Parameter UpdateTime,(number)


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='Load'>(loadfunction)</Parameter>
     <Parameter name='material'>(int)</Parameter>
     ... all remaining parameters with similar elements
    <Parameter name='direction'>(int)</Parameter>
    <Parameter name='MaxVelocity'>(number)</Parameter>
    <Parameter name='Load_Function (function)'/>
    <Parameter name='Kp'>(number)</Parameter>
    <Parameter name='Ki'>(number)</Parameter>
    <Parameter name='smooth'>(number)</Parameter>
    <Parameter name='UpdateTime'>(number)</Parameter>
  </Schedule>
  </Schedule>


== References ==


These are the parameters that this custom task needs to operate:
<references>
 
* <tt>velocity</tt> - This is the starting velocity of the simulation for the specified  [[Rigid Material|Rigid material]]. 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.
* <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 - defaults to 5 m/s.
* <tt>Load_Function</tt> - A [[User Defined Functions|user defined function]] that gives the desired load. This task doesn't work well with discontinuous functions. Note that the function is provided in the <tt>name</tt> of the parameter as a single string. The first word of the string must be "Load_Function" and the remainder of the name is the [[User Defined Functions|user defined function]].
* <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).
* <tt>UpdateTime</tt> - How often to run the load control algorithm. Should be exactly the same as the global archive time (in the script, off by 1000 in xml).
 
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).
<ref name="pidwiki">"PID Controller", [https://en.wikipedia.org/wiki/PID_controller https://en.wikipedia.org/wiki/PID_controller]</ref>
* <tt>Ki </tt> - Integral and Derivative gain factors for PID algorithm. (Note: <tt>Kd = 0.25Ki</tt>) (default 0.001).


<ref name="eswiki">"Exponential Smoothing", [https://en.wikipedia.org/wiki/Exponential_smoothing https://en.wikipedia.org/wiki/Exponential_smoothing] (note that &alpha; on the Wikipedia page is <tt>1-smooth</tt> parameters defined for this custom task)</ref>


== To be developed ==
<ref name="pidphd">T. Westcott, "PID with a PhD," Westcott Design Services, [http://wescottdesign.com/articles/pid/pidWithoutAPhd.pdf http://wescottdesign.com/articles/pid/pidWithoutAPhd.pdf].</ref>
Contact forces are corrupted with fat tail noise. A median filter would help reduce the effect of this noise.


Self-tuning parameters.
</references>

Latest revision as of 13:55, 22 August 2024

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

Introduction

This CustomTask tries to apply a target 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 particles 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 one grid axis. Next create rigid particles to apply the load:

  1. Define a RigidBC material to control velocity in the specified direction or define a RigidContact material. Do not use any setting functions in the rigid material definition.
  2. Place a block of 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. Set the global archiving time to sampling rate for load control (the ideal sample rate will depend on the target load function and other simulation parameters).

Start the custom task and define the following force defining parameters (note: parameters in this documentation assume using a scripted file; see below for how to enter them in XML input files):

CustomTask LoadControl
Parameter direction,(loaddir)
Parameter material,(matID)
Parameter matname,(matname)
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 reaction or contact 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 minVelocity,(minvelocity)
Parameter startupTime,(inittime)
Parameter At,(initAt)
Parameter smoothF,(smoothF)
Parameter smoothA,(smoothA)
Parameter smoothErr,(smoothErr)
Parameter Archive,(stubwext)
Parameter Kp,(Kp)
Parameter Ki,(Ki)
Parameter Kd,(Kd)

Methods to choose these parameters are in the following sections.

Choosing Start Up Conditions

To get started, a load control task needs an initial velocity and an initial stiffness [math]\displaystyle{ A_t }[/math] (which is required to calculate control error). Furthermore, reaction and contact forces in dynamic calculations take a while to settle into reasonable values (such as when loading at constant velocity). A load control task thus normally needs a (inittime), which is a time over which the rigid particles move at constant (initvelocity) without imposing any control. Once the start up time has passed, the load control begins using an initial [math]\displaystyle{ A_t }[/math] that can be determined one of two methods:

  1. If you do not want to (or not able to) calculate an initial [math]\displaystyle{ A_t }[/math], specify a positive (inittime). The initial [math]\displaystyle{ A_t }[/math] will be found by least squares slope for force vs. displacement up to (inittime). Any provided (initAt) will be ignored. Note that this method cannot be used if (initvelocity) is zero.
  2. Specified [math]\displaystyle{ A_t }[/math]: If you can calculate initial stiffness for the simulation, you can enter it in (initAt) parameter and then set (inittime) to minus the desired start up time. Once the time is passed, control will start with the provided [math]\displaystyle{ A_t }[/math].

Finding [math]\displaystyle{ A_t }[/math] from slope of force vs. displacement requires that (inittime) be 10-20 multiples of [math]\displaystyle{ t_g }[/math] to have enough points to fit a line. The start up time must also be long enough that the calculation is not adversely affected by dynamic start-up artifacts. Even when specifying [math]\displaystyle{ A_t }[/math] with negative start up time, the time should be long enough to bypass dynamic start-up artifacts. If control is started too soon, those artifacts may lead to unstable results.

During control steps, the value of [math]\displaystyle{ A_t }[/math] is continually adjusted to the current tangent modulus that is given by

      [math]\displaystyle{ A_t = \frac{F_t - F_{t-1}}{v t_g} }[/math]

If the velocity gets too low (which is expected if control is seeking constant force or reversing direction), this calculation will become unreliable (the denominator will be too small). To avoid unreliable updates to [math]\displaystyle{ A_t }[/math], this calculation can be limited to control steps for which velocity magnitude is greater than absolute value of input (minVelocity) (if no minimum input is provided, the default is to use 5% of (initVelocity)).

Choosing Smoothing Parameters

Reaction and contact forces recorded in global archives are typcially noisy. To avoid this noise from adversely affecting load control calculations, it is usually necessary to smooth some load control parameters. All smoothing is done by exponential smoothing[2] with smoothing parameters from 0 for no smoothing to 1 for complete smoothing (i.e., the result remains fixed at initial value). The three smoothing options are

  1. smoothF - smooth recorded reaction or contact force. This smoothing is probably always required. If no input value is provided, the default value is 0.9. This smoothing is limited to the interval [0,1) (i.e., 1 is not allowed).
  2. smoothA - if dyanamic updates to [math]\displaystyle{ A_t }[/math] are noisy, the updates can be smoothed. This parameter can use the entire iterval [0,1]. A value of 1 means [math]\displaystyle{ A_t }[/math] will remain fixed at its initial value. Note that a fixed [math]\displaystyle{ A_t }[/math] turns this task in a linear PID control algorithm. That approach, however, may not work well for problems where stiffness changes do to effects such as plasticity, damage, or non-linear elasticity. Such problems require non-linear PID with evolving [math]\displaystyle{ A_t }[/math] otherwise control parameters based on linear PID may become unstable.
  3. smoothErr - smooths the e(t) calculation. The default value is zero. This smoothing is limited to the interval [0,1).

Archiving Load Control Details

When using load control, especially when selecting parameters as explained in sections below, it is useful to archive load control results. To include archived results for a simulation, use the Archive parameter and set (stubwext) to a partial name with extension, such as "LC.txt". When this parameter is used, load control results will saved to a file with (stubwext) appended to the root path name defined for the simulation. The file will be a tab-delimited file with time in the first column and the remaining columns having

     [math]\displaystyle{ A_t, \quad e, \quad \frac{1}{t_g}\int_0^t e\thinspace d\tau, \quad t_g \frac{de}{dt}, }[/math]

velocity set by the control algorithm, and smoothed force used in calculations. The file will begin with comment lines (lines starting in "#") that describe the load control parameters being used.

Choosing PID Gain Parameters - An Example

The final, and most challenging step, is to choose the PID gain factors. Furthermore, the optimal values for these parameters might depend on the above start up parameters and smoothing parameters. This section provides one example of choosing parameters. Other guidance can be found in two references.[1][3]

The example is loading a 20 mm long rectangular bar with width and thickness of 5 mm. The bar is clamped on its right edge and pulled in the negative x direction on the left edge. The material is a Mooney Material with E = 1000 MPa and nu = 0.3. The goal is to linearly increase the load using RigidBC particles on the left edge. Thus (direction)=1 and global archiving must include dispx and reactionx for the defined RigidBC material. This simple example could alternatively be done with traction boundary conditions, but this example provides a sample of using load control that could be applied to problems where traction boundary conditions are not acceptable.

Start Up and Smoothing Settings

For start up conditions, the initial [math]\displaystyle{ A_t }[/math] is easily calculated from low-strain modulus as

     [math]\displaystyle{ {\tt (initAt)} = A_t = \frac{EA}{L} = 1250\ {\rm N/mm} }[/math]

The sample was loaded to about 30% strain using an initial velocity of about 0.2% as estimated using the material's low-strain modulus. Simple calculations led to

(initvelocity) = -1961.1613 mm/sec
(load) = -2451.4516*t

to pull in the negative x direction. The load rate was estimated assuming a linear elastic material. For the nonlinear Mooney Material, which softens in tension, the final strain based on this loading rate and time will exceed the 30% strain used for start up calculations. Other startup parameters used were

Global archiving time set to have 500 samples over the estimate loading time
(minVelocity) = 20% of (initvelocity)
(inittime) = -(10% of estimated loading time)
(smoothA) = 1

The (inittime) is negative to tell the load control to use the provided [math]\displaystyle{ A_t }[/math] value once it starts. The entered value defines the start up time as the time to reach about 3% strain. The (smoothA)=1 is to use a fixed [math]\displaystyle{ A_t }[/math] value throughout the simulations. Using a fixed [math]\displaystyle{ A_t }[/math] is often a good way to choose PID gain factors. Once those value of found, however, the (smoothA) should be reduced to allow non-linear PID load control that tracks changes in stiffness expected for the non-linear Mooney Material.

Choose [math]\displaystyle{ K_p }[/math]

The first step is to set (Ki)=(Kd)=0 and vary just (Kp). With an accurate [math]\displaystyle{ A_t }[/math], this value is typically about 0.1. If it is too low, the applied force will not reach the desired force. If it is too high, the simulation will become stable. A good method is to increase (Kp) until unstable and then reduce to well within the stable regime. For this sample problem (Kp)=0.1 worked well.

The following figure plots target and actual smoothed force for this simulation. The actual force lags behind the target force, but may actually be sufficient for this simulation. In other words, using just proportional control may be sufficient for many simulations. For other simulations, adding "I" and "D" may be needed. Two examples are if the lag expected in proportional control in unacceptable or if activation of evolving [math]\displaystyle{ A_t }[/math] causes proportional control to deteriorate from well-controlled simulations.

Kp alone

Choose [math]\displaystyle{ K_i }[/math]

When actual force lags the target force in proportional control, the integrated error will increase. Adding gain related to integrated error can penalize that increase such that the lag is reduced. The next step is to keep (Kd)=0 but now increase (Ki) to reduce the integrated error. As (Ki) is increased, the integrated error will get smaller. As (Ki) gets larger, the control will likely to start to oscillate near the target force. If (Ki) is too large the oscillations will grow in magnitude and the simulation will be come unstable. If (Ki) is about right, the oscillations will remain small and may even decay with time. A good choice seems to be to select (Ki) below the region where oscillations grow in magnitude.

The following plot shows the integrated error (from archive file of results) for several values of (Ki) while keeping (Kp)=0.1. For (Ki)=0, the integrated error is large and continues to grow (plot is truncated at -10). As (Ki) increases, the integrated error gets smaller. When (Ki)=0.0075, some oscillations appear, but they die out with time. For (Ki)=0.01, the oscillations get larger, but do not grow with time. For larger (Ki) (not shown), the oscillations grow and the simulation becomes unstable. For this example, (Ki)=0.01 was selected because it remains stable and it minimized the mean integrate error. Although oscillations are created, the goal of the next section is to remove them.

Kp and Ki control

Choose [math]\displaystyle{ K_d }[/math]

The addition of (Ki) reduced the lag, but caused force to oscillate around the target force. By adding gain related to error derivative, PID contral can suppress the oscillations. Again, increasing (Kd) damps the oscillations, but if it gets too high the simulation becomes unstable. Here using (Kd)=1 worked well.

The following plot compares smoothed force to target force (dashed black line) for PI control alone (in red) and for PID control (in blue). The PI control oscillates around the target force. The PID control is very close to target force with no oscillations.

PID control

Choose Final Smoothing

In most interesting simulations, [math]\displaystyle{ A_t }[/math] will change. To continue PID control under such conditions, this task tries to re-evaluate [math]\displaystyle{ A_t }[/math] each control step. Because incremental calculations of [math]\displaystyle{ A_t }[/math] can be noisy, it is usually necessary to smooth the calcution. The following two plots show results of PID control (using parameters determined above) but with (smoothA) reduced to below 1 to allow evolution of [math]\displaystyle{ A_t }[/math]. The first plots shows the dynanmic [math]\displaystyle{ A_t }[/math] calculated in the load control for (smoothA)=0.95 and (smoothA)=0.99 compared to theoretical expectation for a Mooney Material. The load control [math]\displaystyle{ A_t }[/math] oscillates but tracks the proper decrease with strain. A high value of (smoothA) is needed to avoid large osciallations. The second plot compares globally archived reaction force for a simulation under constant velocity and a simulation under PID control. The constant velocity simulation has persistent ringing. The PID simulation starts with some noise, but then settles to very stable reaction force.

DynamicAt.png FinalForce.png

Task Scheduling

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

CustomTask LoadControl
Parameter Load,(loadfunction)
... all remaining parameters with similar commands

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'>(loadfunction)</Parameter>
   ... all remaining parameters with similar elements
</Schedule>

References

  1. 1.0 1.1 "PID Controller", https://en.wikipedia.org/wiki/PID_controller
  2. "Exponential Smoothing", https://en.wikipedia.org/wiki/Exponential_smoothing (note that α on the Wikipedia page is 1-smooth parameters defined for this custom task)
  3. T. Westcott, "PID with a PhD," Westcott Design Services, http://wescottdesign.com/articles/pid/pidWithoutAPhd.pdf.