シミュレーションの演習のコード
BGSA6のコードを以下に示します。このコードは20-Sim用です。
BGSA6のコード
I parameters real global i =1.0; variables real global vv; equations state = int(p.e,0); p.f = state / i; Integrate parameters real initial = 0; // initial value variables real global ss; equations out = int (input, initial); ss=out; MSe variables real flow; equations p.e = output; flow = p.f; F1=p.e; R parameters real dv=1e-3; real fstick=100.0; real fslip=75.0; real astrick=0.001; real dvel=10.0;//Stribeck Constant real global i; variables real sw; real global ss; real fsl; real fst; equations sw=if abs(p.f) <= dv then 1 else 0.0 end; p.e=if abs(p.f) >= dv then (fslip+(fstick-fslip)*exp(-3*abs(p.f)/dvel))*sign(p.f) else fst end; fst=if abs(F1) >= fstick then sw*fstick*sign(F1) else F1*sw end; ACC=(F1-p.e)/i; Ramp parameters real slope = 2.5 {1/s}; real start_time = 0.0 {s}; real start_position=100.0; variables boolean hidden change; equations "calculate at least at the start time" change = timeevent (start_time); "calculate the ramp signal" out= slope * ramp (start_time)+start_position; Signal Monitor variables real interesting plot; equations plot = ACC; Sine parameters real omega = 0.6292{rad/s}; // angular frequency of the wave variables boolean hidden change; real hidden half; equations "calculate at least 2 points per cycle to get a triangle" half = pi / omega; change = frequencyevent (half, half / 2); "calculate the sine wave" output= port1* sin ( omega * time);