Changeset 4aaf9a80 in OpenModelica
- Timestamp:
- 2021-04-08T13:23:19+02:00 (3 years ago)
- Branches:
- Added-citation-metadata, maintenance/v1.18, maintenance/v1.19, maintenance/v1.20, maintenance/v1.21, maintenance/v1.22, master, omlib-staging
- Children:
- 723951b
- Parents:
- 7d6513e
- git-author:
- Martin Sjölund <martin@…> (04/08/21 13:23:19)
- git-committer:
- GitHub <noreply@…> (04/08/21 13:23:19)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
OMCompiler/Compiler/BackEnd/BackendDAEUtil.mo
r05d9e01 r4aaf9a80 1200 1200 ********************************************/ 1201 1201 1202 public function generateStatePartition "function:generateStatePartition1203 1204 This function traverses the equations to find out which blocks needs to1205 be solved by the numerical solver (Dynamic Section) and which blocks only1206 needs to be solved for output to file ( Accepted Section).1207 This is done by traversing the graph of strong components, where1208 equations/variable pairs correspond to nodes of the graph. The edges of1209 this graph are the dependencies between blocks or components.1210 The traversal is made in the backward direction of this graph.1211 The result is a split of the blocks into two lists.1212 inputs: (blocks: int list list,1213 daeLow: BackendDAE,1214 assignments1: int vector,1215 assignments2: int vector,1216 adjacencyMatrix: AdjacencyMatrix,1217 adjacencyMatrixT: AdjacencyMatrixT)1218 outputs: (dynamicBlocks: int list list, outputBlocks: int list list)1219 "1220 input BackendDAE.EqSystem syst;1221 output BackendDAE.StrongComponents outCompsStates;1222 output BackendDAE.StrongComponents outCompsNoStates;1223 algorithm1224 (outCompsStates,outCompsNoStates):=1225 matchcontinue syst1226 local1227 Integer size;1228 array<Integer> arr,arr_1;1229 BackendDAE.StrongComponents comps,blt_states,blt_no_states;1230 BackendDAE.Variables v;1231 BackendDAE.EquationArray e,se,ie;1232 array<Integer> ass1,ass2;1233 array<list<Integer>> m,mt;1234 case (BackendDAE.EQSYSTEM(matching=BackendDAE.MATCHING(ass1,_,comps)))1235 equation1236 size = arrayLength(ass1) "equation_size(e) => size &";1237 arr = arrayCreate(size, 0);1238 arr_1 = markStateEquations(syst, arr, ass1);1239 (blt_states,blt_no_states) = splitBlocks(comps, arr_1);1240 then1241 (blt_states,blt_no_states);1242 else1243 equation1244 print("- BackendDAEUtil.generateStatePartition failed\n");1245 then1246 fail();1247 end matchcontinue;1248 end generateStatePartition;1249 1250 protected function splitBlocks "Split the blocks into two parts, one dynamic and one output, depending1251 on if an equation in the block is marked or not.1252 inputs: (blocks: int list list, marks: int array)1253 outputs: (dynamic: int list list, output: int list list)"1254 input BackendDAE.StrongComponents inComps;1255 input array<Integer> inIntegerArray;1256 output BackendDAE.StrongComponents outCompsStates;1257 output BackendDAE.StrongComponents outCompsNoStates;1258 algorithm1259 (outCompsStates,outCompsNoStates) := matchcontinue (inComps,inIntegerArray)1260 local1261 BackendDAE.StrongComponents comps,states,output_;1262 BackendDAE.StrongComponent comp;1263 list<Integer> eqns;1264 array<Integer> arr;1265 1266 case ({},_) then ({},{});1267 1268 case (comp::comps,arr)1269 equation1270 (eqns,_) = BackendDAETransform.getEquationAndSolvedVarIndxes(comp);1271 true = blockIsDynamic(eqns, arr) "block is dynamic, belong in dynamic section";1272 (states,output_) = splitBlocks(comps, arr);1273 then1274 ((comp::states),output_);1275 1276 case (comp::comps,arr)1277 equation1278 (states,output_) = splitBlocks(comps, arr) "block is not dynamic, belong in output section";1279 then1280 (states,(comp::output_));1281 else1282 equation1283 print("- BackendDAEUtil.splitBlocks failed\n");1284 then1285 fail();1286 end matchcontinue;1287 end splitBlocks;1288 1289 1202 public function blockIsDynamic "Return true if the block contains a variable that is marked" 1290 1203 input list<Integer> lst;
Note: See TracChangeset
for help on using the changeset viewer.