public void ModifiedSecantMethodTest()
        {
            Numerics.Numerics           target   = new Numerics.Numerics(); // TODO: Initialize to an appropriate value
            double                      fx       = 0F;                      // TODO: Initialize to an appropriate value
            double                      x        = 0F;                      // TODO: Initialize to an appropriate value
            double                      fxdel    = 0F;                      // TODO: Initialize to an appropriate value
            double                      delta    = 0F;                      // TODO: Initialize to an appropriate value
            Dictionary <string, double> expected = null;                    // TODO: Initialize to an appropriate value
            Dictionary <string, double> actual;

            actual = target.ModifiedSecantMethod(fx, x, fxdel, delta);
            Assert.AreEqual(expected, actual);
            Assert.Inconclusive("Verify the correctness of this test method.");
        }
        public override bool PerformTimeStep()
        {
            //reading the input exchange items Quantatiy and ID
            ScalarSet precip = (ScalarSet)this.GetValues(this.GetInputExchangeItem(0).Quantity.ID, this.GetInputExchangeItem(0).ElementSet.ID);

            double[] Fp = new double[precip.Count];
            //double[] F = new double[precip.Count];
            double[] Runoff = new double[precip.Count];
            double[] cumulative_infiltration = new double[precip.Count];

            for (int i = 0; i <= precip.Count - 1; i++)
            {
                //Get input values from elementValues datatable
                _Ks       = Convert.ToSingle(_elementValues.Rows[i]["Ks"]);
                _n        = Convert.ToSingle(_elementValues.Rows[i]["Porosity"]);
                _FieldCap = Convert.ToSingle(_elementValues.Rows[i]["FieldCapacity"]);
                _Wilting  = Convert.ToSingle(_elementValues.Rows[i]["WiltingPoint"]);
                _Phi      = Convert.ToSingle(_elementValues.Rows[i]["SuctionHead"]);
                _DepStor  = Convert.ToSingle(_elementValues.Rows[i]["DepressionStorage"]);
                _theta    = (float).5 * (_Wilting + _FieldCap);

                //Calculate infiltration capacity
                Fp[i] = _Ks + (_Ks * (_n - _theta) * _Phi) / _F[i];


                //Determine how much rainfall will infiltrate
                if (precip.data[i] <= _Ks)
                {
                    //All rainfall will be absorbed
                    _F[i]  += precip.data[i] * _dt;
                    _Excess = 0.0;
                    //Console.WriteLine("Cumulative Infiltration: " + _F[i].ToString());
                }
                else
                {
                    if (PondingCalculated[i] == false)
                    {
                        //Calculate the time ponding occurs
                        calculatePonding(precip.data[i], _F[i]);
                        PondingCalculated[i] = true;
                    }


                    Numerics.Numerics           solver  = new Numerics.Numerics();
                    Dictionary <string, double> Results = new Dictionary <string, double>();

                    double x1 = 0;
                    double x2 = 50;

                    double fx1 = fval(x1);
                    double fx2 = fval(x2);
                    double e   = 1;

                    while (e > 0.000001)
                    {
                        Results = solver.SecantMethod(fx1, x1, fx2, x2);
                        e       = Results["error"];
                        x1      = Results["x1"];
                        x2      = Results["x2"];
                        fx1     = fval(x1);
                        fx2     = fval(x2);
                    }


                    _Excess = _F[i] + precip.data[i] * _dt - x1;
                    _F[i]   = x1;
                }

                //Determine how much rainfall will become depression storage
                if ((_DepStor - _cumStorage[i]) > 0.0)
                {
                    if (_Excess >= (_DepStor - _cumStorage[i]))
                    {
                        _Excess       -= _DepStor - _cumStorage[i];
                        _cumStorage[i] = _DepStor;
                    }
                    else
                    {
                        _cumStorage[i] += _Excess;
                        _Excess         = 0.0;
                    }
                }

                Runoff[i] = _Excess;
                cumulative_infiltration[i] = _cumStorage[i];

                //Add values to DateTimes and Vals, for ODM writeout in Finish()
                _Vals.Add(_Excess);
                TimeStamp t = (TimeStamp)this.GetCurrentTime();
                DateTime  T = CalendarConverter.ModifiedJulian2Gregorian(t.ModifiedJulianDay);
                _DateTimes.Add(T);
            }
            //Console.WriteLine("{0:F2} \t\t {1:F3} \t\t {2:F0} \t\t {3:F2} \t\t {4:F2} \t\t {5:F2} ", _F[0], _dt, precip.data[0], precip.data[0] * _dt, _cumStorage[0], _Excess);


            //set the excess rainfall values as runoff output
            string q1 = this.GetOutputExchangeItem(0).Quantity.ID;
            string e1 = this.GetOutputExchangeItem(0).ElementSet.ID;

            this.SetValues(q1, e1, new ScalarSet(Runoff));

            //set the cumulative infitration storage depth
            string q2 = this.GetOutputExchangeItem(1).Quantity.ID;
            string e2 = this.GetOutputExchangeItem(1).ElementSet.ID;

            this.SetValues(q2, e2, new ScalarSet(_F));

            _T += _dt;
            this.AdvanceTime();
            return(true);
        }
 public void NumericsConstructorTest()
 {
     Numerics.Numerics target = new Numerics.Numerics();
     Assert.Inconclusive("TODO: Implement code to verify target");
 }