//double mu = 1.0e-1;
// initialize virus
- VirusSpecies s1("I");
- species.push_back(&s1);
+ VirusSpecies *s1 = new VirusSpecies("I");
+ species.push_back(s1);
if (r.importState) {
importState(r); // <infile>.st
for (size_t i=0; i<r.initPop.size(); i++) {
Virus V(H, r.mu, r.initPop[i]);
unsigned int N = (unsigned int) r.n * r.initFrac[i];
- s1.pop[V] = N;
- s1.count += N;
+ s1->pop[V] = N;
+ s1->count += N;
}
}
else {
- s1.count = r.n;
- s1.pop[Virus(H,r.mu)] = s1.count; // default mu = 6.0e-5
+ s1->count = r.n;
+ s1->pop[Virus(H,r.mu)] = s1->count; // default mu = 6.0e-5
}
Species_parray print_spec;
- print_spec.push_back(&s1);
+ print_spec.push_back(s1);
- if (r.useEpitope) importEpitope(r,species,reactions,&s1,print_spec); // <infile>.ep
+ if (r.useEpitope) importEpitope(r,species,reactions,s1,print_spec); // <infile>.ep
// V -> V + V'
VirusReaction* r1 = new VirusReaction(r.rate_s); // s_k
//r1->rate_constant = 1.5;
r1->H = H;
- r1->V = &s1;
+ r1->V = s1;
reactions.push_back(r1);
// V -> 0
VirusDeathReaction* r2 = new VirusDeathReaction(r.rate_u); // u
//r2->rate_constant = 0.5;
r2->H = H;
- r2->V = &s1;
+ r2->V = s1;
reactions.push_back(r2);
simulate(reactions, species, r.t_end, r.max_steps, r.sample_interval, print_spec);
gsl_rng_free(rnd); //Free up memory from random number generator
+
+ // clean up reaction array
+ for (Rxn_parray::iterator it = reactions.begin(),
+ end = reactions.end();
+ it != end; ++it) {
+ delete (*it);
+ }
+ reactions.clear();
+
+ // clean up species array
+ for (Species_parray::iterator it = species.begin(),
+ end = species.end();
+ it != end; ++it) {
+ delete (*it);
+ }
+ species.clear();
+
}