Overview
Comment:Uniform version for _sim.m
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | origin/master | trunk
Files: files | file ages | folders
SHA3-256: 4f2d6cb2e98464a83c746e85a65ebd69668917e76c731b13e8c8137f7959fc35
User & Date: gawthrop@users.sourceforge.net on 2000-05-11 19:33:18
Other Links: branch diff | manifest | tags
Context
2000-05-11
19:34:35
Now does state, params + simparams check-in: 7d4618dc38 user: gawthrop@users.sourceforge.net tags: origin/master, trunk
19:33:18
Uniform version for _sim.m check-in: 4f2d6cb2e9 user: gawthrop@users.sourceforge.net tags: origin/master, trunk
19:32:29
Put in c version + sensitivity computation check-in: 0c5526fe81 user: gawthrop@users.sourceforge.net tags: origin/master, trunk
Changes

Modified mttroot/mtt/bin/trans/make_ode2odes from [e383e3f508] to [5be501a234].

1
2
3
4
5
6
7
8
9
10
11



12
13
14
15
16
17
18
#! /bin/sh

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

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$



## Revision 1.31  2000/05/10 18:33:25  peterg
## Use smxa and smxax in place of smx
##
## Revision 1.30  2000/04/18 11:24:19  peterg
## Removed _numpar.
##
## Revision 1.29  2000/04/07 19:10:57  peterg











>
>
>







1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#! /bin/sh

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

###############################################################
## Version control history
###############################################################
## $Id$
## $Log$
## Revision 1.32  2000/05/11 08:30:00  peterg
## Old version -- about to try new parameterised version
##
## Revision 1.31  2000/05/10 18:33:25  peterg
## Use smxa and smxax in place of smx
##
## Revision 1.30  2000/04/18 11:24:19  peterg
## Removed _numpar.
##
## Revision 1.29  2000/04/07 19:10:57  peterg
104
105
106
107
108
109
110


111




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
162
163

# Bourne shell script: make_ode2odes

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

# Tell user
Sys=$1


method=$2




echo  "Creating $1_ode2odes.m with $method integration method"

if [ $method = "implicit" ]; then
    ode=cse
    odeo=cseo
else
    ode=ode
    odeo=odeo
fi

# 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





#Initialise
MTTt = 0.0;


[MTTu]  = zero_input($Nu);	# Zero the input
[MTTx] = $1_state;	        # Read in initial state

[MTTpar] = $1_numpar;	        # Read in parameters














#[mttAA]  = zero_matrix($Nx);	# Zero the A matrix
#[mttAAx] = zero_vector($Nx);	# Zero the AAx vector

#if $Nx>0
#  [MTTx] = $1_switch(MTTx);       # Switches
#endif;

EOF




if [ "$method" = "euler" ]; then
cat << EOF >> $1_ode2odes.m
MTTddt = mttdt/mttstepfactor; # The small sample interval
EOF
fi









>
>
|
>
>
>
>


|













|

|


|
>

<
|
>
|
>
>
>
>
>
>
>
|
<
>
>
>
>

|
|
>

|
|
>
|
>
>
>
>
>
>
>
>
>
>
>

>
>
|
<

<
<
|



>
>
>







107
108
109
110
111
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
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183

184


185
186
187
188
189
190
191
192
193
194
195
196
197
198

# Bourne shell script: make_ode2odes

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

# Tell user
Sys=$1

if [ -n "$2" ]; then
  method=$2    
else
  method=implicit  
fi

echo  "Creating $1_ode2odes.m with $method integration method"

if [ "$method" = "implicit" ]; then
    ode=cse
    odeo=cseo
else
    ode=ode
    odeo=odeo
fi

# 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
lang_header  $1 ode2odes m  'x,U,par,simpar' '[Y,X,t]' > $1_ode2odes.m


cat >> $1_ode2odes.m <<EOF
global MTT_data;

  if nargin<1 
    x  =  $1_state; 
  endif
  if nargin<2
    U =   $1_input(0);
   endif
  if nargin<3
    par = $1_numpar; 

  endif
  if nargin<4
    simpar = $1_simpar; 
  endif

  ## Initialise
  t = 0.0;
  ilast = round(simpar.last/simpar.dt); # Total number of steps

  [u]  = zero_input(1);		# Zero the input

  for it = 1:ilast		#Integration loop
    [y] = $1_cseo(x,u,t,par);# Output 
    [u] = $1_input(t,x,y,U);	# Input
    if (t>=simpar.first)
      mtt_write(t,x,y,$Nx,$Ny); # Write it out
    endif
    [dx] = $1_cse(x,u,t,par);	# State derivative
    [AA] = $1_smxa(x,u,simpar.dt,par);	# (I-Adt) and (I-Adt)x
    [AAx] = $1_smxax(x,u,simpar.dt,par); # (I-Adt) and (I-Adt)x
    [open] = $1_switchopen(x);	# Open switches
    [x] = mtt_implicit(x,dx,AA,AAx,simpar.dt,$Nx,open); # Implicit update
    t = t + simpar.dt;
  endfor;			# Integration loop

  t = MTT_data(:,1);
  Y = MTT_data(:,2);
  X  = MTT_data(:,4);




endfunction

EOF

exit

### old stuff follows
if [ "$method" = "euler" ]; then
cat << EOF >> $1_ode2odes.m
MTTddt = mttdt/mttstepfactor; # The small sample interval
EOF
fi



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