Differences From Artifact [6c35e3e4df]:

To Artifact [81e64960c4]:


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.21  1999/04/02 06:29:25  peterg
## New implicit method - solves numerical prob with ISW
##
## Revision 1.20  1999/04/02 02:13:58  peterg
## Back to RCS
##
## Revision 1.19  1999/03/30 21:39:25  peterg
## In implicit approach, set derivatives to zero (when switch is off)
## before update. This seems to stop numerical leakage though non-return
## switches.
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
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







-
-
+
+

-
-
-
+
+
+












+
-
+
-







#  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
#[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 $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			# Dont if no states
    if mttmethod==1		# Euler
      for MTTjt = 1:mttstepfactor
	[MTTdx] = $1_ode(MTTx,MTTu,MTTt); # State derivative
        [MTTopen] = $1_switchopen(MTTx);        # Open switches
	[MTTx] = mtt_euler(MTTx,MTTdx,MTTddt,$Nx); # Euler update
	[MTTx] = mtt_euler(MTTx,MTTdx,MTTddt,$Nx,MTTopen); # Euler update
	[MTTx] = $1_switch(MTTx);	# Switches
	MTTt = MTTt + MTTddt;
      endfor;
    endif;
    if mttmethod==2		# Implicit 
      [MTTdx] = $1_ode(MTTx,MTTu,MTTt); # State derivative
      [mttAA,mttAAx] = $1_smx(MTTx,MTTu,mttdt);	# (I-Adt) and (I-Adt)x
      [MTTopen] = $1_switchopen(MTTx);        # Open switches

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