public static double CalculateEfficiency(double depth, double NDCIACN, double DCIAPercent, string zone) { // Get the String Index of the Lower and Upper Depths to look up the table if (depth == 0.0) { return(0.0); } double DCIAP = DCIAPercent; if (DCIAP < 5) { DCIAP = 5; } int lowerDepthIndex = GetLowerDepthIndex(depth); int upperDepthIndex = 0; if (lowerDepthIndex < Depths.Length - 1) { upperDepthIndex = lowerDepthIndex + 1; } else { upperDepthIndex = Depths.Length - 1; } string lowerDepth = Depths[lowerDepthIndex]; string upperDepth = Depths[upperDepthIndex]; // Get the Lookup tables needed, we need 2 tables to interpolate between the tables var lowerLookupTable = StaticLookupTables.RetentionEfficiencyTable(lowerDepth, zone); var upperLookupTable = StaticLookupTables.RetentionEfficiencyTable(upperDepth, zone); var lowerEfficiency = lowerLookupTable.Calculate(NDCIACN, DCIAP); var upperEfficiency = upperLookupTable.Calculate(NDCIACN, DCIAP); var lowerD = Convert.ToDouble(lowerDepth); var upperD = Convert.ToDouble(upperDepth); if (Math.Abs(upperEfficiency - lowerEfficiency) < 0.00001) { return(lowerEfficiency); } if (Math.Abs(upperD - lowerD) < 0.000001) { return(lowerEfficiency); } // Added to fix odd efficiency problem if (lowerEfficiency > upperEfficiency) { return(upperEfficiency); } return(lowerEfficiency + ((depth - lowerD) / (upperD - lowerD)) * (upperEfficiency - lowerEfficiency)); }
private void btnViewAnnualC_Click(object sender, EventArgs e) { // #eaglin - make clean output Form form = new frmReport(StaticLookupTables.RationalCTableAsHtml(Globals.Project.RainfallZone)); form.ShowDialog(); }
private void getValues() { RainfallZone = Common.getString(cbMetZone); NDCIACN = Common.getDouble(tbRow); DCIAP = Common.getDouble(tbColumn); RationalC = Common.getDouble(tbTable); lut = StaticLookupTables.RationalCoeffientLookupTable(RainfallZone); wbReport.DocumentText = lut.AsHtml(); }
private void frmRetentionEfficiencyLUT_Load(object sender, EventArgs e) { // Bind Meteorological Zones to Combo cbMetZone.Items.Clear(); BindingSource bs = new BindingSource(); bs.DataSource = StaticLookupTables.RainfallZones(); cbMetZone.DataSource = bs; Common.setValue(cbMetZone, Globals.Project.RainfallZone); }
public static LookupTable getLookupTable(double depth, string zone) { int lowerDepthIndex = GetLowerDepthIndex(depth); int upperDepthIndex = 0; if (lowerDepthIndex < Depths.Length - 1) { upperDepthIndex = lowerDepthIndex + 1; } else { upperDepthIndex = Depths.Length - 1; } string lowerDepth = Depths[lowerDepthIndex]; string upperDepth = Depths[upperDepthIndex]; // Get the Lookup tables needed, we need 2 tables to interpolate between the tables var lowerLookupTable = StaticLookupTables.RetentionEfficiencyTable(lowerDepth, zone); var upperLookupTable = StaticLookupTables.RetentionEfficiencyTable(upperDepth, zone); if (lowerDepth == upperDepth) { return(lowerLookupTable); } double ratio = (depth - Convert.ToDouble(lowerDepth)) / (Convert.ToDouble(upperDepth) - Convert.ToDouble(lowerDepth)); if (ratio == 0) { return(lowerLookupTable); } // Convert To Array double[,] lookupValuesLower = LookupTable.AsDoubleArray2D(lowerLookupTable.TableData); double[,] lookupValuesUpper = LookupTable.AsDoubleArray2D(upperLookupTable.TableData); for (int i = 0; i < lookupValuesLower.GetLength(0); i++) { for (int j = 0; j < lookupValuesLower.GetLength(1); j++) { lookupValuesLower[i, j] = lookupValuesLower[i, j] + ratio * (lookupValuesUpper[i, j] - lookupValuesLower[i, j]); } } // Convert Back to String lowerLookupTable.TableData = LookupTable.ImportData(lookupValuesLower, 2); lowerLookupTable.Name = "Efficiency at Retention Depth: " + depth.ToString() + " (in) for Rainfall " + zone; return(lowerLookupTable); }
public new void Calculate() { RationalCforCAreaAt3inches = StaticLookupTables.MaxRationalC(Globals.Project.RainfallZone); // Not really at 3 inches EquivalentImperviousArea = ContributingArea * RationalCforCAreaAt3inches; // acres if (EquivalentImperviousArea == 0) { return; } HarvestVolumeOverEIA = 12 * HarvestVolume / EquivalentImperviousArea; // Harvest Volume (ac-ft) - inches over EIA //if (SolveForChoice == sHarvestEfficiency) //{ HarvestRate = (AvailableHarvestRate * IrrigationArea * 43560) / (7 * 12); // CF/Day HarvestRateOverEIA = 12.0 * HarvestRate / (EquivalentImperviousArea * 43560.0); CalculatedHarvestEfficiency = getEfficiencyLUT().CalculateRowValue(HarvestVolumeOverEIA, HarvestRateOverEIA); if (CalculatedHarvestEfficiency > maxHarvestTreatmentEfficiency) { CalculatedHarvestEfficiency = maxHarvestTreatmentEfficiency; } HarvestWaterDemand = AvailableHarvestRate * 52 * 0.325829 * IrrigationArea / 12.0; HarvestWaterSupply = CalculatedHarvestEfficiency * EquivalentImperviousArea * Rainfall * 0.325829 / 1200; ProvidedNTreatmentEfficiency = CalculatedHarvestEfficiency; ProvidedPTreatmentEfficiency = CalculatedHarvestEfficiency; //} //if (SolveForChoice == sHarvestRate) //{ // ProvidedNTreatmentEfficiency = HarvestEfficiency; // ProvidedPTreatmentEfficiency = HarvestEfficiency; // HarvestRateOverEIA = getEfficiencyLUT().Calculate(HarvestEfficiency, HarvestVolumeOverEIA); // RequiredHarvestRateCFD = HarvestRateOverEIA * EquivalentImperviousArea * 43560 / 12; // RequiredHarvestRateINWEEK = RequiredHarvestRateCFD * 7 * 12 / ( IrrigationArea * 43560); // HarvestWaterDemand = RequiredHarvestRateINWEEK * 52 * 0.325829 * IrrigationArea / 12; // HarvestWaterSupply = HarvestEfficiency * EquivalentImperviousArea * Rainfall * 0.325829 / 1200; //} if (HarvestWaterDemand > HarvestWaterSupply) { SupplementalWater = HarvestWaterDemand - HarvestWaterSupply; } else { SupplementalWater = 0.0; } base.Calculate(); CalculateMassLoading(); }
private void CalculateLUT() { string LowerDepth = RetentionEfficiencyLookupTables.getLowerDepth(RetentionDepth); string UpperDepth = RetentionEfficiencyLookupTables.getUpperDepth(RetentionDepth); lutLower = StaticLookupTables.RetentionEfficiencyTable(LowerDepth, RainfallZone); lutUpper = StaticLookupTables.RetentionEfficiencyTable(UpperDepth, RainfallZone); if (LowerDepth == UpperDepth) { lut = lutLower; } else { lut = RetentionEfficiencyLookupTables.getLookupTable(RetentionDepth, RainfallZone); } }
public List <string> RainfallZones() { return(StaticLookupTables.RainfallZones()); }