Skip to content

Commit

Permalink
rcontroll 0.2.0.9020: CPP: TROLL version 4.0.1 following discussion w…
Browse files Browse the repository at this point in the history
…ith IM, updating treefall time normalisation
  • Loading branch information
sylvainschmitt committed Jul 12, 2024
1 parent 5bf745b commit f250ab6
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 4 deletions.
2 changes: 1 addition & 1 deletion .vscode/.env
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ R_PDFVIEWER=/usr/bin/xdg-open
R_PLATFORM=x86_64-pc-linux-gnu
R_PRINTCMD=/usr/bin/lpr
R_RD4PDF=times,inconsolata,hyper
R_SESSION_TMPDIR=/tmp/Rtmpp6aUTh
R_SESSION_TMPDIR=/tmp/Rtmp1nQbLw
R_SHARE_DIR=/usr/share/R/share
R_STRIP_SHARED_LIB=strip --strip-unneeded
R_STRIP_STATIC_LIB=strip --strip-debug
Expand Down
4 changes: 4 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# rcontroll 0.2.0.9020

- CPP: TROLL version 4.0.1 following discussion with IM, updating treefall time normalisation

# rcontroll 0.2.0.9019

- CPP: adding back Rseed from V3 for random
Expand Down
2 changes: 1 addition & 1 deletion R/zzz.R
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ NULL
dir.create(tmp_dir)
options(list(
rcontroll.tmp = tmp_dir,
rcontroll.troll = "TROLL version 4.0.0"
rcontroll.troll = "TROLL version 4.0.1"
))
invisible()
}
Expand Down
6 changes: 4 additions & 2 deletions src/troll_rcpp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2275,6 +2275,8 @@ void Tree::Fluxh(int h,float &PPFD, float &VPD, float &Tmp, float &leafarea_laye
if (carbon_starv <= 0.0 && t_NPP <= 0.0) dr+=1.0/timestep; // newIM 2021: carbon starvation occurs when the carbon stocks has been completly depleted, and carbon_starv represents t_carbon_storage (while it represents t_NPPneg when _LA_regulation==0)
}

return dr*timestep;

}
#endif

Expand Down Expand Up @@ -7484,7 +7486,7 @@ if (_WATER_RETENTION_CURVE==1) {
// _BASICTREEFALL: just dependent on height threshold + random uniform distribution
float angle = 0.0, c_forceflex = 0.0;
if(_BASICTREEFALL){
c_forceflex = gsl_rng_uniform(gslrand)*T[site].t_height; // probability of treefall = 1-t_Ct/t_height, compare to genrand2(): genrand2() < 1 - t_Ct/t_height, or: genrand2() > t_Ct/t_height
c_forceflex =( 1- (1-gsl_rng_uniform(gslrand))/(12*timestep))*T[site].t_height ; // probability of treefall = 1-t_Ct/t_height, compare to genrand2(): genrand2() < 1 - t_Ct/t_height, or: genrand2() > t_Ct/t_height
angle = float(twoPi*gsl_rng_uniform(gslrand)); // random angle
}
// above a given stress threshold the tree falls
Expand Down Expand Up @@ -7528,7 +7530,7 @@ if (_WATER_RETENTION_CURVE==1) {
for(int site=0;site<sites;site++){
if(T[site].t_age){
float height_threshold = T[site].t_height/T[site].t_mult_height; // since 2.5: a tree's stability is defined by its species' average height, i.e. we divide by the intraspecific height multiplier to account for lower stability in quickly growing trees; otherwise slender, faster growing trees would be treated preferentially and experience less secondary treefall than more heavily built trees
if(2.0*T[site].t_hurt*gsl_rng_uniform(gslrand) > height_threshold) { // check whether tree dies: probability of death is 1.0-0.5*t_height/t_hurt, so gslrand <= 1.0 - 0.5 * t_height/t_hurt, or gslrand > 0.5 * t_height/t_hurt; modified in v.2.5: probability of death is 1.0 - 0.5*t_height/(t_mult_height * t_hurt), so the larger the height deviation (more slender), the higher the risk of being thrown by another tree
if(2.0*T[site].t_hurt*(1-(1-gsl_rng_uniform(gslrand))/(12*timestep)) > height_threshold) { // check whether tree dies: probability of death is 1.0-0.5*t_height/t_hurt, so gslrand <= 1.0 - 0.5 * t_height/t_hurt, or gslrand > 0.5 * t_height/t_hurt; modified in v.2.5: probability of death is 1.0 - 0.5*t_height/(t_mult_height * t_hurt), so the larger the height deviation (more slender), the higher the risk of being thrown by another tree
if(p_tfsecondary > gsl_rng_uniform(gslrand)){ // check whether tree falls or dies otherwise
float angle = float(twoPi*gsl_rng_uniform(gslrand)); // random angle
T[site].Treefall(angle);
Expand Down

0 comments on commit f250ab6

Please sign in to comment.