Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge feature_space into master #376

Merged
merged 30 commits into from
Aug 21, 2019
Merged
Show file tree
Hide file tree
Changes from 28 commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
661feef
Incorporate space back into transp_contribution_by_group, addressing …
kpalmqui Dec 5, 2018
5a3c31f
Updated Phlox hoodii maxbio
Dec 5, 2018
5af9744
Changed default C4 grass species to BOGR and edited eind
Dec 7, 2018
749cea7
Removed switch statement (issue #204)
Jan 21, 2019
a470acb
Merge branch 'bugfix_interception' into feature_space
kpalmqui Feb 1, 2019
71b06e1
(issue #198) rescaled space if some rgroups are not established.
Feb 6, 2019
1604538
Merge branch 'master' into feature_space
kpalmqui Feb 8, 2019
33da1ad
TransRemaining issues corrected (issue #236)
Mar 15, 2019
4febca1
Moved declaration of variables outside of for loops (issue #236)
Mar 15, 2019
7d1b594
merging pull request #263
Apr 4, 2019
7a6a3e1
Merge branch 'master' into feature_space
kpalmqui May 19, 2019
c3ec9c2
Merge branch 'master' into feature_space
kpalmqui May 22, 2019
f5b7358
Merge branch 'master' into feature_space
kpalmqui Jun 12, 2019
f9264f3
Update g->pr to reflect res_extra, issue #329
kpalmqui Jun 27, 2019
18bfac0
Fix un-initialized variable `tgmod` (function `rgroup_Grow`)
dschlaep Jul 8, 2019
0e9d919
Fix float comparison in function `rgroup_ResPartIndiv`
dschlaep Jul 8, 2019
e2c03a8
Fix float comparison in function `_res_part_extra`
dschlaep Jul 8, 2019
35f66d1
Improve function `_sxw_sw_setup`: remove unnecessarily call to `SW_VP…
dschlaep Jul 8, 2019
cd3fd93
Increase mortality count only if relsize has become zero due to fire …
dschlaep Jul 10, 2019
542f571
Inputs density and pseed changed to units of # / m2 (#350)
dschlaep Jul 14, 2019
7d70c02
Merge branch 'master' into feature_space
dschlaep Jul 18, 2019
1612092
Add code comments to explain variable `_roots_active_rel`
dschlaep Jul 23, 2019
d62551e
Merge branch 'master' into feature_space
kpalmqui Jul 26, 2019
43f180f
Removed est_count from calculation of RGroup relative size, resolved …
kpalmqui Jul 26, 2019
fcec88f
Fix space redistribution (#368)
dschlaep Jul 30, 2019
a3874f4
Removed unnecessary logerror and printf statements
kpalmqui Aug 8, 2019
508bf17
Renamed baseline_min_res_req to space (pr #376)
Aug 12, 2019
13464c6
Clean up function `_sxw_sw_setup`
dschlaep Aug 19, 2019
d04ca2a
Addressed comments of PR #376
Aug 19, 2019
dc27abf
Merge remote-tracking branch 'origin/feature_space' into feature_space
Aug 19, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion ST_indivs.c
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,6 @@ void indiv_proportion_Kill(IndivType *ndv, int killType, RealF proportKilled)
// insertIndivKill(ndv->id, killType);

//kill indiv Proportionally or adjust their real size irrespective of being annual or perennial, both will have this effect
species_Update_Kills(ndv->myspecies, ndv->age);
// saving killing year real size here that is going to use for calculating next year proportional recovery
ndv->prv_yr_relsize = ndv->relsize;

Expand All @@ -238,6 +237,8 @@ void indiv_proportion_Kill(IndivType *ndv, int killType, RealF proportKilled)
if (ZERO(ndv->relsize) || LT(ndv->relsize, 0.0))
{
ndv->relsize =0.0;
// increase mortality count only if relsize has become zero due to fire
species_Update_Kills(ndv->myspecies, ndv->age);
}

#undef xF_DELTA
Expand Down
4 changes: 4 additions & 0 deletions ST_mortality.c
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,10 @@ void mort_Main( Bool *killed) {
/* annuals are not subject to these sources of mortality and instead die in _kill_annuals */
if (g->max_age == 1) continue;

/* Calculate PR at the functional group level: resources required/resources available */
g->pr = ZRO(g->res_avail) ? 0. : g->res_required / g->res_avail;
//printf("g->pr after = %f\n,Group = %s \n",RGroup[rg]->name, g->pr);/* kill plants if low resources for consecutive years */

kpalmqui marked this conversation as resolved.
Show resolved Hide resolved
/* kill plants if low resources for consecutive years */
/* increment yrs_neg_pr if pr > 1, else zero it. */
/* one good year cancels all previous bad years. */
Expand Down
9 changes: 6 additions & 3 deletions ST_params.c
Original file line number Diff line number Diff line change
Expand Up @@ -909,10 +909,12 @@ static void _rgroup_add1( char name[], RealF space, RealF density,
RGroup[rg]->grp_num = rg;
RGroup[rg]->max_stretch = (IntS) stretch;
RGroup[rg]->max_spp_estab = (IntS) estab;
RGroup[rg]->max_density = density;
RGroup[rg]->max_per_sqm = density / Globals.plotsize;
// input of `density` is in units of [# / m2]; convert to units of [# / plot]
RGroup[rg]->max_density = density * Globals.plotsize; // density per plot
RGroup[rg]->max_per_sqm = density; // density per square-meter
RGroup[rg]->use_mort = itob(mort);
RGroup[rg]->slowrate = slow;
RGroup[rg]->space = space;
RGroup[rg]->min_res_req = space;
RGroup[rg]->est_annually = itob(estann);
RGroup[rg]->startyr = styr;
Expand Down Expand Up @@ -1107,7 +1109,8 @@ static void _species_init( void) {
Species[sp]->received_prob = 0;
Species[sp]->cohort_surv = cohort;
Species[sp]->var = var;
Species[sp]->pseed = pseed / Globals.plotsize;
// input of `pseed` is in units of [# / m2]; convert to units of [# / plot]
Species[sp]->pseed = pseed * Globals.plotsize;
/* Species[sp]->ann_mort_prob = (age > 0)
? -log(cohort)/age
: 0.0;
Expand Down
49 changes: 36 additions & 13 deletions ST_resgroups.c
Original file line number Diff line number Diff line change
Expand Up @@ -100,10 +100,6 @@ void rgroup_PartResources(void) {
LogError(logfp, LOGWARN, "RGroup %s : res_avail is Zero and res_required > 0", g->name);
}

/* Calculate PR at the functional group level: resources required/resources available */
g->pr = ZRO(g->res_avail) ? 0. : g->res_required / g->res_avail;
//printf("g->pr = %f\n,Group = %s \n",RGroup[rg]->name, g->pr);

/* If relsize>0 and individuals are established, reset noplants from TRUE to FALSE */
if (GT(getRGroupRelsize(rg), 0.))
noplants = FALSE;
Expand Down Expand Up @@ -257,7 +253,7 @@ static void _res_part_extra(RealF extra, RealF size[]) {
continue;

/* Check to avoid dividing by 0 */
if (sum_size == 0.)
if (ZRO(sum_size))
req_prop = 0.;

/* Calculate proportional biomass of each group out of the total biomass
Expand All @@ -267,9 +263,10 @@ static void _res_part_extra(RealF extra, RealF size[]) {

/* If the group can use extra resources, divide out extra based on
* proportional biomass */
if (g->use_extra_res)
if (g->use_extra_res) {
g->res_extra = req_prop * extra;

g->res_avail += g->res_extra;
}
/* If the group can't use extra resources, set res_extra to 0 */
else
g->res_extra = 0.;
Expand Down Expand Up @@ -384,7 +381,7 @@ void rgroup_ResPartIndiv(void) {

/* If individuals already have the resources they require do
* not assign extra */
if (ndv->res_avail == ndv->res_required) {
if (GE(ndv->res_avail, ndv->res_required)) {
ndv->res_extra = 0.0;
//printf("ndv->res_extra = %f\n", ndv->res_extra);
kpalmqui marked this conversation as resolved.
Show resolved Hide resolved
}
Expand Down Expand Up @@ -471,8 +468,7 @@ void rgroup_Grow(void) {
continue;

/* Modify growth rate by temperature calculated in Env_Generate() */
if (s->tempclass != NoSeason)
tgmod = Env.temp_reduction[s->tempclass];
tgmod = (s->tempclass == NoSeason) ? 1. : Env.temp_reduction[s->tempclass];

/* Now increase size of the individual plants of current species */
ForEachIndiv(ndv, s) {
Expand Down Expand Up @@ -616,6 +612,8 @@ void rgroup_Establish(void) {
/*------------------------------------------------------*/

IntS i, num_est; /* number of individuals of sp. that establish*/
RealF
used_space = 0; /* sums up all of the space that is currently used */
GrpIndex rg;
SppIndex sp;
GroupType *g;
Expand All @@ -634,6 +632,7 @@ void rgroup_Establish(void) {
continue;

g->regen_ok = TRUE; /* default */
g->min_res_req = g->space; /* reset min_res_req, if it was modified last year */

if (Globals.currYear < RGroup[rg]->startyr) {
g->regen_ok = FALSE;
Expand All @@ -652,7 +651,6 @@ void rgroup_Establish(void) {
if (Species[sp]->max_age == 1) {
//printf("Globals.currYear = %hu, call to _add_annuals sp=%d Species[sp]->lastyear_relsize : %.5f \n", Globals.currYear, sp, Species[sp]->lastyear_relsize);
num_est = _add_annuals(rg, sp, Species[sp]->lastyear_relsize);
// printf("g->seedbank annuals=%d \n",g->seedbank);
}

/* Establishment for species that belong to perennial functional groups*/
Expand All @@ -670,8 +668,32 @@ void rgroup_Establish(void) {

} /* end ForEachGroupSpp() */
}

// sum up min_res_req in case we need to redistribute min_res_req
if (g->est_count > 0) {
used_space += g->min_res_req;
} else {
// this group needs no resources because it is not established.
g->min_res_req = 0;
}
} /* end ForEachGroup() */

// If there is unused (or too much used) space we need to redistribute
if (!EQ(used_space, 1.0)) {
//printf("\nYear %d: used_space = %f\n", Globals.currYear, used_space);

kpalmqui marked this conversation as resolved.
Show resolved Hide resolved
ForEachGroup(rg) {
g = RGroup[rg];
/* Redistribute the unused (or too much used) space to all groups that
are established */
if (g->est_count > 0) {
//printf("%s before: %f -- ", g->name, g->min_res_req);
kpalmqui marked this conversation as resolved.
Show resolved Hide resolved
g->min_res_req = g->min_res_req / used_space;
}
}
}
}

/***********************************************************/
void rgroup_IncrAges(void)
{
Expand Down Expand Up @@ -717,17 +739,18 @@ void rgroup_IncrAges(void)
/* Sums relsize for all individuals in all species in RGroup rg.
param rg = RGroup index.
Return: RGroup relsize. */

RealF getRGroupRelsize(GrpIndex rg){
Int n;
SppIndex sp;
double sum = 0.0;

ForEachEstSpp( sp, rg, n){
sum += getSpeciesRelsize(sp);
sum += getSpeciesRelsize(sp);
}

if(RGroup[rg]->est_count > 0){
return (RealF) sum / (RealF) RGroup[rg]->est_count;
return (RealF) sum;
kpalmqui marked this conversation as resolved.
Show resolved Hide resolved
} else {
return 0;
}
Expand Down
7 changes: 4 additions & 3 deletions ST_structs.h
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ struct species_st {
estabs, /* number of individuals established in iter */
*seedprod, /* annuals: array of previous years' seed production (size = viable_yrs)*/
seedbank,
pseed;
pseed; /* average number of seeds produced by annual species per 1g of biomass, per 1m^2 and per year (internally re-calculated as seeds per 1 g biomass per plot and per year) */
RealF lastyear_relsize, /* relsize from the previous year, used for annual establishment */
extragrowth, /* amt of superfluous growth from extra resources */
received_prob, //the chance that this species received seeds this year... only applicable if using seed dispersal and gridded option
Expand Down Expand Up @@ -180,9 +180,10 @@ struct resourcegroup_st {
grazingfrq, /* grazing effect on group at this frequency: <1=prob, >1=# years */
grazingfreq_startyr;/* start year for grazing frequency*/
SppIndex *species; /*list of spp belonging to this grp*/
RealF min_res_req, /* input from table */
RealF space, /* input from table */
min_res_req, /* input from table, rescaled if an rgroup is not established */
kpalmqui marked this conversation as resolved.
Show resolved Hide resolved
max_density, /* number of mature plants per plot allowed */
max_per_sqm, /* convert density and plotsize to max plants/m^2 */
max_per_sqm, /* density of mature plants in units of plants / m^2 */
max_bmass, /* sum of mature biomass for all species in group */
killfreq, /* kill group at this frequency: <1=prob, >1=# years */
ignition, /* cheatgrass biomass (g/m2) that triggers potential ignition of a wildfire */
Expand Down
Loading