function dxdt=actuator(x,u,p)
%From Process Modelling and Model Analysis
% Hangos and Cameron
%Academic Press, 2001
%Page 77

%This is an actuator with a second order behavior
%states:
% x1= stem movement, if we have a valve. This is the output that we will
% use
% x2= variable without physical meaning; used to convert from 1st order ODE
% to 2nd order ODE

%input:
%u= Controller output signal

% parameters:
% p1= actuator gain
% p2= actuator time constant
% p3= actuator damping factor

%This is a second order ODE that is converted to a first order ODE by
%substitution. 
%Then:
%x1=S, which corresponds to the stem movement (for valves, directly related to the opening)
%x2=w, which is the variable using to convert the second-order ODE to a
%first order ODe

S=x(1);     %Stem movement if we have a valve
w=x(2);     %Variable to convert 2 order ODE to first order ODE
I=u;        %Controller output signal
Ga=p(1);    %Actuator gain
tau=p(2);   %Actuator time constant
zeta=p(3);  %Actuator damping factor

dSdt=w;    
dwdt=((Ga*I-S)/(tau^2))-(2*zeta*w/tau);

dxdt=[dSdt;dwdt];
end