Skip to content

Commit

Permalink
cleaning up code
Browse files Browse the repository at this point in the history
creating separate plausibility file
  • Loading branch information
jbrider committed Dec 10, 2021
1 parent d704a92 commit bbdbebc
Show file tree
Hide file tree
Showing 9 changed files with 16,190 additions and 16,099 deletions.
40 changes: 0 additions & 40 deletions Models/PMF/Organs/Root.cs
Original file line number Diff line number Diff line change
Expand Up @@ -944,46 +944,6 @@ public double TotalExtractableWater()
return supply;
}

/// <summary>Plant Avaliable water supply used by sorghum.</summary>
/// <summary>It adds an extra layer proportion calc to extractableWater calc.</summary>
public double PlantAvailableWaterSupply()
{
double[] LL = soilCrop.LL;
double[] KL = soilCrop.KL;
double[] SWmm = PlantZone.WaterBalance.SWmm;
double[] DZ = PlantZone.Physical.Thickness;
double[] available = new double[PlantZone.Physical.Thickness.Length];
double[] supply = new double[PlantZone.Physical.Thickness.Length];

var currentLayer = SoilUtilities.LayerIndexOfDepth(PlantZone.Physical.Thickness, Depth);
var layertop = MathUtilities.Sum(PlantZone.Physical.Thickness, 0, Math.Max(0, currentLayer - 1));
var layerBottom = MathUtilities.Sum(PlantZone.Physical.Thickness, 0, currentLayer);
var layerProportion = Math.Min(MathUtilities.Divide(Depth - layertop, layerBottom - layertop, 0.0), 1.0);

for (int layer = 0; layer < LL.Length; layer++)
{
if (layer <= currentLayer)
{
available[layer] = Math.Max(0.0, SWmm[layer] - LL[layer] * DZ[layer] * PlantZone.LLModifier[layer]);
}
}
available[currentLayer] *= layerProportion;

double supplyTotal = 0;
for (int layer = 0; layer < LL.Length; layer++)
{
if (layer <= currentLayer)
{
supply[layer] = Math.Max(0.0, available[layer] * KL[layer] * klModifier.Value(layer) * KLModiferDueToDamage(layer) *
PlantZone.RootProportions[layer]);

supplyTotal += supply[layer];
}
}
return supplyTotal;
}


/// <summary>Document this model.</summary>
public override IEnumerable<ITag> Document()
{
Expand Down
23 changes: 4 additions & 19 deletions Models/PMF/Organs/SorghumLeaf.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
using System.Linq;
using System.Text;
using APSIM.Shared.Documentation;
using Models.Utilities;

namespace Models.PMF.Organs
{
Expand Down Expand Up @@ -43,9 +44,7 @@ public class SorghumLeaf : Model, IHasWaterDemand, IOrgan, IArbitration, IOrganD
[Link]
private ISummary summary = null;

/// <summary>
/// Culms on the leaf
/// </summary>
/// <summary> Culms on the leaf controls tillering</summary>
[Link]
public LeafCulms culms = null;

Expand Down Expand Up @@ -141,9 +140,6 @@ public class SorghumLeaf : Model, IHasWaterDemand, IOrgan, IArbitration, IOrganD
private double nDeadLeaves;
private double dltDeadLeaves;

/// <summary> The SMM2SM </summary>
private const double smm2sm = 1.0 / 1000000.0; //! conversion factor of mm^2 to m^2

/// <summary>Tolerance for biomass comparisons</summary>
protected double biomassToleranceValue = 0.0000000001;

Expand Down Expand Up @@ -314,11 +310,6 @@ public double PotentialEP
/// <summary>Gets or sets the lai dead.</summary>
public double LAIDead { get; set; }


///// <summary>Gets the total radiation intercepted.</summary>
//[Units("MJ/m^2/day")]
//public double RadiationIntercepted => CoverGreen * metData.Radn;

/// <summary>
/// Intercepted radiation value that is passed to the RUE class to calculate DM supply.
/// </summary>
Expand All @@ -342,7 +333,6 @@ public double RadiationIntercepted
}
}


/// <summary>Nitrogen Photosynthesis Stress.</summary>
public double NitrogenPhotoStress { get; set; }

Expand Down Expand Up @@ -557,11 +547,6 @@ public void UpdateArea()
// culms.AreaActual() will update this.DltLAI
DltLAI = culms.CalculateActualArea();
SenesceArea();

double dltDmGreen = potentialDMAllocation.Structural;
//if (Live.Wt + dltDmGreen > 0.0)
// sla = (LAI + DltStressedLAI) / (Live.Wt + dltDmGreen) * 10000; // (cm^2/g)

}
}
}
Expand Down Expand Up @@ -906,7 +891,6 @@ private double calcSLN(double laiToday, double nGreenToday)
return MathUtilities.Divide(nGreenToday, laiToday, 0.0);
}


/// <summary>Called when [simulation commencing].</summary>
/// <param name="sender">The sender.</param>
/// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
Expand Down Expand Up @@ -979,7 +963,7 @@ private void OnPhaseChanged(object sender, PhaseChangedType phaseChange)

Live.StructuralWt = InitialDMWeight * SowingDensity;
Live.StorageWt = 0.0;
LAI = InitialLAI * smm2sm * SowingDensity;
LAI = InitialLAI * SowingDensity.ConvertSqM2SqMM();
SLN = InitialSLN;

Live.StructuralN = LAI * SLN;
Expand Down Expand Up @@ -1102,6 +1086,7 @@ private void setDMSupply(object sender, EventArgs e)
private void SetNSupply(object sender, EventArgs e)
{
UpdateArea(); //must be calculated before potential N partitioning

var availableLaiN = DltLAI * NewLeafSLN;

double laiToday = CalcLAI();
Expand Down
Loading

0 comments on commit bbdbebc

Please sign in to comment.