Differences From Artifact [1e5df81dfe]:

To Artifact [e985d8ce2c]:


︙︙
12
13
14
15
16
17
18



19
20
21
22
23
24
25
26
27
28
29
30
31
32






33
34
35
36
37

38
39
40
41
42
43
44


% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$



% %% Revision 1.2  1997/12/04 13:48:00  peterg
% %% Added sign info to take account of direction of bonds.
% %%
% %% Revision 1.1  1997/04/09  10:18:26  peterg
% %% Initial revision
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


% Copyright (c) P.J. Gawthrop, 1996.

if nargin<8
  eqnfile = 'stdout';
end;







CorIorISW = CorI;
if CorIorISW==0 % ISW
   CorI = -1;
end;


% Find the number of ports
[ports,junk] = size(bonds);

% Right-hand side causality
RHS_cause = (bonds(:,1)==CorI*ones(ports,1))*CorI
state_cause = zeros(ports,1); % State causality







>
>
>














>
>
>
>
>
>





>







12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54


% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.3  1998/06/29 13:05:08  peterg
% %% Changed cieqn so that sign ignored.
% %%
% %% Revision 1.2  1997/12/04 13:48:00  peterg
% %% Added sign info to take account of direction of bonds.
% %%
% %% Revision 1.1  1997/04/09  10:18:26  peterg
% %% Initial revision
% %%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


% Copyright (c) P.J. Gawthrop, 1996.

if nargin<8
  eqnfile = 'stdout';
end;

if (CorI==1)
  comp_type = "C";
else
  comp_type = "I";
endif

CorIorISW = CorI;
if CorIorISW==0 % ISW
   CorI = -1;
end;


% Find the number of ports
[ports,junk] = size(bonds);

% Right-hand side causality
RHS_cause = (bonds(:,1)==CorI*ones(ports,1))*CorI
state_cause = zeros(ports,1); % State causality
︙︙
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
    fprintf(eqnfile, '%s := MTTx(%1.0f,1);\n', ...
        varname(name,LHS_number, state_cause), state);

    % Print equation of form xdot = input - with sign
    fprintf(eqnfile, 'MTTdX(%1.0f,1) := %s%s;\n', state, sign, ...
                     varname(name,LHS_number,-LHS_cause));
    % Print equation of form output = CR (state) 
    eqn =  equation(name,cr,args,LHS_number,LHS_cause,outport, ...
                             bond_number,state_cause,1:ports);
    fprintf(eqnfile, '%s',eqn);
    structure(1) = state;
  else % Derivative causality
    nonstate = structure(2)+1;
    LHS_cause = -CorI;

    % Print equation of form zdot = MTTdz(i) -- with sign 
    fprintf(eqnfile, '%s := %sMTTdz(%1.0f,1);\n', ...
                             varname(name,LHS_number,LHS_cause), sign, ...
                             nonstate);
    % Print equation of form MTTz(i) = z_i
    fprintf(eqnfile, 'MTTz(%1.0f,1) := %s;\n', nonstate, ...
             varname(name,LHS_number, state_cause));
				 
   % Print equation of form z_i = CR(input)
      eqn =  equation(name,cr,args,LHS_number,state_cause, outport, ...
                             bond_number,RHS_cause,1:ports);
    fprintf(eqnfile, '%s',eqn);
    structure(2) = nonstate;
 end;
end;









|
















|







72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
    fprintf(eqnfile, '%s := MTTx(%1.0f,1);\n', ...
        varname(name,LHS_number, state_cause), state);

    % Print equation of form xdot = input - with sign
    fprintf(eqnfile, 'MTTdX(%1.0f,1) := %s%s;\n', state, sign, ...
                     varname(name,LHS_number,-LHS_cause));
    % Print equation of form output = CR (state) 
    eqn =  equation(comp_type,name,cr,args,LHS_number,LHS_cause,outport, ...
                             bond_number,state_cause,1:ports);
    fprintf(eqnfile, '%s',eqn);
    structure(1) = state;
  else % Derivative causality
    nonstate = structure(2)+1;
    LHS_cause = -CorI;

    % Print equation of form zdot = MTTdz(i) -- with sign 
    fprintf(eqnfile, '%s := %sMTTdz(%1.0f,1);\n', ...
                             varname(name,LHS_number,LHS_cause), sign, ...
                             nonstate);
    % Print equation of form MTTz(i) = z_i
    fprintf(eqnfile, 'MTTz(%1.0f,1) := %s;\n', nonstate, ...
             varname(name,LHS_number, state_cause));
				 
   % Print equation of form z_i = CR(input)
      eqn =  equation(comp_type,name,cr,args,LHS_number,state_cause, outport, ...
                             bond_number,RHS_cause,1:ports);
    fprintf(eqnfile, '%s',eqn);
    structure(2) = nonstate;
 end;
end;


︙︙

MTT: Model Transformation Tools
[ GitHub | SourceHut | Sourceforge | Fossil RSS ]