Exemple #1
0
        private void calcPerm()
        {
            double perm;

            settings.timeInMinutes = timeInMinutes;
            settings.timeInSeconds = timeInSeconds;
            settings.netWeight     = currentNetWeightString;
            settings.Save();
            double flow      = Convert.ToDouble(currentNetWeightString) / Convert.ToDouble(timeInSeconds);
            double thickness = Convert.ToDouble(settings.sampleThickness);
            double viscosity = Convert.ToDouble(settings.viscosity);
            double k1        = flow * thickness * viscosity * 14.7; //the 14.7 is a conversion factor, NOT atmospheric pressure! It lumps together the conversion from centipoise to poise for viscosity, the conversion from PSI to dynes/cm^2, and the conversion from cm^2 to Darcies.
            double area      = 3.1415926 * (Convert.ToDouble(settings.diameter) * Convert.ToDouble(settings.diameter)) / 4;

            //perm = k1  / (60 * area * Convert.ToDouble(textBoxPressure.Text)); //if time were in minutes
            perm = k1 / (area * (0.014 * Convert.ToDouble(settings.height))); //1m =1.4PSI => 1cm=0.014PSI

            //write to last line of file
            try
            {
                filePath = settings.dataPath;
                SR       = new StreamWriter(filePath, true);

                /*
                 * SR.WriteLine("");
                 * SR.WriteLine("Calculated Permeability (Darcies) =\t" + perm.ToString("#.00000"));*/
                SR.WriteLine("");
                SR.WriteLine("Total Weight = " + currentNetWeightString + " g");
                SR.WriteLine("Total Time = " + lastTimeInSeconds.ToString("#0.00") + " Secs");
                //SR.WriteLine("Flow Velocity = " + (weight / (Convert.ToDouble(settings.area) * time)).ToString("#0.000") + " cm/s");

                vel = (Convert.ToDouble(currentNetWeightString) / (Convert.ToDouble(settings.area) * Convert.ToDouble(lastTimeInSeconds.ToString("#0.00")))).ToString("#0.000");
                SR.WriteLine("Flow Velocity = " + vel + " cm/s");
                CommonClass.addVelToLast5(vel);
                SR.Close();
            }
            catch (Exception)
            {
            }
        }
Exemple #2
0
        public void SaveDataTableToFile()
        {
            writeHeader();
            SR = new StreamWriter(filePath, true);
            //option 1: first write the data from the last round

            /*foreach (DataRow row in tableArray[round - 2].Rows)
             * {
             * SR.WriteLine("{0,10}\t{1,10}", row.Field<string>(0), row.Field<string>(1));
             * lastw = row.Field<string>(1);
             * lastT = row.Field<string>(0);
             * }*/

            //option 2: write the average data from all the rounds
            int rowcount = 0;

            try
            {
                foreach (DataRow row in tableArray[round - 2].Rows)
                {
                    double sum     = 0;
                    double average = 0;

                    for (int i = 0; i < (round - 1); i++)
                    {
                        sum = sum + Convert.ToDouble(tableArray[i].Rows[rowcount][1]);
                    }
                    average = sum / (round - 1);
                    rowcount++;
                    SR.WriteLine("{0,10}\t{1,10}", row.Field <string>(0), average.ToString("0"));
                    lastw = average.ToString("0");
                    lastT = row.Field <string>(0);
                }
            }
            catch (Exception)
            {
                Debug.WriteLine("ERROR IN LOOPONG THROUGH tableArray");
            }


            //

            SR.WriteLine("");
            SR.WriteLine("***************************");
            SR.WriteLine("");
            //
            SR.WriteLine("Total Weight = " + lastw + " g");
            SR.WriteLine("Total Time = " + lastT + " Secs");
            //SR.WriteLine("Flow Velocity = " + (weight / (Convert.ToDouble(settings.area) * time)).ToString("#0.000") + " cm/s");
            vel = (Convert.ToDouble(lastw) / (Convert.ToDouble(settings.area) * Convert.ToDouble(lastT))).ToString("#0.000");
            SR.WriteLine("Flow Velocity = " + vel + " cm/s");
            SR.WriteLine("");
            SR.WriteLine("***************************");
            SR.WriteLine("");
            CommonClass.addVelToLast5(vel);
            //
            if (settings.maxRepetitions > 1)
            {
                for (int i = 0; i < round - 1; i++)
                {
                    SR.WriteLine("Round " + ((i + 1).ToString()));
                    foreach (DataRow row in tableArray[i].Rows)
                    {
                        SR.WriteLine("{0,10}\t{1,10}", row.Field <string>(0), row.Field <string>(1));
                    }
                    SR.WriteLine("");
                }
                SR.WriteLine("***************************");
                SR.WriteLine("");
                int k = 0;
                foreach (DataRow row in finalWeights.Rows)
                {
                    k++;
                    SR.WriteLine("{0,10}\t{1,10}", "Weight Round " + k.ToString(), row.Field <string>(0));
                }
                SR.WriteLine("{0,10}\t{1,10}", "Average Weight ", average.ToString("0"));
            }
            SR.Close();
        }