If you right click on the Mean component in the model diagram of rootMeanSquare, you can select "Open Class". You can access the documentationof the component by clicking the "i"-button in the menu bar:
This block calculates the mean of the input signal u over the given period 1/f:
1 T
- ? u(t) dt
T 0
Note: The output is updated after each period defined by 1/f.
If parameter yGreaterOrEqualZero in the Advanced tab is true (default = false), then the modeller provides the information that the mean of the input signal is guaranteed to be ? 0 for the exact solution. However, due to inaccuracies in the numerical integration scheme, the output might be slightly negative. If this parameter is set to true, then the output is explicitly set to 0.0, if the mean value results in a negative value.
You can also get access to the actual code by changing from the "diagram view" to the "text view". To do this click on the document icon (the one with lines) in the menu bar:
block Mean "Calculate mean over period 1/f"
extends Modelica.Blocks.Interfaces.SISO;
parameter Modelica.SIunits.Frequency f(start = 50) "Base frequency";
parameter Real x0 = 0 "Start value of integrator state";
parameter Boolean yGreaterOrEqualZero = false "=true, if output y is guaranteed to be >= 0 for the exact solution" annotation(Evaluate = true, Dialog(tab = "Advanced"));
protected
parameter Modelica.SIunits.Time t0(fixed = false) "Start time of simulation";
Real x "Integrator state";
initial equation
t0 = time;
x = x0;
y = 0;
equation
der(x) = u;
when sample(t0 + 1 / f, 1 / f) then
y = if not yGreaterOrEqualZero then f * pre(x) else max(0.0, f * pre(x));
reinit(x, 0);
end when;
end Mean;
If you would like to create your own version you can simply make a copy of the component you want to modify and make the changes you like. Hope this helps.