Changeset 2f686d3 in OpenModelica


Ignore:
Timestamp:
2013-12-12T10:37:34+01:00 (10 years ago)
Author:
Volker Waurich <volker3189@…>
Branches:
Added-citation-metadata, maintenance/v1.14, maintenance/v1.15, maintenance/v1.16, maintenance/v1.17, maintenance/v1.18, maintenance/v1.19, maintenance/v1.20, maintenance/v1.21, maintenance/v1.22, maintenance/v1.23, master, omlib-staging
Children:
278ccf63
Parents:
b875dff
Message:
  • use analyticJacobian to solve reduced linear equationsystem when using +d=partlintornsystem

git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@18467 f25d12d1-65f4-0310-ae8a-bbce733d8d8e

File:
1 edited

Legend:

Unmodified
Added
Removed
  • Compiler/BackEnd/HpcOmSimCode.mo

    rb3b1f89f r2f686d3  
    922922        BackendDAE.TORNSYSTEM(tearingvars = tvarIdcs, residualequations = resEqIdcs, otherEqnVarTpl = otherEqnVarTpl, linear = linear) = comp;
    923923        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");
    925925           //print("handle tornsystem with compnumber:"+&intString(compIdx)+&"\n");
    926926           //BackendDump.dumpEqSystem(systIn,"the original system");
     
    10161016  list<list<BackendDAE.Var>> xa_i_lst, xa_i_lst1, r_i_lst, r_i_lst1, a_i_lst, a_i_lst1;
    10171017  list<DAE.ComponentRef> tcrs,ovcrs;
     1018  Option<list<tuple<Integer, Integer, BackendDAE.Equation>>> jac;
    10181019algorithm
    10191020   // handle torn systems for the linear case
     
    10951096   
    10961097   //// 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");
    10981106   
    10991107   oComps := List.appendElt(rComp,compsNew);
     
    11021110   //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);
    11031111end reduceLinearTornSystem2;
     1112
     1113
     1114protected function buildLinearJacobian "builds the jac structure out of the given jacobian-entries (all on the diagonal).
     1115author: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;
     1118protected
     1119  list<tuple<Integer, Integer, BackendDAE.Equation>> jac;
     1120algorithm
     1121  jac := List.fold1(List.intRange(listLength(inElements)),buildLinearJacobian1,inElements,{}); 
     1122  jac := listReverse(jac);
     1123  outJac := SOME(jac);
     1124end buildLinearJacobian;
     1125
     1126
     1127protected function buildLinearJacobian1 "builds the jac structure out of the given jacobian-entries (all on the diagonal).
     1128author: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;
     1133protected
     1134  list<BackendDAE.Var> elements;
     1135  list<tuple<Integer, Integer, BackendDAE.Equation>> jac;
     1136algorithm
     1137  elements := listGet(inElements,rowIdx);
     1138  outJac := List.fold2(List.intRange(listLength(inElements)),buildLinearJacobian2,elements,rowIdx,inJac); 
     1139end buildLinearJacobian1;
     1140
     1141
     1142protected function buildLinearJacobian2 "builds the jac structure out of the given jacobian-entries (all on the diagonal).
     1143author: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;
     1149protected
     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;
     1156algorithm
     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;
     1164end buildLinearJacobian2;
    11041165
    11051166
Note: See TracChangeset for help on using the changeset viewer.