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>();

            _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. 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>();
            _variables = new TwoPort <Complex>(_complex, context);
            Branch     = _complex.CreatePrivateVariable(Name.Combine("branch"), Units.Ampere);
            var pos     = _complex.Map[_variables.Right.Positive];
            var neg     = _complex.Map[_variables.Right.Negative];
            var contPos = _complex.Map[_variables.Left.Positive];
            var contNeg = _complex.Map[_variables.Left.Negative];
            var br      = _complex.Map[Branch];

            _elements = new ElementSet <Complex>(_complex.Solver,
                                                 new MatrixLocation(pos, br),
                                                 new MatrixLocation(neg, br),
                                                 new MatrixLocation(br, pos),
                                                 new MatrixLocation(br, neg),
                                                 new MatrixLocation(br, contPos),
                                                 new MatrixLocation(br, contNeg));
        }
Esempio n. 3
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Time" /> class.
 /// </summary>
 /// <param name="context">The context.</param>
 /// <exception cref="ArgumentNullException">Thrown if <paramref name="context"/> is <c>null</c>.</exception>
 public Time(IComponentBindingContext context)
     : base(context)
 {
     _time     = context.GetState <ITimeSimulationState>();
     _pos1     = BiasingState.Map[BiasingState.GetSharedVariable(context.Nodes[0])];
     _neg1     = BiasingState.Map[BiasingState.GetSharedVariable(context.Nodes[1])];
     _pos2     = BiasingState.Map[BiasingState.GetSharedVariable(context.Nodes[2])];
     _neg2     = BiasingState.Map[BiasingState.GetSharedVariable(context.Nodes[3])];
     _br1      = BiasingState.Map[Branch1];
     _br2      = BiasingState.Map[Branch2];
     _elements = new ElementSet <double>(BiasingState.Solver, new[] {
         new MatrixLocation(_br1, _pos2),
         new MatrixLocation(_br1, _neg2),
         new MatrixLocation(_br1, _br2),
         new MatrixLocation(_br2, _pos1),
         new MatrixLocation(_br2, _neg1),
         new MatrixLocation(_br2, _br1)
     }, new[] { _br1, _br2 });
     Signals = new DelayedSignal(2, Parameters.Delay);
 }
        /// <summary>
        /// Initializes a new instance of the <see cref="Time"/> class.
        /// </summary>
        /// <param name="context"></param>
        public Time(IComponentBindingContext context)
            : base(context)
        {
            context.ThrowIfNull(nameof(context));
            context.Nodes.CheckNodes(LaplaceVoltageControlledVoltageSource.PinCount);

            var state = context.GetState <IBiasingSimulationState>();

            _variables = new TwoPort <double>(state, context);
            var pos     = state.Map[_variables.Right.Positive];
            var neg     = state.Map[_variables.Right.Negative];
            var contPos = state.Map[_variables.Left.Positive];
            var contNeg = state.Map[_variables.Left.Negative];

            _elements = new ElementSet <double>(state.Solver, new[] {
                new MatrixLocation(pos, contPos),
                new MatrixLocation(pos, contNeg),
                new MatrixLocation(neg, contPos),
                new MatrixLocation(neg, contNeg)
            }, new[] { pos, neg });
        }
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>();

            _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. 6
0
        /// <summary>
        /// Initializes a new instance of the <see cref="FrequencyBehavior"/> class.
        /// </summary>
        /// <param name="context">The context.</param>
        /// <exception cref="ArgumentNullException">Thrown if <paramref name="context"/> is <c>null</c>.</exception>
        public FrequencyBehavior(IComponentBindingContext context)
            : base(context)
        {
            ComplexState = context.GetState <IComplexSimulationState>();

            DrainPrime  = ComplexState.GetSharedVariable(context.Nodes[0]);
            _drainNode  = ComplexState.Map[DrainPrime];
            _gateNode   = ComplexState.Map[ComplexState.GetSharedVariable(context.Nodes[1])];
            SourcePrime = ComplexState.GetSharedVariable(context.Nodes[2]);
            _sourceNode = ComplexState.Map[SourcePrime];

            if (ModelParameters.DrainResistance > 0)
            {
                DrainPrime = ComplexState.CreatePrivateVariable(Name.Combine("drain"), Units.Volt);
            }
            _drainPrimeNode = ComplexState.Map[DrainPrime];

            if (ModelParameters.SourceResistance > 0)
            {
                SourcePrime = ComplexState.CreatePrivateVariable(Name.Combine("source"), Units.Volt);
            }
            _sourcePrimeNode = ComplexState.Map[SourcePrime];

            ComplexElements = new ElementSet <Complex>(ComplexState.Solver,
                                                       new MatrixLocation(_drainNode, _drainNode),
                                                       new MatrixLocation(_gateNode, _gateNode),
                                                       new MatrixLocation(_sourceNode, _sourceNode),
                                                       new MatrixLocation(_drainPrimeNode, _drainPrimeNode),
                                                       new MatrixLocation(_sourcePrimeNode, _sourcePrimeNode),
                                                       new MatrixLocation(_drainNode, _drainPrimeNode),
                                                       new MatrixLocation(_gateNode, _drainPrimeNode),
                                                       new MatrixLocation(_gateNode, _sourcePrimeNode),
                                                       new MatrixLocation(_sourceNode, _sourcePrimeNode),
                                                       new MatrixLocation(_drainPrimeNode, _drainNode),
                                                       new MatrixLocation(_drainPrimeNode, _gateNode),
                                                       new MatrixLocation(_drainPrimeNode, _sourcePrimeNode),
                                                       new MatrixLocation(_sourcePrimeNode, _gateNode),
                                                       new MatrixLocation(_sourcePrimeNode, _sourceNode),
                                                       new MatrixLocation(_sourcePrimeNode, _drainPrimeNode));
        }
Esempio n. 7
0
        /// <summary>
        /// Initializes a new instance of the <see cref="BiasingBehavior"/> class.
        /// </summary>
        /// <param name="context">The context.</param>
        /// <exception cref="ArgumentNullException">Thrown if <paramref name="context"/> is <c>null</c>.</exception>
        public BiasingBehavior(IComponentBindingContext context)
            : base(context)
        {
            context.ThrowIfNull(nameof(context));
            context.Nodes.CheckNodes(4);

            _biasing   = context.GetState <IBiasingSimulationState>();
            Parameters = context.GetParameterSet <Parameters>();
            _variables = new TwoPort <double>(_biasing, context);

            var pos     = _biasing.Map[_variables.Right.Positive];
            var neg     = _biasing.Map[_variables.Right.Negative];
            var contPos = _biasing.Map[_variables.Left.Positive];
            var contNeg = _biasing.Map[_variables.Left.Negative];

            _elements = new ElementSet <double>(_biasing.Solver, new[] {
                new MatrixLocation(pos, contPos),
                new MatrixLocation(pos, contNeg),
                new MatrixLocation(neg, contPos),
                new MatrixLocation(neg, contNeg)
            });
        }
Esempio n. 8
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)
            });
        }
Esempio n. 9
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Biasing"/> class.
        /// </summary>
        /// <param name="context">The context.</param>
        /// <exception cref="ArgumentNullException">Thrown if <paramref name="context"/> is <c>null</c>.</exception>
        public Biasing(IComponentBindingContext context)
            : base(context)
        {
            context.ThrowIfNull(nameof(context));
            context.Nodes.CheckNodes(4);

            Parameters = context.GetParameterSet <Parameters>();
            _biasing   = context.GetState <IBiasingSimulationState>();
            _variables = new TwoPort <double>(_biasing, context);
            Branch     = _biasing.CreatePrivateVariable(Name.Combine("branch"), Units.Ampere);
            var pos     = _biasing.Map[_variables.Right.Positive];
            var neg     = _biasing.Map[_variables.Right.Negative];
            var contPos = _biasing.Map[_variables.Left.Positive];
            var contNeg = _biasing.Map[_variables.Left.Negative];
            var br      = _biasing.Map[Branch];

            _elements = new ElementSet <double>(_biasing.Solver,
                                                new MatrixLocation(pos, br),
                                                new MatrixLocation(neg, br),
                                                new MatrixLocation(br, pos),
                                                new MatrixLocation(br, neg),
                                                new MatrixLocation(br, contPos),
                                                new MatrixLocation(br, contNeg));
        }
Esempio n. 10
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Accept"/> class.
 /// </summary>
 /// <param name="context">The context.</param>
 /// <exception cref="ArgumentNullException">Thrown if <paramref name="context"/> is <c>null</c>.</exception>
 public Accept(IComponentBindingContext context)
     : base(context)
 {
     _method = context.GetState <IIntegrationMethod>();
 }
Esempio n. 11
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Accept"/> class.
 /// </summary>
 /// <param name="context">The context.</param>
 /// <exception cref="ArgumentNullException">Thrown if <paramref name="context"/> is <c>null</c>.</exception>
 public Accept(IComponentBindingContext context)
     : base(context)
 {
     context.ThrowIfNull(nameof(context));
     _method = context.GetState <IIntegrationMethod>();
 }