odefunction.pl 1.22 KB
Newer Older
FAGES Francois's avatar
FAGES Francois committed
1 2 3
:- module(
  odefunction,
  [
Thierry Martinez's avatar
ode  
Thierry Martinez committed
4
    add_function/1
FAGES Francois's avatar
FAGES Francois committed
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
  ]
).


:- devdoc('\\section{Commands}').


add_function(FunctionList) :-
  biocham_command(*),
  type(FunctionList, '*'(term = term)),
  doc('
    adds reactions to compute the result of a function of the current variables in the concentration of a new variable at steady state.
    \\begin{example}
  '),
  biocham_silent(clear_model),
  biocham(present(x,1)),
  biocham(present(y,3)),
  biocham(add_function(z=x+y)),
  biocham(list_reactions),
Thierry Martinez's avatar
Thierry Martinez committed
24
  biocham(list_ode),
FAGES Francois's avatar
FAGES Francois committed
25 26 27
  doc('
    \\end{example}
  '),
Thierry Martinez's avatar
Thierry Martinez committed
28 29 30 31
  new_ode_system(OdeSystem),
  export_ode(FunctionList, OdeSystem),
  import_reactions_from_ode_system(OdeSystem),
  delete_item(OdeSystem).
FAGES Francois's avatar
FAGES Francois committed
32 33


Thierry Martinez's avatar
Thierry Martinez committed
34
export_ode(_, OdeSystem) :-
Thierry Martinez's avatar
ode  
Thierry Martinez committed
35 36 37 38 39
  enumerate_molecules(L), % useless if item backtracks on Object (not clear to FF)
  member(Object, L),
  get_initial_concentration(Object, Concentration),
  set_ode_initial_value(OdeSystem, Object, Concentration),
  fail.
Thierry Martinez's avatar
Thierry Martinez committed
40 41

export_ode(FunctionList, OdeSystem) :-
Thierry Martinez's avatar
ode  
Thierry Martinez committed
42 43 44
  member(Variable = _, FunctionList),
  set_ode_initial_value(OdeSystem, Variable, 0),
  fail.
Thierry Martinez's avatar
Thierry Martinez committed
45 46

export_ode(FunctionList, OdeSystem) :-
Thierry Martinez's avatar
ode  
Thierry Martinez committed
47 48 49
  member(Variable = Value, FunctionList),
  add_ode(OdeSystem, d(Variable)/dt = Value - Variable),
  fail.
FAGES Francois's avatar
FAGES Francois committed
50

Thierry Martinez's avatar
Thierry Martinez committed
51
export_ode(_,_).