Ejemplo n.º 1
0
        private static void CreateInfiltrationParametersDefaultFile(string infiltrationParametersFileName)
        {
            //Add an empty parameters group to InfiltrationParameters:
            var anInfiltrationGroup = new Universal.InfiltrationParametersGroup();

            anInfiltrationGroup.ParametersFileName = infiltrationParametersFileName;
            anInfiltrationGroup.ModelType          = "1";
            anInfiltrationGroup.DecayRate          = "0";
            anInfiltrationGroup.FinalRate          = "0";
            anInfiltrationGroup.InitialRate        = "0";
            Universal.InfiltrationParametersFiles.Add(infiltrationParametersFileName, anInfiltrationGroup);

            // Write new empty infiltration parameters file:
            TextWriter infiltrationParametersFile = new StreamWriter(infiltrationParametersFileName);

            infiltrationParametersFile.WriteLine("1");
            infiltrationParametersFile.WriteLine("0  0  0");
            infiltrationParametersFile.Close();
        }
Ejemplo n.º 2
0
        private static void LoadInfiltrationSecondaryData(string wholeFileName, ref List <string> warnings)
        {
            // Create new item in InfiltrationParametersFiles structure (of type InfiltrationParametersGroup) (if it is not already there) with
            // data from infiltration parameters file name.

            if (!Universal.InfiltrationParametersFiles.ContainsKey(wholeFileName))
            {
                if (File.Exists(wholeFileName))
                {
                    try
                    {
                        var          thisInfiltrationParameters = new Universal.InfiltrationParametersGroup();
                        StreamReader parametersFile;
                        parametersFile = File.OpenText(wholeFileName);

                        string   modelType   = parametersFile.ReadLine();
                        string   nParameters = parametersFile.ReadLine();
                        string   parameters  = parametersFile.ReadLine();
                        string[] split       = parameters.Split(new[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries);

                        parametersFile.Close();

                        //Store parameters:
                        thisInfiltrationParameters.ModelType          = modelType;
                        thisInfiltrationParameters.ParametersFileName = wholeFileName;
                        switch (Convert.ToInt32(modelType))
                        {
                        case 1: //Horton model
                            thisInfiltrationParameters.DecayRate   = split[0];
                            thisInfiltrationParameters.FinalRate   = split[1];
                            thisInfiltrationParameters.InitialRate = split[2];
                            break;

                        case 2: //HorGreen-Ampt model
                            thisInfiltrationParameters.HydraulicConductivity = split[0];
                            thisInfiltrationParameters.PsiWetting            = split[1];
                            thisInfiltrationParameters.DeltaTheta            = split[2];

                            thisInfiltrationParameters.DecayRate   = split[0];
                            thisInfiltrationParameters.FinalRate   = split[1];
                            thisInfiltrationParameters.InitialRate = split[2];

                            break;

                        case 3: //SCS-CN model
                            thisInfiltrationParameters.CNCurveNumber      = split[0];
                            thisInfiltrationParameters.InitialAbstraction = split[1];

                            thisInfiltrationParameters.DecayRate   = split[0];
                            thisInfiltrationParameters.FinalRate   = split[1];
                            thisInfiltrationParameters.InitialRate = "";
                            break;
                        }

                        //Store this new group of parameters:
                        Universal.InfiltrationParametersFiles.Add(wholeFileName, thisInfiltrationParameters);
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(Universal.Idioma("ERROR 2504172139: error reading file ", "ERROR 2504172139: error leyendo archivo ") +
                                        wholeFileName + ". " + ex.Message, "RiverFlow2D", MessageBoxButtons.OK,
                                        MessageBoxIcon.Error);
                    }
                }
                else
                {
                    //Gates apertures file doesn't exist. See if a default file was created.
                    if (warnings.IndexOf(wholeFileName) == -1)
                    {
                        // Write this default file.
                        warnings.Add(wholeFileName);
                        CreateInfiltrationParametersDefaultFile(wholeFileName);
                    }
                }
            }
        }