Commit 55d7f8b7 authored by HEMERY Mathieu's avatar HEMERY Mathieu
Browse files

Add the time_event type for a latter special treatment (not done yet)

parent 93cfaf1b
......@@ -3,6 +3,7 @@
[
% Public API
add_event/2,
add_time_event/2,
list_events/0,
list_model_events/0
]
......@@ -51,10 +52,22 @@ add_event(Condition, ParameterValues) :-
add_item([kind: event, item: event(Condition, ParameterValues)]).
add_time_event(Condition, ParameterValues) :-
biocham_command(*),
type(Condition, condition),
Condition =.. [_Functor, 'Time', _Time_thr],
type(ParameterValues, '*'(parameter_name = arithmetic_expression)),
doc('Introduce a special kind of event when Time is the only variable, they may be used
for efficiency reason during numerical integration. The only allowed syntax is of the
form: Time > a or Time >= b.'),
add_item([kind: time_event, item: event(Condition, ParameterValues)]).
list_events :-
biocham_command,
doc('lists all the declared events.'),
list_items([kind: event]).
list_items([kind: event]),
list_items([kind: time_event]).
:- devdoc('\\section{Private predicates}').
......@@ -65,6 +78,7 @@ list_model_events :-
lists all the events in a loadable syntax
(auxiliary predicate of list_model).
'),
% List the regular events
\+ (
item(
[no_inheritance, kind: event, item: event(Condition, ParameterValues)]
......@@ -78,4 +92,19 @@ list_model_events :-
),
write(').\n')
)
),
% List the time events
\+ (
item(
[no_inheritance, kind: time_event, item: event(Condition, ParameterValues)]
),
\+ (
format('add_time_event(~w, ', [Condition]),
write_successes(
member(Parameter = Value, ParameterValues),
write(', '),
format('~w = ~w', [Parameter, Value])
),
write(').\n')
)
).
......@@ -294,7 +294,9 @@ prepare_numerical_simulation_options(Options) :-
true
),
gather_initial_values(InitialValues),
gather_events(Events),
gather_events(RegularEvents, event),
gather_events(TimeEvents, time_event),
append(RegularEvents, TimeEvents, Events),
gather_fields(Events, Fields),
gather_initial_parameter_values(InitialParameterValues),
jacobian(Equations, Jacobian),
......@@ -447,14 +449,14 @@ gather_initial_parameter_values(InitialParameterValues) :-
).
gather_events(Events) :-
gather_events(Events, Type) :-
findall(
Event,
(
bagof(
ParameterValue,
ParameterValues ^ (
item([kind: event, item: event(Condition, ParameterValues)]),
item([kind: Type, item: event(Condition, ParameterValues)]),
member(ParameterValue, ParameterValues)
),
ParameterValues
......
......@@ -37,14 +37,14 @@ test(eva_coeff_2) :-
rosenbrock:eval_coeff(infinity,[1.5,2.5,3.5],[-1,2], 1, R3), R3 =:= inf,
rosenbrock:eval_coeff(random,[1.5,2.5,3.5],[-1,2], 1, _R4).
test(simple_integration, [cleanup(command(clear_model))]) :-
test(simple_integration, [setup(command(clear_model)), cleanup(command(clear_model))]) :-
command(a => b),
command(present(a,1.0)),
command(numerical_simulation(method:rsbk)),
get_table_data(D),
check_integration_1(D, 1e-5).
test(cosinus_integration, [cleanup(command(clear_model))]) :-
test(cosinus_integration, [setup(command(clear_model)), cleanup(command(clear_model))]) :-
command(1.0*a for "_" => b),
command(-1.0*b for "_" => a),
command(present(a,1.0)),
......
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