forked from st35/frustration-ODEs-modeling
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSteadystate_Methods.hpp
63 lines (58 loc) · 1.18 KB
/
Steadystate_Methods.hpp
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
56
57
58
59
60
61
62
63
int Is_Valid(const std::vector<double> x)
{
int flag = 0;
for(int i = 0; i < x.size(); i++)
{
if(std::abs(x[i]) < 1e-16)
{
flag = 1;
}
if(x[i] < 0.0)
{
flag = 1;
}
if(std::isnan(x[i]))
{
flag = 1;
}
}
return(flag);
}
void Find_Steadystates(RegNetwork R, std::vector<std::vector<double>> P, std::string inicond_filename, std::vector<int> &numstablestates, std::ofstream *f, std::ofstream *g)
{
std::vector<std::vector<double>> I;
std::vector<double> x;
for(int i = 0; i < R.numnodes; i++)
{
x.push_back(0.0);
}
I = Read_Initial_Conditions_Alt(R, inicond_filename);
int source, target, statecount = 0;
for(int i = 0; i < P.size(); i++)
{
for(int j = 0; j < I.size(); j++)
{
for(int k = 0; k < R.numnodes; k++)
{
x[k] = I[j][k];
}
boost::numeric::odeint::integrate(odesystem{R, P[i]}, x, 0.0, 500.0, 0.1);
if(Is_Valid(x) == 1)
{
continue;
}
(*f) << i << " " << numstablestates[i] << " ";
for(int k = 0; k < R.numnodes; k++)
{
(*f) << x[k] << " ";
}
(*f) << "\n";
(*g) << i << " " << numstablestates[i] << " ";
for(int k = 0; k < R.numnodes; k++)
{
(*g) << I[j][k] << " ";
}
(*g) << "\n";
}
}
}