123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253 |
- #include "config.h"
- #include "canexch.h"
- #include "driver.h"
- #include "q10.h"
- #include "bvoc.h"
- #include "ncompete.h"
- #include <assert.h>
- namespace {
- const double N0 = 7.15 * 0.001;
- LookupQ10 lookup_tau(0.57, 2600.0);
- LookupQ10 lookup_ko(1.2, 3.0e4);
- LookupQ10 lookup_kc(2.1, 30.0);
- }
- void interception(Patch& patch,Climate& climate) {
-
-
- double scap;
- double fwet;
- double pet;
- pet=climate.eet*PRIESTLEY_TAYLOR;
-
- Vegetation& vegetation=patch.vegetation;
- patch.intercep=0.0;
- if (date.day == 0) {
- for (int d = 0; d < date.year_length(); d++) {
- patch.dintercep[d] = 0.0;
- }
- }
-
- vegetation.firstobj();
- while (vegetation.isobj) {
- Individual& indiv=vegetation.getobj();
-
- if (!negligible(pet)) {
- if (indiv.alive) {
-
- scap=climate.prec*min(indiv.lai_indiv_today()*indiv.pft.intc,0.999);
-
- fwet=min(scap/pet,patch.fpc_rescale);
-
- indiv.intercep=fwet*pet*indiv.fpc;
- patch.intercep+=indiv.intercep;
- }
- else {
- indiv.intercep=0.0;
- }
- }
- else {
- indiv.intercep=0.0;
- patch.intercep=0.0;
- }
-
- vegetation.nextobj();
- }
-
- patch.eet_net_veg=max(climate.eet-patch.intercep,0.0);
-
- patch.aintercep+=patch.intercep;
- patch.mintercep[date.month]+=patch.intercep;
- patch.dintercep[date.day] = patch.intercep;
- }
- void fpar(Patch& patch) {
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- const double VSTEP=2.0;
- const double PHEN_GROWINGSEASON=0.5;
-
- double plai;
- double plai_leafon;
-
- double plai_layer;
- double plai_leafon_layer;
-
- double plai_grass;
- double plai_leafon_grass;
-
- double flai;
- double fpar_layer_top;
- double fpar_leafon_layer_top;
-
- double fpar_layer_bottom;
- double fpar_leafon_layer_bottom;
- double fpar_grass;
- double fpar_leafon_grass;
-
- double fpar_ff;
- double fpar_leafon_ff;
-
- double frac;
-
-
- double atoh;
- double height_veg;
- int toplayer;
- int layer;
- double lowbound;
- double highbound;
- double fpar_min;
- double par_grass;
- double phen_veg;
-
- double fpar_uptake_layer;
- double fpar_uptake_leafon_layer;
-
- Vegetation& vegetation=patch.vegetation;
-
- const Climate& climate = patch.get_climate();
- if (vegmode==POPULATION) {
-
-
- vegetation.firstobj();
- while (vegetation.isobj) {
- Individual& indiv=vegetation.getobj();
-
- indiv.fpar=indiv.fpc_today();
- indiv.fpar_leafon=indiv.fpc * indiv.growingseason();
- vegetation.nextobj();
- }
- }
- else {
-
-
-
- plai=0.0;
- plai_leafon=0.0;
- plai_grass=0.0;
- plai_leafon_grass=0.0;
- phen_veg=0.0;
- height_veg=0.0;
-
- vegetation.firstobj();
- while (vegetation.isobj) {
- Individual& indiv=vegetation.getobj();
-
- if (indiv.growingseason()) {
- indiv.fpar=0.0;
- indiv.fpar_leafon=0.0;
- if (indiv.height>height_veg) height_veg=indiv.height;
- plai_leafon+=indiv.lai;
- if (indiv.pft.lifeform==GRASS) {
- plai_leafon_grass+=indiv.lai;
- plai_grass+=indiv.lai_today();
- }
-
- phen_veg+=indiv.lai_today();
- }
- vegetation.nextobj();
- }
-
-
- if (!negligible(plai_leafon))
- phen_veg/=plai_leafon;
- else
- phen_veg=1.0;
-
- toplayer=(int)(height_veg/VSTEP-0.0001);
-
- plai=0.0;
- plai_leafon=0.0;
-
- fpar_layer_bottom=1.0;
- fpar_leafon_layer_bottom=1.0;
- for (layer=toplayer;layer>=0;layer--) {
- lowbound=(double)layer*VSTEP;
- highbound=lowbound+VSTEP;
-
- fpar_layer_top=fpar_layer_bottom;
- fpar_leafon_layer_top=fpar_leafon_layer_bottom;
- plai_layer=0.0;
- plai_leafon_layer=0.0;
-
- vegetation.firstobj();
- while (vegetation.isobj) {
- Individual& indiv=vegetation.getobj();
-
- if (indiv.pft.lifeform==TREE) {
- if (indiv.height>lowbound && indiv.boleht<highbound &&
- !negligible(indiv.height-indiv.boleht)) {
-
-
- frac=1.0;
- if (indiv.height<highbound)
- frac-=(highbound-indiv.height)/VSTEP;
- if (indiv.boleht>lowbound)
- frac-=(indiv.boleht-lowbound)/VSTEP;
-
- atoh=indiv.lai/(indiv.height-indiv.boleht);
- indiv.lai_leafon_layer=atoh*frac*VSTEP;
- plai_layer+=indiv.lai_leafon_layer*indiv.phen;
- plai_leafon_layer+=indiv.lai_leafon_layer;
- }
- else {
- indiv.lai_layer=0.0;
- indiv.lai_leafon_layer=0.0;
- }
- }
-
- vegetation.nextobj();
- }
-
- plai+=plai_layer;
- plai_leafon+=plai_leafon_layer;
-
-
- fpar_layer_bottom = lambertbeer(plai);
- fpar_leafon_layer_bottom = lambertbeer(plai_leafon);
-
- fpar_uptake_layer=fpar_layer_top-fpar_layer_bottom;
- fpar_uptake_leafon_layer=fpar_leafon_layer_top-fpar_leafon_layer_bottom;
-
- vegetation.firstobj();
- while (vegetation.isobj) {
- Individual& indiv=vegetation.getobj();
-
- if (indiv.pft.lifeform==TREE) {
- if (!negligible(plai_leafon_layer))
-
-
- indiv.fpar_leafon+=fpar_uptake_leafon_layer*
- indiv.lai_leafon_layer/plai_leafon_layer;
- if (!negligible(plai_layer))
- indiv.fpar+=fpar_uptake_layer*
- (indiv.lai_leafon_layer*indiv.phen)/plai_layer;
- }
-
- vegetation.nextobj();
- }
- }
-
- fpar_grass = lambertbeer(plai);
- fpar_leafon_grass = lambertbeer(plai_leafon);
-
-
-
- fpar_ff = lambertbeer(plai+plai_grass);
- plai+=plai_grass;
-
- patch.fpar_ff=fpar_ff;
- plai_leafon+=plai_leafon_grass;
- fpar_leafon_ff = lambertbeer(plai_leafon);
-
-
-
-
-
- double fpar_tree_total=0.0;
- vegetation.firstobj();
- while (vegetation.isobj) {
- Individual& indiv=vegetation.getobj();
-
- if (indiv.pft.lifeform==GRASS) {
-
-
- if (!negligible(plai_grass))
- flai=indiv.lai_today()/plai_grass;
- else
- flai=1.0;
- if (!negligible(climate.par))
- fpar_min=min(indiv.pft.parff_min/climate.par,1.0);
- else
- fpar_min=1.0;
- indiv.fpar=max(0.0,fpar_grass*flai-max(fpar_ff*flai,fpar_min));
-
- if (!negligible(plai_leafon_grass))
- flai=indiv.lai/plai_leafon_grass;
- else
- flai=1.0;
- indiv.fpar_leafon=max(0.0,fpar_leafon_grass*flai-
- max(fpar_leafon_ff*flai,fpar_min));
- }
- if (indiv.pft.lifeform==TREE) fpar_tree_total+=indiv.fpar;
- vegetation.nextobj();
- }
-
-
-
-
-
-
-
-
- patch.fpar_grass=fpar_grass;
- par_grass=fpar_grass*climate.par;
- if (date.day==0) {
- patch.par_grass_mean=0.0;
- patch.nday_growingseason=0;
- }
- if (phen_veg>PHEN_GROWINGSEASON && patch.get_climate().daylength >= 11.0) {
- patch.par_grass_mean+=par_grass;
- patch.nday_growingseason++;
- }
-
- if (date.islastday && date.islastmonth && patch.nday_growingseason) {
- patch.par_grass_mean/=(double)patch.nday_growingseason;
- }
- }
- }
- double alphaa(const Pft& pft) {
- if (!ECEARTH) {
-
- if (pft.phenology == CROPGREEN)
- return ifnlim ? ALPHAA_CROP_NLIM : ALPHAA_CROP;
- else
- return ifnlim ? ALPHAA_NLIM : ALPHAA;
- }
- else {
-
- if (pft.phenology == CROPGREEN)
- return ifnlim ? ALPHAA_CROP_NLIM_ECE : ALPHAA_CROP;
- else
- return ifnlim ? ALPHAA_NLIM_ECE : ALPHAA;
- }
- }
- void vmax(double b, double c1, double c2, double apar, double tscal,
- double daylength, double temp, double nactive, bool ifnlimvmax, double& vm, double& vmaxnlim, double& nactive_opt) {
-
-
-
- double s = 24.0 / daylength * b;
- double sigma = sqrt(max(0., 1. - (c2 - s) / (c2 - THETA * s)));
- vm = 1 / b * CMASS * CQ * c1 / c2 * tscal * apar *
- (2. * THETA * s * (1. - sigma) - s + c2 * sigma);
-
-
- const double M = 25.0;
-
-
-
- double CN = 1.0 / (3600 * daylength * CMASS);
- double tfac = exp(-0.0693 * (temp - 25.0));
- double vm_max = nactive / (M * CN * tfac);
-
- nactive_opt = M * vm * CN * tfac;
- if (vm > vm_max && ifnlimvmax) {
- vmaxnlim = vm_max / vm;
- vm = vm_max;
- }
- else {
- vmaxnlim = 1.0;
- }
- }
- void photosynthesis(double co2, double temp, double par, double daylength,
- double fpar, double lambda, const Pft& pft,
- double nactive, bool ifnlimvmax,
- PhotosynthesisResult& result, double vm) {
-
-
-
-
-
-
-
-
-
-
-
-
- assert(vm >= 0 || lambda == pft.lambda_max);
- assert(lambda <= pft.lambda_max);
- const double PATMOS = 1e5;
-
- if (negligible(daylength) || negligible(fpar) || temp > pft.pstemp_max || temp < pft.pstemp_min || !vm) {
- result.clear();
- return;
- }
-
-
-
- double apar = par * fpar * alphaa(pft);
- double b, c1, c2;
-
-
-
-
- double k1 = (pft.pstemp_min+pft.pstemp_low) / 2.0;
- double tscal = (1. - .01*exp(4.6/(pft.pstemp_max-pft.pstemp_high)*(temp-pft.pstemp_high)))/
- (1.0+exp((k1-temp)/(k1-pft.pstemp_min)*4.6));
- if (pft.pathway == C3) {
-
-
- double gammastar = PO2 / 2.0 / lookup_tau[temp];
-
-
- double pi_co2 = lambda * co2 * PATMOS * CO2_CONV;
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- c1 = (pi_co2 - gammastar) / (pi_co2 + 2.0 * gammastar) * ALPHA_C3;
-
- c2 = (pi_co2 - gammastar) / (pi_co2 + lookup_kc[temp] * (1.0 + PO2/lookup_ko[temp]));
- b = BC3;
- }
- else {
-
-
-
- c1 = min(lambda/LAMBDA_SC4, 1.0) * ALPHA_C4;
- c2 = 1;
- b = BC4;
- }
- if (vm < 0) {
-
- vmax(b, c1, c2, apar, tscal, daylength, temp, nactive, ifnlimvmax, result.vm, result.vmaxnlim, result.nactive_opt);
- }
- else {
- result.vm = vm;
- }
-
-
- result.rd_g = result.vm * b;
-
-
- result.je = c1 * tscal * apar * CMASS * CQ / daylength;
-
-
- double jc = c2 * result.vm / 24.0;
-
-
-
-
- result.agd_g = (result.je + jc - sqrt((result.je + jc) * (result.je + jc) - 4.0 * THETA * result.je * jc)) /
- (2.0 * THETA) * daylength;
-
-
- double adt = result.agd_g - daylength / 24.0 * result.rd_g;
-
- result.adtmm = adt / CMASS * 8.314 * (temp + K2degC) / PATMOS * 1e3;
- }
- inline double gpterm(double adtmm, double co2, double lambda, double daylength) {
- if (adtmm <= 0) {
- return 0;
- }
- return 1.6 / CO2_CONV / 3600 * adtmm / co2 / (1 - lambda) / daylength;
- }
- void photosynthesis_nostress(Patch& patch, Climate& climate) {
-
-
-
- if (!patch.id) {
- for (int p=0; p<npft; p++) {
- Standpft& spft = patch.stand.pft[p];
- if (spft.active) {
-
- photosynthesis(climate.co2, climate.temp, climate.par, climate.daylength,
- 1.0, spft.pft.lambda_max, spft.pft, 1.0, false, spft.photosynthesis, -1);
- }
- }
- }
-
- Vegetation& vegetation = patch.vegetation;
- vegetation.firstobj();
- while (vegetation.isobj) {
- Individual& indiv = vegetation.getobj();
- Pft& pft = indiv.pft;
-
- photosynthesis(climate.co2, climate.temp, climate.par, climate.daylength,
- indiv.fpar, pft.lambda_max, pft,
- 1.0, false,
- indiv.photosynthesis,
- -1);
- indiv.gpterm = gpterm(indiv.photosynthesis.adtmm, climate.co2, pft.lambda_max, climate.daylength);
- if (date.diurnal()) {
- indiv.gpterms.assign(date.subdaily, 0);
- PhotosynthesisResult res;
- indiv.phots.assign(date.subdaily, res);
- for (int i=0; i<date.subdaily; i++) {
- PhotosynthesisResult& result = indiv.phots[i];
- photosynthesis(climate.co2, climate.temps[i], climate.pars[i], 24,
- indiv.fpar, pft.lambda_max, pft,
- 1.0, false,
- result,
- indiv.photosynthesis.vm);
- indiv.gpterms[i] = gpterm(result.adtmm, climate.co2, pft.lambda_max, 24);
- }
- }
- vegetation.nextobj();
- }
- }
- double nitrogen_uptake_strength(const Individual& indiv) {
- return pow(max(0.0, indiv.cmass_root_today()) * indiv.pft.nupscoeff * indiv.cton_status / indiv.densindiv, 2.0 / 3.0) * indiv.densindiv;
- }
- void fnuptake(Vegetation& vegetation, double nmass_avail) {
-
- std::vector<NCompetingIndividual> individuals(vegetation.nobj);
- for (unsigned int i = 0; i < vegetation.nobj; i++) {
- individuals[i].ndemand = vegetation[i].ndemand;
- individuals[i].strength = nitrogen_uptake_strength(vegetation[i]);
- }
-
- ncompete(individuals, nmass_avail);
-
- for (unsigned int i = 0; i < vegetation.nobj; i++) {
- vegetation[i].fnuptake = individuals[i].fnuptake;
- }
- }
- void nstore_usage(Vegetation& vegetation) {
- vegetation.firstobj();
- while (vegetation.isobj) {
- Individual& indiv=vegetation.getobj();
-
- double excess_ndemand = (indiv.leafndemand + indiv.rootndemand) * (1.0 - indiv.fnuptake)
- + indiv.leafndemand_store + indiv.rootndemand_store;
-
- if (!negligible(excess_ndemand)) {
-
- if (excess_ndemand <= indiv.nstore_labile) {
-
- double leaf_ndemand = indiv.leafndemand * (1.0 - indiv.fnuptake) + indiv.leafndemand_store;
- indiv.nmass_leaf += leaf_ndemand;
- indiv.nstore_labile -= leaf_ndemand;
-
- double root_ndemand = indiv.rootndemand * (1.0 - indiv.fnuptake) + indiv.rootndemand_store;
- indiv.nmass_root += root_ndemand;
- indiv.nstore_labile -= root_ndemand;
- #ifdef CRESCENDO_FACE
- indiv.report_flux(Fluxes::DNGL, leaf_ndemand);
- indiv.report_flux(Fluxes::DNGR, root_ndemand);
- #endif
- indiv.nstress = false;
- }
- else {
- if (!negligible(indiv.nstore_labile)) {
-
- double tot_nmass = indiv.nmass_leaf + indiv.nmass_root + indiv.fnuptake * (indiv.leafndemand + indiv.rootndemand) + indiv.nstore_labile;
-
- double cton_leaf = (indiv.cmass_leaf_today() + indiv.cmass_root_today() * (indiv.pft.cton_leaf_avr / indiv.pft.cton_root_avr)) / tot_nmass;
-
- double labile_nto_leaf = indiv.cmass_leaf_today() / cton_leaf - (indiv.nmass_leaf + indiv.fnuptake * indiv.leafndemand);
-
- indiv.nmass_leaf += labile_nto_leaf;
-
- indiv.nmass_root += indiv.nstore_labile - labile_nto_leaf;
- #ifdef CRESCENDO_FACE
- indiv.report_flux(Fluxes::DNGL, labile_nto_leaf);
- indiv.report_flux(Fluxes::DNGR, indiv.nstore_labile - labile_nto_leaf);
- #endif
- indiv.nstore_labile = 0.0;
- }
-
- indiv.nstress = ifnlim;
-
- }
- }
- else
-
- indiv.nstress = false;
- vegetation.nextobj();
- }
- }
- void ndemand(Patch& patch, Vegetation& vegetation) {
- Gridcell& gridcell = patch.stand.get_gridcell();
- Soil& soil = patch.soil;
-
- patch.ndemand = 0.0;
-
- double temp_scale = soil.temp > 0.0 ? max(0.0, 0.0326 + 0.00351 * pow(soil.temp, 1.652) - pow(soil.temp / 41.748, 7.19)) : 0.0;
-
- double kNmin = 0.05;
- vegetation.firstobj();
- while (vegetation.isobj) {
- Individual& indiv = vegetation.getobj();
-
- indiv.fnuptake = 1.0;
-
- indiv.nstress = false;
-
- double leafoptn;
-
- double cton_leaf_opt;
-
- if (!negligible(indiv.phen) || !negligible(indiv.cmass_leaf_today())) {
- indiv.nday_leafon++;
-
-
- indiv.nextin = exp(0.12 * min(10.0*indiv.phen, indiv.lai_indiv_today()));
-
-
- leafoptn = indiv.photosynthesis.nactive_opt * indiv.nextin + N0 * indiv.cmass_leaf_today();
-
- if (indiv.cmass_leaf_today() / leafoptn < indiv.pft.cton_leaf_min) {
- leafoptn = indiv.cmass_leaf_today() / indiv.pft.cton_leaf_min;
- }
-
- else if (indiv.cmass_leaf_today() / leafoptn > indiv.pft.cton_leaf_max) {
- leafoptn = indiv.cmass_leaf_today() / indiv.pft.cton_leaf_max;
- }
-
- indiv.cton_leaf_aopt = min(indiv.cmass_leaf_today() / leafoptn, indiv.cton_leaf_aopt);
-
- indiv.leafndemand = max(leafoptn - indiv.nmass_leaf, 0.0);
-
- if (indiv.leafndemand) {
- cton_leaf_opt = indiv.cmass_leaf_today() / leafoptn;
- }
- else {
- cton_leaf_opt = max(indiv.pft.cton_leaf_min, indiv.cton_leaf());
- }
- }
- else {
- indiv.leafndemand = 0.0;
- cton_leaf_opt = indiv.cton_leaf();
- }
-
-
- indiv.rootndemand = max(0.0, indiv.cmass_root_today() / (cton_leaf_opt * indiv.pft.cton_root_avr / indiv.pft.cton_leaf_avr) - indiv.nmass_root);
-
- if (indiv.pft.lifeform == TREE) {
- indiv.sapndemand = max(0.0, indiv.cmass_sap / (cton_leaf_opt * indiv.pft.cton_sap_avr / indiv.pft.cton_leaf_avr) - indiv.nmass_sap) * ((1.0 + (double)date.day) / (double)date.year_length());
- }
-
- indiv.storendemand = indiv.ndemand_storage(cton_leaf_opt);
-
- indiv.hondemand = 0.0;
-
- double ndemand_tot = indiv.leafndemand + indiv.rootndemand + indiv.sapndemand + indiv.storendemand + indiv.hondemand;
-
-
- double ntoc = !negligible(indiv.cmass_leaf_today() + indiv.cmass_root_today()) ? (indiv.nmass_leaf + indiv.nmass_root) / (indiv.cmass_leaf_today() + indiv.cmass_root_today()) : 0.0;
-
- indiv.cton_status = max(0.0, (ntoc - 1.0 / indiv.pft.cton_leaf_min) / (1.0 / indiv.pft.cton_leaf_avr - 1.0 / indiv.pft.cton_leaf_min));
-
- double nmin_scale = kNmin + soil.nmass_avail / (soil.nmass_avail + gridcell.pft[indiv.pft.id].Km);
-
-
-
- double max_indiv_avail = min(1.0, indiv.fpc * 4.0) * soil.nmass_avail;
-
-
- double maxnup = min(2.0 * indiv.pft.nuptoroot * nmin_scale * temp_scale * indiv.cton_status * indiv.cmass_root_today(), max_indiv_avail);
-
- double fractomax = ndemand_tot > 0.0 ? min(maxnup/ndemand_tot,1.0) : 0.0;
-
- indiv.leafndemand_store = indiv.leafndemand * (1.0 - fractomax);
- indiv.rootndemand_store = indiv.rootndemand * (1.0 - fractomax);
-
- indiv.leafndemand *= fractomax;
- indiv.rootndemand *= fractomax;
- indiv.sapndemand *= fractomax;
- indiv.storendemand *= fractomax;
-
- indiv.ndemand = indiv.leafndemand + indiv.rootndemand + indiv.sapndemand + indiv.storendemand;
-
- if (indiv.ndemand <= 0.0) {
- indiv.ndemand = 0.0;
-
- indiv.leaffndemand = 0.0;
- indiv.rootfndemand = 0.0;
- indiv.sapfndemand = 0.0;
- indiv.storefndemand = 0.0;
- }
- else {
-
- indiv.leaffndemand = indiv.leafndemand / indiv.ndemand;
- indiv.rootfndemand = indiv.rootndemand / indiv.ndemand;
- indiv.sapfndemand = indiv.sapndemand / indiv.ndemand;
- indiv.storefndemand = max(0.0, 1.0 - (indiv.leaffndemand + indiv.rootfndemand + indiv.sapfndemand));
- }
-
- patch.ndemand += indiv.ndemand;
- vegetation.nextobj();
- }
- }
- void vmax_nitrogen_stress(Patch& patch, Climate& climate, Vegetation& vegetation) {
-
-
-
- double tot_nmass_avail = patch.soil.nmass_avail * min(1.0, patch.fpc_total);
- if (patch.stand.landcover == CROPLAND && ifnlim) {
-
- tot_nmass_avail *= patch.soil.wcont[0] * 0.9 + patch.soil.wcont[1] * 0.1;
- }
-
- if (patch.ndemand > tot_nmass_avail) {
-
- fnuptake(vegetation, tot_nmass_avail);
- }
-
- nstore_usage(vegetation);
-
-
- vegetation.firstobj();
- while (vegetation.isobj) {
- Individual& indiv = vegetation.getobj();
- Pft& pft = indiv.pft;
-
-
-
-
-
- double nmass_leaf = indiv.nmass_leaf + indiv.leafndemand * indiv.fnuptake;
- if (indiv.phen > 0.0) {
- indiv.nactive = max(0.0, nmass_leaf - N0 * indiv.cmass_leaf_today());
- }
- else {
- indiv.nactive = 0.0;
- }
-
- if (indiv.nstress) {
-
- photosynthesis(climate.co2, climate.temp, climate.par, climate.daylength,
- indiv.fpar, pft.lambda_max, pft,
- indiv.nactive / indiv.nextin, true,
- indiv.photosynthesis,
- -1);
- indiv.gpterm = gpterm(indiv.photosynthesis.adtmm, climate.co2, pft.lambda_max, climate.daylength);
- if (date.diurnal()) {
- for (int i=0; i<date.subdaily; i++) {
- PhotosynthesisResult& result = indiv.phots[i];
- photosynthesis(climate.co2, climate.temps[i], climate.pars[i], 24,
- indiv.fpar, pft.lambda_max, pft,
- indiv.nactive / indiv.nextin, true,
- result,
- indiv.photosynthesis.vm);
- indiv.gpterms[i] = gpterm(result.adtmm, climate.co2, pft.lambda_max, 24);
- }
- }
- }
-
- if (indiv.phen)
- indiv.avmaxnlim += indiv.photosynthesis.vmaxnlim;
-
-
- if (date.islastday && date.islastmonth) {
- if (!negligible(indiv.nday_leafon)) {
- indiv.avmaxnlim /= (double)indiv.nday_leafon;
- }
- else {
- indiv.avmaxnlim = 0.0;
- }
- }
- vegetation.nextobj();
- }
- }
- void wdemand(Patch& patch, Climate& climate, Vegetation& vegetation, const Day& day) {
-
-
- double gp_patch = 0.0;
-
-
- double gp_leafon_patch = 0.0;
-
-
- vegetation.firstobj();
- while (vegetation.isobj) {
- Individual& indiv = vegetation.getobj();
- Pft& pft = indiv.pft;
-
-
-
-
-
-
- if (indiv.growingseason()) {
- PhotosynthesisResult leafon_photosynthesis;
-
-
-
- double temp = date.diurnal() ? climate.temps[day.period] : climate.temp;
- double par = date.diurnal() ? climate.pars[day.period] : climate.par;
- double daylength = date.diurnal() ? 24 : climate.daylength;
-
- photosynthesis(climate.co2, temp, par, daylength,
- indiv.fpar_leafon, pft.lambda_max, pft,
- 1.0, false,
- leafon_photosynthesis,
- -1);
- double gp_leafon = gpterm(leafon_photosynthesis.adtmm, climate.co2, pft.lambda_max, daylength) + pft.gmin * indiv.fpc;
-
- gp_patch += (date.diurnal() ? indiv.gpterms[day.period] : indiv.gpterm) + pft.gmin * indiv.fpc_today();
- gp_leafon_patch += gp_leafon;
- }
- vegetation.nextobj();
- }
-
-
- if (!negligible(gp_patch) && !negligible(patch.fpc_total)) {
- gp_patch /= patch.fpc_total;
- patch.wdemand = aet_monteith(patch.eet_net_veg, gp_patch);
- }
- else
- patch.wdemand = 0.0;
- patch.wdemand_day += patch.wdemand;
- if (day.isend) {
- patch.wdemand_day /= date.subdaily;
- }
- if (!negligible(gp_leafon_patch) && !negligible(patch.fpc_total)) {
- gp_leafon_patch /= patch.fpc_total;
- patch.wdemand_leafon = aet_monteith(patch.eet_net_veg, gp_leafon_patch);
- }
- else
- patch.wdemand_leafon = 0.0;
- }
- inline double water_uptake(double wcont[NSOILLAYER], double awc[NSOILLAYER],
- double rootdist[NSOILLAYER], double emax, double fpc_rescale,
- double fwuptake[NSOILLAYER], bool ifsmart, double species_drought_tolerance) {
-
-
-
-
-
-
-
-
-
-
-
-
-
- double wr;
- int s;
- switch (wateruptake) {
- case WR_WCONT:
-
-
- wr = 0.0;
- for (s=0; s<NSOILLAYER; s++) {
- fwuptake[s] = rootdist[s] * wcont[s] * fpc_rescale;
- wr += fwuptake[s];
- }
- break;
-
- case WR_SPECIESSPECIFIC:
-
-
-
- wr = 0.0;
- for (s=0; s<NSOILLAYER; s++) {
- double max_rel_uptake = pow(wcont[s], 2.0 * 0.1);
- fwuptake[s] = rootdist[s] * min(pow(wcont[s], 2.0 * species_drought_tolerance), max_rel_uptake) * fpc_rescale;
- wr += fwuptake[s];
- }
- break;
- case WR_ROOTDIST:
-
-
- wr = 0.0;
- for (s=0; s<NSOILLAYER; s++) {
- fwuptake[s] = min(wcont[s] * awc[s] * fpc_rescale, emax * rootdist[s]) / emax;
- wr += fwuptake[s];
- }
- break;
- case WR_SMART:
- {
-
-
-
- double wcsum = 0.0;
- double wcfrac;
- for (s=0; s<NSOILLAYER; s++) wcsum += wcont[s];
- wr = 0.0;
- if (negligible(wcsum))
- for (s=0; s<NSOILLAYER; s++) fwuptake[s] = 0.0;
- else {
- for (s=0; s<NSOILLAYER; s++) {
- wcfrac = wcont[s] / wcsum;
- if (ifsmart)
- fwuptake[s] = min(wcont[s] * awc[s] * wcfrac * fpc_rescale, emax * wcfrac) / emax;
- else
- fwuptake[s] = min(wcont[s] * awc[s] * fpc_rescale, emax * rootdist[s]) / emax;
- wr += fwuptake[s];
- }
- }
- }
- break;
- default:
-
- fail("Unsupported wateruptake type");
- }
- if (!negligible(wr))
- for (s=0; s<NSOILLAYER; s++)
- fwuptake[s] /= wr;
- return wr;
- }
- double irrigated_water_uptake(Patch& patch, Pft& pft, const Day& day) {
- Patchpft& ppft = patch.pft[pft.id];
- double* awc = patch.soil.soiltype.awc;
- double wcont_cp[NSOILLAYER];
- for (int i=0;i<NSOILLAYER;i++) {
- wcont_cp[i] = patch.soil.wcont[i];
- }
- if (day.isstart) {
- ppft.water_deficit_d = 0.0;
- if (date.day == 0) {
- ppft.water_deficit_y = 0.0;
- }
- }
- if (patch.soil.wcont[0]<0.9 && ppft.phen > 0.0) {
- double wcont_0_opt = 0.0;
- double wr_opt = min(1.0, patch.wdemand / ppft.phen / pft.emax);
- if (wateruptake == WR_ROOTDIST) {
- wcont_0_opt = (wr_opt * pft.emax - min(patch.soil.wcont[1] * awc[1] * patch.fpc_rescale, pft.emax * pft.rootdist[1])) / awc[0] / patch.fpc_rescale;
- if (wcont_0_opt * awc[0] * patch.fpc_rescale > pft.emax * pft.rootdist[0]) {
- wcont_0_opt = pft.emax * pft.rootdist[0] / awc[0] / patch.fpc_rescale;
- }
- }
- else {
- fail("Irrigation soil water only balanced for WR_ROOTDIST currently !\n");
- }
- if (wcont_0_opt > patch.soil.wcont[0]) {
- ppft.water_deficit_d += (wcont_0_opt-patch.soil.wcont[0]) * awc[0];
- wcont_cp[0] = wcont_0_opt;
- }
- if (day.isend) {
- ppft.water_deficit_d /= date.subdaily;
- ppft.water_deficit_y += ppft.water_deficit_d;
- }
- }
- return water_uptake(wcont_cp, awc, pft.rootdist, pft.emax, patch.fpc_rescale,
- ppft.fwuptake, pft.lifeform == TREE, pft.drought_tolerance);
- };
- void aet_water_stress(Patch& patch, Vegetation& vegetation, const Day& day) {
-
-
-
-
-
-
- for (int p=0; p<npft; p++) {
- Standpft& spft = patch.stand.pft[p];
- if (!spft.active)
- continue;
-
- Patchpft& ppft = patch.pft[p];
-
- Pft& pft = ppft.pft;
- if (day.isstart || spft.irrigated && pft.id == patch.stand.pftid) {
-
-
-
-
- double wr;
- if (spft.irrigated && pft.id == patch.stand.pftid) {
- wr = irrigated_water_uptake(patch, pft, day);
- } else {
- wr = water_uptake(patch.soil.wcont, patch.soil.soiltype.awc,
- pft.rootdist, pft.emax, patch.fpc_rescale, ppft.fwuptake,
- pft.lifeform == TREE, pft.drought_tolerance);
- }
-
- if (patch.stand.landcover!=CROPLAND || ppft.cropphen->growingseason)
- ppft.wsupply_leafon = pft.emax * wr;
- else
- ppft.wsupply_leafon = 0.0;
- ppft.wsupply = ppft.wsupply_leafon * ppft.phen;
- }
- ppft.wstress = ppft.wsupply < patch.wdemand && !negligible(ppft.phen) && !(pft.phenology==CROPGREEN && !largerthanzero(patch.wdemand-ppft.wsupply, -10));
-
-
-
-
-
-
-
- double gmin = pft.phenology==CROPGREEN ? ppft.phen * pft.gmin : pft.gmin;
- ppft.gcbase = ppft.wstress ? max(gc_monteith(ppft.wsupply, patch.eet_net_veg)-
- gmin * ppft.wsupply / patch.wdemand, 0.0) : 0;
- if (!date.diurnal()) {
- ppft.wstress_day = ppft.wstress;
- ppft.gcbase_day = ppft.gcbase;
- }
- else if (day.isend) {
- ppft.wstress_day = ppft.wsupply < patch.wdemand_day && !negligible(ppft.phen) && !(pft.phenology==CROPGREEN && !largerthanzero(patch.wdemand-ppft.wsupply, -10));
- ppft.gcbase_day = ppft.wstress_day ? max(gc_monteith(ppft.wsupply,
- patch.eet_net_veg) - gmin * ppft.wsupply / patch.wdemand_day, 0.0) : 0;
- }
- }
-
- vegetation.firstobj();
- while (vegetation.isobj) {
- Individual& indiv = vegetation.getobj();
- Patchpft& ppft = patch.pft[indiv.pft.id];
- if (day.isstart) {
- indiv.aet = 0;
- if (date.day == 0)
- indiv.aaet = 0.0;
- }
- indiv.wstress = ppft.wstress;
- if (indiv.alive) {
- if (indiv.wstress) {
- indiv.aet += ppft.wsupply;
- }
- else {
- indiv.aet += negligible(indiv.phen) ? 0.0 : patch.wdemand;
- }
- }
- if (day.isend) {
- indiv.aet *= indiv.fpc / date.subdaily;
- }
- if (day.isend) {
- indiv.aaet += indiv.aet;
- }
- vegetation.nextobj();
- }
- }
- void water_scalar(Patch& patch, Vegetation& vegetation, const Day& day) {
-
-
-
-
- for (int p=0; p<npft; p++) {
-
- Patchpft& ppft = patch.pft[p];
- if (!patch.stand.pft[p].active)
- continue;
- if (day.isstart) {
- ppft.wscal = 0;
- if (date.day == 0) {
- ppft.wscal_mean = 0;
- if (ppft.pft.phenology==CROPGREEN || ppft.pft.isintercropgrass)
- ppft.cropphen->growingdays_y=0;
- }
- }
-
- if (!negligible(patch.wdemand_leafon)) {
- ppft.wscal += min(1.0, ppft.wsupply_leafon/patch.wdemand_leafon);
- }
- else {
- ppft.wscal += 1.0;
- }
- if (day.isend) {
- ppft.wscal /= (double)date.subdaily;
- if (patch.stand.landcover!=CROPLAND
- || ppft.pft.phenology==ANY && ppft.pft.id==patch.stand.pftid) {
- ppft.wscal_mean += ppft.wscal;
-
- if (date.islastday && date.islastmonth) {
- ppft.wscal_mean /= (double)date.year_length();
- }
- }
- else if (ppft.cropphen->growingseason
- || ppft.pft.phenology == CROPGREEN && date.day == ppft.cropphen->hdate
- || ppft.pft.isintercropgrass && date.day == patch.pft[patch.stand.pftid].cropphen->eicdate) {
- ppft.cropphen->growingdays_y++;
- ppft.wscal_mean = ppft.wscal_mean + (ppft.wscal - ppft.wscal_mean) / ppft.cropphen->growingdays_y;
- }
- }
- }
- }
- void assimilation_wstress(const Pft& pft, double co2, double temp, double par,
- double daylength, double fpar, double fpc, double gcbase,
- double vmax, PhotosynthesisResult& phot_result, double& lambda,
- double nactive, bool ifnlimvmax) {
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- lambda = -1;
- if (negligible(fpc) || negligible(fpar) || negligible(gcbase * daylength * 3600)) {
-
- phot_result.clear();
- return;
- }
-
-
- double gcphot = gcbase * daylength * 3600 / 1.6 * co2 * CO2_CONV;
-
-
-
-
-
-
- photosynthesis(co2, temp, par, daylength, fpar, pft.lambda_max, pft, nactive, ifnlimvmax, phot_result, vmax);
- double f_lambda_max = phot_result.adtmm / fpc - gcphot * (1 - pft.lambda_max);
- if (f_lambda_max <= 0) {
-
- phot_result.clear();
- return;
- }
- const double EPS = 0.1;
- double xmid;
-
- double x1 = 0.02;
- double x2 = pft.lambda_max;
- double rtbis = x1;
- double dx = x2 - x1;
- const int MAXTRIES = 6;
- int b = 0;
- double fmid = EPS + 1.0;
- while (fabs(fmid) > EPS && b <= MAXTRIES) {
- b++;
- dx *= 0.5;
- xmid = rtbis + dx;
-
-
-
- photosynthesis(co2, temp, par, daylength, fpar, xmid, pft, nactive, ifnlimvmax, phot_result, vmax);
-
-
-
-
-
-
- fmid = phot_result.adtmm / fpc - gcphot * (1 - xmid);
- if (fmid < 0) {
- rtbis = xmid;
- }
- }
-
- lambda=xmid;
- }
- void respiration(double gtemp_air, double gtemp_soil, lifeformtype lifeform,
- double respcoeff, double cton_sap, double cton_root,
- double cmass_sap, double cmass_root_today, double assim, double& resp,
- double& resp_root, double& resp_sap, double& resp_growth) {
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- const double K=0.095218;
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- if (lifeform == TREE) {
-
- resp_sap = respcoeff * K * cmass_sap / cton_sap * gtemp_air;
-
-
- resp_root = respcoeff * K * cmass_root_today / cton_root * gtemp_soil;
-
- resp_growth = (assim - resp_sap - resp_root) * 0.25;
-
-
- if(resp_growth < 0.0) resp_growth = 0.0;
-
- resp = resp_sap + resp_root + resp_growth;
- }
- else if (lifeform == GRASS) {
-
- resp_root = respcoeff * K * cmass_root_today / cton_root * gtemp_soil;
- resp_sap = 0.0;
-
- resp_growth = (assim - resp_root) * 0.25;
-
-
- if(resp_growth < 0.0) resp_growth = 0.0;
-
- resp = resp_root + resp_growth;
- }
- else fail ("Canopy exchange function respiration: unknown life form");
- }
- void npp(Patch& patch, Climate& climate, Vegetation& vegetation, const Day& day) {
-
-
-
-
-
-
-
-
- double par, temp, assim, resp, resp_leaf, resp_root, resp_sap, resp_growth, lambda, rad, gtemp;
- double hours = 24;
- if (date.diurnal()) {
- par = climate.pars[day.period];
- temp = climate.temps[day.period];
- rad = climate.rads[day.period];
- gtemp = climate.gtemps[day.period];
- }
- else {
- par = climate.par;
- temp = climate.temp;
- hours = climate.daylength;
- rad = climate.rad;
- gtemp = climate.gtemp;
- }
- vegetation.firstobj();
- while (vegetation.isobj) {
- Individual& indiv = vegetation.getobj();
-
-
- Pft& pft = indiv.pft;
- Patchpft& ppft = patch.pft[pft.id];
-
- if (!indiv.growingseason()) {
- indiv.dnpp=0.0;
- vegetation.nextobj();
- continue;
- }
- PhotosynthesisResult phot = date.diurnal() ? indiv.phots[day.period] : indiv.photosynthesis;
- if (indiv.wstress) {
-
-
- assimilation_wstress(pft, climate.co2, temp, par, hours, indiv.fpar, indiv.fpc,
- ppft.gcbase, phot.vm, phot, lambda,
- indiv.nactive / indiv.nextin, ifnlim);
- }
- else {
- lambda = indiv.pft.lambda_max;
- }
-
- assim = phot.agd_g * 1e-3;
- resp_leaf = phot.rd_g * 1e-3;
- if (ifbvoc) {
- PhotosynthesisResult phot_nostress = date.diurnal() ? indiv.phots[day.period] : indiv.photosynthesis;
- bvoc(temp, hours, rad, climate, patch, indiv, pft, phot_nostress, phot.adtmm, day);
- }
-
- double cmass_root;
- if (indiv.cropindiv && indiv.cropindiv->isintercropgrass && indiv.phen == 0.0)
- cmass_root = 0.0;
- else
- cmass_root = indiv.cmass_root_today();
-
-
- double cton_sap, cton_root;
- if (ifnlim) {
- cton_sap = indiv.cton_sap();
- cton_root = indiv.cton_root();
- }
- else {
- cton_sap = pft.cton_sap_avr;
- cton_root = pft.cton_root_avr;
- }
- respiration(gtemp, patch.soil.gtemp, indiv.pft.lifeform,
- indiv.pft.respcoeff, cton_sap, cton_root,
- indiv.cmass_sap, cmass_root, assim, resp, resp_root, resp_sap, resp_growth);
- resp += resp_leaf;
-
- assim /= date.subdaily;
- resp /= date.subdaily;
-
- indiv.dnpp = assim - resp;
- indiv.anpp += indiv.dnpp;
- indiv.mgpp[date.month] += assim;
- indiv.mlambda_gpp[date.month] += lambda * assim;
- indiv.report_flux(Fluxes::NPP, indiv.dnpp);
- indiv.report_flux(Fluxes::GPP, assim);
- indiv.report_flux(Fluxes::RA, resp);
- indiv.report_flux(Fluxes::RALEAF, resp_leaf);
- indiv.report_flux(Fluxes::RASTEM, resp_sap);
- indiv.report_flux(Fluxes::RAROOT, resp_root);
- indiv.report_flux(Fluxes::RAGROWTH, resp_growth);
- if (indiv.pft.lifeform == TREE) {
- indiv.report_flux(Fluxes::GPPTREE, assim);
- indiv.report_flux(Fluxes::RATREE, resp);
- }
- else if (indiv.pft.landcover != CROPLAND) {
- indiv.report_flux(Fluxes::GPPGRASS, assim);
- indiv.report_flux(Fluxes::RAGRASS, resp);
- }
- #ifdef CRESCENDO_FACE
- indiv.report_flux(Fluxes::DRALEAF, resp_leaf);
- indiv.report_flux(Fluxes::DRASTEM, resp_sap);
- indiv.report_flux(Fluxes::DRAROOT, resp_root);
- indiv.report_flux(Fluxes::DRAGROWTH, resp_growth);
- #endif
- if (indiv.lai_today() > indiv.mlai_max[date.month])
- indiv.mlai_max[date.month] = indiv.lai_today();
- if (day.isend) {
- indiv.mlai[date.month] += indiv.lai_today() / (double)date.ndaymonth[date.month];
- }
- vegetation.nextobj();
- }
- }
- void leaf_senescence(Vegetation& vegetation) {
- if (!(vegetation.patch.stand.is_true_crop_stand() && ifnlim)) {
- return;
- }
- vegetation.firstobj();
- while (vegetation.isobj) {
- Individual& indiv = vegetation.getobj();
-
- if (indiv.patchpft().cropphen->dev_stage > 1.0) {
- const double senNr = 0.1;
- double senN = senNr * (indiv.nmass_leaf-indiv.cmass_leaf_today() / (indiv.pft.cton_leaf_max));
-
- if (vegetation.patch.stand.get_gridcell().getsimulationyear(date.year) > nyear_spinup && senN > 0) {
- indiv.nmass_leaf -= senN;
- indiv.cropindiv->nmass_agpool += senN;
- }
- }
- double r = 0.0;
-
- if (indiv.cmass_leaf_today() > 0.0) {
- double Ln = indiv.lai_nitrogen_today();
- double Lnld = indiv.lai_today();
- r = (Lnld - min(Lnld, Ln))/indiv.pft.sla/10.0;
- }
-
- if (indiv.patchpft().cropphen->fphu < 0.05) {
- indiv.daily_cmass_leafloss = 0.0;
- } else {
- indiv.daily_cmass_leafloss = max(0.0, r);
- }
- indiv.daily_nmass_leafloss = 0.0;
- vegetation.nextobj();
- }
- }
- void forest_floor_conditions(Patch& patch) {
- const Climate& climate = patch.get_climate();
- double lambda;
- PhotosynthesisResult phot;
- for (int p=0; p<npft; p++) {
- Patchpft& ppft = patch.pft[p];
- Standpft& spft = patch.stand.pft[p];
- if (!spft.active) {
- continue;
- }
- Pft& pft = spft.pft;
-
- if (date.day == 0) {
- ppft.anetps_ff = 0.0;
- }
- if (patch.stand.landcover != CROPLAND || pft.phenology != CROPGREEN && ppft.cropphen->growingseason) {
- double assim = 0;
- if (ppft.wstress_day) {
- assimilation_wstress(pft, climate.co2, climate.temp, climate.par,
- climate.daylength, patch.fpar_grass * ppft.phen, 1., ppft.gcbase_day,
- spft.photosynthesis.vm, phot, lambda, 1.0, false);
- assim = phot.net_assimilation();
- }
- else {
- assim = spft.photosynthesis.net_assimilation() * ppft.phen * patch.fpar_grass;
- }
-
- ppft.anetps_ff += assim;
- }
- if (date.islastmonth && date.islastday) {
-
- ppft.anetps_ff = max(0.0, ppft.anetps_ff);
- if (ppft.anetps_ff > spft.anetps_ff_max) {
- spft.anetps_ff_max = ppft.anetps_ff;
- }
- }
- }
- }
- void init_canexch(Patch& patch, Climate& climate, Vegetation& vegetation) {
- if (date.day == 0) {
- vegetation.firstobj();
- while (vegetation.isobj) {
- Individual& indiv = vegetation.getobj();
- indiv.anpp = 0.0;
- indiv.leafndemand = 0.0;
- indiv.rootndemand = 0.0;
- indiv.sapndemand = 0.0;
- indiv.storendemand = 0.0;
- indiv.hondemand = 0.0;
- indiv.nday_leafon = 0;
- indiv.avmaxnlim = 1.0;
- indiv.cton_leaf_aavr = 0.0;
- if (!negligible(indiv.cmass_leaf) && !negligible(indiv.nmass_leaf))
- indiv.cton_leaf_aopt = indiv.cmass_leaf / indiv.nmass_leaf;
- else
- indiv.cton_leaf_aopt = indiv.pft.cton_leaf_max;
- for (int m=0; m<12; m++) {
- indiv.mlai[m] = 0.0;
- indiv.mlai_max[m] = 0.0;
- indiv.mgpp[m] = 0.0;
- indiv.mlambda_gpp[m] = 0.0;
- }
- vegetation.nextobj();
- }
- }
- patch.wdemand_day = 0;
- }
- void canopy_exchange(Patch& patch, Climate& climate) {
-
-
-
-
-
-
-
-
-
-
-
- Vegetation& vegetation = patch.vegetation;
-
- init_canexch(patch, climate, vegetation);
-
- fpar(patch);
-
- photosynthesis_nostress(patch, climate);
-
- ndemand(patch, vegetation);
-
- vmax_nitrogen_stress(patch, climate, vegetation);
-
- for (Day day; day.period != date.subdaily; day.next()) {
- wdemand(patch, climate, vegetation, day);
- aet_water_stress(patch, vegetation, day);
- water_scalar(patch, vegetation, day);
- npp(patch, climate, vegetation, day);
- }
- leaf_senescence(vegetation);
-
- forest_floor_conditions(patch);
-
-
-
-
-
-
-
-
- double pet_patch = patch.wdemand_day * patch.fpc_total + patch.intercep +
- climate.eet * PRIESTLEY_TAYLOR * max(1.0-patch.fpc_total, 0.0);
- patch.apet += pet_patch;
- patch.mpet[date.month] += pet_patch;
- patch.dpet[date.day] += pet_patch;
- }
|