ADDED mttroot/mtt/lib/comp/simple/RS_cause.m Index: mttroot/mtt/lib/comp/simple/RS_cause.m ================================================================== --- /dev/null +++ mttroot/mtt/lib/comp/simple/RS_cause.m @@ -0,0 +1,48 @@ +function [bonds,status] = RS_cause(bonds); +% Causality for RS component + +%SUMMARY RS: resistor with entropy generation +%DESCRIPTION Port[in]: a simple one port resistor +%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,'RS')==0 + return +end + +% There are 2 ports; extract the information +in_bonds = bonds(1,:); +out_bonds = bonds(2,:); + +% Port [in] is an ordinary resistor +[in_bonds,in_status] = R_cause(in_bonds); + +% Port [out] has the same causality pattern as an ordinary resistor +[out_bonds,out_status] = R_cause(out_bonds); + +% Reconstruct the bonds +bonds = [in_bonds; out_bonds]; + +% Generate an overall status +if (in_status==1)|(out_status==1) + status = 1; +elseif + (in_status==-1)|(out_status==-1) + status=-1; +else + status = 0; +end; + + ADDED mttroot/mtt/lib/comp/simple/RS_eqn.m Index: mttroot/mtt/lib/comp/simple/RS_eqn.m ================================================================== --- /dev/null +++ mttroot/mtt/lib/comp/simple/RS_eqn.m @@ -0,0 +1,55 @@ +function structure = RS_eqn(name,bond_number,bonds,direction,cr,args, ... + structure,eqnfile); +% RS_eqn - equations for flow-modulated resistor +% +% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% %%%%% Model Transformation Tools %%%%% +% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% Matlab function RS_eqn +% RS_eqn(name,bond_number,bonds,direction,cr,args, ... +% structure,eqnfile); + + +% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% %% Version control history +% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% %% $Id$ +% %% $Log$ +% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + + +% 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,'RS')==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 +structure = R_eqn(name,bond_number(1),in_bonds,in_direction,cr,args, ... + structure,eqnfile); + +% Do port [out] - the thermal bit. RS 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)) ); + +