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
|
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
|
+
+
-
+
-
+
+
+
+
+
-
+
-
+
-
-
-
-
+
-
-
+
-
-
-
-
-
+
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
+
|
printf(" mttx(%s)=0.0;\n", $2);
printf(" end;\n");
printf("end;\n");
}
}' Nx=$Nx < $1_switch.txt >> $1_switch.m
## Set index version
echo Creating $1_switchopen.m
# Implicit integration version
#Write some file headers
lang_header $1 switcha m 'mttAA,mttx' '[mttAA]' > $1_switcha.m
lang_header $1 switchopen m 'mttx' '[open]' > $1_switchopen.m
# Set states to zero
awk '{
if ($1=="#"){
printf("#== open - boolean vector of open switches ==#\n")
printf("[open] = zero_vector(%i); # Default to not open\n", Nx);
printf("#== Switches set row and column of A matrix to zero ==#\n")
}
else{
printf("#== Switch: %s ==#\n",$1)
printf("\n#== Switch: %s ==#\n",$1)
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(" open(%s) = 1;\n", $2);
printf(" mttAA(%s,%s) = 1.0;\n", $2,$2);
printf("end;\n\n")
printf("end;\n");
printf("if (%s<0.0)\n",$1);
printf(" if (mttx(%s)<=0.0)\n",$2);
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(" open(%s) = 1;\n", $2);
printf(" mttAA(%s,%s) = 1.0;\n", $2,$2);
printf(" end;\n");
printf("end;\n");
}
}' Nx=$Nx < $1_switch.txt >> $1_switchopen.m
#echo Creating $1_switcha.m
# Implicit integration 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) \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")
#
# printf("if (%s<0.0)\n",$1);
# printf(" if (mttx(%s)<=0.0)\n",$2);
# 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");
# printf("end;\n");
#
# }
}' Nx=$Nx < $1_switch.txt >> $1_switcha.m
# }' Nx=$Nx < $1_switch.txt >> $1_switcha.m
|