シミュレーションの演習のコード
GS18.BGSのコードを以下に示します。このコードは BGSP用です。第1行の
BOND SYMBOL EXPR OUT DEFIN PARM INIT
はコードの一部ですから省略してはいけません。また、BGSPではカラム指定が厳格で1カラムでもずれるとエラーになります。また、許される文字は英数字、コロン(:)、スラッシュ(/)、加減乗算記号(+-*)、半角空白のみであり、制御文字が入るとエラーになります。倍角の空白はエラーを生じますが、ソースをプリントしても気づきにくいので注意が必要です。
GS18のコード
BOND SYMBOL EXPR OUT DEFIN PARM INIT SF1 11 ZJ -11 12 -14 13 OJ -12 35 42 OJ -41 15 14 SE2 42 RE1 35 CI1 13 SE1 41 ZJ -15 25 27 TF1 27 26 OJ -26 23 24 22 II1 24 RE4 22 RE3 25 CI2 23 / BC: Q11 FL11 BC: P13 EF13 BC: X231 DP23 BC: P35 EF35 BC: F35 FL35 BC: E231 EF23 BC: F15 FL15 BC: F25 FL25 BC: F27 FL27 BC: E25 EF25 OP: X231 PA: P10 1.000D+03 FB: X231 DP23 OP=X231*P10 EOD / SF1 PA: PSF1 5.000D+01 PA: PSIN 3.1416D+00 PA: P200 2.0000D+00 PA: PPEAK -1.170D+01 F=PPEAK*DSIN(P200*PSIN*PSF1*T) EOD SE1 PA: PSIN2 0.0000D+00 E=PSIN2 EOD SE2 PA: PSE1 2.0000D-01 E=PSE1 EOD RE1 PA: PR1 -1.0000D+00 PA: PR2 0.00000D+00 PA: PR3 1.0000D+00 PA: PR4 3.8000D+02 R=Z/PR3 IF(R.LE.PR2)THEN R=PR2 ELSE R=Z*PR4 ENDIF EOD CI1 PA: PC1 1.10000D-02 PA: PC2 1.59350D-01 C=Z/PC1+PC2 EOD RE4 PA: PR6 4.0000D-02 R=Z*PR6 EOD RE3 PA: PCCZ 9.500D+05 RV: XXRR IF(XXRR.GE.0.0)THEN R=Z*PCCZ*XXRR ELSE R=0.0 ENDIF EOD TF1 PA: PATF 2.5400D+00 TF=1/PATF EOD II1 PA: PI1 3.6000D-05 PA: PI2 1.755551D-02 L=Z/PI1+PI2 EOD CI2 PA: PC3 1.0000D+00 PA: PC4 -1.620D-05 PA: PC5 -4.000D-04 PA: PC6 -1.0000D+01 PA: PC7 0.0000D+00 PA: PC8 4.0000D-04 PA: PC9 8.0000D-04 PA: PCF1 2.5000D+04 PA: PCF2 2.5000D+01 PA: PCF4 2.49750D+04 PA: PCF5 -9.9800D+00 RV: XXRR C=Z/PC3+PC4 ZZ=C XXRR=ZZ IF(ZZ.LE.PC5)THEN C=PC6 ELSEIF(ZZ.LE.PC7)THEN C=PCF1*ZZ ELSEIF(ZZ.LE.PC8)THEN C=PCF2*ZZ ELSEIF(ZZ.LE.PC9)THEN C=PCF4*ZZ+PCF5 ELSE C=1.000D+01 ENDIF EOD / 0.0000 2.000D-02 1.000D-9 4000 /
20-Simによるシミュレーションのコード
Sine parameters real amplitude = -1.170e+01; // amplitude of the wave real omega = 5.0e0 {rad/s}; // angular frequency of the wave real pi=3.141593; 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 = amplitude * sin ( 2*omega *pi* time); MSf11 variables real effort; equations p.f = flow; effort = p.e; Se41 parameters real effort = 0.0000; variables real flow; equations p.e = effort; flow = p.f; C13 parameters real pc1 = 1.1000e-02;//CI1 real pc2=1.59350e-01; equations state = int(p.f); p.e = state / pc1+pc2; R351 parameters real pr1= -1.0;//R351 real pr2=0.000; real pr3=1.000; real pr4=3.8000e+02; variables real zz; equations zz= p.e/pr3; p.f=if zz <= pr2 then pr2 else p.e*pr4 end; Se12 parameters real effort =- 2.000e-01; variables real flow; equations p.e = effort; flow = p.f; R151 parameters real pccz = 9.500e+05;//RE3 real pczero=0.0000; equations p.f= if port1 >= pczero then port1* pccz * p.e else pczero end; TF2726 parameters real r = 2.5400; equations p1.e = p2.e/r; p2.f = p1.f/r; R22 parameters real r = 4.0e-02;//RE4 equations p.e = r * p.f; I24 parameters real pi1 = 3.6000e-05; real pi2=1.75555e-02; equations state = int(p.e); p.f = state / pi1+pi2; C231 parameters real pc3 = 1.000;//CI2 real pc4=-1.620e-05; real pc5=-4.000e-04; real pc6=-1.000e+01; real pc7=0.000; real pc8=4.000e-04; real pc9=8.000e-04; real pcf1=2.500e+04; real pcf2=2.500e+01; real pcf4=2.49750e+04; real pcf5=-9.980e+00; variables real zz; equations state = int(p.f); zz=state/pc3+pc4;//efort port1=zz; p.e=if zz <=pc5 then pc6 else if zz <= pc7 then pcf1*zz else if zz <= pc8 then pcf2*zz else if zz <= pc9 then pcf4*zz+pcf5 else 1.000e+01 end end end end;