コード例 #1
0
        /// <summary>
        /// Transient behavior
        /// </summary>
        /// <param name="simulation">Time-based simulation</param>
        public override void Transient(TimeSimulation simulation)
        {
            if (simulation == null)
            {
                throw new ArgumentNullException(nameof(simulation));
            }

            var    state = simulation.RealState;
            double vd    = state.Solution[_posPrimeNode] - state.Solution[_negNode];

            // This is the same calculation
            GetDcState(simulation);

            // Integrate
            CapCharge.Integrate();
            double geq = CapCharge.Jacobian(Capacitance);
            double ceq = CapCharge.RhsCurrent(geq, vd);

            // Store the current
            Current = _load.Current + CapCharge.Derivative;

            // Load Rhs vector
            NegPtr.Value      += ceq;
            PosPrimePtr.Value -= ceq;

            // Load Y-matrix
            NegNegPtr.Value           += geq;
            PosPrimePosPrimePtr.Value += geq;
            NegPosPrimePtr.Value      -= geq;
            PosPrimeNegPtr.Value      -= geq;
        }
コード例 #2
0
 /// <summary>
 /// Use local truncation error to cut timestep
 /// </summary>
 /// <returns>The timestep that satisfies the LTE</returns>
 public override double Truncate() => CapCharge.LocalTruncationError();