Commit 32089d6a authored by Mathieu Hemery's avatar Mathieu Hemery
Browse files

Merge branch 'feature/remove_fraction' into develop

parents fd1ff122 57003622
......@@ -427,7 +427,9 @@ 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),
......@@ -1358,7 +1360,8 @@ normalize_ode(NormalForm) :-
d( X )/dt = NewExpr,
(
ode(Id, X, Expr),
normalize_expression(Expr, ListVar, NewExpr)
distribute(Expr, ExprT),
normalize_expression(ExprT, ListVar, NewExpr)
),
NormalForm
)
......@@ -1375,7 +1378,8 @@ normalize_expression(-Term, ListVar, NTerm) :- !,
normalize_expression(Term, ListVar, NTerm) :-
normalize_term(Term, ListVar, NTerm).
normalize_term(Term, ListVar, NewTerm) :-
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).
......
......@@ -104,4 +104,12 @@ test(
remove_fraction(d(a)/dt = a/b + c/d + e, d(a)/dt = a*d + c*b + e*b*d),
remove_fraction(d(a)/dt = a/b + c/d, d(a)/dt = a*d + c*b).
test(
'normalize_ode', []) :-
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)])
)).
:- 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