From f250ab60751b56ca70f3f15479cecf964a73dbdd Mon Sep 17 00:00:00 2001 From: Sylvain Schmitt Date: Fri, 12 Jul 2024 15:51:17 +0200 Subject: [PATCH] rcontroll 0.2.0.9020: CPP: TROLL version 4.0.1 following discussion with IM, updating treefall time normalisation --- .vscode/.env | 2 +- NEWS.md | 4 ++++ R/zzz.R | 2 +- src/troll_rcpp.cpp | 6 ++++-- 4 files changed, 10 insertions(+), 4 deletions(-) diff --git a/.vscode/.env b/.vscode/.env index 918faa6..fd0c600 100755 --- a/.vscode/.env +++ b/.vscode/.env @@ -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 diff --git a/NEWS.md b/NEWS.md index 1039378..3229276 100755 --- a/NEWS.md +++ b/NEWS.md @@ -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 diff --git a/R/zzz.R b/R/zzz.R index ba7cf7d..5baddb8 100755 --- a/R/zzz.R +++ b/R/zzz.R @@ -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() } diff --git a/src/troll_rcpp.cpp b/src/troll_rcpp.cpp index ebce612..284d062 100755 --- a/src/troll_rcpp.cpp +++ b/src/troll_rcpp.cpp @@ -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 @@ -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 @@ -7528,7 +7530,7 @@ if (_WATER_RETENTION_CURVE==1) { for(int site=0;site 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);