More types and units
This commit is contained in:
35
m_Test.mo
35
m_Test.mo
@@ -6,7 +6,7 @@ model m_Test
|
||||
y = v;
|
||||
end m_Constant0;
|
||||
model m_gain0
|
||||
input Real u;
|
||||
input Real u(quantity="Velocity", unit="m/s");
|
||||
output Real y;
|
||||
parameter Real k = 2.5;
|
||||
equation
|
||||
@@ -16,7 +16,7 @@ model m_Test
|
||||
output Real y;
|
||||
parameter Real v = 4.8;
|
||||
equation
|
||||
y = v+sin(time);
|
||||
y = v+sin(10*time);
|
||||
end m_const_and_time;
|
||||
model m_gain1
|
||||
input Real u;
|
||||
@@ -31,14 +31,43 @@ model m_Test
|
||||
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;
|
||||
end m_Test;
|
||||
Integrate0.u = add0.y;
|
||||
Differentiate0.u = add0.y;
|
||||
end m_Test;
|
||||
|
||||
Reference in New Issue
Block a user