Skip to content

Commit 23d8e21

Browse files
author
Peter Aronsson
committed
Added solving of linear systems in residual form.
git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@1631 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
1 parent 5d0e1e3 commit 23d8e21

File tree

1 file changed

+27
-5
lines changed

1 file changed

+27
-5
lines changed

modeq/simcodegen.rml

Lines changed: 27 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -837,11 +837,12 @@ end
837837

838838
axiom build_residual_blocks(_,_,_,_,[]) => []
839839

840-
(* rule (* For system of equations *) *)
841-
(* build_system(dlow,ass1,ass2,block) &
842-
build_residual_blocks(dae,dlow,ass1,ass2,blocks)
843-
-------------------------------------
844-
build_residual_blocks(dae,dlow,ass1,ass2,(block as (_::_::_))::blocks)*)
840+
rule (* For system of equations *)
841+
build_residual_system(dae,dlow,ass1,ass2,block) => eqn_str &
842+
build_residual_blocks(dae,dlow,ass1,ass2,blocks) => res
843+
-------------------------------------
844+
build_residual_blocks(dae,dlow,ass1,ass2,(block as (_::_::_))::blocks)
845+
=> eqn_str::res
845846

846847
rule (* for single equations *)
847848
build_residual_equation(dae,dlow,ass1,ass2,eqn) => eqn_str &
@@ -854,6 +855,27 @@ end
854855
build_residual_blocks(_,_,_,_,_) => fail
855856
end
856857

858+
(** relation build_residual_system
859+
** A system of equations on residual form is still only an output of each residual
860+
** equation. The numerical solver will solve the system.
861+
**)
862+
relation build_residual_system: (DAE.DAElist,
863+
DAELow.DAELow,
864+
int vector, (* assignments1*)
865+
int vector, (* assignments2*)
866+
int list (* equation no. *)
867+
) => string =
868+
869+
axiom build_residual_system(_,_,_,_,[]) => ""
870+
871+
rule build_residual_equation(dae,dlow,ass1,ass2,eqn) => s1 &
872+
build_residual_system(dae,dlow,ass1,ass2,eqns) => s2 &
873+
string_append(s1,s2) => str
874+
---------------------------------------------
875+
build_residual_system(dae,dlow,ass1,ass2,eqn::eqns) => str
876+
end
877+
878+
857879
(** relation build_residual_equation
858880
** This relation generates code on residual form for one equation.
859881
** It is used both for state variables and algebraic variables.

0 commit comments

Comments
 (0)