VEZY / DynACof

The Dynamic Agroforestry Coffee Crop Model

Home Page:https://vezy.github.io/DynACof/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Rewrite the way we compute senescence due to lifespan

VEZY opened this issue · comments

For now, lifespan is used as a ratio over the total dry mass for each organ. It should be used to remove organ mass that was created lifespan_organ days before "i".
This is what we do:

  S$Sim$Mact_CR_Tree[i]=
    S$Sim$CM_CR_Tree[previous_i(i,1)]/S$Parameters$lifespanCR_Tree

This is what we should do:

  S$Sim$Mact_CR_Tree[i]=
    S$Sim$NPP_CR_Tree[previous_i(i,S$Parameters$lifespanCR_Tree)]*
         after(i,S$Parameters$lifespanCR_Tree)

With after() a function to avoid a positive value of NPP if i is before any mortality:

after= function(x,ref){
  index= x-ref
  index[index<=0]= 0
  index[index>0]=1
  return(index)
}

This technique will remove only the old dry mass instead of a constant ratio of the dry mass.