Skip to content

Commit

Permalink
chore: casing/naming quick tidy
Browse files Browse the repository at this point in the history
  • Loading branch information
Nibble-Byte committed Jun 1, 2024
1 parent eea65f6 commit 08d326b
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 32 deletions.
48 changes: 23 additions & 25 deletions SVSModel/Configuration/Constants.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
// Copyright (c) 2024 The New Zealand Institute for Plant and Food Research Limited

using System.Collections.Generic;
using System.ComponentModel;
using static SVSModel.Configuration.InputCategories;

namespace SVSModel.Configuration
{
Expand All @@ -14,7 +12,7 @@ public static class Constants
public const double InitialN = 50;

/// <summary>Dictionary containing values for the proportion of maximum DM that occurs at each predefined crop stage</summary>
public static readonly Dictionary<string, double> PropnMaxDM = new()
public static readonly Dictionary<string, double> PropNMaxDM = new()
{
{ "Seed", 0.004 },
{ "Seedling", 0.011 },
Expand All @@ -26,8 +24,8 @@ public static class Constants
{ "Late", 0.9995 }
};

/// <summary>Dictionary containing values for the proportion of thermal time to maturity that has accumulate at each predefined crop stage</summary>
public static readonly Dictionary<string, double> PropnTt = new()
/// <summary>Dictionary containing values for the proportion of thermal time to maturity that has accumulated at each predefined crop stage</summary>
public static readonly Dictionary<string, double> PropNTt = new()
{
{ "Seed", -0.0517 },
{ "Seedling", 0.050 },
Expand All @@ -47,7 +45,7 @@ public static class Constants
{ "kg/head", 1.0 }
};

/// <summary>Dictionary containing conversion from specified residue treatments to proportoins returned </summary>
/// <summary>Dictionary containing conversion from specified residue treatments to proportions returned </summary>
public static readonly Dictionary<string, double> ResidueFactRetained = new()
{
{ "None removed", 1.0 },
Expand All @@ -57,7 +55,7 @@ public static class Constants
{ "All removed", 0.0 }
};

/// <summary>Dictionary containing conversion from specified residue treatments to proportoins returned </summary>
/// <summary>Dictionary containing conversion from specified residue treatments to proportions returned </summary>
public static readonly Dictionary<string, double> ResidueIncorporation = new()
{
{ "None (Surface)", 0.0 },
Expand Down Expand Up @@ -101,7 +99,7 @@ public static class Constants
{ "Full", 0.9 }
};

/// <summary>Sample depth factor to adjust measurments to equivelent of 30cm measure</summary>
/// <summary>Sample depth factor to adjust measurements to equivalent of 30cm measure</summary>
public static readonly Dictionary<string, double> SampleDepthFactor = new()
{
{ "Top15cm", 0.75 },
Expand All @@ -111,7 +109,7 @@ public static class Constants
};

/// <summary>Available water capacity %</summary>
public static readonly Dictionary<string, double> AWCpct = new()
public static readonly Dictionary<string, double> AWCPercent = new()
{
{ "Sand", 8 },
{ "LoamySand", 18 },
Expand All @@ -127,7 +125,7 @@ public static class Constants
{ "Clay", 18 },
};

/// <summary>The porocity (mm3 pores/mm3 soil volume) of different soil texture classes</summary>
/// <summary>The porosity (mm3 pores/mm3 soil volume) of different soil texture classes</summary>
public static readonly Dictionary<string, double> Porosity = new()
{
{ "Sand", 0.5 },
Expand All @@ -148,28 +146,28 @@ public static class Constants
public static readonly Dictionary<string, double> ParticleDensity = new()
{
{ "Sedimentary", 2.65 },
{ "Volcanic", 1.9 },
{ "Volcanic", 1.9 }
};

public static double BulkDensity(string soilCategory, string soilTexture)
{
return Constants.ParticleDensity[soilCategory] * (1 - Constants.Porosity[soilTexture]);
return ParticleDensity[soilCategory] * (1 - Porosity[soilTexture]);
}

public static readonly Dictionary<string, Dictionary<string, double>> MoistureFactor = new Dictionary<string, Dictionary<string, double>>()
public static readonly Dictionary<string, Dictionary<string, double>> MoistureFactor = new()
{
{"Clay", new Dictionary<string, double>() { { "Dry", 1.8}, { "Moist", 1.5},{ "Wet", 1.3} } },
{"ClayLoam", new Dictionary<string, double>() { { "Dry", 1.7}, { "Moist", 1.4},{ "Wet", 1.3} } },
{"Loam", new Dictionary<string, double>() { { "Dry", 2.0}, { "Moist", 1.5},{ "Wet", 1.3} } },
{"LoamySand", new Dictionary<string, double>() { { "Dry", 1.8}, { "Moist", 1.5},{ "Wet", 1.4} } },
{"Sand", new Dictionary<string, double>() { { "Dry", 1.8}, { "Moist", 1.5},{ "Wet", 1.4} } },
{"SandyClay", new Dictionary<string, double>() { { "Dry", 1.8}, { "Moist", 1.4},{ "Wet", 1.3} } },
{"SandyClayLoam", new Dictionary<string, double>() { { "Dry", 1.9}, { "Moist", 1.6},{ "Wet", 1.4} } },
{"SandyLoam", new Dictionary<string, double>() { { "Dry", 2.1}, { "Moist", 1.8},{ "Wet", 1.5} } },
{"Silt", new Dictionary<string, double>() { { "Dry", 1.9}, { "Moist", 1.4},{ "Wet", 1.3} } },
{"SiltLoam", new Dictionary<string, double>() { { "Dry", 1.7}, { "Moist", 1.4},{ "Wet", 1.3} } },
{"SiltyClay", new Dictionary<string, double>() { { "Dry", 1.9}, { "Moist", 1.6},{ "Wet", 1.4} } },
{"SiltyClayLoam", new Dictionary<string, double>() { { "Dry", 1.9}, { "Moist", 1.5},{ "Wet", 1.4} } },
{ "Clay", new Dictionary<string, double> { { "Dry", 1.8}, { "Moist", 1.5}, { "Wet", 1.3} } },
{ "ClayLoam", new Dictionary<string, double> { { "Dry", 1.7}, { "Moist", 1.4}, { "Wet", 1.3} } },
{ "Loam", new Dictionary<string, double> { { "Dry", 2.0}, { "Moist", 1.5}, { "Wet", 1.3} } },
{ "LoamySand", new Dictionary<string, double> { { "Dry", 1.8}, { "Moist", 1.5}, { "Wet", 1.4} } },
{ "Sand", new Dictionary<string, double> { { "Dry", 1.8}, { "Moist", 1.5}, { "Wet", 1.4} } },
{ "SandyClay", new Dictionary<string, double> { { "Dry", 1.8}, { "Moist", 1.4}, { "Wet", 1.3} } },
{ "SandyClayLoam", new Dictionary<string, double> { { "Dry", 1.9}, { "Moist", 1.6}, { "Wet", 1.4} } },
{ "SandyLoam", new Dictionary<string, double> { { "Dry", 2.1}, { "Moist", 1.8}, { "Wet", 1.5} } },
{ "Silt", new Dictionary<string, double> { { "Dry", 1.9}, { "Moist", 1.4}, { "Wet", 1.3} } },
{ "SiltLoam", new Dictionary<string, double> { { "Dry", 1.7}, { "Moist", 1.4}, { "Wet", 1.3} } },
{ "SiltyClay", new Dictionary<string, double> { { "Dry", 1.9}, { "Moist", 1.6}, { "Wet", 1.4} } },
{ "SiltyClayLoam", new Dictionary<string, double> { { "Dry", 1.9}, { "Moist", 1.5}, { "Wet", 1.4} } }
};
}
}
Expand Down
11 changes: 4 additions & 7 deletions SVSModel/Models/Crop.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,10 @@

using System;
using System.Collections.Generic;
using System.Collections.Immutable;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.InteropServices.ComTypes;
using Microsoft.Data.Analysis;
using SVSModel;
using SVSModel.Configuration;
using SVSModel.Simulation;

Expand Down Expand Up @@ -44,19 +41,19 @@ public static CropType Grow(Dictionary<DateTime, double> meanT,
thisCrop.TtSowToEmerg = cropParams.TtSowtoEmerge;
}

double PropnTt_EstToHarv = Constants.PropnTt[cf.HarvestStage] - Math.Max(Constants.PropnTt[cf.EstablishStage], 0); //Constants.PropnTt["Emergence"]);
double PropnTt_EstToHarv = Constants.PropNTt[cf.HarvestStage] - Math.Max(Constants.PropNTt[cf.EstablishStage], 0); //Constants.PropNTt["Emergence"]);
thisCrop.TtEmergToMat = (thisCrop.TtEstabToHarv - thisCrop.TtSowToEmerg) * 1 / PropnTt_EstToHarv;

thisCrop.TtEmergToSeedling = 0;
if (cf.EstablishStage == "Seedling")
{
thisCrop.TtEmergToSeedling = thisCrop.TtEmergToMat * Constants.PropnTt["Seedling"];
thisCrop.TtEmergToSeedling = thisCrop.TtEmergToMat * Constants.PropNTt["Seedling"];
}

thisCrop.Xo_Biomass = thisCrop.TtEmergToMat * 0.5;
thisCrop.b_Biomass = thisCrop.Xo_Biomass * .2;
thisCrop.T_maxRD = Constants.PropnTt["EarlyReproductive"] * thisCrop.TtEmergToMat;
thisCrop.T_sen = Constants.PropnTt["MidReproductive"] * thisCrop.TtEmergToMat;
thisCrop.T_maxRD = Constants.PropNTt["EarlyReproductive"] * thisCrop.TtEmergToMat;
thisCrop.T_sen = Constants.PropNTt["MidReproductive"] * thisCrop.TtEmergToMat;
thisCrop.Xo_cov = thisCrop.Xo_Biomass * 0.4 / cropParams.rCover;
thisCrop.b_cov = thisCrop.Xo_cov * 0.2;
if (cropParams.TypicalYieldUnits == "kg/head")
Expand Down

0 comments on commit 08d326b

Please sign in to comment.