シミュレーションの演習のコード

GS8.BGSのコードを以下に示します。このコードは BGSP用です。第1行の

BOND SYMBOL EXPR OUT DEFIN PARM INIT

はコードの一部ですから省略してはいけません。また、BGSPではカラム指定が厳格で1カラムでもずれるとエラーになります。また、許される文字は英数字、コロン(:)、スラッシュ(/)、加減乗算記号(+-*)、半角空白のみであり、制御文字が入るとエラーになります。倍角の空白はエラーを生じますが、ソースをプリントしても気づきにくいので注意が必要です。

GS8のコード

BOND SYMBOL EXPR OUT DEFIN PARM INIT
SF1    11
OJ     -11   12    19
RE1    12
TF1    19    20
ZJ     -20   23    21    22
CI1    23
RE2    22
OJ     -21   25    24    241
RE3    25
II1    24
ZJ     -241  27    29    26
CI2    27
RE4    26
TF2    29    31
OJ     -31   39    34    35
II2    34
RE5    35
SE1    39
/
BC: P23   EF23
BC: W34   FL34
BC: Q34   FL241
/
SF1
PA: PFLW   1.5700D+02
       F=PFLW
EOD
RE1
PA: PCLR   4.000D-02
       R=Z*PCLR
EOD
TF1
PA: PTF1   1.600D+01
       TF=PTF1
EOD
RE2
PA: PR2    2.5000D+00
       R=Z/PR2
EOD
CI1
PA: PC1    4.7000D+01
      C=Z/PC1
EOD
RE3
PA: PR3    1.4700D-04
      R=Z*PR3
EOD
II1
PA: PI1    2.660D-05
      L=Z/PI1
EOD
CI2
PA: PC2    4.700D+01
      C=Z/PC2
EOD
RE4
PA: PR4    2.5000D+00
      R=Z/PR4
EOD
TF2
PA: PTF2   1.6000D+01
      TF=1/PTF2
EOD
II2
PA: PI2    1.800D-02
      L=Z/PI2
EOD
RE5
PA: PR5    8.000D-02
       R=PR5*Z
EOD
SE1
PA: PSE1   3.2000D+01
       E=PSE1
EOD
/
0.00              2.00D-00          1.000D-05         3000
/

20-Simのコード

Sf1
parameters
	real flow = 1.57e2;
variables
	real effort;
equations
	p.f = flow;
	effort = p.e;
R12
parameters
	real r1 = 4.0e-2;
equations
	p.e = r1 * p.f;

Constant
parameters
	real C = 1.6e1;		// output value
equations
	output = C;
     
MTF
equations
	p1.e = r * p2.e;
	p2.f = r * p1.f;

C23
parameters
	real c = 4.7e1;
equations
	state = int(p.f);
	p.e = state / c;

R22
parameters
	real r2 = 2.5;
equations
	p.f =  p.e/r2;

R25
parameters
	real r3 = 1.47e-4;
equations
	p.e = r3 * p.f;

I24
parameters
	real i = 2.6e-5;
equations
    state = int(p.e);
    p.f = state / i;

C27
parameters
	real c2 = 4.7e1;
equations
	state = int(p.f);
	p.e = state / c2;
R26
parameters
	real r4 = 2.5;
equations
	p.f = p.e/r4;


TF
parameters
	real r = 1.6e1;
equations
	p1.e =  p2.e/r;
	p2.f =  p1.f/r;
I34
parameters
	real i = 1.8e-2;
equations
    state = int(p.e);
    p.f = state / i;

R35
parameters
	real r5 = 8.0e-2;
equations
	p.e = r5* p.f;

Se39
parameters
	real effort =- 3.2e1;
variables
	real flow;
equations
	p.e = effort;
	flow = p.f;