Skip to content

Commit

Permalink
fixed solid fertigation calculation injection rate unit conversion
Browse files Browse the repository at this point in the history
  • Loading branch information
lunamoonmoon committed Dec 24, 2024
1 parent 74ac817 commit 4689fb0
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions app/Server/src/SERVERAPI/Controllers/NutrientsController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -990,6 +990,7 @@ private void SolidFertigationCalculation(FertigationDetailsViewModel fgvm){
decimal tankVolume;
decimal solInWater;
decimal fertArea;
decimal convertedInjectionRate = 1;

if (fgvm.amountToDissolveUnits != "1"){
decimal convertedAmount = ConvertDissolve(Convert.ToDecimal(fgvm.amountToDissolve), (DissolveUnit)Convert.ToInt32(fgvm.amountToDissolveUnits), DissolveUnit.Pounds);
Expand All @@ -1014,15 +1015,30 @@ private void SolidFertigationCalculation(FertigationDetailsViewModel fgvm){
solInWater = Convert.ToDecimal(fgvm.solInWater);
}

// used to calculate fertigation time
switch (fgvm.selInjectionRateUnitOption)
{
case "1": // US gallon/min to Imperial Gallon/min
convertedInjectionRate = Convert.ToDecimal(fgvm.injectionRate) / 1.20095M;
break;
case "2": // L/min to Imperial Gallon/min
convertedInjectionRate = Convert.ToDecimal(fgvm.injectionRate) / 4.54609M;
break;
case "3": // Imperial Gallon/min
convertedInjectionRate = Convert.ToDecimal(fgvm.injectionRate);
break;
}

fertArea = Convert.ToDecimal(fgvm.fieldArea);

//Need in lb/us gallon
fgvm.nutrientConcentrationN = Convert.ToString(Math.Round(amountToDissolve * Convert.ToDecimal(fgvm.valN) / 100 / (tankVolume * 1.20095m), 2));
fgvm.nutrientConcentrationK2O = Convert.ToString(Math.Round(amountToDissolve * Convert.ToDecimal(fgvm.valK2o) / 100 / (tankVolume * 1.20095m), 2));
fgvm.nutrientConcentrationP205 = Convert.ToString(Math.Round(amountToDissolve * Convert.ToDecimal(fgvm.valP2o5) / 100 / (tankVolume * 1.20095m), 2));

decimal injectionRate = Convert.ToDecimal(fgvm.injectionRate);
fgvm.fertigationTime = Math.Round(Convert.ToDecimal(fgvm.tankVolume) / injectionRate, 0);

fgvm.fertigationTime = Math.Round(tankVolume / convertedInjectionRate, 0);


if (amountToDissolve <= tankVolume * solInWater/1000){
fgvm.dryAction = "Soluble";
Expand Down

0 comments on commit 4689fb0

Please sign in to comment.