Esempio n. 1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Frequency"/> class.
        /// </summary>
        /// <param name="context">The context.</param>
        /// <exception cref="ArgumentNullException">Thrown if <paramref name="context"/> is <c>null</c>.</exception>
        public Frequency(IComponentBindingContext context)
            : base(context)
        {
            _complex = context.GetState <IComplexSimulationState>();

            CollectorPrime = _complex.GetSharedVariable(context.Nodes[0]);
            BasePrime      = _complex.GetSharedVariable(context.Nodes[1]);
            EmitterPrime   = _complex.GetSharedVariable(context.Nodes[2]);
            _collectorNode = _complex.Map[CollectorPrime];
            _baseNode      = _complex.Map[BasePrime];
            _emitterNode   = _complex.Map[EmitterPrime];
            _substrateNode = _complex.Map[_complex.GetSharedVariable(context.Nodes[3])];

            // Add a series collector node if necessary
            if (ModelParameters.CollectorResistance > 0)
            {
                CollectorPrime = _complex.CreatePrivateVariable(Name.Combine("col"), Units.Volt);
            }
            _collectorPrimeNode = _complex.Map[CollectorPrime];

            // Add a series base node if necessary
            if (ModelParameters.BaseResist > 0)
            {
                BasePrime = _complex.CreatePrivateVariable(Name.Combine("base"), Units.Volt);
            }
            _basePrimeNode = _complex.Map[BasePrime];

            // Add a series emitter node if necessary
            if (ModelParameters.EmitterResistance > 0)
            {
                EmitterPrime = _complex.CreatePrivateVariable(Name.Combine("emit"), Units.Volt);
            }
            _emitterPrimeNode = _complex.Map[EmitterPrime];

            _elements = new ElementSet <Complex>(_complex.Solver,
                                                 new MatrixLocation(_collectorNode, _collectorNode),
                                                 new MatrixLocation(_baseNode, _baseNode),
                                                 new MatrixLocation(_emitterNode, _emitterNode),
                                                 new MatrixLocation(_collectorPrimeNode, _collectorPrimeNode),
                                                 new MatrixLocation(_basePrimeNode, _basePrimeNode),
                                                 new MatrixLocation(_emitterPrimeNode, _emitterPrimeNode),
                                                 new MatrixLocation(_collectorNode, _collectorPrimeNode),
                                                 new MatrixLocation(_baseNode, _basePrimeNode),
                                                 new MatrixLocation(_emitterNode, _emitterPrimeNode),
                                                 new MatrixLocation(_collectorPrimeNode, _collectorNode),
                                                 new MatrixLocation(_collectorPrimeNode, _basePrimeNode),
                                                 new MatrixLocation(_collectorPrimeNode, _emitterPrimeNode),
                                                 new MatrixLocation(_basePrimeNode, _baseNode),
                                                 new MatrixLocation(_basePrimeNode, _collectorPrimeNode),
                                                 new MatrixLocation(_basePrimeNode, _emitterPrimeNode),
                                                 new MatrixLocation(_emitterPrimeNode, _emitterNode),
                                                 new MatrixLocation(_emitterPrimeNode, _collectorPrimeNode),
                                                 new MatrixLocation(_emitterPrimeNode, _basePrimeNode),
                                                 new MatrixLocation(_substrateNode, _substrateNode),
                                                 new MatrixLocation(_collectorPrimeNode, _substrateNode),
                                                 new MatrixLocation(_substrateNode, _collectorPrimeNode),
                                                 new MatrixLocation(_baseNode, _collectorPrimeNode),
                                                 new MatrixLocation(_collectorPrimeNode, _baseNode));
        }
Esempio n. 2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Frequency" /> class.
        /// </summary>
        /// <param name="context">The context.</param>
        /// <exception cref="ArgumentNullException">Thrown if <paramref name="context"/> is <c>null</c>.</exception>
        public Frequency(IComponentBindingContext context)
            : base(context)
        {
            _complex = context.GetState <IComplexSimulationState>();

            _pos1 = _complex.Map[_complex.GetSharedVariable(context.Nodes[0])];
            _neg1 = _complex.Map[_complex.GetSharedVariable(context.Nodes[1])];
            _pos2 = _complex.Map[_complex.GetSharedVariable(context.Nodes[2])];
            _neg2 = _complex.Map[_complex.GetSharedVariable(context.Nodes[3])];

            Internal1 = _complex.CreatePrivateVariable(Name.Combine("int1"), Units.Volt);
            _int1     = _complex.Map[Internal1];
            Internal2 = _complex.CreatePrivateVariable(Name.Combine("int2"), Units.Volt);
            _int2     = _complex.Map[Internal2];
            Branch1   = _complex.CreatePrivateVariable(Name.Combine("branch1"), Units.Ampere);
            _br1      = _complex.Map[Branch1];
            Branch2   = _complex.CreatePrivateVariable(Name.Combine("branch2"), Units.Ampere);
            _br2      = _complex.Map[Branch2];

            _elements = new ElementSet <Complex>(_complex.Solver,
                                                 new MatrixLocation(_pos1, _pos1),
                                                 new MatrixLocation(_pos1, _int1),
                                                 new MatrixLocation(_neg1, _br1),
                                                 new MatrixLocation(_pos2, _pos2),
                                                 new MatrixLocation(_neg2, _br2),
                                                 new MatrixLocation(_int1, _pos1),
                                                 new MatrixLocation(_int1, _int1),
                                                 new MatrixLocation(_int1, _br1),
                                                 new MatrixLocation(_int2, _int2),
                                                 new MatrixLocation(_int2, _br2),
                                                 new MatrixLocation(_br1, _neg1),
                                                 new MatrixLocation(_br1, _pos2),
                                                 new MatrixLocation(_br1, _neg2),
                                                 new MatrixLocation(_br1, _int1),
                                                 new MatrixLocation(_br1, _br2),
                                                 new MatrixLocation(_br2, _pos1),
                                                 new MatrixLocation(_br2, _neg1),
                                                 new MatrixLocation(_br2, _neg2),
                                                 new MatrixLocation(_br2, _int2),
                                                 new MatrixLocation(_br2, _br1),
                                                 new MatrixLocation(_pos2, _int2),
                                                 new MatrixLocation(_int2, _pos2));
        }
Esempio n. 3
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Frequency"/> class.
        /// </summary>
        /// <param name="context">The context.</param>
        /// <exception cref="ArgumentNullException">Thrown if <paramref name="context"/> is <c>null</c>.</exception>
        public Frequency(IComponentBindingContext context)
            : base(context)
        {
            _complex   = context.GetState <IComplexSimulationState>();
            _variables = new OnePort <Complex>(_complex, context);
            Branch     = _complex.CreatePrivateVariable(Name.Combine("branch"), Units.Ampere);

            var pos = _complex.Map[_variables.Positive];
            var neg = _complex.Map[_variables.Negative];
            var br  = _complex.Map[Branch];

            _elements = new ElementSet <Complex>(_complex.Solver,
                                                 new MatrixLocation(pos, br),
                                                 new MatrixLocation(neg, br),
                                                 new MatrixLocation(br, neg),
                                                 new MatrixLocation(br, pos),
                                                 new MatrixLocation(br, br));
        }
Esempio n. 4
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Frequency"/> class.
        /// </summary>
        /// <param name="context">The context.</param>
        /// <exception cref="ArgumentNullException">Thrown if <paramref name="context"/> is <c>null</c>.</exception>
        public Frequency(IComponentBindingContext context)
            : base(context)
        {
            _complex = context.GetState <IComplexSimulationState>();

            _posNode     = _complex.Map[_complex.GetSharedVariable(context.Nodes[0])];
            _negNode     = _complex.Map[_complex.GetSharedVariable(context.Nodes[1])];
            _contPosNode = _complex.Map[_complex.GetSharedVariable(context.Nodes[2])];
            _contNegNode = _complex.Map[_complex.GetSharedVariable(context.Nodes[3])];
            Branch       = _complex.CreatePrivateVariable(Name.Combine("branch"), Units.Ampere);
            _branchEq    = _complex.Map[Branch];

            _elements = new ElementSet <Complex>(_complex.Solver, new[] {
                new MatrixLocation(_posNode, _branchEq),
                new MatrixLocation(_negNode, _branchEq),
                new MatrixLocation(_branchEq, _posNode),
                new MatrixLocation(_branchEq, _negNode),
                new MatrixLocation(_branchEq, _contPosNode),
                new MatrixLocation(_branchEq, _contNegNode)
            });
        }
Esempio n. 5
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Frequency"/> class.
        /// </summary>
        /// <param name="context">The context.</param>
        /// <exception cref="ArgumentNullException">Thrown if <paramref name="context"/> is <c>null</c>.</exception>
        public Frequency(IComponentBindingContext context)
            : base(context)
        {
            _complex = context.GetState <IComplexSimulationState>();

            _variables = new TwoPort <Complex>(_complex, context);
            int posNode     = _complex.Map[_variables.Right.Positive];
            int negNode     = _complex.Map[_variables.Right.Negative];
            int contPosNode = _complex.Map[_variables.Left.Positive];
            int contNegNode = _complex.Map[_variables.Left.Negative];

            Branch = _complex.CreatePrivateVariable(Name.Combine("branch"), Units.Ampere);
            int branchEq = _complex.Map[Branch];

            _elements = new ElementSet <Complex>(_complex.Solver, new[] {
                new MatrixLocation(posNode, branchEq),
                new MatrixLocation(negNode, branchEq),
                new MatrixLocation(branchEq, posNode),
                new MatrixLocation(branchEq, negNode),
                new MatrixLocation(branchEq, contPosNode),
                new MatrixLocation(branchEq, contNegNode)
            });
        }