Changeset 18467
- Timestamp:
- 2013-12-12T10:37:34+01:00 (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Compiler/BackEnd/HpcOmSimCode.mo
r18460 r18467 922 922 BackendDAE.TORNSYSTEM(tearingvars = tvarIdcs, residualequations = resEqIdcs, otherEqnVarTpl = otherEqnVarTpl, linear = linear) = comp; 923 923 true = linear; 924 print("handle linear torn systems of size: "+&intString(listLength(tvarIdcs)+listLength(otherEqnVarTpl))+&"\n");924 Debug.fcall(Flags.HPCOM_DUMP,print,"handle linear torn systems of size: "+&intString(listLength(tvarIdcs)+listLength(otherEqnVarTpl))+&"\n"); 925 925 //print("handle tornsystem with compnumber:"+&intString(compIdx)+&"\n"); 926 926 //BackendDump.dumpEqSystem(systIn,"the original system"); … … 1016 1016 list<list<BackendDAE.Var>> xa_i_lst, xa_i_lst1, r_i_lst, r_i_lst1, a_i_lst, a_i_lst1; 1017 1017 list<DAE.ComponentRef> tcrs,ovcrs; 1018 Option<list<tuple<Integer, Integer, BackendDAE.Equation>>> jac; 1018 1019 algorithm 1019 1020 // handle torn systems for the linear case … … 1095 1096 1096 1097 //// get the strongComponent for the residual equations and add it at the end of the new StrongComponents 1097 rComp := BackendDAE.EQUATIONSYSTEM(residualEqs,tearingVars,NONE(),BackendDAE.JAC_NO_ANALYTIC()); 1098 1099 jac := buildLinearJacobian(a_i_lst); // TODO: check this flatten 1100 //print("Jac:\n" +& BackendDump.dumpJacobianStr(jac) +& "\n"); 1101 rComp := BackendDAE.EQUATIONSYSTEM(residualEqs,tearingVars,jac,BackendDAE.JAC_TIME_VARYING()); 1102 //rComp := BackendDAE.EQUATIONSYSTEM(residualEqs,tearingVars,NONE(),BackendDAE.JAC_NO_ANALYTIC()); 1103 //rComp := BackendDAE.TORNSYSTEM(tearingVars,residualEqs,{},true); 1104 //BackendDump.dumpEquationList(resEqsOut,"the equatinos of the system\n"); 1105 //BackendDump.dumpVarList(tvars, "the vars of the system\n"); 1098 1106 1099 1107 oComps := List.appendElt(rComp,compsNew); … … 1102 1110 //printPartLinTornInfo(tcrs,reqns,otherEqnsLst,ovcrs,xa_i_lst,g_i_lst,r_i_lst,h_i_lst,a_i_lst,hs_i_lst,hs,compsNew); 1103 1111 end reduceLinearTornSystem2; 1112 1113 1114 protected function buildLinearJacobian "builds the jac structure out of the given jacobian-entries (all on the diagonal). 1115 author:Waurich TUD 2013-12" 1116 input list<list<BackendDAE.Var>> inElements; //outer list refers to the row, inner list to the column 1117 output Option<list<tuple<Integer, Integer, BackendDAE.Equation>>> outJac; 1118 protected 1119 list<tuple<Integer, Integer, BackendDAE.Equation>> jac; 1120 algorithm 1121 jac := List.fold1(List.intRange(listLength(inElements)),buildLinearJacobian1,inElements,{}); 1122 jac := listReverse(jac); 1123 outJac := SOME(jac); 1124 end buildLinearJacobian; 1125 1126 1127 protected function buildLinearJacobian1 "builds the jac structure out of the given jacobian-entries (all on the diagonal). 1128 author:Waurich TUD 2013-12" 1129 input Integer rowIdx; 1130 input list<list<BackendDAE.Var>> inElements; 1131 input list<tuple<Integer, Integer, BackendDAE.Equation>> inJac; 1132 output list<tuple<Integer, Integer, BackendDAE.Equation>> outJac; 1133 protected 1134 list<BackendDAE.Var> elements; 1135 list<tuple<Integer, Integer, BackendDAE.Equation>> jac; 1136 algorithm 1137 elements := listGet(inElements,rowIdx); 1138 outJac := List.fold2(List.intRange(listLength(inElements)),buildLinearJacobian2,elements,rowIdx,inJac); 1139 end buildLinearJacobian1; 1140 1141 1142 protected function buildLinearJacobian2 "builds the jac structure out of the given jacobian-entries (all on the diagonal). 1143 author:Waurich TUD 2013-12" 1144 input Integer colIdx; 1145 input list<BackendDAE.Var> inElements; 1146 input Integer rowIdx; 1147 input list<tuple<Integer, Integer, BackendDAE.Equation>> inJac; 1148 output list<tuple<Integer, Integer, BackendDAE.Equation>> outJac; 1149 protected 1150 DAE.ComponentRef cref; 1151 DAE.Exp exp; 1152 BackendDAE.Equation eq; 1153 BackendDAE.Var elem; 1154 tuple<Integer,Integer,BackendDAE.Equation> entry; 1155 list<tuple<Integer, Integer, BackendDAE.Equation>> jac; 1156 algorithm 1157 elem := listGet(inElements,colIdx); 1158 cref := BackendVariable.varCref(elem); 1159 exp := DAE.CREF(cref,DAE.T_REAL_DEFAULT); 1160 exp := DAE.UNARY(DAE.UMINUS(DAE.T_REAL_DEFAULT),exp); 1161 eq := BackendDAE.RESIDUAL_EQUATION(exp,DAE.emptyElementSource,false); 1162 entry := (colIdx,rowIdx,eq); 1163 outJac := entry::inJac; 1164 end buildLinearJacobian2; 1104 1165 1105 1166
Note: See TracChangeset
for help on using the changeset viewer.