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

GS16のコードを以下に示します。このコードは 20-Sim用です。ここに示すコードとは20-Simにおける各要素の式です。20-Simでは式は自動的に入力されますが、必ずしも正しいとは言えないので十分点検する必要があります。ここでは表の値も示しました。便宜上表はc:\usrにあるとしましたが、任意です。

GS16のコード

C
parameters
	real c = 0.2;
equations
    state = int(p.f);
    p.e = state / c;

C1
parameters
	real c = 1;
   string filename='c:\usr\func2.txt';
equations
    state = int(p.f);
    p.e =table(filename,state)/c;

I
parameters
	real i = 6.5e-3;
equations
    state = int(p.e);
    p.f = state / i;

MR
equations
    p.e= if r>=4.0 and p.f>0.0 then					
	  p.f
   else
   0.0
   end;

MSE
variables
	real flow;
equations
	p.e = effort;
	flow = p.f;


R   
parameters
	real r = 1.0e-2;
equations					
	p.e = r * p.f;

SIN
parameters
	real amplitude = 8.0e1;//amplitude of the wave
	real omega = 6.28319e1{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 = amplitude * sin ( omega * time);

TABLE
Rparameters					
	string filename='c:\usr\func1.txt';
equations					
	output = table (filename, input);

c:\usr\func1.txt
-10.0000      0.0000
0.00000       0.0000
10.0000       10.000

c:\usr\func2.txt
0.0000     0.000
4.0000     0.000
10.000     1.800e3