Ejemplo n.º 1
0
        /// <summary>
        /// Advance the time with the specified timestep for the first time
        /// The actual timestep may be smaller due to breakpoints
        /// </summary>
        public void Resume()
        {
            // Are we at a breakpoint, or indistinguishably close?
            if (Time.Equals(Breaks.First) || Breaks.First - Time <= DeltaMin)
            {
                // First timepoint after a breakpoint: cut integration order
                Order = 1;

                // Limit the next timestep if there is a breakpoint
                double mt = Math.Min(SaveDelta, Breaks.Delta);
                Delta = Math.Min(Delta, 0.1 * mt);

                // Spice will divide the delta by 10 in the first step
                if (SavedTime.Equals(0.0))
                {
                    Delta /= 10.0;
                }

                // But we don't want to go below delmin for no reason
                Delta = Math.Max(Delta, DeltaMin * 2.0);
            }
            else if (Time + Delta >= Breaks.First)
            {
                // Breakpoint reached
                SaveDelta = Delta;
                Delta     = Breaks.First - Time;

                // We reached a breakpoint!
                Break = true;
            }

            // Update old delta's with the current delta
            DeltaOld.Store(Delta);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Initialize/reset the integration method
        /// </summary>
        /// <param name="behaviors">Truncation behaviors</param>
        public virtual void Initialize(BehaviorList <BaseTransientBehavior> behaviors)
        {
            // Initialize variables
            Time       = 0.0;
            _savetime  = 0.0;
            Delta      = 0.0;
            Order      = 1;
            Prediction = null;
            DeltaOld.Clear(0.0);
            Solutions.Clear((Vector <double>)null);

            // Get parameters
            BaseParameters = Parameters.Get <IntegrationParameters>();

            // Register default truncation methods
            _transientBehaviors = behaviors;
            if (BaseParameters.TruncationMethod.HasFlag(IntegrationParameters.TruncationMethods.PerDevice))
            {
                Truncate += TruncateDevices;
            }
            if (BaseParameters.TruncationMethod.HasFlag(IntegrationParameters.TruncationMethods.PerNode))
            {
                Truncate += TruncateNodes;
            }

            // Last point was START so the current point is the point after a breakpoint (start)
            Break = true;
        }