Ejemplo n.º 1
0
void Lattice::checkEvent(int ii,int jj)
{
    uniform_real_distribution<double> unif(0,1);
    double r = unif(mt_rand);
    Site* S = &lat[ii][jj];
    if(S->isEmpty() || S->isDeveloped())
    {
        return;
    }
    double trueDeathRate = getDeathRate(*S);
    if( r < trueDeathRate*dt)
    {
        S->die();
    }
    else if(r < (trueDeathRate + birthRate[S->getSpecies()])*dt ) //if roll birth
    {
        int r2 = int(unif(mt_rand)*numNeighbors);
        S->growIntoNeighbor(r2);
    }
//    else if( S->getSpecies() == parasite && r <  ( trueDeathRate + birthRate[S->getSpecies()] + parasiteBirthIncrement )*dt ) //if roll colonization into grass site TODO: replace getspecies with parasite. one less function call.
//    {
//        int r2 = int(unif(mt_rand)*numNeighbors);
//        if(S->getNeighbor(r2)->getSpecies()==grass)
//        {
//            S->growIntoNeighbor(r2);
//        }
//    }
    
}
Ejemplo n.º 2
0
double Lattice::getDeathRate(Site S) //TODO: move into site
{
    double rate = 0;
    if( !(S.isEmpty() || S.isDeveloped()))
       {
           rate = deathRate[S.getSpecies()];
           if(S.getSpecies()==grass)
           {
               for ( int i  = 0; i< numNeighbors; i++)
               {
                   if(S.getNeighbor(i)->getSpecies()==parasite)
                   {
                       rate = rate + parasiteOnGrassDeathIncrement;
                   }
                   else if(S.getNeighbor(i)->getSpecies()==forb)
                   {
                       rate = rate + forbOnGrassDeathIncrement;
                   }
               }
           }
       }
    return rate;
}