/// <summary>
        /// Allocate elements in the Y-matrix and Rhs-vector to populate during loading. Additional
        /// equations can also be allocated here.
        /// </summary>
        /// <param name="variables">The variable set.</param>
        /// <param name="solver">The solver.</param>
        public void GetEquationPointers(VariableSet variables, Solver <double> solver)
        {
            variables.ThrowIfNull(nameof(variables));
            solver.ThrowIfNull(nameof(solver));

            SourcePrimeNode = ModelParameters.SourceResistance > 0 ? variables.Create(Name.Combine("source")).Index : SourceNode;
            DrainPrimeNode  = ModelParameters.DrainResistance > 0 ? variables.Create(Name.Combine("drain")).Index : DrainNode;

            GateNodePtr               = solver.GetRhsElement(GateNode);
            DrainPrimeNodePtr         = solver.GetRhsElement(DrainPrimeNode);
            SourcePrimeNodePtr        = solver.GetRhsElement(SourcePrimeNode);
            DrainDrainPrimePtr        = solver.GetMatrixElement(DrainNode, DrainPrimeNode);
            GateDrainPrimePtr         = solver.GetMatrixElement(GateNode, DrainPrimeNode);
            GateSourcePrimePtr        = solver.GetMatrixElement(GateNode, SourcePrimeNode);
            SourceSourcePrimePtr      = solver.GetMatrixElement(SourceNode, SourcePrimeNode);
            DrainPrimeDrainPtr        = solver.GetMatrixElement(DrainPrimeNode, DrainNode);
            DrainPrimeGatePtr         = solver.GetMatrixElement(DrainPrimeNode, GateNode);
            DrainPrimeSourcePrimePtr  = solver.GetMatrixElement(DrainPrimeNode, SourcePrimeNode);
            SourcePrimeGatePtr        = solver.GetMatrixElement(SourcePrimeNode, GateNode);
            SourcePrimeSourcePtr      = solver.GetMatrixElement(SourcePrimeNode, SourceNode);
            SourcePrimeDrainPrimePtr  = solver.GetMatrixElement(SourcePrimeNode, DrainPrimeNode);
            DrainDrainPtr             = solver.GetMatrixElement(DrainNode, DrainNode);
            GateGatePtr               = solver.GetMatrixElement(GateNode, GateNode);
            SourceSourcePtr           = solver.GetMatrixElement(SourceNode, SourceNode);
            DrainPrimeDrainPrimePtr   = solver.GetMatrixElement(DrainPrimeNode, DrainPrimeNode);
            SourcePrimeSourcePrimePtr = solver.GetMatrixElement(SourcePrimeNode, SourcePrimeNode);
        }
        /// <summary>
        /// Gets matrix pointers
        /// </summary>
        /// <param name="variables">Nodes</param>
        /// <param name="solver">Solver</param>
        public void GetEquationPointers(VariableSet variables, Solver <double> solver)
        {
            variables.ThrowIfNull(nameof(variables));
            solver.ThrowIfNull(nameof(solver));

            // Add series drain node if necessary
            if (ModelParameters.DrainResistance > 0 || ModelParameters.SheetResistance > 0 && BaseParameters.DrainSquares > 0)
            {
                DrainNodePrime = variables.Create(Name.Combine("drain")).Index;
            }
            else
            {
                DrainNodePrime = DrainNode;
            }

            // Add series source node if necessary
            if (ModelParameters.SourceResistance > 0 || ModelParameters.SheetResistance > 0 && BaseParameters.SourceSquares > 0)
            {
                SourceNodePrime = variables.Create(Name.Combine("source")).Index;
            }
            else
            {
                SourceNodePrime = SourceNode;
            }

            // Get matrix pointers
            DrainDrainPtr             = solver.GetMatrixElement(DrainNode, DrainNode);
            GateGatePtr               = solver.GetMatrixElement(GateNode, GateNode);
            SourceSourcePtr           = solver.GetMatrixElement(SourceNode, SourceNode);
            BulkBulkPtr               = solver.GetMatrixElement(BulkNode, BulkNode);
            DrainPrimeDrainPrimePtr   = solver.GetMatrixElement(DrainNodePrime, DrainNodePrime);
            SourcePrimeSourcePrimePtr = solver.GetMatrixElement(SourceNodePrime, SourceNodePrime);
            DrainDrainPrimePtr        = solver.GetMatrixElement(DrainNode, DrainNodePrime);
            GateBulkPtr               = solver.GetMatrixElement(GateNode, BulkNode);
            GateDrainPrimePtr         = solver.GetMatrixElement(GateNode, DrainNodePrime);
            GateSourcePrimePtr        = solver.GetMatrixElement(GateNode, SourceNodePrime);
            SourceSourcePrimePtr      = solver.GetMatrixElement(SourceNode, SourceNodePrime);
            BulkDrainPrimePtr         = solver.GetMatrixElement(BulkNode, DrainNodePrime);
            BulkSourcePrimePtr        = solver.GetMatrixElement(BulkNode, SourceNodePrime);
            DrainPrimeSourcePrimePtr  = solver.GetMatrixElement(DrainNodePrime, SourceNodePrime);
            DrainPrimeDrainPtr        = solver.GetMatrixElement(DrainNodePrime, DrainNode);
            BulkGatePtr               = solver.GetMatrixElement(BulkNode, GateNode);
            DrainPrimeGatePtr         = solver.GetMatrixElement(DrainNodePrime, GateNode);
            SourcePrimeGatePtr        = solver.GetMatrixElement(SourceNodePrime, GateNode);
            SourcePrimeSourcePtr      = solver.GetMatrixElement(SourceNodePrime, SourceNode);
            DrainPrimeBulkPtr         = solver.GetMatrixElement(DrainNodePrime, BulkNode);
            SourcePrimeBulkPtr        = solver.GetMatrixElement(SourceNodePrime, BulkNode);
            SourcePrimeDrainPrimePtr  = solver.GetMatrixElement(SourceNodePrime, DrainNodePrime);

            // Get rhs pointers
            BulkPtr        = solver.GetRhsElement(BulkNode);
            DrainPrimePtr  = solver.GetRhsElement(DrainNodePrime);
            SourcePrimePtr = solver.GetRhsElement(SourceNodePrime);
        }
Exemple #3
0
        /// <summary>
        /// Gets the node indexes (in order).
        /// </summary>
        /// <param name="nodes">The nodes.</param>
        /// <returns>An enumerable for all nodes.</returns>
        /// <exception cref="ArgumentNullException">nodes</exception>
        public IEnumerable <int> GetNodeIndexes(VariableSet nodes)
        {
            nodes.ThrowIfNull(nameof(nodes));

            // Map connected nodes
            foreach (var node in _connections)
            {
                var index = nodes.MapNode(node).Index;
                yield return(index);
            }
        }
Exemple #4
0
        /// <summary>
        /// Gets matrix pointers
        /// </summary>
        /// <param name="variables">Variables</param>
        /// <param name="solver">Solver</param>
        public void GetEquationPointers(VariableSet variables, Solver <double> solver)
        {
            variables.ThrowIfNull(nameof(variables));
            solver.ThrowIfNull(nameof(solver));

            BranchEq            = variables.Create(Name.Combine("branch"), VariableType.Current).Index;
            PosBranchPtr        = solver.GetMatrixElement(PosNode, BranchEq);
            NegBranchPtr        = solver.GetMatrixElement(NegNode, BranchEq);
            BranchPosPtr        = solver.GetMatrixElement(BranchEq, PosNode);
            BranchNegPtr        = solver.GetMatrixElement(BranchEq, NegNode);
            BranchControlPosPtr = solver.GetMatrixElement(BranchEq, ContPosNode);
            BranchControlNegPtr = solver.GetMatrixElement(BranchEq, ContNegNode);
        }
Exemple #5
0
        /// <summary>
        /// Update the indices for the component.
        /// </summary>
        /// <param name="nodes">The variable set.</param>
        /// <returns>The node indices.</returns>
        protected int[] ApplyConnections(VariableSet nodes)
        {
            nodes.ThrowIfNull(nameof(nodes));

            // Map connected nodes
            var indexes = new int[_connections.Length];

            for (var i = 0; i < _connections.Length; i++)
            {
                indexes[i] = nodes.MapNode(_connections[i]).Index;
            }
            return(indexes);
        }
        /// <summary>
        /// Gets matrix pointers
        /// </summary>
        /// <param name="variables">Variables</param>
        /// <param name="solver">Solver</param>
        public void GetEquationPointers(VariableSet variables, Solver <double> solver)
        {
            variables.ThrowIfNull(nameof(variables));
            solver.ThrowIfNull(nameof(solver));

            // Add a series collector node if necessary
            CollectorPrimeNode = ModelParameters.CollectorResistance.Value > 0 ? variables.Create(Name.Combine("col")).Index : CollectorNode;

            // Add a series base node if necessary
            BasePrimeNode = ModelParameters.BaseResist.Value > 0 ? variables.Create(Name.Combine("base")).Index : BaseNode;

            // Add a series emitter node if necessary
            EmitterPrimeNode = ModelParameters.EmitterResistance.Value > 0 ? variables.Create(Name.Combine("emit")).Index : EmitterNode;

            // Get solver pointers
            CollectorCollectorPrimePtr    = solver.GetMatrixElement(CollectorNode, CollectorPrimeNode);
            BaseBasePrimePtr              = solver.GetMatrixElement(BaseNode, BasePrimeNode);
            EmitterEmitterPrimePtr        = solver.GetMatrixElement(EmitterNode, EmitterPrimeNode);
            CollectorPrimeCollectorPtr    = solver.GetMatrixElement(CollectorPrimeNode, CollectorNode);
            CollectorPrimeBasePrimePtr    = solver.GetMatrixElement(CollectorPrimeNode, BasePrimeNode);
            CollectorPrimeEmitterPrimePtr = solver.GetMatrixElement(CollectorPrimeNode, EmitterPrimeNode);
            BasePrimeBasePtr              = solver.GetMatrixElement(BasePrimeNode, BaseNode);
            BasePrimeCollectorPrimePtr    = solver.GetMatrixElement(BasePrimeNode, CollectorPrimeNode);
            BasePrimeEmitterPrimePtr      = solver.GetMatrixElement(BasePrimeNode, EmitterPrimeNode);
            EmitterPrimeEmitterPtr        = solver.GetMatrixElement(EmitterPrimeNode, EmitterNode);
            EmitterPrimeCollectorPrimePtr = solver.GetMatrixElement(EmitterPrimeNode, CollectorPrimeNode);
            EmitterPrimeBasePrimePtr      = solver.GetMatrixElement(EmitterPrimeNode, BasePrimeNode);
            CollectorCollectorPtr         = solver.GetMatrixElement(CollectorNode, CollectorNode);
            BaseBasePtr       = solver.GetMatrixElement(BaseNode, BaseNode);
            EmitterEmitterPtr = solver.GetMatrixElement(EmitterNode, EmitterNode);
            CollectorPrimeCollectorPrimePtr = solver.GetMatrixElement(CollectorPrimeNode, CollectorPrimeNode);
            BasePrimeBasePrimePtr           = solver.GetMatrixElement(BasePrimeNode, BasePrimeNode);
            EmitterPrimeEmitterPrimePtr     = solver.GetMatrixElement(EmitterPrimeNode, EmitterPrimeNode);
            SubstrateSubstratePtr           = solver.GetMatrixElement(SubstrateNode, SubstrateNode);
            CollectorPrimeSubstratePtr      = solver.GetMatrixElement(CollectorPrimeNode, SubstrateNode);
            SubstrateCollectorPrimePtr      = solver.GetMatrixElement(SubstrateNode, CollectorPrimeNode);
            BaseCollectorPrimePtr           = solver.GetMatrixElement(BaseNode, CollectorPrimeNode);
            CollectorPrimeBasePtr           = solver.GetMatrixElement(CollectorPrimeNode, BaseNode);

            // Get RHS pointers
            CollectorPrimePtr = solver.GetRhsElement(CollectorPrimeNode);
            BasePrimePtr      = solver.GetRhsElement(BasePrimeNode);
            EmitterPrimePtr   = solver.GetRhsElement(EmitterPrimeNode);
        }
Exemple #7
0
        /// <summary>
        /// Get equation pointers
        /// </summary>
        /// <param name="variables">Variables</param>
        /// <param name="solver">Solver</param>
        public void GetEquationPointers(VariableSet variables, Solver <double> solver)
        {
            variables.ThrowIfNull(nameof(variables));
            solver.ThrowIfNull(nameof(solver));

            // Create
            PosPrimeNode = ModelParameters.Resistance > 0 ? variables.Create(Name.Combine("pos")).Index : PosNode;

            // Get matrix elements
            PosPosPrimePtr      = solver.GetMatrixElement(PosNode, PosPrimeNode);
            NegPosPrimePtr      = solver.GetMatrixElement(NegNode, PosPrimeNode);
            PosPrimePosPtr      = solver.GetMatrixElement(PosPrimeNode, PosNode);
            PosPrimeNegPtr      = solver.GetMatrixElement(PosPrimeNode, NegNode);
            PosPosPtr           = solver.GetMatrixElement(PosNode, PosNode);
            NegNegPtr           = solver.GetMatrixElement(NegNode, NegNode);
            PosPrimePosPrimePtr = solver.GetMatrixElement(PosPrimeNode, PosPrimeNode);

            // Get RHS elements
            NegPtr      = solver.GetRhsElement(NegNode);
            PosPrimePtr = solver.GetRhsElement(PosPrimeNode);
        }
Exemple #8
0
        /// <summary>
        /// Allocate elements in the Y-matrix and Rhs-vector to populate during loading. Additional
        /// equations can also be allocated here.
        /// </summary>
        /// <param name="variables">The variable set.</param>
        /// <param name="solver">The solver.</param>
        public void GetEquationPointers(VariableSet variables, Solver <double> solver)
        {
            variables.ThrowIfNull(nameof(variables));
            solver.ThrowIfNull(nameof(solver));

            // Allocate branch equations first
            Internal1 = variables.Create(Name.Combine("int1")).Index;
            Internal2 = variables.Create(Name.Combine("int2")).Index;
            BranchEq1 = variables.Create(Name.Combine("branch1"), VariableType.Current).Index;
            BranchEq2 = variables.Create(Name.Combine("branch2"), VariableType.Current).Index;

            Pos1Pos1Ptr = solver.GetMatrixElement(Pos1, Pos1);
            Pos1Int1Ptr = solver.GetMatrixElement(Pos1, Internal1);
            Int1Pos1Ptr = solver.GetMatrixElement(Internal1, Pos1);
            Int1Int1Ptr = solver.GetMatrixElement(Internal1, Internal1);
            Int1Ibr1Ptr = solver.GetMatrixElement(Internal1, BranchEq1);
            Ibr1Int1Ptr = solver.GetMatrixElement(BranchEq1, Internal1);
            Neg1Ibr1Ptr = solver.GetMatrixElement(Neg1, BranchEq1);
            Ibr1Neg1Ptr = solver.GetMatrixElement(BranchEq1, Neg1);

            Pos2Pos2Ptr = solver.GetMatrixElement(Pos2, Pos2);
            Pos2Int2Ptr = solver.GetMatrixElement(Pos2, Internal2);
            Int2Pos2Ptr = solver.GetMatrixElement(Internal2, Pos2);
            Int2Int2Ptr = solver.GetMatrixElement(Internal2, Internal2);
            Int2Ibr2Ptr = solver.GetMatrixElement(Internal2, BranchEq2);
            Ibr2Int2Ptr = solver.GetMatrixElement(BranchEq2, Internal2);
            Neg2Ibr2Ptr = solver.GetMatrixElement(Neg2, BranchEq2);
            Ibr2Neg2Ptr = solver.GetMatrixElement(BranchEq2, Neg2);

            // These pointers are only used to calculate the DC operating point
            Ibr1Pos1Ptr = solver.GetMatrixElement(BranchEq1, Pos1);
            Ibr1Pos2Ptr = solver.GetMatrixElement(BranchEq1, Pos2);
            Ibr1Neg2Ptr = solver.GetMatrixElement(BranchEq1, Neg2);
            Ibr2Ibr1Ptr = solver.GetMatrixElement(BranchEq2, BranchEq1);
            Ibr2Ibr2Ptr = solver.GetMatrixElement(BranchEq2, BranchEq2);
        }