74 lines
1.4 KiB
Plaintext
74 lines
1.4 KiB
Plaintext
model m_Test
|
|
model m_Constant0
|
|
output Real y;
|
|
parameter Real v = 2;
|
|
equation
|
|
y = v;
|
|
end m_Constant0;
|
|
model m_gain0
|
|
input Real u(quantity="Velocity", unit="m/s");
|
|
output Real y;
|
|
parameter Real k = 2.5;
|
|
equation
|
|
y = k*u;
|
|
end m_gain0;
|
|
model m_const_and_time
|
|
output Real y;
|
|
parameter Real v = 4.8;
|
|
equation
|
|
y = v+sin(10*time);
|
|
end m_const_and_time;
|
|
model m_gain1
|
|
input Real u;
|
|
output Real y;
|
|
parameter Real k = -5;
|
|
equation
|
|
y = k*u;
|
|
end m_gain1;
|
|
model m_add0
|
|
input Real u[2];
|
|
output Real y;
|
|
equation
|
|
y = sum(u[i] for i in 1:2 );
|
|
end m_add0;
|
|
model m_Integrate0
|
|
input Real u;
|
|
output Real y;
|
|
parameter Real y_start = 0;
|
|
initial equation
|
|
y = y_start;
|
|
equation
|
|
der(y) = u;
|
|
end m_Integrate0;
|
|
model m_Differentiate0
|
|
input Real u;
|
|
output Real y;
|
|
parameter Real x_start = 0;
|
|
parameter Real y_start = 0;
|
|
parameter Real k = 1;
|
|
parameter Real T = 0.01;
|
|
Real x(start=x_start);
|
|
initial equation
|
|
y = y_start;
|
|
equation
|
|
assert(T > 0, "Differentiate time constant T must be positive");
|
|
|
|
der(x) = (u - x)/T;
|
|
y = (k/T)*(u - x);
|
|
end m_Differentiate0;
|
|
m_Constant0 Constant0;
|
|
m_gain0 gain0;
|
|
m_const_and_time const_and_time;
|
|
m_gain1 gain1;
|
|
m_add0 add0;
|
|
m_Integrate0 Integrate0;
|
|
m_Differentiate0 Differentiate0;
|
|
equation
|
|
gain0.u = Constant0.y;
|
|
gain1.u = const_and_time.y;
|
|
add0.u[1] = gain0.y;
|
|
add0.u[2] = gain1.y;
|
|
Integrate0.u = add0.y;
|
|
Differentiate0.u = add0.y;
|
|
end m_Test;
|