示例#1
0
        /// <summary>
        /// Load the inductor in the circuit
        /// </summary>
        /// <param name="ckt"></param>
        public override void Load(Circuit ckt)
        {
            var state  = ckt.State;
            var rstate = state.Real;

            // Initialize
            if (state.UseIC && INDinitCond.Given)
            {
                state.States[0][INDstate + INDflux] = INDinduct * INDinitCond;
            }
            else
            {
                state.States[0][INDstate + INDflux] = INDinduct * rstate.OldSolution[INDbrEq];
            }

            // Handle mutual inductances
            UpdateMutualInductance?.Invoke(this, ckt);

            // Finally load the Y-matrix
            // Note that without an integration method, the result will be a short circuit
            if (ckt.Method != null)
            {
                var result = ckt.Method.Integrate(state, INDstate + INDflux, INDinduct);
                rstate.Rhs[INDbrEq]             += result.Ceq;
                rstate.Matrix[INDbrEq, INDbrEq] -= result.Geq;
            }

            rstate.Matrix[INDposNode, INDbrEq] += 1;
            rstate.Matrix[INDnegNode, INDbrEq] -= 1;
            rstate.Matrix[INDbrEq, INDposNode] += 1;
            rstate.Matrix[INDbrEq, INDnegNode] -= 1;
        }
示例#2
0
        /// <summary>
        /// Setup the inductor
        /// </summary>
        /// <param name="ckt">The circuit</param>
        public override void Setup(Circuit ckt)
        {
            var nodes = BindNodes(ckt);

            INDposNode = nodes[0].Index;
            INDnegNode = nodes[1].Index;
            INDbrEq    = CreateNode(ckt, CircuitNode.NodeType.Current).Index;

            // Create 2 states
            INDstate = ckt.State.GetState(2);

            // Clear all events
            foreach (var inv in UpdateMutualInductance.GetInvocationList())
            {
                UpdateMutualInductance -= (UpdateMutualInductanceEventHandler)inv;
            }
        }