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

New bugs, new fixes !

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