Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Maize leaf #7620

Open
wants to merge 19 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 49 additions & 0 deletions Models/Functions/BellCurveDeltaLAIFunction.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
using System;
using Models.Core;

namespace Models.Functions
{
/// <summary>
/// Calculates the daily change in plant leaf area (mm2/plant) assuming a Bell-shaped curve distribution of plant leaf sizes, accounting for mutliple leaves expanding in parallel.
/// </summary>
[Serializable]
public class BellCurveDeltaLAIFunction : Model, IFunction
{
/// <summary>The largest leaf position</summary>
[Link(Type = LinkType.Child, ByName = true)] IFunction largestLeafPosition = null; // Node position where the largest leaf occurs (e.g. 10 is the 10th leaf from bottom to top)
/// <summary>The area maximum</summary>
[Link(Type = LinkType.Child, ByName = true)] IFunction areaMax = null; // Area of the largest leaf of a plant (m2)
/// <summary>The breadth</summary>
[Link(Type = LinkType.Child, ByName = true)] IFunction breadth = null;
/// <summary>The skewness</summary>
[Link(Type = LinkType.Child, ByName = true)] IFunction skewness = null;
/// <summary>The number of leaf tips</summary>
[Link(Type = LinkType.Child, ByName = true)] IFunction leafTips = null;
/// <summary>The number of leaf ligules (ie fully expanded leaves)</summary>
[Link(Type = LinkType.Child, ByName = true)] IFunction leafLigules = null;
/// <summary>Leaf Apprearance Rate</summary>
[Link(Type = LinkType.Child, ByName = true)] IFunction leafAppearanceRate = null; // (/day)
/// <summary>Plant Population</summary>
[Link(Type = LinkType.Child, ByName = true)] IFunction population = null; // (/m2)


/// <summary>Gets the value.</summary>
public double Value(int arrayIndex = -1)
{
double tips = leafTips.Value(arrayIndex);
double collars = leafLigules.Value(arrayIndex);

double deltaLAI = 0;
int lowestExpandingLeaf = Convert.ToInt32(collars + 1);
int highestExpandingLeaf = Convert.ToInt32(tips);

for (int l = lowestExpandingLeaf; l < highestExpandingLeaf; l++)
{
double leafarea = areaMax.Value(arrayIndex) * Math.Exp(breadth.Value(arrayIndex) * Math.Pow(l - largestLeafPosition.Value(arrayIndex), 2.0)
+ skewness.Value(arrayIndex) * (Math.Pow(l - largestLeafPosition.Value(arrayIndex), 3.0)));
deltaLAI += leafarea * leafAppearanceRate.Value(arrayIndex) * population.Value(arrayIndex);
}
return deltaLAI;
}
}
}
30 changes: 16 additions & 14 deletions Models/PMF/Phenology/Scales/BBCH.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System;
using APSIM.Shared.Utilities;
using Models.Core;
using Models.Functions;
using Models.PMF.Organs;
using Models.PMF.Struct;

Expand Down Expand Up @@ -47,20 +48,14 @@ public class BBCH : Model
Phenology Phenology = null;

/// <summary>
/// The Leaf class
/// The Simple Leaf class
/// </summary>
[Link]
Leaf leaf = null;

/// <summary>
/// The Structure class
/// </summary>
[Link]
Structure structure = null;
SimpleLeaf leaf = null;

bool StemExtensionInitialised = false;
bool TasselVisiable = false;
int ligulesAtStartStemExtension = 0;
double ligulesAtStartStemExtension = 0;
double FractionInPhaseAtBBCH50 = 0;

/// <summary>Gets the stage.</summary>
Expand All @@ -73,24 +68,31 @@ public double Stage
{
double fracInCurrent = Phenology.FractionInCurrentPhase;
double BBCH_stage = 0.0;
double LeafTips = (leaf.FindChild("Tips") as IFunction).Value();
double LeafLigules = (leaf.FindChild("Ligules") as IFunction).Value();
double FinalLeafNumber = (leaf.FindChild("FinalLeafNumber") as IFunction).Value();

if (Phenology.InPhase("Germinating"))
BBCH_stage = 5.0f * fracInCurrent;
else if (Phenology.InPhase("Emerging"))
{

BBCH_stage = 5.0f + 5 * fracInCurrent;
}
else if (Phenology.InPhase("Juvenile") || Phenology.InPhase("PhotoSensitive"))
{
BBCH_stage = Math.Min(19.0, 10.0f + Math.Max(0, leaf.AppearedCohortNo - 1));
BBCH_stage = Math.Min(19.0, 10.0f + Math.Max(0, LeafTips - 1));
}
else if (Phenology.InPhase("LeafAppearance") && (leaf.AppearedCohortNo <= structure.finalLeafNumber.Value()))
else if (Phenology.InPhase("LeafAppearance") && (LeafTips <= FinalLeafNumber))
{
if (StemExtensionInitialised == false)
{
ligulesAtStartStemExtension = leaf.ExpandedCohortNo;
ligulesAtStartStemExtension = LeafLigules;
StemExtensionInitialised = true;
}
BBCH_stage = 30.0f + Math.Min(9, leaf.ExpandedCohortNo - ligulesAtStartStemExtension);
BBCH_stage = 30.0f + Math.Min(9, LeafLigules - ligulesAtStartStemExtension);
}
else if (Phenology.InPhase("LeafAppearance") && (leaf.AppearedCohortNo >= structure.finalLeafNumber.Value()))
else if (Phenology.InPhase("LeafAppearance") && (LeafTips >= FinalLeafNumber))
{
if (TasselVisiable == false)
{
Expand Down
Loading