#==========================================================================================#
#==========================================================================================#
# Function that converts DBH to height. #
#------------------------------------------------------------------------------------------#
dbh2h = function(dbh,ipft){
#----- Constants. ----------------------------------------------------------------------#
b1Ht = c(0.0352 ,0.0352 ,0.0352,0.0352,0.4778,27.1400,27.1400,22.7900,22.6799
,25.1800,23.3874,0.4778,0.4778,0.0352,0.0352,0.0352,0.0352)
b2Ht = c(0.69400,0.69400,0.69400,0.69400,-0.75000,-0.03884,-0.03884,-0.04445
,-0.06534,-0.04964,-0.05404,-0.75000,-0.75000,0.69400,0.69400,0.69400,1.041)
dbh.crit = c(0.5971399 ,96.2578090,96.2578090,96.2578090, 3.9943097,77.7029455
,77.7029455,64.0400158,43.4927941,59.3171178,53.1458689, 3.9943097
,3.9943097 ,0.5971399 ,0.5971399 , 0.5971399,29.41504573)
hgt.ref = c(61.7,61.7,61.7,61.7, 0.0, 1.3, 1.3, 1.3, 1.3
, 1.3, 1.3, 0.0, 0.0,61.7,61.7,61.7,61.7)
#---------------------------------------------------------------------------------------#
#----- Check whether plants are tropical or not. ---------------------------------------#
tropical = ipft %in% c(1,2,3,4,14,15,16,17)
#---------------------------------------------------------------------------------------#
#----- Cap the height above a certain dbh. ---------------------------------------------#
dbh.use = pmin(dbh,dbh.crit[ipft])
#---------------------------------------------------------------------------------------#
height = ifelse( tropical
, hgt.ref[ipft] * (1.0 - exp( -b1Ht[ipft] * dbh.use^b2Ht[ipft] ) )
, hgt.ref[ipft] + b1Ht[ipft] * (1.0 - exp( b2Ht[ipft] * dbh.use ) )
)#typend ifelse
return(height)
}#end function dbh2h
#==========================================================================================!
#==========================================================================================!
#==========================================================================================#
#==========================================================================================#
# Function that converts DBH to living biomass. #
#------------------------------------------------------------------------------------------#
dbh2ba = function(dbh,ipft){
#----- Constants. ----------------------------------------------------------------------#
b1Bl = c(0.1576947,0.4178911,0.5598163,0.7096263,0.0800000,0.0240000,0.0240000
,0.0454000,0.0129000,0.0480000,0.0170000,0.0800000,0.0800000,0.1576947
,0.1576947,0.1576947,0.4651995,0.0240000)
b2Bl = c(0.9749494,0.9749494,0.9749494,0.9749494,1.0000000,1.8990000,1.8990000
,1.6829000,1.7477000,1.4550000,1.7310000,1.0000000,1.0000000,0.9749494
,0.9749494,0.9749494,0.9749494)
qroot = c(1.0000,1.0000,1.0000,1.0000,1.0000,0.3463,0.3463,0.3463,1.1274,1.1274
,1.1274,1.0000,1.0000,1.0000,1.0000,1.0000,1.0000)
qsapwood = c(0.005641026,0.004102564,0.002974359,0.002479487,0.005641026,0.001538462
,0.002307692,0.002564103,0.007692308,0.006205128,0.015384615,0.005641026
,0.005641026,0.005641026,0.005641026,0.005641026,0.002564103)
dbh.crit = c(0.5971399 ,96.2578090,96.2578090,96.2578090, 3.9943097,77.7029455
,77.7029455,64.0400158,43.4927941,59.3171178,53.1458689, 3.9943097
,3.9943097 ,0.5971399 ,0.5971399 , 0.5971399,29.41504573)
#---------------------------------------------------------------------------------------#
height = dbh2h(dbh=dbh,ipft=ipft)
dbh.use = pmin(dbh,dbh.crit[ipft])
bleaf = 0.5 * b1Bl[ipft] * dbh.use ^ b2Bl[ipft]
broot = qroot[ipft] * bleaf
bsapwood = qsapwood[ipft] * height * bleaf
balive = bleaf + broot + bsapwood
return(balive)
}# end function dbh2ba
#==========================================================================================#
#==========================================================================================#
#==========================================================================================#
#==========================================================================================#
# Function that converts DBH to leaf area index. #
#------------------------------------------------------------------------------------------#
dbh2lai = function(dbh,nplant,ipft){
#----- Constants. ----------------------------------------------------------------------#
b1Bl = c(0.1576947,0.4178911,0.5598163,0.7096263,0.0800000,0.0240000,0.0240000
,0.0454000,0.0129000,0.0480000,0.0170000,0.0800000,0.0800000,0.1576947
,0.1576947,0.1576947,0.4651995,0.0240000)
b2Bl = c(0.9749494,0.9749494,0.9749494,0.9749494,1.0000000,1.8990000,1.8990000
,1.6829000,1.7477000,1.4550000,1.7310000,1.0000000,1.0000000,0.9749494
,0.9749494,0.9749494,0.9749494)
SLA = c(22.70000,16.01794,11.64482,9.66342,22.00000,6.00000,9.00000,10.00000
,30.00000,24.20000,60.00000,22.00000,22.00000,22.70000,22.70000,22.70000
,10.00000)
dbh.crit = c(0.5971399 ,96.2578090,96.2578090,96.2578090, 3.9943097,77.7029455
,77.7029455,64.0400158,43.4927941,59.3171178,53.1458689, 3.9943097
,3.9943097 ,0.5971399 ,0.5971399 , 0.5971399,96.2578090)
#---------------------------------------------------------------------------------------#
dbh.use = pmin(dbh,dbh.crit[ipft])
bleaf = 0.5 * b1Bl[ipft] * dbh.use ^ b2Bl[ipft]
lai = nplant * bleaf * SLA[ipft]
return(lai)
}# end function dbh2lai
#==========================================================================================#
#==========================================================================================#
#==========================================================================================#
#==========================================================================================#
# Function that converts DBH to structural biomass. #
#------------------------------------------------------------------------------------------#
dbh2bd = function(dbh,ipft){
#----- Constants. ----------------------------------------------------------------------#
b1Bs.small = c(0.06272279,0.16621539,0.22266590,0.28225255,0.00001000,0.14700000
,0.14700000,0.16170000,0.02648000,0.16170000,0.23500000,0.00001000
,0.00001000,0.06272279,0.06272279,0.06272279,0.18503222)
b2Bs.small = c(2.432361,2.432361,2.432361,2.432361,1.000000,2.238000,2.238000,2.153600
,2.959540,2.457200,2.251800,1.000000,1.000000,2.432361,2.432361,2.432361
,2.432361)
b1Bs.large = c(0.0647230 ,0.1715160 ,0.2297667 ,0.2912535 ,0.0000100 ,0.1470000
,0.1470000 ,0.1617000 ,0.0264800 ,0.1617000 ,0.2350000 ,0.0000100
,0.0000100 ,0.0647230 ,0.0647230 ,0.0647230 ,0.1909329 )
b2Bs.large = c(2.425574,2.425574,2.425574,2.425574,1.000000,2.238000,2.238000,2.153600
,2.959540,2.457200,2.251800,1.000000,1.000000,2.425574,2.425574,2.425574
,2.425574)
dbh.crit = c(0.5971399 ,96.2578090,96.2578090,96.2578090, 3.9943097,77.7029455
,77.7029455,64.0400158,43.4927941,59.3171178,53.1458689, 3.9943097
,3.9943097 ,0.5971399 ,0.5971399 , 0.5971399,96.2578090)
#---------------------------------------------------------------------------------------#
bdead = ifelse( dbh <= dbh.crit[ipft]
, 0.5 * b1Bs.small[ipft] * dbh ^ b2Bs.small[ipft]
, 0.5 * b1Bs.large[ipft] * dbh ^ b2Bs.large[ipft]
)#end ifelse
return(bdead)
}# end function dbh2bd
#==========================================================================================#
#==========================================================================================#
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.