ADDED mttroot/mtt/lib/comp/simple/EMTF_cause.m Index: mttroot/mtt/lib/comp/simple/EMTF_cause.m ================================================================== --- /dev/null +++ mttroot/mtt/lib/comp/simple/EMTF_cause.m @@ -0,0 +1,83 @@ +function [bonds,status] = EMTF_cause(bonds); +% EMTF_cause - causality for a modulated TF component +% +% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% %%%%% Model Transformation Tools %%%%% +% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% Matlab function EMTF_cause +% [bonds,status] = EMTF_cause(bonds) +% Causality for effort-modulated EMTF +% At the moment, modulation can NOT be inverted. + +%SUMMARY EMTF: effort-modulated transformer +%DESCRIPTION Energy conserving three-port +%DESCRIPTION Ports [1] and [2] as for TF +%DESCRIPTION e_1 = f(f_2); f_1 = f(e_2) +%DESCRIPTION Effort on port[3] modulates the CR + + +% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% %% Version control history +% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% %% $Id$ +% %% $Log$ +% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + +% Copyright (c) P.J. Gawthrop, 1996. + +status = -1; + +% Check that there are exactly three bonds. +if check_bonds(bonds,3,'EMTF')==0 + return +end + +% Extract the bond information +TF_bonds = bonds(1:2,:); +e_3 = bonds(3,1); +f_3 = bonds(3,2); + +%Causality of EMTF is same as that of a TF on ports 1 and 2 +[TF_bonds,TF_status] = TF_cause(TF_bonds); + + +% Effort is the modulation - imposed on component. +if e_3==-1 % Conflict + mod_status_e = 1; +else % Do the rest of the causality + if e_3==0 % Set to the fixed causality + e_3 = 1; + end; + mod_status_e = 0; +end; + +% Zero flow imposed by component. +if f_3==-1 % Conflict + mod_status_f = 1; +else % Do the rest of the causality + if f_3==0 % Set to the fixed causality + f_3 = 1; + end; + mod_status_f = 0; +end; + +bonds = [TF_bonds + e_3 f_3]; + +if (TF_status == 0) & (mod_status_e == 0) & (mod_status_f == 0) + status = 0; +end; + +if (TF_status == 1) | (mod_status_e == 1) | (mod_status_f == 1) + status = 1; +end; + + + + + + + + ADDED mttroot/mtt/lib/comp/simple/GY_eqn.m Index: mttroot/mtt/lib/comp/simple/GY_eqn.m ================================================================== --- /dev/null +++ mttroot/mtt/lib/comp/simple/GY_eqn.m @@ -0,0 +1,77 @@ +function structure = GY_eqn(name,bond_number,bonds,direction,cr,args, ... + structure,eqnfile); +% GY_eqn - equations for GY component +% +% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% %%%%% Model Transformation Tools %%%%% +% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% Matlab function GY_eqn +% structure = GY_eqn(bond_number,bonds,direction,cr,args, ... +% structure,eqnfile); + +% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% %% Version control history +% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% %% $Id$ +% %% $Log$ +% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + +% Copyright (c) P.J. Gawthrop, 1996. + + +if nargin<8 + eqnfile = 'stdout'; +end; + + +% There are 2 ports; extract the information +e_1 = bonds(1,1); +f_1 = bonds(1,2); +e_2 = bonds(2,1); +f_2 = bonds(2,2); + + +% Effort - flow +if e_1==1 + outbond = bond_number(2); + inbond = bond_number(1); + outport = 2; + inport = 1; + outcause = -1; + incause = 1; +else + outbond = bond_number(1); + inbond = bond_number(2); + outport = 1; + inport = 2; + outcause = 1; + incause = -1; +end; + +eqn = equation(name,cr,args,outbond,outcause,outport, ... + inbond,incause,inport); +fprintf(eqnfile, '%s',eqn); + +% Flow-effort +if f_1==-1 + outbond = bond_number(2); + inbond = bond_number(1); + outport = 2; + inport = 1; + outcause = 1; + incause = -1; +else + outbond = bond_number(1); + inbond = bond_number(2); + outport = 1; + inport = 2; + outcause = -1; + incause = 1; +end; + +eqn = equation(name,cr,args,outbond,outcause,outport, ... + inbond,incause,inport); +fprintf(eqnfile, '%s',eqn); + ADDED mttroot/mtt/lib/comp/simple/RST_cause.m Index: mttroot/mtt/lib/comp/simple/RST_cause.m ================================================================== --- /dev/null +++ mttroot/mtt/lib/comp/simple/RST_cause.m @@ -0,0 +1,30 @@ +function [bonds,status] = RST_cause(bonds); +% Causality for RST component + +%SUMMARY RST: thermal resistor with entropy generation +%DESCRIPTION Port[in]: a simple one port resistor but: +%DESCRIPTION flow is multiplied by e_out +%DESCRIPTION Port[out]: thermal power - effort is temperature, flow is entropy flow +%DESCRIPTION Not bicausal (yet) + + +% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% %% Version control history +% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% %% $Id$ +% %% $Log$ +% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + +% Copyright (c) P.J. Gawthrop, 1997. + +status = -1; + +% Check that there are exactly two bonds. +if check_bonds(bonds,2,'RST')==0 + return +end + +% Same causality as RS +[bonds,status] = RS_cause(bonds); + ADDED mttroot/mtt/lib/comp/simple/RST_eqn.m Index: mttroot/mtt/lib/comp/simple/RST_eqn.m ================================================================== --- /dev/null +++ mttroot/mtt/lib/comp/simple/RST_eqn.m @@ -0,0 +1,76 @@ +function structure = RT_eqn(name,bond_number,bonds,direction,cr,args, ... + structure,eqnfile); +% RT_eqn - equations for flow-modulated resistor +% +% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% %%%%% Model Transformation Tools %%%%% +% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% Matlab function RT_eqn +% RT_eqn(name,bond_number,bonds,direction,cr,args, ... +% structure,eqnfile); + + +% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% %% VeRTion control history +% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% %% $Id$ +% %% $Log$ +% %% Revision 1.1 1997/09/03 09:30:45 peterg +% %% Initial revision +% %% +% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + + +% Copyright (c) P.J. Gawthrop, 1997. + + +if nargin<6 + eqnfile = 'stdout'; +end; + +% Check that there are exactly two bonds. +ports = 2; +if check_bonds(bonds,ports,'RT')==0 + return +end + + +% There are 2 ports; extract the information +in_bonds = bonds(1,:); +out_bonds = bonds(2,:); +in_direction = direction(1,:); +out_direction = direction(2,:); + +% Do port [in] - a standard resistor -- except for modulation by e_2 +structure = R_eqn(name,bond_number(1),in_bonds,in_direction,cr,args, ... + structure,eqnfile); + +% Resistance is multiplied by effort e_1 + e_2 (ie effort on upsteam side of +% the 1 junction) +if in_bonds(1) == 1 % Flow output - divide by e_1+e_2 + fprintf(eqnfile,'%s := %s/(%s+%s);\n' , ... + varname(name,bond_number(1), -1), ... + varname(name,bond_number(1), -1), ... + varname(name,bond_number(1), 1), ... + varname(name,bond_number(2), 1) ); +else + % Effort output - multiply by e_1+e_2 + fprintf(eqnfile,'%s := %s*(%s+%s);\n' , ... + varname(name,bond_number(1), 1), ... + varname(name,bond_number(1), 1), ... + varname(name,bond_number(1), 1), ... + varname(name,bond_number(2), 1) ); +end; + + +% Do port [out] - the thermal bit. RT is power conserving. +% This computes f_2 = e_1*f_1/e_2 or e_2 = e_1*f_1/f_2 +fprintf(eqnfile,'%s := %s*%s/%s;\n' , ... + varname(name,bond_number(2), -out_bonds(1)), ... + varname(name,bond_number(1), 1), ... + varname(name,bond_number(1), -1), ... + varname(name,bond_number(2), out_bonds(1)) ); + + ADDED mttroot/mtt/lib/comp/simple/cicause.m Index: mttroot/mtt/lib/comp/simple/cicause.m ================================================================== --- /dev/null +++ mttroot/mtt/lib/comp/simple/cicause.m @@ -0,0 +1,46 @@ +function [bonds,status] = cicause(bonds,default); +% cicause - Sets causality for C & I components +% +% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% %%%%% Model Transformation Tools %%%%% +% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% Matlab function cicause +% [bonds,status] = cicause(bonds,default) + +% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% %% Version control history +% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% %% $Id$ +% %% $Log$ +% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + +% Copyright (c) P.J. Gawthrop, 1996. + + + +if (norm(bonds)>1) + if (bonds(1)==-bonds(2)) % Over causal + status = 1; + else % Causal + status = 0; + end; +elseif norm(bonds)==0 % Acausal + % bonds = default*[1 1]; %Set integral causality + % status = 0; + status = -1; +else % Set causality + % Effort + if bonds(1)==0 + status = 0; + bonds(1) = bonds(2); + end; + + % Flow + if bonds(2)==0 + status = 0; + bonds(2) = bonds(1); + end; + +end; ADDED mttroot/mtt/lib/comp/simple/one_cause.m Index: mttroot/mtt/lib/comp/simple/one_cause.m ================================================================== --- /dev/null +++ mttroot/mtt/lib/comp/simple/one_cause.m @@ -0,0 +1,34 @@ +function [bonds,status] = one_cause(bonds); +% one_cause - causality for a one junction +% +% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% %%%%% Model Transformation Tools %%%%% +% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% Matlab function one_cause + + +% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% %% Version control history +% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% %% $Id$ +% %% $Log$ +% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + +% Copyright (c) P.J. Gawthrop, 1996. + +%Effort +[bonds,e_status] = juncause(bonds,-1,1); + +%Flow +[bonds,f_status] = juncause(bonds,-1,-1); + +if (e_status==1)|(f_status==1) % Over causal + status = 1; +elseif (e_status==-1)|(f_status==-1) % Under causal + status = -1; +else % causal + status = 0; +end; + ADDED mttroot/mtt/lib/comp/simple/zero_cause.m Index: mttroot/mtt/lib/comp/simple/zero_cause.m ================================================================== --- /dev/null +++ mttroot/mtt/lib/comp/simple/zero_cause.m @@ -0,0 +1,32 @@ +function [bonds,status] = zero_cause(bonds); +% zero_cause - causality for zero junctions +% +% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% %%%%% Model Transformation Tools %%%%% +% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% Matlab function zero_cause +% [bonds,status] = zero_cause(bonds); + +% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% %% Version control history +% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% %% $Id$ +% %% $Log$ +% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +%Effort +[bonds,e_status] = juncause(bonds,1,1); + +%Flow +[bonds,f_status] = juncause(bonds,1,-1); + +status = 0; +if (e_status==1)|(f_status==1) % Over causal + status = 1; +endif; +if (e_status==-1)|(f_status==-1) % Under causal + status = -1; +endif; + +