Commit 11dc1360 authored by HEMERY Mathieu's avatar HEMERY Mathieu
Browse files

Reflow list_hybrid_ode

parent ad08ab3d
......@@ -357,23 +357,21 @@ write_hybrid_ode(Stream, Hybrid_original_list) :-
%
%
list_hybrid_ode(Stream,Hybrid_original_list) :- % Only MA are converted, need to do others
all_items([kind: reaction], Reactions),
list_hybrid_ode(Stream, Hybrid_original_list) :- % Only MA are converted, need to do others
all_items([kind: reaction], List_Reactions),
forall(
member(Reaction,Reactions),
member(Reaction, List_Reactions),
(
Reaction =.. [Op,_,_],
Op = (=>)
->
convert_MA(Reaction,Reactions,Hybrid_original_list,NewKinetics),
NewReaction =.. [for,NewKinetics,Reaction],
write(Stream,NewReaction),write(Stream,'.'),nl(Stream)
;
Reaction =.. [Op,_,_], % Otherwise says Singleton variable in branch: Op
Reaction =.. [Op,_,SecondPart],
convert_MA(Reaction,Reactions,Hybrid_original_list,NewKinetics),
NewReaction =.. [for,NewKinetics,SecondPart],
write(Stream,NewReaction),write(Stream,'.'),nl(Stream)
Reaction =.. [Op,_,SecondPart],
convert_MA(Reaction, List_Reactions, Hybrid_original_list, NewKinetics),
(
Op = (=>)
->
NewReaction =.. [for, NewKinetics, Reaction]
;
NewReaction =.. [for, NewKinetics, SecondPart]
),
format(Stream, "~w.~n", NewReaction)
)
).
......@@ -385,7 +383,7 @@ list_hybrid_ode(Stream,Hybrid_original_list) :- % Only MA are converted, need to
%
%
convert_MA(Reaction,Reactions,Hybrid_original_list,NewKinetics) :-
convert_MA(Reaction, List_Reactions, Hybrid_original_list, NewKinetics) :-
reaction(Reaction, [kinetics: Kinetics,reactants: Reactants,inhibitors: _, products: _]),
Kinetics =.. ['MA',K],
kinetics:eval_kinetics(Reactants, _, product(in('S'*'M', [reactants]), 'M'^'S'), Value),
......@@ -393,7 +391,7 @@ convert_MA(Reaction,Reactions,Hybrid_original_list,NewKinetics) :-
(
nb_current(dynamic_parameters,_)
->
nth1(ReactionNumber,Reactions,Reaction),
nth1(ReactionNumber,List_Reactions,Reaction),
atom_concat('k',ReactionNumber,Kdiff1),
atom_concat(Kdiff1,'_diff',Kdiff),
NewPartialKinetics = K * NewValue,
......@@ -403,6 +401,21 @@ convert_MA(Reaction,Reactions,Hybrid_original_list,NewKinetics) :-
NewKinetics = K * NewValue
).
convert_MA2(Reaction, ODESpecies, NewKinetics, Reactants, Products) :-
reaction(Reaction, [kinetics: Kinetics,reactants: Reactants,inhibitors: _, products: Products]),
Kinetics =.. ['MA',K],
kinetics:eval_kinetics(Reactants, _, product('S'*'M' in [reactants], 'M'^'S'), Value),
convert_into_hybrid(Value, ODESpecies, stoch, NewValue),!,
NewKinetics = K * NewValue,
(
nb_current(dynamic_parameters,_)
->
true
;
assertz(reaction_kinetics(Reaction,NewKinetics))
).
%! convert_into_hybrid(+Rate, +List_species, +Mode, -NewRate)
%
......@@ -446,6 +459,10 @@ convert_into_hybrid(Molecule, _List_species, _Mode, HybridMolecule) :-
!.
%! prepare_change_list
%
%
prepare_change_list(Reactions2,ODESpecies,List) :- % Only MA are converted, need to do others
findall([Reactants,Products,Kinetics],
(
......@@ -455,20 +472,6 @@ prepare_change_list(Reactions2,ODESpecies,List) :- % Only MA are converted, need
List
).
convert_MA2(Reaction,ODESpecies,NewKinetics,Reactants,Products) :-
reaction(Reaction, [kinetics: Kinetics,reactants: Reactants,inhibitors: _, products: Products]),
Kinetics =.. ['MA',K],
kinetics:eval_kinetics(Reactants, _, product('S'*'M' in [reactants], 'M'^'S'), Value),
convert_into_hybrid(Value, ODESpecies, stoch, NewValue),!,
NewKinetics = K * NewValue,
(
nb_current(dynamic_parameters,_)
->
true
;
assertz(reaction_kinetics(Reaction,NewKinetics))
).
% build_stoechiometry(+Reactant_list, +Product_list, +Species_list, -Stoechiometry)
%
......
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