シミュレーションの演習のコード
BGSA5のコードを以下に示します。このコードは20-Sim用です。
BGSA5のコード
C
parameters
real c = 1 {N/m};
variables
real global fspring;
equations
state = int(p.f);
p.e = state / c;
fspring=p.e;
I
parameters
real global i =0.1 {kg};
variables
real global vv;
boolean global reset;
equations
state = resint(p.e,0,reset,0);
p.f = state / i;
Integrate
parameters
real initial = 0; // initial value
variables
real global vv;
boolean global reset;
equations
reset=event(input);
out = int (input, initial);
vv=out;
MSe
variables
real flow;
real global F1;
equations
p.e = out;
flow = p.f;
port1=p.e;
F1=p.e;
R
parameters
real static=1 {N};
real fslide =0.1 {N};
real ddv =1.0e-10;
real global i;
variables
real global a2;
real sta_f;
real global fspring;
real s1;
equations
s1=port1-fspring;
sta_f =if abs(p.f) > ddv then
fslide*sign(p.f)
else
if abs(s1) > static then//port1=Input Force
static*sign(s1)
else
s1
end
end;
p.e=sta_f;
Ramp
parameters
real slope = 1 {1/s};
real start_time = 0.0 {s};
variables
boolean hidden change;
equations
"calculate at least at the start time"
change = timeevent (start_time);
"calculate the ramp signal"
output = slope * ramp (start_time);
Ramp1
parameters
real slope = 2 {1/s};
real start_time = 5.0 {s};
variables
boolean hidden change;
equations
"calculate at least at the start time"
change = timeevent (start_time);
"calculate the ramp signal"
output = slope * ramp (start_time);
Ramp2
parameters
real slope = 2 {1/s};
real start_time = 10.0 {s};
variables
boolean hidden change;
equations
"calculate at least at the start time"
change = timeevent (start_time);
"calculate the ramp signal"
output = slope * ramp (start_time);
Ramp3
parameters
real slope = 2 {1/s};
real start_time = 15.0 {s};
variables
boolean hidden change;
equations
"calculate at least at the start time"
change = timeevent (start_time);
"calculate the ramp signal"
output = slope * ramp (start_time);
X
variables
real interesting plot;
equations
plot = input;
