ADDED mttroot/mtt/lib/comp/simple/EBTF_cause.m Index: mttroot/mtt/lib/comp/simple/EBTF_cause.m ================================================================== --- /dev/null +++ mttroot/mtt/lib/comp/simple/EBTF_cause.m @@ -0,0 +1,67 @@ +function [bonds,status] = EBTF_cause(bonds); +% EBTF_cause - causality for a EBTF component +% +% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% %%%%% Model Transformation Tools %%%%% +% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% +% Matlab function EBTF_cause +% [bonds,status] = EBTF_cause(bonds) + +%SUMMARY EBTF: transformer component - bicausal on effort +%DESCRIPTION Energy conserving two-port +%DESCRIPTION e_1 f_1 = e_2 f_2 and e_1 and e_2 are both imposed. + + +% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% % Version control history +% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% % $Id$ +% % $Log$ +% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + + + + +% Copyright (c) P.J. Gawthrop, 1998. + +% Check that there are exactly two bonds. +if check_bonds(bonds,2,'EBTF')==0 + return +end + +% Effort must be imposed by both bonds +if (bonds(1,1)==-1)|(bonds(2,1)==-1) % Overcausal + status = 1; + return +end; + +bonds(1,1) = 1; +bonds(2,1) = 1; + +% Flow bond must have through causality +if (bonds(1,2)==0)&(bonds(2,2)==0) % Undercausal + status = -1; + return +end; + +if (bonds(1,2)==bonds(2,2))&(bonds(1,2)!=0) % Overcausal + status = 1; + return +end; + +%Set flow causality +if (bonds(1,2)!=0) + bonds(2,2) = -bonds(1,2) +else + bonds(1,2) = -bonds(2,2) +end; + +status = 0; + + + + + + + ADDED mttroot/mtt/lib/comp/simple/EBTF_eqn.m Index: mttroot/mtt/lib/comp/simple/EBTF_eqn.m ================================================================== --- /dev/null +++ mttroot/mtt/lib/comp/simple/EBTF_eqn.m @@ -0,0 +1,51 @@ +function structure = EBTF_eqn(name,bond_number,bonds,direction,cr,args, ... + structure,eqnfile); + +if nargin<8 + eqnfile = 'stdout'; +end; + +% Check that there are exactly two bonds. +if check_bonds(bonds,2,'EBTF')==0 + return +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 -- no equation + +% Flow +effort1_name = varname(name,bond_number(1), 1); +effort2_name = varname(name,bond_number(2), 1); +flow1_name = varname(name,bond_number(1), -1); +flow2_name = varname(name,bond_number(2), -1); + +if f_1==-1 %Write flow on port 2 + fprintf(eqnfile,'%s := (%s/%s)*%s;\n' , ... + flow2_name, ... + effort1_name, ... + effort2_name, ... + flow1_name); +else %Write flow on port 1 + fprintf(eqnfile,'%s := (%s/%s)*%s;\n' , ... + flow1_name, ... + effort2_name, ... + effort1_name, ... + flow2_name); +end; + + + + + + + + + + +