In its most general form, which includes a bias constant ubias, the algorithm for the PID controller provided by this add-in reads:
You can use the PID controller to control any model variable or parameter. The requirements for using the add-in is that the model contains at least one component with some physics to control. You define the measured variable output c(
t) by adding a probe, typically a domain point probe or boundary point probe, representing a process measurement. Once the add-in has been imported from the COMSOL Multiphysics Add-in Library, it can be added to the model from the
Add-ins menu on the
Developer tab.
Once you have defined all the controller parameters, click the Create button (

) to add a 0D component that implements the controller using global equations. When the creation of the PID controller is successful, you get a message about the available control variable (such as
comp2.u_in_ctrl) and the deduced unit for the controller. It is important to make sure that all controller quantities have compatible units; otherwise, a unit consistency error appears.
Select the desired component from the Component list. When applying the PID controller, a new 0D component will be added to your model with variables and global equations that implement the PID controller, and you will be presented with the name of the control variable. This variable can then be used in your model as the actuator; for example, the velocity at an inlet for a transport model.
Select the Bias check box to include a bias that you enter in the
ubias text field. If the
Bias check box is cleared, the bias is ignored.
Define the controller constants kp,
ki, and
kd in the
Proportional gain,
Integral gain, and
Derivative gain text field, respectively. Leaving
kd at its default zero value gives a PI controller. Defining these controller constants as global parameters makes it easy to change them without recreating the PID controller.
In the Reference value text field you specify the setpoint,
cset.
Select or clear the Lower limit and
Upper limit check boxes to restrict the lower and upper limits of the control value to the values
umin and
umax, respectively.
Select the Enable integral anti-windup check box and enter a time constant
Tt (SI unit: s) in the
Time constant text field to enable integral anti-windup. Integral windup can occur when the control variable (actuator) reaches a limit. The control error will then continue to be integrated and become very large (that is, it “winds up”). This phenomenon means that an actuator saturation can cause large transients for a controller with an integral action. The anti-windup scheme keeps the integrator at a value so that the controller output is exactly at the limit so that no windup occurs. You can control the amount of anti-windup with the time constant; the smaller the value of
Tt, the faster the reset of the integrator, but a too small value may cause some loss of stability when a derivative action is included in the PID controller.
Select the Enable filtering of derivative check box and enter a time constant
Tf (SI unit: s) in the
Time constant text field to enable filtering of the derivative term. Such a filter works as a high-frequency filter that avoids that the derivative term becomes large due to high-frequency noise and instead only acts as a derivative for low-frequency components. The larger the time constant, the more filtering is added for the high-frequency noise.