Differences From Artifact [c4ac8a5bd5]:

To Artifact [de3020d4fa]:


1
2
3
4
5
6
7
8
9
10
11



12
13
14
15
16
17
18
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.18  1999/03/15 01:17:07  peterg
## Removed some spurious debugging code
##
## Revision 1.17  1999/03/15 01:09:15  peterg
## Fixed bugs when Nx=0 (no state)
##
## Revision 1.16  1999/03/06 02:28:38  peterg
## Rearranged evaluation to: state - input - output - write
##
## Revision 1.15  1999/03/06 02:19:43  peterg
83
84
85
86
87
88
89
90

91
92
93
94



95
96
97
98
99
100
101
102
103
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
86
87
88
89
90
91
92

93
94



95
96
97
98
99
100
101
102
103
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







-
+

-
-
-
+
+
+



















-
+










+



-







$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_vector($Nu);	# Zero the input
if $Nx>0
#if $Nx>0
  [MTTx] = $1_state;	        # Read in initial state
else
  MTTx = 0;			# Dummy value
endif;
#else
#  MTTx = 0;			# Dummy value
#endif;

[MTTy] = $1_odeo(MTTx,MTTu,MTTt); # Evaluate initial output
[MTTu] = $1_input(MTTt,MTTx,MTTy);	# Evaluate initial input
mtt_write(MTTt,MTTx,MTTy,$Nx,$Ny); # And write them

[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;

if mttmethod==1			# Euler
  MTTddt = mttdt/mttstepfactor; # The small sample interval
endif;


for MTTit = 1:MTTilast		#Integration loop

  if $Nx>0			# Don't if no states
  if $Nx>0			# Dont if no states
    if mttmethod==1		# Euler
      for MTTjt = 1:mttstepfactor
	[MTTdx] = $1_ode(MTTx,MTTu,MTTt); # State derivative
	[MTTx] = mtt_euler(MTTx,MTTdx,MTTddt,$Nx); # Euler update
	[MTTx] = $1_switch(MTTx);	# Switches
	MTTt = MTTt + MTTddt;
      endfor;
    endif;
    if mttmethod==2		# Implicit 
      [MTTdx] = $1_ode(MTTx,MTTu,MTTt); # State derivative
      [MTTdx] = $1_switch(MTTx);	# Set derivs to zero if states to zero
      [mttAA,mttAAx] = $1_smx(MTTx,MTTu,mttdt);	# (I-Adt) and (I-Adt)x
      [mttAA] = $1_switcha(mttAA,MTTx);	# Switches
      [MTTx] = mtt_implicit(MTTx,MTTdx,mttAA,mttAAx,mttdt,$Nx); # Implicit update
      [MTTx] = $1_switch(MTTx);	# Switches
      MTTt = MTTt + mttdt;
    endif;
    else
      MTTt = MTTt + mttdt;
  endif;			# $Nx>0

  [MTTy] = $1_odeo(MTTx,MTTu,MTTt);     # Output 

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