Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Lifeware
biocham
Commits
e7e44be2
Commit
e7e44be2
authored
Nov 18, 2019
by
HEMERY Mathieu
Browse files
Rewrite print_static_alpha
parent
de8aab01
Changes
1
Hide whitespace changes
Inline
Side-by-side
hybrid.pl
View file @
e7e44be2
...
...
@@ -520,7 +520,7 @@ print_event(Reactions_data, Stoch_list, Hybrid_reactants_list, Constraints_list,
% 1. Build Starting String for the event.
format
(
Stream
,
"add_event(Time > tau,~n"
,[]),
print_static_alpha
(
Number_of_alpha
,
Reactions_data
,
1
,
Stream
),
print_static_alpha
(
Stream
),
format
(
Stream
,
"tau = (if alpha_sum <= 0 then inf else Time+((-1 / alpha_sum) * log(random_float))/~w),~n"
,
[
Rate
]),
...
...
@@ -577,55 +577,42 @@ print_constraints_parameters_sr([N|Tail], Stream) :-
print_constraints_parameters_sr
(
Tail
,
Stream
).
%! print_static_alpha(+Stream)
%
% write the expression of the various alphas and their sum
print_static_alpha
(
Stream
)
:-
nb_getval
(
reactions
,
Reactions
),
print_static_alpha
(
Reactions
,
1
,
Stream
).
print_static_alpha
(
Number_of_alpha
,
Reactions_data
,
Current_count
,
Stream
)
:-
write
(
Stream
,
' alpha'
),
write
(
Stream
,
Current_count
),
write
(
Stream
,
' = '
),
nb_getval
(
reactions
,
Reactions
),
nth1
(
Current_count
,
Reactions
,
Reaction
),
reaction_kinetics
(
Reaction
,
NewKinetics
),
print_static_alpha
([
Reaction
|
Tail_Reactions
],
Counter
,
Stream
)
:-
reaction_kinetics
(
Reaction
,
NewKinetics
),
(
nb_current
(
dynamic_parameters
,
_
)
nb_current
(
dynamic_parameters
,
_
)
->
atom_concat
(
'k'
,
Current_count
,
Kdiff1
),
atom_concat
(
Kdiff1
,
'_diff'
,
Kdiff
),
TrueKinetics
=
(
1
-
Kdiff
)
*
NewKinetics
,
write
(
Stream
,
TrueKinetics
)
atomic_list_concat
([
'k'
,
Counter
,
'_diff'
],
Kdiff
),
PrintedKinetics
=
(
1
-
Kdiff
)
*
NewKinetics
;
write
(
Stream
,
NewKinetics
)
),
write
(
Stream
,
','
),
nl
(
Stream
),
(
Current_count
<
Number_of_alpha
->
Next_count
is
Current_count
+
1
,
print_static_alpha
(
Number_of_alpha
,
Reactions_data
,
Next_count
,
Stream
)
;
write
(
Stream
,
' alpha_sum = '
),
length
(
Reactions_data
,
NumberOfReactions
),
write
(
Stream
,
'alpha1'
),
(
PrintedKinetics
=
NewKinetics
),
format
(
Stream
,
" alpha~d = ~w,~n"
,
[
Counter
,
PrintedKinetics
]),
Counterp
is
Counter
+
1
,
print_static_alpha
(
Tail_Reactions
,
Counterp
,
Stream
).
print_static_alpha
([],
Counter
,
Stream
)
:-
format
(
Stream
,
" alpha_sum = "
,
[]),
N_alpha
is
Counter
-
1
,
numlist
(
1
,
N_alpha
,
NumListReac
),
print_alpha_sr
(
NumListReac
,
Stream
),
format
(
Stream
,
",~n"
,
[]).
print_alpha_sr
([
N
],
Stream
)
:-
format
(
Stream
,
"alpha~d"
,
[
N
]),!.
print_alpha_sr
([
N
|
Tail
],
Stream
)
:-
format
(
Stream
,
"alpha~d + "
,
[
N
]),
print_alpha_sr
(
Tail
,
Stream
).
NumberOfReactions
=
1
->
write
(
Stream
,
','
),
nl
(
Stream
)
;
assertz
(
alpha_counter
(
1
)),
repeat
,
retract
(
alpha_counter
(
Counter
)),
NewCounter
is
Counter
+
1
,
write
(
Stream
,
' + alpha'
),
write
(
Stream
,
NewCounter
),
assertz
(
alpha_counter
(
NewCounter
)),
NewCounter
=
NumberOfReactions
,
!,
retractall
(
alpha_counter
(
_
)),
write
(
Stream
,
','
),
nl
(
Stream
)
)
).
convert_kinetics
(
Kinetics1
*
Kinetics2
,
NewKinetics1
*
NewKinetics2
)
:-
!,
...
...
@@ -1264,7 +1251,7 @@ print_dynamic_event(SortedSpecies,Reactions_data, HybridDynamicReactants,MaxPart
% 1. Build Starting String for the event.
write
(
Stream
,
'add_event(Time > tau,'
),
nl
(
Stream
),
print_dynamic_event_condition
(
SortedSpecies
,
HybridDynamicReactants
,
1
,
PropTresh
,
MaxParticleChange
,
Stream
),
print_static_alpha
(
Number_of_alpha
,
Reactions_data
,
1
,
Stream
),
print_static_alpha
(
Stream
),
write
(
Stream
,
' delta_t = (if alpha_sum <= 0 then step_size else (-1 / alpha_sum) * log(random_float)),'
),
nl
(
Stream
),
write
(
Stream
,
' tau = Time+delta_t/'
),
write
(
Stream
,
Rate
),
write
(
Stream
,
','
),
nl
(
Stream
),
write
(
Stream
,
' ran = random_float,'
),
nl
(
Stream
),
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment