123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668 |
- #include "config.h"
- #include "vegdynam.h"
- #include "growth.h"
- #include "driver.h"
- void report_fire_nfluxes(Patch& patch, double nflux_fire) {
- patch.fluxes.report_flux(Fluxes::NH3_FIRE, Fluxes::NH3_FIRERATIO * nflux_fire);
- patch.fluxes.report_flux(Fluxes::NOx_FIRE, Fluxes::NOx_FIRERATIO * nflux_fire);
- patch.fluxes.report_flux(Fluxes::N2O_FIRE, Fluxes::N2O_FIRERATIO * nflux_fire);
- patch.fluxes.report_flux(Fluxes::N2_FIRE, Fluxes::N2_FIRERATIO * nflux_fire);
- }
- int randpoisson(double expectation, long& seed) {
-
-
-
-
- double p, q, r;
- int n;
- if (expectation <= 100) {
-
- p = exp(-expectation);
- q = p;
- r=randfrac(seed);
- n = 0;
- while (q < r) {
- n++;
- p *= expectation / (double)n;
- q += p;
- }
- return n;
- }
-
-
-
- do {
- r=randfrac(seed)*8.0-4.0;
- p = exp(-r * r / 2.0);
- } while (randfrac(seed)>p);
- return max(0, (int)(r * sqrt(expectation) + expectation + 0.5));
- }
- bool establish(Patch& patch, const Climate& climate, Pft& pft) {
-
-
-
-
-
-
-
-
-
-
- if (climate.lat < -65.0)
- return false;
- if (!patch.managed && (climate.mtemp_min20 < pft.tcmin_est ||
- climate.mtemp_min20 > pft.tcmax_est ||
- climate.mtemp_max < pft.twmin_est ||
- climate.agdd5 < pft.gdd5min_est)) return false;
-
- if(patch.stand.landcover != CROPLAND) {
- if (vegmode != POPULATION && patch.par_grass_mean < pft.parff_min) return false;
- }
-
-
- if (ifdroughtlimitedestab) {
-
-
-
- if (pft.drought_tolerance > patch.soil.awcont[0]) {
- return false;
- }
- }
-
- return true;
- }
- bool survive(const Climate& climate, Pft& pft) {
-
-
-
-
-
-
- if (climate.mtemp_min20 < pft.tcmin_surv ||
- climate.mtemp_max20 - climate.mtemp_min20 < pft.twminusc) return false;
-
-
- return true;
- }
- void establishment_lpj(Stand& stand,Patch& patch) {
-
-
-
-
-
-
-
-
-
- const double K_EST=0.12;
- double fpc_tree;
- double fpc_grass;
- double est_tree;
-
- double est_pft;
-
-
- int ntree_est;
- int ngrass_est;
- bool present;
-
- Vegetation& vegetation=patch.vegetation;
-
-
- pftlist.firstobj();
- while (pftlist.isobj) {
- Pft& pft=pftlist.getobj();
- if (stand.pft[pft.id].active) {
-
- present=false;
- vegetation.firstobj();
- while (vegetation.isobj && !present) {
- Individual& indiv=vegetation.getobj();
- if (indiv.pft.id==pft.id) present=true;
- vegetation.nextobj();
- }
- if (!present) {
- if (establish(patch,stand.get_climate(),pft)) {
-
-
- Individual& indiv=vegetation.createobj(pft,vegetation);
- if (pft.lifeform==GRASS) {
- indiv.height=0.0;
- indiv.crownarea=1.0;
- indiv.densindiv=1.0;
- indiv.fpc=0.0;
- }
- }
- }
- }
- pftlist.nextobj();
- }
-
-
- fpc_tree=0.0;
- fpc_grass=0.0;
- ntree_est=0;
- ngrass_est=0;
-
- vegetation.firstobj();
- while (vegetation.isobj) {
- Individual& indiv=vegetation.getobj();
-
- if (indiv.pft.lifeform==TREE) {
- if (establish(patch, stand.get_climate(), indiv.pft)) ntree_est++;
- fpc_tree+=indiv.fpc;
- }
- else if (indiv.pft.lifeform==GRASS) {
- fpc_grass+=indiv.fpc;
- if (establish(patch, stand.get_climate(), indiv.pft)) ngrass_est++;
- }
- vegetation.nextobj();
- }
-
-
-
-
-
- est_tree=K_EST*(1.0-exp(-5.0*(1.0-fpc_tree)))*(1.0-fpc_tree);
-
- vegetation.firstobj();
- while (vegetation.isobj) {
-
- Individual& indiv=vegetation.getobj();
- if (indiv.pft.lifeform==TREE && establish(patch, stand.get_climate(), indiv.pft)) {
-
-
- est_pft=est_tree/(double)ntree_est;
- if (est_pft<0.0)
- fail("establishment_area: negative establishment rate");
-
-
- indiv.densindiv+=est_pft;
-
-
- if(!indiv.istruecrop_or_intercropgrass()) {
- indiv.report_flux(Fluxes::ESTC,
- -(indiv.pft.regen.cmass_leaf+
- indiv.pft.regen.cmass_root+indiv.pft.regen.cmass_sap+
- indiv.pft.regen.cmass_heart)*est_pft);
- #ifdef CRESCENDO_FACE
- indiv.report_flux(Fluxes::DESTC,
- -(indiv.pft.regen.cmass_leaf +
- indiv.pft.regen.cmass_root + indiv.pft.regen.cmass_sap +
- indiv.pft.regen.cmass_heart)*est_pft);
- #endif
- }
-
-
- indiv.cmass_leaf+=indiv.pft.regen.cmass_leaf*est_pft;
- indiv.cmass_root+=indiv.pft.regen.cmass_root*est_pft;
- indiv.cmass_sap+=indiv.pft.regen.cmass_sap*est_pft;
- indiv.cmass_heart+=indiv.pft.regen.cmass_heart*est_pft;
-
- indiv.max_n_storage = (indiv.cmass_leaf + indiv.cmass_root) / indiv.pft.cton_leaf_avr;
- if (!indiv.alive)
- indiv.scale_n_storage = indiv.max_n_storage * indiv.pft.cton_leaf_avr /
- ((indiv.pft.regen.cmass_leaf + indiv.pft.regen.cmass_root +
- indiv.pft.regen.cmass_sap + indiv.pft.regen.cmass_heart) * est_pft);
- }
- else if ((indiv.pft.lifeform==GRASS && indiv.pft.phenology!=CROPGREEN) &&
- establish(patch, stand.get_climate(), indiv.pft)) {
-
-
-
- est_pft=(1.0-fpc_tree-fpc_grass)/(double)ngrass_est;
-
- if (!indiv.istruecrop_or_intercropgrass()) {
- indiv.report_flux(Fluxes::ESTC,
- -(indiv.pft.regen.cmass_leaf+
- indiv.pft.regen.cmass_root)*est_pft);
- #ifdef CRESCENDO_FACE
- indiv.report_flux(Fluxes::DESTC,
- -(indiv.pft.regen.cmass_leaf +
- indiv.pft.regen.cmass_root)*est_pft);
- #endif
- }
-
- indiv.cmass_leaf+=est_pft*indiv.pft.regen.cmass_leaf;
- indiv.cmass_root+=est_pft*indiv.pft.regen.cmass_root;
-
- indiv.max_n_storage = (indiv.cmass_leaf + indiv.cmass_root) / indiv.pft.cton_leaf_avr;
- if (!indiv.alive)
- indiv.scale_n_storage = indiv.max_n_storage * indiv.pft.cton_leaf_avr /
- ((indiv.pft.regen.cmass_leaf + indiv.pft.regen.cmass_root) * est_pft);
- }
-
- allometry(indiv);
- vegetation.nextobj();
- }
- }
- void establishment_guess(Stand& stand,Patch& patch) {
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- const double SAPSIZE=0.1;
-
-
- bool present;
- double c;
- double est;
- double nsapling;
-
-
- double bminit;
- double ltor;
- int newindiv=0;
- double kest_bg;
- int i;
-
-
- int ncohort;
- const int MAXCOHORT=10;
-
- Vegetation& vegetation=patch.vegetation;
- const bool establish_active_pfts_before_management = true;
-
-
- int nwoodypfts_estab=0;
- pftlist.firstobj();
- while (pftlist.isobj) {
- Pft& pft=pftlist.getobj();
- Standpft& standpft=stand.pft[pft.id];
- bool force_planting = patch.plant_this_year && standpft.plant;
- bool est_this_year;
- if(establish_active_pfts_before_management)
- est_this_year = !patch.managed || !patch.plant_this_year && standpft.reestab;
- else
- est_this_year = !run_landcover || !patch.plant_this_year && standpft.reestab;
- if (establish(patch, stand.get_climate(), pft) && pft.lifeform == TREE && standpft.active && (est_this_year || force_planting))
- nwoodypfts_estab++;
- pftlist.nextobj();
- }
-
- pftlist.firstobj();
- while (pftlist.isobj) {
- Pft& pft=pftlist.getobj();
- Standpft& standpft=stand.pft[pft.id];
-
-
- bool init_clone = date.year == stand.clone_year && pft.landcover == stand.landcover;
-
- bool force_planting = patch.plant_this_year && standpft.plant;
- bool est_this_year;
- if(establish_active_pfts_before_management)
- est_this_year = !patch.managed || !patch.plant_this_year && standpft.reestab;
- else
- est_this_year = !run_landcover || !patch.plant_this_year && standpft.reestab;
- if (stand.pft[pft.id].active) {
- if (patch.age==0 || init_clone) {
- patch.pft[pft.id].anetps_ff_est=patch.pft[pft.id].anetps_ff;
- patch.pft[pft.id].wscal_mean_est=patch.pft[pft.id].wscal_mean;
-
- if (date.year==0 || date.year==stand.first_year || init_clone)
- patch.pft[pft.id].anetps_ff_est_initial=patch.pft[pft.id].anetps_ff;
- }
- else {
- patch.pft[pft.id].anetps_ff_est+=patch.pft[pft.id].anetps_ff;
- patch.pft[pft.id].wscal_mean_est+=patch.pft[pft.id].wscal_mean;
- }
- if (establish(patch, stand.get_climate(), pft) && (est_this_year || force_planting)) {
- if (pft.lifeform==GRASS) {
-
-
-
- present=false;
- vegetation.firstobj();
- while (vegetation.isobj && !present) {
- if (vegetation.getobj().pft.id==pft.id) present=true;
- vegetation.nextobj();
- }
- if (!present) {
-
- Individual& indiv=vegetation.createobj(pft,vegetation);
- indiv.height=0.0;
- indiv.crownarea=1.0;
- indiv.densindiv=1.0;
- indiv.fpc=1.0;
-
-
- if(pft.phenology == CROPGREEN)
- bminit = SAPSIZE * 0.01;
- else if(patch.has_disturbances() && patch.disturbed)
- bminit = SAPSIZE * patch.pft[pft.id].anetps_ff_est_initial;
- else
- bminit = SAPSIZE * patch.pft[pft.id].anetps_ff;
-
-
- ltor=patch.pft[pft.id].wscal_mean*pft.ltor_max;
-
- if(!indiv.istruecrop_or_intercropgrass())
- allocation_init(bminit,ltor,indiv);
-
- allometry(indiv);
-
- if(indiv.pft.phenology == CROPGREEN) {
- indiv.max_n_storage = CMASS_SEED / indiv.pft.cton_leaf_avr;
- indiv.scale_n_storage = indiv.max_n_storage * indiv.pft.cton_leaf_avr / CMASS_SEED;
- }
- else {
- indiv.max_n_storage = indiv.cmass_root * indiv.pft.fnstorage / indiv.pft.cton_leaf_avr;
- indiv.scale_n_storage = indiv.max_n_storage * indiv.pft.cton_leaf_avr / bminit;
- }
-
-
-
- }
- }
- else if (pft.lifeform==TREE) {
-
- if (patch.age == 0 || init_clone){
-
-
- est=pft.est_max*patcharea;
- }
- else {
-
-
- if (patch.pft[pft.id].anetps_ff>0.0 &&
- !negligible(patch.pft[pft.id].anetps_ff)) {
- double expval=max(-100.0,pft.alphar-pft.alphar/patch.pft[pft.id].anetps_ff*stand.pft[pft.id].anetps_ff_max);
- c=exp(expval)*pft.est_max*patcharea;
- }
- else
- c=0.0;
-
- if (ifbgestab)
- kest_bg=pft.kest_bg;
- else
- kest_bg=0.0;
-
-
- if (ifsme)
- est=c*(pft.kest_repr*stand.pft[pft.id].cmass_repr+kest_bg);
- else if (!negligible(stand.pft[pft.id].cmass_repr))
- est=c*(pft.kest_pres+kest_bg);
- else
- est=c*kest_bg;
- }
-
-
- est*=3.0/double(nwoodypfts_estab);
-
-
-
- if (ifstochestab && !force_planting || vegmode==INDIVIDUAL) nsapling=randpoisson(est, stand.seed);
- else nsapling=est;
- if (vegmode==COHORT) {
-
- if (patch.has_disturbances() && patch.disturbed || force_planting) {
- patch.pft[pft.id].anetps_ff_est=
- patch.pft[pft.id].anetps_ff_est_initial;
- patch.pft[pft.id].wscal_mean_est=patch.pft[pft.id].wscal_mean;
- newindiv=!negligible(nsapling / patcharea);
- }
- else if (patch.age%estinterval && !init_clone || patch.plant_this_year) {
-
-
-
- patch.pft[pft.id].nsapling+=nsapling;
- }
- else {
- if (patch.age && !init_clone) {
- nsapling+=patch.pft[pft.id].nsapling;
- patch.pft[pft.id].anetps_ff_est/=(double)estinterval;
- patch.pft[pft.id].wscal_mean_est/=(double)estinterval;
- }
- newindiv=!negligible(nsapling / patcharea);
-
- }
-
-
-
- ncohort=0;
- vegetation.firstobj();
- while (vegetation.isobj) {
- Individual& indiv=vegetation.getobj();
- if (indiv.pft.id==pft.id) ncohort++;
- vegetation.nextobj();
- }
- if (ncohort>=MAXCOHORT) newindiv=0;
-
- }
- else if (vegmode == INDIVIDUAL) {
- newindiv=(int)(nsapling+0.5);
- }
-
- if (deforest_method_type > 0) {
- bool est_disabled=false;
- switch(deforest_method_type) {
- case 1:
- if (deforest_start_year>0) {
- est_disabled=(date.get_calendar_year() >= deforest_start_year);
- patch.deforest_active=true;
- }
-
- if (est_disabled && (deforest_end_year>0)) {
-
- if (date.get_calendar_year() > deforest_end_year) {
- est_disabled=false;
- patch.deforest_active=false;
- }
- }
- break;
- case 2:
-
- if (patch.deforest_active) {
- est_disabled = true;
- }
- if (stand.get_gridcell().landcover.frac_transfer[NATURAL][NATURAL]>0) {
- if (deforest_start_year>0) {
- if (date.get_calendar_year() >= deforest_start_year) {
- est_disabled=true;
-
- patch.deforest_active=true;
- }
- } else {
- est_disabled=true;
- patch.deforest_active=true;
- }
- }
- if (est_disabled && (deforest_end_year>0)) {
-
- if (date.get_calendar_year() > deforest_end_year) {
- est_disabled=false;
- patch.deforest_active=false;
- }
- }
- break;
- default:
- est_disabled=false;
- break;
- }
- if (est_disabled) {
- newindiv=0;
- }
- }
-
-
- for (i=0;i<newindiv;i++) {
-
-
- Individual& indiv=vegetation.createobj(pft,vegetation);
- if (vegmode==COHORT)
- indiv.densindiv=nsapling/patcharea;
- else if (vegmode==INDIVIDUAL)
- indiv.densindiv=1.0/patcharea;
- indiv.age=0.0;
-
-
- bminit=SAPSIZE*patch.pft[pft.id].anetps_ff_est;
-
-
- ltor=patch.pft[pft.id].wscal_mean_est*pft.ltor_max;
-
- allocation_init(bminit,ltor,indiv);
-
- allometry(indiv);
-
- indiv.max_n_storage = indiv.cmass_sap * indiv.pft.fnstorage / indiv.pft.cton_leaf_avr;
- indiv.scale_n_storage = indiv.max_n_storage * indiv.pft.cton_leaf_avr / bminit;
-
-
-
- }
- }
- }
-
- if (vegmode!=COHORT || !(patch.age%estinterval) && !patch.plant_this_year) {
- patch.pft[pft.id].nsapling=0.0;
- patch.pft[pft.id].wscal_mean_est=0.0;
- patch.pft[pft.id].anetps_ff_est=0.0;
- }
- }
-
- pftlist.nextobj();
- }
- }
- void mortality_lpj(Stand& stand, Patch& patch, const Climate& climate, double fireprob) {
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- const double K_MORT1=0.01;
- const double K_MORT2=35.0;
-
-
-
- const double FPC_TREE_MAX=0.95;
- double fpc_dec;
- double fpc_tree;
- double fpc_grass;
- double deltafpc_tree_total;
- double mort;
-
- double mort_greffic;
-
-
- double mort_shade;
-
- double mort_fire;
- bool killed;
-
- Vegetation& vegetation=patch.vegetation;
-
- fpc_tree=0.0;
- fpc_grass=0.0;
- deltafpc_tree_total=0.0;
-
- vegetation.firstobj();
- while (vegetation.isobj) {
- Individual& indiv=vegetation.getobj();
-
- if (indiv.pft.lifeform==TREE) {
- fpc_tree+=indiv.fpc;
- if (indiv.deltafpc<0.0) indiv.deltafpc=0.0;
- deltafpc_tree_total+=indiv.deltafpc;
- }
- else if (indiv.pft.lifeform==GRASS) fpc_grass+=indiv.fpc;
- vegetation.nextobj();
- }
-
-
- vegetation.firstobj();
- while (vegetation.isobj) {
- Individual& indiv=vegetation.getobj();
-
- killed=false;
- if (!survive(climate,indiv.pft)) {
-
- indiv.kill();
- vegetation.killobj();
- killed=true;
- }
- if (!killed) vegetation.nextobj();
- }
-
-
- vegetation.firstobj();
- while (vegetation.isobj) {
- Individual& indiv=vegetation.getobj();
-
- killed=false;
- if (indiv.pft.lifeform==TREE) {
-
-
-
-
-
- mort_greffic=K_MORT1/(1.0+K_MORT2*max(indiv.anpp,0.0)/indiv.cmass_leaf/
- indiv.pft.sla);
-
-
-
- if (fpc_tree>FPC_TREE_MAX) {
- if (!negligible(deltafpc_tree_total))
- fpc_dec=(fpc_tree-FPC_TREE_MAX)*indiv.deltafpc/deltafpc_tree_total;
- else
- fpc_dec=0.0;
- mort_shade=1.0-fracmass_lpj(indiv.fpc-fpc_dec,indiv.fpc,indiv);
- }
- else
- mort_shade=0.0;
-
- if (patch.has_fires()) mort_fire=fireprob*(1.0-indiv.pft.fireresist);
- else mort_fire=0.0;
-
- mort=min(mort_greffic+mort_shade+mort_fire,1.0);
-
-
- indiv.reduce_biomass(mort, mort_fire);
- }
- else if (indiv.pft.lifeform==GRASS) {
-
- if (indiv.pft.landcover==CROPLAND)
- fpc_grass=indiv.fpc;
-
-
- if (fpc_grass>1.0-min(fpc_tree,FPC_TREE_MAX)) {
- fpc_dec=(fpc_grass-1.0+min(fpc_tree,FPC_TREE_MAX))*indiv.fpc/fpc_grass;
- mort_shade=1.0-fracmass_lpj(indiv.fpc-fpc_dec,indiv.fpc,indiv);
- }
- else
- mort_shade=0.0;
-
- if (patch.has_fires())
- mort_fire=fireprob*(1.0-indiv.pft.fireresist);
- else mort_fire=0.0;
-
- mort=min(mort_shade+mort_fire,1.0);
-
-
- indiv.reduce_biomass(mort, mort_fire);
- }
-
- if (negligible(indiv.densindiv)) {
- vegetation.killobj();
- killed=true;
- }
-
- else allometry(indiv);
- if (!killed) vegetation.nextobj();
- }
- }
- void mortality_guess(Stand& stand, Patch& patch, const Climate& climate, double fireprob) {
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- if(patch.managed_this_year)
- return;
-
-
- double mort;
-
-
- double mort_min;
-
- double mort_greff;
-
- double mort_fire;
-
-
- double frac_survive;
-
- double greff;
-
- double greff_mean;
-
- int nindiv;
- int nindiv_prev;
- int i;
- bool killed;
- const double KMORTGREFF=0.3;
-
- const double KMORTBG_LNF=-log(0.001);
-
-
-
- const double KMORTBG_Q=2.0;
-
-
-
-
-
- Vegetation& vegetation=patch.vegetation;
-
- double fpcgrasses = 0.0;
- if (stand.landcover == PASTURE || stand.landcover == URBAN || stand.landcover == PEATLAND) {
- vegetation.firstobj();
- while (vegetation.isobj) {
- Individual& indiv = vegetation.getobj();
-
- if (indiv.pft.lifeform == GRASS)
- fpcgrasses += indiv.fpc;
- vegetation.nextobj();
- }
- }
-
- if (patch.has_fires()) {
-
- if (randfrac(stand.seed)<fireprob) {
-
- vegetation.firstobj();
- while (vegetation.isobj) {
- Individual& indiv=vegetation.getobj();
-
- killed=false;
-
- mort_fire=1.0-indiv.pft.fireresist;
- if (indiv.pft.lifeform==GRASS) {
-
-
- indiv.reduce_biomass(mort_fire, mort_fire);
-
- allometry(indiv);
- }
- else {
-
- if (ifstochmort) {
-
-
-
-
- nindiv=(int)(indiv.densindiv*patcharea+0.5);
- nindiv_prev=nindiv;
- for (i=0;i<nindiv_prev;i++)
- if (randfrac(stand.seed)>indiv.pft.fireresist) nindiv--;
- if (nindiv_prev)
- frac_survive=(double)nindiv/(double)nindiv_prev;
- else
- frac_survive=0.0;
- }
-
- else frac_survive=1.0-mort_fire;
-
-
- indiv.reduce_biomass(1.0 - frac_survive, 1.0 - frac_survive);
-
-
- if (negligible(indiv.densindiv)) {
- vegetation.killobj();
- killed=true;
- }
- }
- if (!killed) vegetation.nextobj();
- }
- }
- }
-
-
- vegetation.firstobj();
- while (vegetation.isobj) {
- Individual& indiv=vegetation.getobj();
-
- killed=false;
-
- if (!survive(climate,indiv.pft)) {
-
- indiv.kill();
- vegetation.killobj();
- killed=true;
- }
- else {
- if (indiv.pft.lifeform==TREE) {
-
-
- if (!negligible(indiv.cmass_leaf))
- greff=max(indiv.anpp,0.0)/indiv.cmass_leaf/indiv.pft.sla;
- else
- greff=0.0;
-
- indiv.greff_5.add(greff);
- greff_mean = indiv.greff_5.mean();
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- mort_min=min(1.0,KMORTBG_LNF*(KMORTBG_Q+1)/indiv.pft.longevity*
- pow(indiv.age/indiv.pft.longevity,KMORTBG_Q));
-
-
-
- if (ifsmoothgreffmort)
- mort_greff=KMORTGREFF/(1.0+pow((greff_mean/(indiv.pft.greff_min)),5.0));
- else {
-
- if (greff_mean<indiv.pft.greff_min)
- mort_greff=KMORTGREFF;
- else
- mort_greff=0.0;
- }
-
-
- if (vegmode==COHORT) {
- if (indiv.crownarea*indiv.densindiv>1.0)
- mort_greff=max((indiv.crownarea*indiv.densindiv-1.0)/
- (indiv.crownarea*indiv.densindiv),mort_greff);
- }
-
- mort=mort_min+mort_greff-mort_min*mort_greff;
-
- if (mort > 1.0 || mort < 0.0)
- fail("error in mortality_guess: bad mort value");
- if (ifstochmort) {
-
-
- nindiv=(int)(indiv.densindiv*patcharea+0.5);
- nindiv_prev=nindiv;
- for (i=0;i<nindiv_prev;i++)
- if (randfrac(stand.seed)<mort) nindiv--;
- if (nindiv_prev)
- frac_survive=(double)nindiv/(double)nindiv_prev;
- else
- frac_survive=0.0;
- }
-
- else frac_survive=1.0-mort;
-
-
- indiv.reduce_biomass(1.0 - frac_survive, 0.0);
-
-
- if (negligible(indiv.densindiv)) {
- vegetation.killobj();
- killed=true;
- }
-
- else allometry(indiv);
- }
- else {
-
-
-
- if (ECEARTH) {
- double mort_shade = 0.0;
- if ((stand.landcover == PASTURE || stand.landcover == URBAN || stand.landcover == PEATLAND) && !negligible(indiv.cmass_leaf) &&
- indiv.pft.lifeform == GRASS) {
-
- const double maxlai_urban_pasture_peatland = 6.0;
- double maxfpc_urban_pasture_peatland = 1.0 - exp(-.5 * maxlai_urban_pasture_peatland);
-
- double grasslai = indiv.cmass_leaf * indiv.pft.sla;
- double grassfpc = 1.0 - exp(-.5 * grasslai);
- if (grassfpc > maxfpc_urban_pasture_peatland) {
-
-
- double fpc_dec = (grassfpc - maxfpc_urban_pasture_peatland) * grassfpc / fpcgrasses;
- mort_shade = 1.0 - fracmass_lpj(grassfpc - fpc_dec, grassfpc, indiv);
- }
-
- if (mort_shade> 0.0) {
- indiv.reduce_biomass(mort_shade, 0.0);
- allometry(indiv);
- }
- }
- }
- }
- }
-
- if (!killed) vegetation.nextobj();
- }
- }
- void fire(Patch& patch,double& fireprob) {
-
-
-
-
-
-
-
-
-
- const double MINFUEL=0.2;
-
- double litter_ag;
-
- double me_mean;
-
-
- double pm;
-
-
- double n;
-
-
- double s;
-
-
- double sm;
- double mort_fire;
- double burnt_litter;
- int p;
-
- litter_ag=0.0;
-
- for (p=0;p<npft;p++) {
- litter_ag += patch.pft[p].litter_leaf + patch.pft[p].litter_sap + patch.pft[p].litter_heart +
- patch.pft[p].litter_repr;
- }
-
- litter_ag += patch.soil.sompool[SURFSTRUCT].cmass + patch.soil.sompool[SURFMETA].cmass +
- patch.soil.sompool[SURFFWD].cmass + patch.soil.sompool[SURFCWD].cmass;
-
- if (litter_ag<MINFUEL) {
- fireprob=0.0;
- return;
- }
-
- me_mean=0.0;
-
- for (p=0;p<npft;p++) {
- me_mean += (patch.pft[p].litter_leaf + patch.pft[p].litter_sap + patch.pft[p].litter_heart +
- patch.pft[p].litter_repr) * patch.pft[p].pft.litterme / litter_ag;
- }
-
- me_mean += (patch.soil.sompool[SURFSTRUCT].cmass * patch.soil.sompool[SURFSTRUCT].litterme +
- patch.soil.sompool[SURFMETA].cmass * patch.soil.sompool[SURFMETA].litterme +
- patch.soil.sompool[SURFFWD].cmass * patch.soil.sompool[SURFFWD].litterme +
- patch.soil.sompool[SURFCWD].cmass * patch.soil.sompool[SURFCWD].litterme) / litter_ag;
-
-
-
- n=0.0;
- for (int day = 0; day < date.year_length(); day++) {
-
-
-
- pm = exp(-PI*patch.soil.dwcontupper[day] / me_mean*patch.soil.dwcontupper[day] /
- me_mean);
-
-
-
- n+=pm;
- }
-
-
- s=n/(double)date.year_length();
- sm=s-1;
- fireprob=s*exp(sm/(0.45*sm*sm*sm+2.83*sm*sm+2.96*sm+1.04));
- if (fireprob>1.0)
- fail("fire: probability of fire >1.0");
- else if (fireprob<0.001) fireprob=0.001;
-
-
- for (p=0;p<npft;p++) {
-
- mort_fire=fireprob*(1.0-patch.pft[p].pft.fireresist);
-
- burnt_litter = mort_fire*(patch.pft[p].litter_leaf + patch.pft[p].litter_sap +
- patch.pft[p].litter_heart + patch.pft[p].litter_repr);
- patch.fluxes.report_flux(Fluxes::FIREC, burnt_litter);
- patch.fluxes.report_flux(Fluxes::FIRELITTERC, burnt_litter);
- report_fire_nfluxes(patch, mort_fire * (patch.pft[p].nmass_litter_leaf +
- patch.pft[p].nmass_litter_sap + patch.pft[p].nmass_litter_heart));
-
- patch.pft[p].litter_leaf *= (1.0 - mort_fire);
- patch.pft[p].litter_sap *= (1.0 - mort_fire);
- patch.pft[p].litter_heart *= (1.0 - mort_fire);
- patch.pft[p].litter_repr *= (1.0 - mort_fire);
- patch.pft[p].nmass_litter_leaf *= (1.0 - mort_fire);
- patch.pft[p].nmass_litter_sap *= (1.0 - mort_fire);
- patch.pft[p].nmass_litter_heart *= (1.0 - mort_fire);
- }
-
- double mort_fire_struct = fireprob * (1.0 - patch.soil.sompool[SURFSTRUCT].fireresist);
- double mort_fire_meta = fireprob * (1.0 - patch.soil.sompool[SURFMETA].fireresist);
- double mort_fire_fwd = fireprob * (1.0 - patch.soil.sompool[SURFFWD].fireresist);
- double mort_fire_cwd = fireprob * (1.0 - patch.soil.sompool[SURFCWD].fireresist);
- burnt_litter = patch.soil.sompool[SURFSTRUCT].cmass * mort_fire_struct +
- patch.soil.sompool[SURFMETA].cmass * mort_fire_meta +
- patch.soil.sompool[SURFFWD].cmass * mort_fire_fwd +
- patch.soil.sompool[SURFCWD].cmass * mort_fire_cwd;
-
- patch.fluxes.report_flux(Fluxes::FIREC, burnt_litter);
- patch.fluxes.report_flux(Fluxes::FIRELITTERC, burnt_litter);
-
- patch.soil.sompool[SURFSTRUCT].cmass *= (1.0 - mort_fire_struct);
- patch.soil.sompool[SURFMETA].cmass *= (1.0 - mort_fire_meta);
- patch.soil.sompool[SURFFWD].cmass *= (1.0 - mort_fire_fwd);
- patch.soil.sompool[SURFCWD].cmass *= (1.0 - mort_fire_cwd);
-
- double nflux_fire = patch.soil.sompool[SURFSTRUCT].nmass * mort_fire_struct +
- patch.soil.sompool[SURFMETA].nmass * mort_fire_meta +
- patch.soil.sompool[SURFFWD].nmass * mort_fire_fwd +
- patch.soil.sompool[SURFCWD].nmass * mort_fire_cwd;
- report_fire_nfluxes(patch, nflux_fire);
- patch.soil.sompool[SURFSTRUCT].nmass *= (1.0 - mort_fire_struct);
- patch.soil.sompool[SURFMETA].nmass *= (1.0 - mort_fire_meta);
- patch.soil.sompool[SURFFWD].nmass *= (1.0 - mort_fire_fwd);
- patch.soil.sompool[SURFCWD].nmass *= (1.0 - mort_fire_cwd);
- }
- void disturbance(Patch& patch, double disturb_prob) {
-
-
-
-
-
-
- if (randfrac(patch.stand.seed)<disturb_prob) {
- Vegetation& vegetation = patch.vegetation;
- vegetation.firstobj();
- while (vegetation.isobj) {
- Individual& indiv = vegetation.getobj();
- indiv.kill();
- vegetation.killobj();
- }
- patch.disturbed = true;
- patch.age = 0;
- }
- else patch.disturbed = false;
- }
- void vegetation_dynamics(Stand& stand,Patch& patch) {
-
-
-
-
-
- double fireprob = 0.0;
-
-
-
- if (patch.has_fires()) {
- fire(patch,fireprob);
- }
- patch.fireprob = fireprob;
- if (vegmode == POPULATION) {
-
-
- mortality_lpj(stand, patch, stand.get_climate(), fireprob);
-
- establishment_lpj(stand,patch);
- }
- else {
-
-
-
- if (ifcentury && ifnlim && patch.stand.get_gridcell().getsimulationyear(date.year) == freenyears) {
- disturbance(patch, 1.0);
- if (patch.disturbed) {
- return;
- }
- }
-
- if (patch.has_disturbances()) {
-
- bool during_century_solvesom = ifcentury &&
- patch.stand.get_gridcell().getsimulationyear(date.year) >= patch.soil.solvesomcent_beginyr &&
- patch.stand.get_gridcell().getsimulationyear(date.year) <= patch.soil.solvesomcent_endyr;
- if (patch.age && !during_century_solvesom && date.year != stand.clone_year) {
- disturbance(patch,1.0 / distinterval);
- if (patch.disturbed) {
- return;
- }
- }
- }
-
- mortality_guess(stand, patch, stand.get_climate(), fireprob);
-
- establishment_guess(stand,patch);
- }
- patch.age++;
- }
|