Commit aa486408 authored by REMONDEAU Paul's avatar REMONDEAU Paul
Browse files

now does not go beyond the final time of the simulation (20 by default)

parent ac0ae2e2
......@@ -50,6 +50,7 @@ kinetics_init_hook :-
step_size,
step_doubling,
init_stoch,
TIMETRESH = 0.01,
SAFE = 0.9, GROW = 1.5, PGROW = -0.25,
SHRINK = 0.5, PSHRINK is -1.0/3.0, ERRCON = 0.1296,
%MAXTRY = 40,
......@@ -60,6 +61,7 @@ kinetics_init_hook :-
E1 is 17.0/54.0, E2 is 7.0/36.0, E3 is 0.0, E4 is 125.0/108.0,
% C1X, C2X, C3X, C4X,
% A2X is 1.0, A3X is 3.0/5.0,
nb_setval(time_tresh,TIMETRESH),
nb_setval(k_rbk_safe,SAFE),
nb_setval(k_rbk_grow,GROW),
nb_setval(k_rbk_pgrow,PGROW),
......@@ -271,6 +273,24 @@ counter(Times) :-
Times is Time + 1,
nb_setval(counterr,Times).
final_interpolation(_,[],_,[],_,[]).
final_interpolation(Time1,[Value1|Data1],Time2,[Value2|Data2],FinalTime,[NewValue|NewData]) :-
NewValue is (20 * (Value1 - Value2) + Time2 * Value2 - Time1 * Value1) / (Time2 - Time1),
final_interpolation(Time1,Data1,Time2,Data2,FinalTime,NewData).
final_interpolation(FinalTime) :- %Make th final point at the time FinalTime, with linear interpolation between 2 last state
nb_getval(numerical_table,Data),
get_last_line(Data,Time1,State1),
last(Data,LastRow),
append(Data2,[LastRow],Data),
get_last_line(Data2,Time2,State2),
final_interpolation(Time1,State1,Time2,State2,FinalTime,FinalValues),
FinalRow =.. [row,FinalTime|FinalValues],
append(Data2,[FinalRow],FinalData),
nb_setval(numerical_table,FinalData).
rosenbrock(Equations,InitialTime,Duration,Parameters,Jacobian) :-
% formal differenciation
......@@ -335,6 +355,7 @@ rosenbrock(Equations,InitialTime,Duration,Parameters,Jacobian) :-
nb_setval(numerical_table,NewTable),
EventTime >= FinalTime,!,
%end_event,
final_interpolation(FinalTime),
nb_setval(hdid,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