File mttroot/mtt/bin/trans/make_ode2odes artifact 43be042abf part of check-in b93f24a29b


#! /bin/sh

     ###################################### 
     ##### Model Transformation Tools #####
     ######################################

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.7  1998/07/30 11:29:54  peterg
## Added implicit integration stuff
##
## Revision 1.6  1998/07/30 10:44:37  peterg
## INcluded othe integration methods.
##
## Revision 1.5  1998/07/26 11:02:20  peterg
## Put mtt or MTT  in front of variable names to avoid clashes with
## globals
##
## Revision 1.4  1998/07/25 20:14:00  peterg
## update code added for flexibility and octave efficiency
##
###############################################################


# Bourne shell script: make_ode2odes

# Copyright (c) P.J.Gawthrop July 1998.

# Tell user
echo  Creating $1_ode2odes.m

Sys=$1

# Find system constants
Nx=`grep "MTTNx " <$Sys\_def.r | awk '{print $3}' | sed 's/;//'`
Nu=`grep "MTTNu " <$Sys\_def.r | awk '{print $3}' | sed 's/;//'`
Ny=`grep "MTTNy " <$Sys\_def.r | awk '{print $3}' | sed 's/;//'`
 

cat << EOF > $1_ode2odes.m
# Program $1_ode2odes
EOF

# Do the globals
sympar2global_txt2m $1 >> $1_ode2odes.m

# The rest of the program
cat << EOF >> $1_ode2odes.m

$1_simpar;			# Read in simulation parameters
$1_numpar;			# Read in parameters
MTTilast = round(mttlast/mttdt);         # Total number of steps
mttddt = mttdt/mttstepfactor;

#Initialise
MTTt = 0.0;
[MTTx] = $1_state;	        # Read in initial state
[MTTu] = $1_input(MTTx,MTTt);        # Evaluate initial input
[MTTy] = $1_odeo(MTTx,MTTu,MTTt);    # Evaluate initial output
mtt_write(MTTt,MTTx,MTTy,$Nx,$Ny); # And write them
[mttA] = zeros($Nx); # Zero the A matrix

if mttmethod==2 #Linear implicit
  mttA = $1_smx(MTTx,MTTu); # Set up A matrix - linearised system
end;

#Integration loop
for MTTit = 1:MTTilast
    for MTTi = 1:mttstepfactor
        [MTTu] = $1_input(MTTx,MTTt);# Input
        [MTTx] = $1_switch(MTTx); # Switches
        [MTTdx] = $1_ode(MTTx,MTTu,MTTt);
        if mttmethod==3
          mttA = $1_smx(MTTx,MTTu); # Set up A matrix - linearised system
        end;
        [MTTx] = mtt_update(MTTdx,MTTx,mttddt,$Nx,mttmethod,mttA);
        [MTTy] = $1_odeo(MTTx,MTTu,MTTt);
	MTTt = MTTt + mttddt;
    end;
    mtt_write(MTTt,MTTx,MTTy,$Nx,$Ny);
end;

EOF






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