Commit 50805643 authored by SOLIMAN Sylvain's avatar SOLIMAN Sylvain
Browse files

use annotations to store compiled form of conservations

parent 3754983f
...@@ -31,15 +31,16 @@ add_conservation(Conservation) :- ...@@ -31,15 +31,16 @@ add_conservation(Conservation) :-
a warning.' a warning.'
), ),
solution_to_conservation(Conservation, C), solution_to_conservation(Conservation, C),
add_item(conservation, C). add_item(conservation, [], Conservation, Id),
set_annotation(Id, conservation_list, C).
delete_conservation(Conservation) :- delete_conservation(Conservation) :-
biocham_command, biocham_command,
type(Conservation, solution), type(Conservation, solution),
doc('removes the given mass conservation law.'), doc('removes the given mass conservation law.'),
solution_to_conservation(Conservation, C), find_item(
find_item([model: current_model, id: Id, type: conservation, item: C]), [model: current_model, id: Id, type: conservation, item: Conservation]),
delete_item(Id). delete_item(Id).
...@@ -65,7 +66,10 @@ check_conservations :- ...@@ -65,7 +66,10 @@ check_conservations :-
(see also \\command{add_conservation/1}).' (see also \\command{add_conservation/1}).'
), ),
forall( forall(
item([model: current_model, kind: conservation, item: C]), (
item([model: current_model, kind: conservation, id: Id]),
get_annotation(Id, conservation_list, C)
),
check_conservation(C) check_conservation(C)
). ).
......
...@@ -9,10 +9,11 @@ test( ...@@ -9,10 +9,11 @@ test(
[ [
setup(models:clear_model), setup(models:clear_model),
cleanup(models:clear_model), cleanup(models:clear_model),
true(Conservations == [[1*'a-a', 2*'a']]) forall(member(Input, ['a-a' + 2*'a', 'b', 'a' + 'b'])),
true(Conservations == [Input])
] ]
) :- ) :-
command(add_conservation(a-a + 2*a)), command(add_conservation(Input)),
all_items([model: current_model, kind: conservation], Conservations). all_items([model: current_model, kind: conservation], Conservations).
%%% FIXME should test that conservations are properly used for numerical %%% FIXME should test that conservations are properly used for numerical
...@@ -23,7 +24,7 @@ test( ...@@ -23,7 +24,7 @@ test(
[ [
setup(set_some_conservations), setup(set_some_conservations),
cleanup(models:clear_model), cleanup(models:clear_model),
true(Conservations == [[1*'a-a', 2*'a'], [1*'c-c', 2*'c']]) true(Conservations == ['a-a'+2*a,'c-c'+2*c])
] ]
) :- ) :-
command(delete_conservation(b-b + 2*b)), command(delete_conservation(b-b + 2*b)),
...@@ -48,7 +49,7 @@ test( ...@@ -48,7 +49,7 @@ test(
setup(set_some_conservations), setup(set_some_conservations),
cleanup(models:clear_model), cleanup(models:clear_model),
true(Conservations == true(Conservations ==
'[0] [1*a-a,2*a]\n[1] [1*b-b,2*b]\n[2] [1*c-c,2*c]\n') '[0] a-a+2*a\n[1] b-b+2*b\n[2] c-c+2*c\n')
] ]
) :- ) :-
with_output_to(atom(Conservations), command(list_conservations)). with_output_to(atom(Conservations), command(list_conservations)).
......
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