Overview
Comment:Now generates _switcha.m as well -- needed for implicit integration
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | origin/master | trunk
Files: files | file ages | folders
SHA3-256: 82f51e3de39d5ef969740074e432692dccf941157abd629db828986b32070f3b
User & Date: gawthrop@users.sourceforge.net on 1998-10-01 15:46:34
Other Links: branch diff | manifest | tags
Context
1998-10-01
16:01:09
Now does implicit integration with switches check-in: 5f43ad54ef user: gawthrop@users.sourceforge.net tags: origin/master, trunk
15:46:34
Now generates _switcha.m as well -- needed for implicit integration check-in: 82f51e3de3 user: gawthrop@users.sourceforge.net tags: origin/master, trunk
1998-09-30
17:41:24
Implicit method now allows for switches via _switchA check-in: c6d26e5133 user: gawthrop@users.sourceforge.net tags: origin/master, trunk
Changes

Modified mttroot/mtt/bin/trans/switch_txt2m from [bf7ae14172] to [b75f922f5a].

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

# Convert switch file from txt to m
# P.J.Gawthrop May 1997
# Copyright (c) P.J.Gawthrop, 1997.


echo Creating  $1_switch.m


# Find system constants
Nx=`grep "MTTNx " <$1_def.r | awk '{print $3}' | sed 's/;//'`

#Write some file headers
lang_header $1 switch m mttx '[mttxs]' > $1_switch.m

# This is the main transformation using gawk
awk '{
  if ($1=="#"){
    printf("for MTTi=1:%s\n", Nx)
    printf("  mttxs(MTTi) = mttx(MTTi);\n")
    printf("end;\n\n")

  }
  else{


  printf("if (%s==0.0)\n  mttxs(%s)=0.0;\nend;\n\n", $1,$2)
  printf("if (%s<0.0)\n  if (mttx(%s)<0.0)\n    mttxs(%s)=0.0;\n  end;\nend;\n", $1,$2,$2)
  }
}' Nx=$Nx < $1_switch.txt >> $1_switch.m






























>





|

|


|
|
|
>


>
>
|
|



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



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

# Convert switch file from txt to m
# P.J.Gawthrop May 1997
# Copyright (c) P.J.Gawthrop, 1997.


echo Creating  $1_switch.m
echo Creating  $1_switcha.m

# Find system constants
Nx=`grep "MTTNx " <$1_def.r | awk '{print $3}' | sed 's/;//'`

#Write some file headers
lang_header $1 switch m 'mttx' '[mttx]' > $1_switch.m

# Set states to zero
awk '{
  if ($1=="#"){
#    printf("for MTTi=1:%s\n", Nx)
#    printf("  mttxs(MTTi) = mttx(MTTi);\n")
#    printf("end;\n\n")
    printf("#== Switches set element of state vector to zero ==#\n")
  }
  else{
  printf("\n#== Switch: %s ==#\n",$1)
  printf("if ((%s==0.0)||((%s<0.0)&&mttx(%s)<=0.0)) \n", $1,$1,$2);
  printf("  mttx(%s)=0.0;\n", $2);
  printf("end;\n");
  }
}' Nx=$Nx < $1_switch.txt >> $1_switch.m

# Matrix version
#Write some file headers
lang_header $1 switcha m 'mttAA,mttx' '[mttAA]' > $1_switcha.m
awk '{
  if ($1=="#"){
    printf("#== Switches set row and column of A matrix to zero ==#\n")
  }
  else{
  printf("#== Switch: %s ==#\n",$1)
  #printf("if ((%s==0.0)||((%s<0.0)&&mttx(%s)<=0.0)) \n", $1,$1,$2);
  printf("if (%s==0.0) \n", $1);
  printf("  for  MTTi=1:%s\n",Nx)
  printf("    mttAA(MTTi,%s)=0.0;\n", $2)
  printf("    mttAA(%s,MTTi)=0.0;\n", $2)
  printf("  end;\n");
  printf("  mttAA(%s,%s) = 1.0;\n", $2,$2);
  printf("end;\n\n")
  }
}' Nx=$Nx < $1_switch.txt >> $1_switcha.m




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