Attention une mise à jour du serveur va être effectuée le lundi 17 mai entre 13h et 13h30. Cette mise à jour va générer une interruption du service de quelques minutes.

Commit 8fedc60a authored by Mathieu Hemery's avatar Mathieu Hemery

Improve the put_back_implicit_species function

parent 4103e241
......@@ -765,9 +765,38 @@ put_back_implicit_species(Id) :-
!
).
% Deal with the one species case
% correct_implicit_species(+Id, +Implicit_Species)
%
% modify the current ODE system to add the implicit species and insert it in the
% derivatives
correct_implicit_species(Id, K-X-Y) :-
% Add the ODE
ode(Id, X, Expr_X),
ode(Id, Y, Expr_Y),
atom_concat(X, Y, XY),
atom_concat(XY, '_m', XY_m),
distribute(-1*Expr_X + -1*Expr_Y, Der_Tempo),
simplify(Der_Tempo, Expr_m),
add_ode(Id, d(XY_m)/dt = Expr_m),
% Add the initial value
get_initial_concentration(X, X0),
get_initial_concentration(Y, Y0),
Init_m is K-X0-Y0,
set_ode_initial_value(XY_m, Init_m),
% And replace the expression by the variable
forall(
ode(Id, Var, Deriv),
(
delete_single_ode(Var),
substitute_all(K, X, Y, XY_m, Deriv, NewDeriv),
add_ode(Id, d(Var)/dt = NewDeriv)
)
).
correct_implicit_species(Id, K-X) :-
% Add the ODE of the implicit species
% Add the ODE
ode(Id, X, Expr),
atom_concat(X, '_m', X_m),
distribute(-1*Expr, Der_Tempo),
......@@ -787,12 +816,34 @@ correct_implicit_species(Id, K-X) :-
)
).
substitute_all(K, X, Y, XYm, In, Out) :-
substitute([K-X-Y], [XYm], In, E1),
substitute([-X+K-Y], [XYm], E1, E2),
substitute([-X-Y+K], [XYm], E2, E3),
substitute([V1+K-X-Y], [V1+XYm], E3, E4),
substitute([K+V2-X-Y], [V2+XYm], E4, E5),
substitute([K-X+V3-Y], [V3+XYm], E5, E6),
substitute([V4-X+K-Y], [V4+XYm], E6, E7),
substitute([-X+V5+K-Y], [V5+XYm], E7, E8),
substitute([-X+K+V6-Y], [V6+XYm], E8, E9),
substitute([V7-X-Y+K], [V7+XYm], E9, E10),
substitute([-X+V8-Y+K], [V8+XYm], E10, E11),
substitute([-X-Y+V9+K], [V9+XYm], E11, Test),
(
In = Test
->
Test = Out
;
substitute_all(K, X, Y, XYm, Test, Out)
).
substitute_all(K, X, Xm, In, Out) :-
substitute([K-X], [Xm], In, E1),
substitute([-X+K], [Xm], E1, E2),
substitute([V1+K-X], [V1+Xm], E2, E3),
substitute([K+V2-X], [V2+Xm], E3, E4),
substitute([V3-X+K], [V3+Xm], E4, Test),
substitute([K-X], [Xm], In, E1),
substitute([-X+K], [Xm], E1, E2),
substitute([V1+K-X], [V1+Xm], E2, E3),
substitute([K+V2-X], [V2+Xm], E3, E4),
substitute([V3-X+K], [V3+Xm], E4, E5),
substitute([-X+V4+K], [V4+Xm], E5, Test),
(
In = Test
->
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment