diff --git a/src/crop/almass.jl b/src/crop/almass.jl index eb7db59037c188e707de12c30e65eb43c0aacf49..9c624066ffba5947cbd2ffe4e22597e8add15fbd 100644 --- a/src/crop/almass.jl +++ b/src/crop/almass.jl @@ -201,10 +201,10 @@ function stepagent!(cs::CropState, model::SimulationModel) # (https://www.eea.europa.eu/publications/europes-changing-climate-hazards-1/heat-and-cold/heat-and-cold-2014-mean) basetemp = cs.croptype.mingrowthtemp ismissing(basetemp) && (basetemp = 5.0) - gdd = (maxtemp(model)+mintemp(model))/2 - basetemp - gdd > 0 && (cs.growingdegreedays += gdd) + delta_gdd = bounds((maxtemp(model) + mintemp(model)) / 2 - basetemp) + cs.growingdegreedays += delta_gdd # update crop growth - growcrop!(cs, gdd, model) + growcrop!(cs, delta_gdd, model) end @@ -248,14 +248,18 @@ end #TODO till!() """ - growcrop!(cropstate, gdd, model) + growcrop!(cropstate, delta_gdd, model) -Apply the relevant crop growth model to update the plants crop state -on this farm plot. Implements the ALMaSS crop growth model by Topping -et al. (see `ALMaSS/Landscape/plant.cpp:PlantGrowthData::FindDiff()` and +Update the crop state on this farm plot for a given daily change in +growing-degree days `delta_gdd` (units of 'Kelvin Days'). + +Implements the ALMaSS crop growth model by Topping et al. (see +`ALMaSS/Landscape/plant.cpp:PlantGrowthData::FindDiff()` and `ALMaSS/Landscape/elements.cpp:VegElement::DoDevelopment()`). """ -function growcrop!(cs::CropState, gdd::Float64, model::SimulationModel) +function growcrop!(cs::CropState, delta_gdd::Real, model::SimulationModel) + total_gdd = cs.growingdegreedays + # TODO: logic the wrong way around for fertiliser? fertiliser in cs.events ? curve = cs.croptype.lownutrientgrowth : curve = cs.croptype.highnutrientgrowth @@ -270,17 +274,11 @@ function growcrop!(cs::CropState, gdd::Float64, model::SimulationModel) cs.LAIgreen = curve.LAIgreen[cs.phase][p] return else - gdd = cs.growingdegreedays # figure out which is the correct slope value to use for growth - if p == length(points) || gdd < points[p+1] - #FIXME it appears to me from the ALMaSS source code that the curve value - # for the day is multiplied with that day's growingdegreedays to give the - # diff, which is then added to the previous values. However, this results - # in values that are staggeringly too large. I'm not quite sure what the - # issue is here... - cs.height += bounds(curve.height[cs.phase][p]*gdd) - cs.LAItotal += bounds(curve.LAItotal[cs.phase][p]*gdd) - cs.LAIgreen += bounds(curve.LAIgreen[cs.phase][p]*gdd) + if p == length(points) || total_gdd < points[p+1] + cs.height += curve.height[cs.phase][p] * delta_gdd + cs.LAItotal += curve.LAItotal[cs.phase][p] * delta_gdd + cs.LAIgreen += curve.LAIgreen[cs.phase][p] * delta_gdd return end #XXX To be precise, we ought to figure out if one or more inflection