/********************************************************************************/ /* */ /* This function computes the neighbourhood weights for events */ /* */ /********************************************************************************/ void death_weights(current) struct individual *current; { struct individual *focal, *neighbour; double x1,y1,x2,y2; int i,j; int num=0; double effect[2], norm[2]; double distance; double weighting=0.0; double sum=0.0; int m,n; int spp1, spp2; num=0; focal=current; { num++; weighting=0.0; x1 = focal->xpos; y1 = focal->ypos; spp1 = focal->species; extent-=focal->death_event; death_sum-=focal->death_event; extent-=focal->birth_event; birth_sum-=focal->birth_event; extent-=focal->move_event; /* move_sum-=focal->move_event;*/ extent-=focal->attack_event; neighbour = start; { while(neighbour!=NULL) { x2 = neighbour->xpos; y2 = neighbour->ypos; spp2 = neighbour->species; /***Compute the pair distance allowing for periodic boundaries***/ distance = get_distance(x1,y1, x2,y2, wfoormax[spp2][spp1]); /***Compute neighbourhood effect on death***/ if(neighbour != focal) if(distance<=wfoormax[spp2][spp1]) { num++; /***Bivariate normal competition kernel***/ if(wfoo_kernel == 1) { norm[1] = 2.0 * Pi * wfoostdv[spp2][spp1] * wfoostdv[spp2][spp1]; effect[1] = distance/wfoostdv[spp1][spp2]; effect[1]*= effect[1]; effect[1] = exp(-0.5 * effect[1]); effect[1]/=norm[1]; } /***Flat kernel***/ else if(wfoo_kernel == 2) { effect[0] = 1.0/(Pi * wfoormax[spp1][spp2] * wfoormax[spp1][spp2]); } neighbour->attack_event-= effect[1]*alpha[spp2][spp1]; extent-= effect[1]*alpha[spp2][spp1]; neighbour->death_event-=effect[1]*D2[spp2][spp1]; extent-=effect[1]*D2[spp2][spp1]; death_sum-=effect[1]*D2[spp2][spp1]; /* fprintf(weight,"x1: %lf y1: %lf x2: %lf y2: %lf distance: %lf effect: %lf\n", x1,y1, x2,y2, distance, effect); fflush(weight);*/ } neighbour = neighbour->next; } } } }