Theory reminder - P2prod/Filter-Modeling-Simulation GitHub Wiki

Here's a bit of theory

Analog filters are characterized by their transfer function, which defines the ratio of the filter output signal to the filter input signal $$\displaystyle H(s) = \frac{Y(s)}{U(s)}$$ , in the Laplace domain (frequency domain) where time is replaced by a variable named p or s. In this blog, I will use indifferently p and s. It is possible to move from the time domain to the Laplace domain by means of the transform of the same name, and vice versa (from the Laplace domain to the time domain) by means of the inverse...Laplace transform.

I won't elaborate on this aspect, as it is widely presented in the scientific literature and on the web too.

Laplace vs Time domain

In the frequency domain (Laplace), the filter equation is easy to solve because we get : $$Y(s) = U(s) \cdot H(s)$$ whereas in the time domain, the equation is complicated to solve because multiplication becomes convolution: $$y(t) = u(t)$$ * $$h(t) $$

An analog filter can be modeled by components assembled together in a certain order, or by lines of code in Python, Matlab, etc.

RLC series circuit

Below is the Open Modelica code for the 2nd-order low-pass filter with its characteristic constants z (damping coefficient) and $$\tau$$ (time constant):

model SecondOrderLoPassFilter
  parameter Real K=1.0;
  parameter Real T=5.0;
  parameter Real z = 0.5;
  Real u;
  Real x1;
  Real x2;
  Real y;
equation
  u=1.0;
  der(x1) = x2;
  der(x2) = -(1/T^2)x1 - (2z/T)*x2 + (K/T^2)*u;
  y = x1;
end SecondOrderLoPassFilter;

Below is the simulation result for a unit step at the input (Heaviside):

2nd order filter with Open Modelica