To receive notifications about scheduled maintenance, please subscribe to the mailing-list gitlab-operations@sympa.ethz.ch. You can subscribe to the mailing-list at https://sympa.ethz.ch

Commit 22881476 authored by ahuegli's avatar ahuegli

p1

parent c7494708
......@@ -125,26 +125,41 @@ void SSA_CPU::operator()()
// - compute propensities a[0], a[1], .., a[3] and a0
// - use values Sa and Sb, and values stored in k[4], check initialization in SSA_CPU.hpp
a[0] = 0.0;
a[1] = 0.0;
a[2] = 0.0;
a[3] = 0.0;
a[0] = k[0]*Sa;
a[1] = k[1]*Sb;
a[2] = k[2]*Sa*Sb;
a[3] = k[3];
double a0 = a[0]+a[1]+a[2]+a[3];
double a0 = 0.0;
// TODO: Task 1a) (STEP 1)
// - sample tau using the inverse sampling method and increment time, use uniform random numbers initialized in r48
time += 0.1; // 0.1 is a dummy
time += -1.0 * log(r48[iter*s]) / a0;
// TODO: Task 1a) (STEP 2)
// - sample a reaction, use uniform random numbers initialized in r48
double cdf = 0.0;
double rand = r48[iter*s+1];
double prob;
int r = 1;
for(;r <= m; ++r)
{
prob = a[r-1]/a0;
if( cdf + prob > rand)
break;
cdf += prob;
}
// TODO: Task 1a) (STEP 3)
// - increment Sa, Sb
Sa += reactionChannels[(r-1)*n + 0];
Sb += reactionChannels[(r-1)*n + 1];
Sa += 0;
Sb += 0;
iter++;
}
......
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