Example #1
0
        /// <summary>
        /// Update inductor 2
        /// </summary>
        /// <param name="sender">Inductor 2</param>
        /// <param name="ckt">The circuit</param>
        private void UpdateMutualInductance(Inductor sender, Circuit ckt)
        {
            var state  = ckt.State;
            var rstate = ckt.State.Real;

            if (sender == ind1)
            {
                state.States[0][ind1.INDstate + INDflux]  += MUTfactor * rstate.OldSolution[ind2.INDbrEq];
                rstate.Matrix[ind1.INDbrEq, ind2.INDbrEq] -= MUTfactor * ckt.Method.Slope;
            }
            else
            {
                state.States[0][ind2.INDstate + INDflux]  += MUTfactor * rstate.OldSolution[ind1.INDbrEq];
                rstate.Matrix[ind2.INDbrEq, ind1.INDbrEq] -= MUTfactor * ckt.Method.Slope;
            }
        }
Example #2
0
        /// <summary>
        /// Setup the mutual inductance
        /// </summary>
        /// <param name="ckt">The circuit</param>
        public override void Setup(Circuit ckt)
        {
            // Find the inductors
            ind1 = ckt.Components[MUTind1] as Inductor;
            ind2 = ckt.Components[MUTind2] as Inductor;
            if (ind1 == null)
            {
                throw new CircuitException($"{Name}: Could not find inductor '{MUTind1.Value}'");
            }
            if (ind2 == null)
            {
                throw new CircuitException($"{Name}: Could not find inductor '{MUTind2.Value}'");
            }

            // Register our method for updating mutual inductance flux
            ind1.UpdateMutualInductance += UpdateMutualInductance;
        }