Ejemplo n.º 1
0
        /// <summary>
        /// Setup the current source
        /// </summary>
        /// <param name="ckt">The circuit</param>
        public override void Setup(Circuit ckt)
        {
            var nodes = BindNodes(ckt);

            ISRCposNode = nodes[0].Index;
            ISRCnegNode = nodes[1].Index;

            // Setup waveform
            ISRCwaveform?.Setup(ckt);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Load the current source in the circuit
        /// </summary>
        /// <param name="ckt"></param>
        public override void Load(Circuit ckt)
        {
            var state  = ckt.State;
            var rstate = state.Real;

            double value = 0.0;
            double time  = 0.0;

            // Time domain analysis
            if (state.Domain == CircuitState.DomainTypes.Time)
            {
                if (ckt.Method != null)
                {
                    time = ckt.Method.Time;
                }

                // Use the waveform if possible
                if (ISRCwaveform != null)
                {
                    value = ISRCwaveform.At(time);
                }
                else
                {
                    value = ISRCdcValue * state.SrcFact;
                }
            }
            else
            {
                // AC or DC analysis use the DC value
                value = ISRCdcValue * state.SrcFact;
            }

            rstate.Rhs[ISRCposNode] += value;
            rstate.Rhs[ISRCnegNode] -= value;
            Current = value;
        }
Ejemplo n.º 3
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="name">The name of the current source</param>
 /// <param name="pos">The positive node</param>
 /// <param name="neg">The negative node</param>
 /// <param name="w">The waveform</param>
 public Currentsource(string name, string pos, string neg, Waveform w) : base(name, 2)
 {
     Connect(pos, neg);
     ISRCwaveform.Set(w);
 }
Ejemplo n.º 4
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="name">The name of the current source</param>
 /// <param name="pos">The positive node</param>
 /// <param name="neg">The negative node</param>
 /// <param name="dc">The DC value</param>
 public Currentsource(string name, string pos, string neg, double dc) : base(name, 2)
 {
     Connect(pos, neg);
     ISRCwaveform.Set(dc);
 }