示例#1
0
        /// <summary>
        ///
        /// </summary>
        /// <returns></returns>
        public bool SimulateDay()
        {
            bool result = true;

            try
            {
                ControlError = "";
                if (!FReset)
                {
                    ClimateController.Simulate();
                }
                if (!FReset)
                {
                    AdjustKeyDatesForYear();
                }
                if (!FReset)
                {
                    SetStartOfDayParameters();
                }
                if (!FReset)
                {
                    ApplyResetsIfAny();
                }
                if (!FReset)
                {
                    TryModelIrrigation();
                }
                if (!FReset)
                {
                    SoilController.TryModelSoilCracking();
                }
                if (!FReset)
                {
                    SoilController.CalculateRunoff();
                }

                if (!FReset)
                {
                    SoilController.CalculatSoilEvaporation();
                }
                //
                //if (!FReset) SoilController.UpdateWaterBalance();
                //
                if (!FReset)
                {
                    TryModelVegetation();
                }
                if (!FReset)
                {
                    SoilController.UpdateWaterBalance();
                }
                if (!FReset)
                {
                    TryModelTillage();
                }
                if (!FReset)
                {
                    SoilController.CalculateResidue();
                }
                if (!FReset)
                {
                    SoilController.CalculateErosion();
                }
                if (!FReset)
                {
                    TryModelRingTank();
                }
                if (!FReset)
                {
                    TryModelPesticide();
                }
                if (!FReset)
                {
                    TryModelPhosphorus();
                }
                if (!FReset)
                {
                    TryModelNitrate();
                }
                if (!FReset)
                {
                    TryModelSolutes();
                }
                if (!FReset)
                {
                    SoilController.TryModelLateralFlow();
                }
                if (!FReset)
                {
                    UpdateCropWaterBalance();
                }
                if (!FReset)
                {
                    SoilController.UpdateFallowWaterBalance();
                }
                if (!FReset)
                {
                    SoilController.UpdateTotalWaterBalance();
                }
                if (!FReset)
                {
                    TryUpdateRingTankWaterBalance();
                }
                //if (!FReset) SoilController.UpdateMonthlyStatistics();
                if (!FReset)
                {
                    SoilController.CalculateVolumeBalanceError();
                }
                if (!FReset)
                {
                    ExportDailyOutputs();
                }
                if (!FReset)
                {
                    ResetAnyParametersIfRequired();
                }
            }
            catch (Exception e)
            {
                result = false;

                List <string> Text = new List <string>();
                if (Today > new DateTime(1800, 1, 1) && Today < new DateTime(2100, 1, 1))
                {
                    //Text.Add("There was an error in the simulation on day " + (seriesindex + 1).ToString() + " (" + Today.ToString("dd/mm/yyyy") + ")");
                    Text.Add("There was an error in the simulation on day " + " (" + Today.ToString("dd/mm/yyyy") + ")");
                }
                if (ControlError.Length > 0)
                {
                    Text.Add("The error occurred in the function called " + ControlError);
                }
                if (Text.Count > 0 && Text.Count < 3)
                {
                    //throw (new Exception(String.Join("\n", Text.ToArray(), e.Message))); //mtError
                }
                else
                {
                    throw (new Exception("Error Simulating Day", new Exception(e.Message)));
                }
            }
            return(result);
        }