Commit 91daa629 authored by Mathieu Hemery's avatar Mathieu Hemery
Browse files

New bugs, new fixes !

parent 32089d6a
......@@ -427,9 +427,7 @@ remove_fraction :-
new_ode_system(NewId),
set_ode_system_name(NewId, without_fraction_ode),
normalize_ode(ListOde),
writeln(ListOde),
maplist(remove_fraction, ListOde, NewListOde),
writeln(NewListOde),
maplist(add_ode(NewId), NewListOde),
with_current_ode_system((
get_current_ode_system(Id),
......@@ -1373,16 +1371,22 @@ normalize_expression(Expr + Term, ListVar, NExpr + NTerm) :- !,
normalize_expression(Expr - Term, ListVar, NExpr + NTerm) :- !,
normalize_term(Term*(-1), ListVar, NTerm),
normalize_expression(Expr, ListVar, NExpr).
normalize_expression(-Term, ListVar, NTerm) :- !,
normalize_term(Term*(-1), ListVar, NTerm).
normalize_expression(Term, ListVar, NTerm) :-
normalize_term(Term, ListVar, NTerm).
normalize_term(TermRaw, ListVar, NewTerm) :-
simplify(TermRaw, Term),
filter_denominator(Term, Numerator, Denominator),
filter_other(Numerator, ListVar, Numbers, Parameters, Variables),
rewrite_term(Numbers, Parameters, Variables, Denominator, NewTerm).
(
Term =.. [-, TermP]
->
filter_denominator(TermP, Numerator, Denominator),
filter_other(Numerator, ListVar, Numbers, Parameters, Variables),
rewrite_term([-1|Numbers], Parameters, Variables, Denominator, NewTerm)
;
filter_denominator(Term, Numerator, Denominator),
filter_other(Numerator, ListVar, Numbers, Parameters, Variables),
rewrite_term(Numbers, Parameters, Variables, Denominator, NewTerm)
).
%! filter_denominator(Term, Numerator, Denominator)
......
......@@ -105,11 +105,19 @@ test(
remove_fraction(d(a)/dt = a/b + c/d, d(a)/dt = a*d + c*b).
test(
'normalize_ode', []) :-
'normalize_ode1', []) :-
clear_model,
with_current_ode_system((
add_ode(d(x)/dt = (1*(k9*k1*k2) + (-1)*(k9*k3*x1) + (-1)*(k9*k8*x*x/(x+k7)))/k9),
normalize_ode([d(x)/dt=k2*k1+ - (k3*x1)+ -1*x^2*k8/(x+k7)])
normalize_ode([d(x)/dt= k2*k1+ -1*x1*k3+ -1*x^2*k8/(x+k7)])
)).
test(
'normalize_ode2', []) :-
clear_model,
with_current_ode_system((
add_ode(d(x)/dt = k7+ -1*k8*x + -1*k9*x/(x+k1)),
normalize_ode([d(x)/dt = k7+ -1*k8*x+ -1*k9*x/(x+k1)])
)).
:- end_tests(ode).
Supports Markdown
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