Differences From Artifact [d319395afb]:

To Artifact [b856f2f0d6]:


1
2
3
4
5
6
7
8
9
10
11

12
13
14
15
16
17



18
19
20
21
22
23
24
function [port_bonds, status] = abg2cbg(system_name, ...
    system_type, full_name, ...
    port_bonds,infofile)
% [bonds,status] = abg2cbg(system_name, system_type, full_name, port_bonds, infofile)
% 
%     %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
%     %%%%% Model Transformation Tools %%%%%
%     %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% 
% Matlab function  abg2cbg.m
% Acausal bond graph to causal bond graph: mfile format


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



% %%Revision 1.7  1996/08/16  12:58:58  peter
% %% Now does preferred causality of I and C.
% %% Revision 1.6  1996/08/09 08:27:29  peter
% %% Added a few deguging lines
% %%
% %% Revision 1.5  1996/08/08 18:06:18  peter
% %% Unified file naming scheme



|
|






>






>
>
>







1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
function [port_bonds, status] = abg2cbg(system_name, ...
    system_type, full_name, ...
    port_bonds,infofile)
% abg2cbg - acausal to causal bg conversion
%
%     %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
%     %%%%% Model Transformation Tools %%%%%
%     %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% 
% Matlab function  abg2cbg.m
% Acausal bond graph to causal bond graph: mfile format
% [bonds,status] = abg2cbg(system_name, system_type, full_name, port_bonds, infofile)

% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% Version control history
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %% $Id$
% %% $Log$
% %% Revision 1.8  1996/08/26  10:04:25  peterg
% %% Fixed error due to a line wrap.
% %%
% %%Revision 1.7  1996/08/16  12:58:58  peter
% %% Now does preferred causality of I and C.
% %% Revision 1.6  1996/08/09 08:27:29  peter
% %% Added a few deguging lines
% %%
% %% Revision 1.5  1996/08/08 18:06:18  peter
% %% Unified file naming scheme
112
113
114
115
116
117
118

119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
  old_done = inf;
  % Inner loop propogates causality
  while done~=old_done
    disp(sprintf('Causality is %3.0f%s complete.', done, pc));
    old_done = done;
  
    for i = 1:n_components

      comp = nozeros(components(i,:));
      bond_list = abs(comp);
      direction = sign(comp)'*[1 1];
      % Convert from arrow orientated to component orientated causality
      comp_bonds = bonds(bond_list,:).*direction;
      eval([ '[comp_type,name,cr,arg] = ', system_type, '_cmp(i);' ]);
      % change name of 0 and 1 components -- matlab doesn't like numbers here
      if strcmp(comp_type,'0')
	comp_type = 'zero';
      end;
      if strcmp(comp_type,'1')
	comp_type = 'one';
      end;
      
      % Component causality procedure name
      cause_name = [comp_type, '_cause'];
      
      % Invoke  the appropriate causality procedure
      if exist(cause_name)~=2 % Try a compound component
	% disp('------------PUSH-----------------');
	[comp_bonds,s] = abg2cbg(name, comp_type, full_name, comp_bonds, ...
	    infofile);
	status(i)=max(abs(s));
	% disp('------------POP-----------------');
      else % its a simple component
	% disp(['---', name, ' (', cause_name, ') ---']);
	% comp_bonds
	eval([ '[comp_bonds,status(i)] = ', cause_name, '(comp_bonds);' ]);
	% comp_bonds
      end;
      
      % Update the full bonds list
      % and convert from component orientated to arrow orientated causality
      bonds(bond_list,:) = comp_bonds.*direction; 
    end;
    
    
    done = sum(sum(abs(bonds)))/total*100;
    %  mtt_info(sprintf('Causality is %3.0f%s complete.', done, pc), infofile);
    
  end;
  
  % Set causality of C and I which is not set







>



















<



<

|









|







116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142

143
144
145

146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
  old_done = inf;
  % Inner loop propogates causality
  while done~=old_done
    disp(sprintf('Causality is %3.0f%s complete.', done, pc));
    old_done = done;
  
    for i = 1:n_components
      if status(i) ~= 0 % only do this if causality not yet complete
      comp = nozeros(components(i,:));
      bond_list = abs(comp);
      direction = sign(comp)'*[1 1];
      % Convert from arrow orientated to component orientated causality
      comp_bonds = bonds(bond_list,:).*direction;
      eval([ '[comp_type,name,cr,arg] = ', system_type, '_cmp(i);' ]);
      % change name of 0 and 1 components -- matlab doesn't like numbers here
      if strcmp(comp_type,'0')
	comp_type = 'zero';
      end;
      if strcmp(comp_type,'1')
	comp_type = 'one';
      end;
      
      % Component causality procedure name
      cause_name = [comp_type, '_cause'];
      
      % Invoke  the appropriate causality procedure
      if exist(cause_name)~=2 % Try a compound component

	[comp_bonds,s] = abg2cbg(name, comp_type, full_name, comp_bonds, ...
	    infofile);
	status(i)=max(abs(s));

      else % its a simple component
	disp(['---', name, ' (', cause_name, ') ---']);
	% comp_bonds
	eval([ '[comp_bonds,status(i)] = ', cause_name, '(comp_bonds);' ]);
	% comp_bonds
      end;
      
      % Update the full bonds list
      % and convert from component orientated to arrow orientated causality
      bonds(bond_list,:) = comp_bonds.*direction; 
    end;
    end;
    
    done = sum(sum(abs(bonds)))/total*100;
    %  mtt_info(sprintf('Causality is %3.0f%s complete.', done, pc), infofile);
    
  end;
  
  % Set causality of C and I which is not set

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