forked from klavinslab/gro
-
Notifications
You must be signed in to change notification settings - Fork 0
/
reaction.cpp
55 lines (41 loc) · 1.7 KB
/
reaction.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
/////////////////////////////////////////////////////////////////////////////////////////
//
// gro is protected by the UW OPEN SOURCE LICENSE, which is summaraized here.
// Please see the file LICENSE.txt for the complete license.
//
// THE SOFTWARE (AS DEFINED BELOW) AND HARDWARE DESIGNS (AS DEFINED BELOW) IS PROVIDED
// UNDER THE TERMS OF THIS OPEN SOURCE LICENSE (“LICENSE”). THE SOFTWARE IS PROTECTED
// BY COPYRIGHT AND/OR OTHER APPLICABLE LAW. ANY USE OF THIS SOFTWARE OTHER THAN AS
// AUTHORIZED UNDER THIS LICENSE OR COPYRIGHT LAW IS PROHIBITED.
//
// BY EXERCISING ANY RIGHTS TO THE SOFTWARE AND/OR HARDWARE PROVIDED HERE, YOU ACCEPT AND
// AGREE TO BE BOUND BY THE TERMS OF THIS LICENSE. TO THE EXTENT THIS LICENSE MAY BE
// CONSIDERED A CONTRACT, THE UNIVERSITY OF WASHINGTON (“UW”) GRANTS YOU THE RIGHTS
// CONTAINED HERE IN CONSIDERATION OF YOUR ACCEPTANCE OF SUCH TERMS AND CONDITIONS.
//
// TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
//
//
#include "Micro.h"
Reaction::Reaction( float k ) : rate(k) {
}
void Reaction::add_reactant ( int i ) {
reactants.push_back ( i );
printf ( "added reactant %d\n", i );
}
void Reaction::add_product ( int i ) {
products.push_back ( i );
printf ( "added product %d\n", i );
}
void Reaction::integrate ( std::vector<Signal *> * signal_list, int i, int j, float dt ) {
float v = rate;
for ( int k = 0; k < reactants.size(); k++ ) {
v *= (*signal_list)[reactants[k]]->get(i,j);
}
for ( int k = 0; k < reactants.size(); k++ ) {
(*signal_list)[reactants[k]]->dec ( i, j, v * dt );
}
for ( int k = 0; k < products.size(); k++ ) {
(*signal_list)[products[k]]->inc ( i, j, v * dt );
}
}