Commit 56e5dbc1 authored by Mathieu Hemery's avatar Mathieu Hemery
Browse files

Move separate_list/4 to util.pl and clean rosenbrock accordingly

parent 07946017
......@@ -123,14 +123,6 @@ ode_solver([
format("Simulation time: ~ps~n",[TT]),
retractall(k_fail).
%! take(+N, +List, -Sublist)
%
% Sublist is the N first element of List
take(Size, List, Sublist) :-
prefix(Sublist, List),
length(Sublist, Size).
%! initialize_functions_list
%
......@@ -395,8 +387,9 @@ final_interpolation(FinalTime) :-
append(Data2,[FinalRow],FinalData),
nb_setval(numerical_table,FinalData).
/*********************/
/* Rosenbrock method */
/*********************/
%! rosenbrock(+Equations, +InitialTime, +Duration, +Jacobian)
%
......@@ -433,7 +426,7 @@ rosenbrock(Equations,InitialTime,Duration,Jacobian) :-
get_last_row(CurrentTable, Time, State_full),
debug(rosenbrock, "entering step for ~p", [Time]),
length(Equations, NumberTrueVariable), % Cut the function values at the end of State_full
take(NumberTrueVariable, State_full, CurrentState),
separate_list(State_full, NumberTrueVariable, CurrentState, _FunctionState),
% Here is the true rosenbrock step
rosenbrock_step(Equations, Jacobian, CurrentState, Parameters, Next_state),
nb_getval(hdid,NewStepSize),
......@@ -660,24 +653,14 @@ scale_error([E|Err],[V|L],[SE|SErr]) :-
scale_error(Err,L,SErr).
/*******************/
/* Events handling */
/*******************/
:- dynamic(conditional_events_status/2).
:- dynamic(rosenbrock_events_status/2).
/* Tool to separate a list in two sublists */
separate_list([],0,[],[]).
separate_list([Element|List],0,[],[Element|Rest]) :-
separate_list(List,0,[],Rest),!.
separate_list([Element|List],IndexSeparation,[Element|FirstElements],Rest) :-
NewIndexSeparation is IndexSeparation - 1,
separate_list(List,NewIndexSeparation,FirstElements,Rest).
/* This gives acces to the traditionnal events list and the kinetics conditionnal events list */
get_events_lists(EventsList,ConditionalEventsList) :-
......@@ -831,23 +814,6 @@ handle_rosenbrock_events(State,Time) :-
)
).
/*handle_rosenbrock_events(State,Time) :-
get_events_lists(Events,_),
forall(
(member(Event, Events),Event =.. [->,Condition,AssignmentList]),
(
test_condition(State,Time,Condition,Result),
Result
->
maplist(apply_changes(State,Time), AssignmentList),
nb_getval(events_number,EventsNumber),
NewEventsNumber is EventsNumber - 1,
nb_setval(events_number,NewEventsNumber)
;
true
)
).*/
%! test_condition(+State, +Time, +Condition, +Result)
%
......
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