コード例 #1
0
ファイル: Accept.cs プロジェクト: saugkim/aaa_SpiceSharp
        /// <inheritdoc/>
        void IAcceptBehavior.Accept()
        {
            if (_method is IBreakpointMethod method)
            {
                // The integration method supports breakpoints, let's see if we need to add one
                if (_wasBreak || method.Break)
                {
                    // Calculate the slope of the accepted timepoint
                    var slope = method.Time.Equals(0.0)
                        ? 0.0
                        : (Signal.GetValue(0, 0) - Signal.GetValue(1, 0)) /
                                (Signal.GetTime(0) - Signal.GetTime(1));

                    // The previous point was a breakpoint, let's see if we need to add another breakpoint
                    if (_wasBreak)
                    {
                        var tol = Parameters.RelativeTolerance * Math.Max(Math.Abs(_oldSlope), Math.Abs(slope)) + Parameters.AbsoluteTolerance;
                        if (Math.Abs(slope - _oldSlope) > tol)
                        {
                            method.Breakpoints.SetBreakpoint(Signal.GetTime(1) + Signal.Delay);
                        }
                    }

                    // Track for the next time
                    _oldSlope = slope;
                    _wasBreak = method.Break;
                }
            }

            // Move to the next probed value
            Signal.AcceptProbedValues();
        }