Overview
Comment:Initial revision
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | origin/master | trunk
Files: files | file ages | folders
SHA3-256: 23e6161d32023b25483bc8f83bd40450b41894c3a8581c7fa9c35032e97c5cb2
User & Date: gawthrop@users.sourceforge.net on 1996-08-25 08:37:44
Other Links: branch diff | manifest | tags
Context
1996-08-25
08:38:14
Error handling added. check-in: 1ee6a53a73 user: gawthrop@users.sourceforge.net tags: origin/master, trunk
08:37:44
Initial revision check-in: 23e6161d32 user: gawthrop@users.sourceforge.net tags: origin/master, trunk
08:27:14
Now checks ports correctely - I hope. check-in: 5983e17b4f user: gawthrop@users.sourceforge.net tags: origin/master, trunk
Changes

Added mttroot/mtt/bin/trans/ode2obs_r version [7d474fce73].























































































































































































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
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
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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#! /bin/sh

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

# Bourne shell script: ode2obs_r
# Odrinary differential equations to observer function equations
# P.J.Gawthrop 14 June 1991, 8 Aug 1991, 2 April 1992, 14 April 1994, 28 Dec 94,
#		12th July 1995, April 1996
# Copyright (c) P.J.Gawthrop 1991, 1992, 1994, 1995, 1996.

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

#Inform user
echo Creating $1_obs.r

# Remove the old log file
rm -f ode2obs_r.log

# Use reduce to accomplish the transformation
reduce >ode2obs_r.log << EOF

OFF Echo;
OFF Nat;
ON NERO;

in "$1_def.r";
MTTdxs := MTTdX;  %Save the symbolic form of dX

%Set default values - reset by sympar file.
MTTGPCNy := 2;
MTTGPCNu := 0;

in "$1_sympar.r";
in "$1_ode.r";


%Create the U vector of input derivatives.
MTTNuu := (MTTGPCNu+1)*MTTNu;
MTTNuu1 := MTTGPCNu*MTTNu;
Matrix MTTUU(MTTNuu,1);

FOR i := 1:MTTNu DO
  MTTUU(i,1) := MTTU(i,1);
END;

IF MTTGPCNu>0 THEN
FOR i := 1:MTTNu DO
  MTTUU(i+MTTNu,1) := MTTdU(i,1);
END;

MTTU := MTTU;
MTTdU := MTTdU;
MTTUU := MTTUU;

%Create the Y vector of output derivatives.
MTTNyy := (MTTGPCNy+1)*MTTNy;
Matrix MTTYY(MTTNyy,1);

FOR i := 1:MTTNy DO
  MTTYY(i,1) := MTTY(i,1);
END;

l := MTTNy;
FOR i := 1:MTTGPCNy DO
    FOR j := 1:MTTNy DO
    BEGIN
    l := l+1;
    MTTYY(l,1) := 0;
    FOR k := 1:MTTNx DO %Derivatives wrt x
    BEGIN
      xk := MTTX(k,1);
      MTTYY(l,1) := MTTYY(l,1) + df(MTTYY(l-MTTNy,1), xk, 1)*MTTdX(k,1);
    END;
    IF MTTNuu1>0 THEN
    FOR k := 1:MTTNuu1 DO %Derivatives wrt u
    BEGIN
      uk := MTTUU(k,1);
      MTTYY(l,1) := MTTYY(l,1) + df(MTTYY(l-MTTNy,1), uk, 1)*MTTUU(k+MTTNu,1);
    END;
  END;
END;

%Create O_x - derivative of YY wrt x
Matrix MTTO_x(MTTNyy,MTTNx);
FOR j := 1:MTTNx DO
  BEGIN
  xj := MTTX(j,1);
  FOR i := 1:MTTNyy DO
    BEGIN
    MTTO_x(i,j) := df(MTTYY(i,1), xj);
    END;
  END;

%Create O_u - derivative of YY wrt u (Assumes GPC Nu = 0)
MTTNNu := (MTTGPCNu+1)*MTTNu;
Matrix MTTO_u(MTTNyy,MTTNNu);
FOR j := 1:MTTNNu DO
  BEGIN
  uj := MTTu(j,1);	
  FOR i := 1:MTTNyy DO
    BEGIN
    MTTO_u(i,j) := df(MTTYY(i,1), uj);
    END;
  END;


%Create O_uu - derivative of O_u wrt u (Assumes GPC Nu = 0)
%This is a multi-dimensional matrix kth elements stacked sideways.
Matrix MTTO_uu(MTTNyy,MTTNNu*MTTNNu);
FOR k := 1:MTTNNu DO
  BEGIN
  uk := MTTu(k,1);	
  FOR j := 1:MTTNNu DO
    BEGIN
    FOR i := 1:MTTNyy DO
      BEGIN
      jk := j+(k-1)*MTTNu;
      MTTO_uu(i,jk) := df(MTTO_u(i,j), uk);
      END;
    END;
  END;

%Create O_ux - derivative of O_u wrt x 
%This is a multi-dimensional matrix kth elements stacked sideways.
Matrix MTTO_ux(MTTNyy,MTTNu*MTTNx);
FOR k := 1:MTTNx DO
  BEGIN
  xk := MTTx(k,1);	
  FOR j := 1:MTTNu DO
    BEGIN
    FOR i := 1:MTTNyy DO
      BEGIN
      jk := j+(k-1)*MTTNu;
      MTTO_ux(i,jk) := df(MTTO_u(i,j), xk);
      END;
    END;
  END;



%%Create the _obs.r file
OUT "$1_obs.r";

MTTYY := MTTYY;
MTTO_x := MTTO_x;
MTTO_u := MTTO_u;
MTTO_uu := MTTO_uu;
MTTO_ux := MTTO_ux;

write ";END;";

SHUT "$1_obs.r";
quit;

EOF


#Reduce writes errors to std output with ***** in front.
grep '\*\*\*\*\*' ode2obs_r.log >mtt_error
# Test for errors and print if any
err_length=$(wc -c <mtt_error)
if [ $err_length != "0" ]
then
  echo MTT has failed with the following errors '...'
  cat mtt_error
  exit 1
else
  exit 0
fi







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