diff --git a/src/Plankton/CarbonMode/growth_kernels.jl b/src/Plankton/CarbonMode/growth_kernels.jl index 05c511c7..b9cd7c69 100644 --- a/src/Plankton/CarbonMode/growth_kernels.jl +++ b/src/Plankton/CarbonMode/growth_kernels.jl @@ -16,8 +16,10 @@ end ##### allocation of functional biomass to repair ##### only functional when damaged biomass is greater than 0.0 -@inline function gamma_alloc(temp, Bd, p) - γ = max(0.0, temp - p.Topt) / (p.Tmax - p.Topt) * isless(0.0, Bd) +##### use Bd/Bm as the allocation, more damaged biomass means more allocation to repair +@inline function gamma_alloc(Bm, Bd) + #γ = max(0.0, temp - p.Topt) / (p.Tmax - p.Topt) * isless(0.0, Bd) + γ = Bd / max(1.0e-30, Bm) * isless(0.0, Bd) γ = min(1.0, γ) return γ end @@ -48,7 +50,7 @@ end ##### calculate repair rate (mmolC/individual/second) @kernel function calc_repair_kernel!(plank, T, p) i = @index(Global) - @inbounds plank.RP[i] = plank.PS[i] * gamma_alloc(T[i], plank.Bd[i], p) + @inbounds plank.RP[i] = plank.PS[i] * gamma_alloc(plank.Bm[i], plank.Bd[i]) end function calc_repair!(plank, T, p, arch) kernel! = calc_repair_kernel!(device(arch), 256, (size(plank.ac,1))) @@ -59,7 +61,7 @@ end ##### calculate biosynthesis rate (mmolC/individual/second) @kernel function calc_BS_kernel!(plank, T, p) i = @index(Global) - @inbounds plank.BS[i] = plank.PS[i] * (1.0 - gamma_alloc(T[i], plank.Bd[i], p)) + @inbounds plank.BS[i] = plank.PS[i] * (1.0 - gamma_alloc(plank.Bm[i], plank.Bd[i])) end function calc_BS!(plank, T, p, arch) kernel! = calc_BS_kernel!(device(arch), 256, (size(plank.ac,1)))