Exemplo n.º 1
0
        /// <summary>
        /// Sets up for the specified simulation.
        /// </summary>
        /// <param name="simulation">The time-based simulation.</param>
        public override void Setup(TimeSimulation simulation)
        {
            base.Setup(simulation);

            // Base configuration
            var bp = simulation.Configurations.Get <BaseConfiguration>().ThrowIfNull("base configuration");

            AbsTol = bp.AbsoluteTolerance;
            RelTol = bp.RelativeTolerance;

            // Basic time configuration
            var tc = simulation.Configurations.Get <TimeConfiguration>().ThrowIfNull("time configuration");

            Breakpoints.SetBreakpoint(tc.InitTime);
            Breakpoints.SetBreakpoint(tc.FinalTime);
            MaxStep = tc.MaxStep;
            MinStep = tc.DeltaMin;
            // _saveDelta = tc.FinalTime / 50.0;
            _saveDelta = double.PositiveInfinity;

            // Detect spice configuration
            if (simulation.Configurations.TryGet(out SpiceConfiguration sc))
            {
                TrTol     = sc.TrTol;
                LteRelTol = sc.LteRelTol;
                LteAbsTol = sc.LteAbsTol;
                ChgTol    = sc.ChgTol;
                Expansion = sc.Expansion;
            }

            // Allocate a new vector for predictions
            Prediction = new DenseVector <double>(simulation.RealState.Solver.Order);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Accepts the last evaluated time point.
        /// </summary>
        /// <param name="simulation">The time-based simulation.</param>
        public override void Accept(TimeSimulation simulation)
        {
            // Clear breakpoints
            while (Time > Breakpoints.First)
            {
                Breakpoints.ClearBreakpoint();
            }
            Break = false;

            base.Accept(simulation);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Destroys the integration method.
        /// </summary>
        public override void Unsetup(TimeSimulation simulation)
        {
            base.Unsetup(simulation);

            // Clear prediction
            Prediction = null;

            // Clear all truncatable states
            TruncatableStates.Clear();

            // Remove all breakpoints
            Breakpoints.Clear();
            Break = false;
        }