Overview
Comment:The main transformation for sorted elementary equations
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | origin/master | trunk
Files: files | file ages | folders
SHA3-256: 976e0c6b3d96a202038a72406c2cb01cedb0d2720534f6bd94cf3976061e2583
User & Date: gawthrop@users.sourceforge.net on 2003-03-13 15:44:53
Other Links: branch diff | manifest | tags
Context
2003-03-13
15:47:35
Added sese rep. check-in: f761d6e16e user: gawthrop@users.sourceforge.net tags: origin/master, trunk
15:44:53
The main transformation for sorted elementary equations check-in: 976e0c6b3d user: gawthrop@users.sourceforge.net tags: origin/master, trunk
15:43:36
Helper for _sese generation check-in: 6752210f2e user: gawthrop@users.sourceforge.net tags: origin/master, trunk
Changes

Added mttroot/mtt/bin/trans/cbg2sese_m2r version [bbff01e03c].































































































































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
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
#! /bin/sh

  ###################################### 
  ##### Model Transformation Tools #####
  ######################################
  
  ###############################################################
  ## Version control history
  ###############################################################
  ## $Id$
  ## $Log$
  ## Revision 1.3  2003/03/13 09:00:22  peterg
  ## Revised for new mtt_component_eqn arg list
  ##
  ## Revision 1.2  2003/03/11 10:16:03  peterg
  ## Removed NAME argument
  ##
  ## Revision 1.1  2003/03/11 10:08:49  peterg
  ## Initial revision
  ##
  ##
  ###############################################################

## cbg2seqn_m2r: Converts causal bond graph into sorted equations
## Copyright (C) 2003 by Peter J. Gawthrop


strucfile=$1_struc.txt
outfile=$1_sese.r
make=mtt_make_sese.m
CD='%%%% ====='
## Inform user
echo Creating ${outfile}

## Header
create_header() {
cat<<EOF    
$CD File ${outfile}
$CD Created by MTT on `date`

EOF
}

## Setup states etc
set_known() {
  gawk '{
  name["state"]="x";
  name["input"]="u";

  if ($1==which) {
   printf("MTT%s_%s := MTT%s(%s,1);\n", name[$1], $4, name[$1], $2);
   }
}'  which=$1 < ${strucfile}      
}

## Setup outputs, derivatives etc
set_out() {
  gawk '{
  name["state"]="dx";
  name["output"]="y";

  if ($1==which) {
   printf("MTT%s(%s,1) := MTT%s_%s;\n", name[$1], $2, name[$1], $4);
   }
}'  which=$1 < ${strucfile}      
}


## Create the octave commands for state, output etc
create_octave() {
gawk '{
  if ($1==which) {
     printf("printf(\"\\n%s The %s equation for %s\");\n", CD, $1, $4);
     printf("[known] = mtt_component_eqn\\\n");
     printf("(\"%s\",1,mtt_other_causality(\"%s\"),known);\n", $4, $6);
   }
}' "CD=${CD}" which=$1 < ${strucfile}         
}

create_octave_header() {
cat <<EOF
## Octave commands to generate sese file
## Created by mtt on `date`

known = "";

EOF
}

## Header
create_header > ${outfile}
cat >> ${outfile}<<EOF
${CD} Set up the state and input variables

EOF
which_list="state input"
for which in ${which_list}; do
    set_known ${which} >> ${outfile}
done


## Create a file of octave commands
create_octave_header > ${make}
which_list="state output"
for which in ${which_list}; do
    create_octave ${which} >> ${make}
done


## Execute the m file
octave -q < ${make} >> ${outfile}

## Tail
cat >> ${outfile}<<EOF

${CD} Set up the state derivative and output variables

EOF
which_list="state output"
for which in ${which_list}; do
    set_out ${which} >> ${outfile}
done

cat<<EOF >> ${outfile}
END;
EOF


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