Commit 5e4ba131 authored by FAGES Francois's avatar FAGES Francois

francoisODEfunction

parent 0018af7d
:- module(
odefunction,
[
'add_function'/1
]
).
:- 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),
biocham(list_ODE),
doc('
\\end{example}
'),
setup_call_cleanup(
open('external_ode_function.ode', write, Stream),
export_ode(FunctionList,Stream),
close(Stream)
),
add_ode('external_ode_function.ode').
export_ode(_,Stream):-
enumerate_molecules(L), % useless if item backtracks on Object (not clear to FF)
member(Object,L),
get_initial_concentration(Object, Concentration),
format(Stream, 'init ~a = ~d\n', [Object,Concentration]),
fail.
export_ode(FunctionList,Stream):-
member(Variable = _, FunctionList),
format(Stream, 'init ~a = 0\n', [Variable]),
fail.
export_ode(FunctionList,Stream):-
member(Variable = Value, FunctionList),
format(Stream, 'd~a/dt = ~w - ~a\n', [Variable,Value,Variable]),
fail.
export_ode(_,_).
:- use_module(library(plunit)).
:- begin_tests(odefunction).
test('add_function'):-
clear_model,
command(present(x,3)),
command(present(y,2)),
command(set_parameter(k=0.00001)),
command(k*[x] for x=>y),
command(add_function(z=x+y, u=x*y)).
:- end_tests(ode).
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