/// <summary> /// Initializes a new instance of the <see cref="Frequency"/> class. /// </summary> /// <param name="context">The binding context.</param> public Frequency(IComponentBindingContext context) : base(context) { context.ThrowIfNull(nameof(context)); context.Nodes.CheckNodes(LaplaceVoltageControlledVoltageSource.PinCount); var bstate = context.GetState <IBiasingSimulationState>(); _dblVariables = new TwoPort <double>(bstate, context); var pos = bstate.Map[_dblVariables.Right.Positive]; var neg = bstate.Map[_dblVariables.Right.Negative]; var contPos = bstate.Map[_dblVariables.Left.Positive]; var contNeg = bstate.Map[_dblVariables.Left.Negative]; _dblElements = new ElementSet <double>(bstate.Solver, new[] { new MatrixLocation(pos, contPos), new MatrixLocation(pos, contNeg), new MatrixLocation(neg, contPos), new MatrixLocation(neg, contNeg) }); var cstate = context.GetState <IComplexSimulationState>(); _cplxVariables = new TwoPort <Complex>(cstate, context); pos = cstate.Map[_cplxVariables.Right.Positive]; neg = cstate.Map[_cplxVariables.Right.Negative]; contPos = cstate.Map[_cplxVariables.Left.Positive]; contNeg = cstate.Map[_cplxVariables.Left.Negative]; _cplxElements = new ElementSet <Complex>(cstate.Solver, new[] { new MatrixLocation(pos, contPos), new MatrixLocation(pos, contNeg), new MatrixLocation(neg, contPos), new MatrixLocation(neg, contNeg) }); }
/// <summary> /// Initializes a new instance of the <see cref="Frequency"/> class. /// </summary> /// <param name="context">The binding 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); _elements = new ElementSet <Complex>(_complex.Solver, null, _variables.GetRhsIndices(_complex.Map)); }
/// <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>(); ComplexVariables = new DiodeVariables <Complex>(Name, _complex, context); _elements = new ElementSet <Complex>(_complex.Solver, ComplexVariables.GetMatrixLocations(_complex.Map)); }
/// <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 <VoltageDelayParameters>(); var state = context.GetState <IBiasingSimulationState>(); _posNode = state.Map[state.GetSharedVariable(context.Nodes[0])]; _negNode = state.Map[state.GetSharedVariable(context.Nodes[1])]; _contPosNode = state.Map[state.GetSharedVariable(context.Nodes[2])]; _contNegNode = state.Map[state.GetSharedVariable(context.Nodes[3])]; Branch = state.CreatePrivateVariable(Name.Combine("branch"), Units.Ampere); _branchEq = state.Map[Branch]; BiasingElements = new ElementSet <double>(state.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) }); }
/// <summary> /// Initializes a new instance of the <see cref="MosfetVariables{T}"/> struct. /// </summary> /// <param name="context">The binding context.</param> /// <param name="factory">The variable factory.</param> public MosfetVariables(IComponentBindingContext context, IVariableFactory <IVariable <T> > factory) { var nodes = context.Nodes.CheckNodes(4); Drain = factory.GetSharedVariable(nodes[0]); Gate = factory.GetSharedVariable(nodes[1]); Source = factory.GetSharedVariable(nodes[2]); Bulk = factory.GetSharedVariable(nodes[3]); var bp = context.GetParameterSet <Parameters>(); var mbp = context.ModelBehaviors.GetParameterSet <ModelParameters>(); if (!mbp.DrainResistance.Equals(0.0) || !mbp.SheetResistance.Equals(0.0) && bp.DrainSquares > 0) { DrainPrime = factory.CreatePrivateVariable(context.Behaviors.Name.Combine("drain"), Units.Volt); } else { DrainPrime = Drain; } if (!mbp.SourceResistance.Equals(0.0) || !mbp.SheetResistance.Equals(0.0) && bp.SourceSquares > 0) { SourcePrime = factory.CreatePrivateVariable(context.Behaviors.Name.Combine("source"), Units.Volt); } else { SourcePrime = Source; } }
/// <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.Nodes.CheckNodes(4); // Get configurations BaseConfiguration = context.GetSimulationParameterSet <BiasingParameters>(); // Get states Iteration = context.GetState <IIterationSimulationState>(); CollectorPrime = BiasingState.GetSharedVariable(context.Nodes[0]); BasePrime = BiasingState.GetSharedVariable(context.Nodes[1]); EmitterPrime = BiasingState.GetSharedVariable(context.Nodes[2]); _collectorNode = BiasingState.Map[CollectorPrime]; _baseNode = BiasingState.Map[BasePrime]; _emitterNode = BiasingState.Map[EmitterPrime]; // Add a series collector node if necessary if (ModelParameters.CollectorResistance > 0) { CollectorPrime = BiasingState.CreatePrivateVariable(Name.Combine("col"), Units.Volt); } _collectorPrimeNode = BiasingState.Map[CollectorPrime]; // Add a series base node if necessary if (ModelParameters.BaseResist > 0) { BasePrime = BiasingState.CreatePrivateVariable(Name.Combine("base"), Units.Volt); } _basePrimeNode = BiasingState.Map[BasePrime]; // Add a series emitter node if necessary if (ModelParameters.EmitterResistance > 0) { EmitterPrime = BiasingState.CreatePrivateVariable(Name.Combine("emit"), Units.Volt); } _emitterPrimeNode = BiasingState.Map[EmitterPrime]; // Get solver pointers _elements = new ElementSet <double>(BiasingState.Solver, new[] { 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[] { _collectorPrimeNode, _basePrimeNode, _emitterPrimeNode }); }
/// <summary> /// Initializes a new instance of the <see cref="Biasing"/> class. /// </summary> /// <param name="context">The binding context.</param> public Time(IComponentBindingContext context) : base(context) { context.ThrowIfNull(nameof(context)); context.Nodes.CheckNodes(4); var _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[] { new MatrixLocation(pos, br), new MatrixLocation(neg, br), new MatrixLocation(br, pos), new MatrixLocation(br, neg), new MatrixLocation(br, contPos), new MatrixLocation(br, contNeg) }, new[] { br }); }
/// <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>(); var state = context.GetState <IBiasingSimulationState>(); Variables = new TwoPort <double>(state, context); int posNode = state.Map[Variables.Right.Positive]; int negNode = state.Map[Variables.Right.Negative]; int contPosNode = state.Map[Variables.Left.Positive]; int contNegNode = state.Map[Variables.Left.Negative]; Branch = state.CreatePrivateVariable(Name.Combine("branch"), Units.Ampere); int branchEq = state.Map[Branch]; BiasingElements = new ElementSet <double>(state.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) }); }
/// <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) { var state = context.GetState <IComplexSimulationState>(); _variables = new OnePort <Complex>(state, context); _elements = new ElementSet <Complex>(state.Solver, _variables.GetMatrixLocations(state.Map)); }
/// <summary> /// Creates a new diode biasing behavior. /// </summary> /// <param name="context"></param> public DiodeBiasing(IComponentBindingContext context) : base(context) { var biasingState = context.GetState <IBiasingSimulationState>(); // Get the variables that our diode is connected to _variableA = biasingState.GetSharedVariable(context.Nodes[0]); _variableB = biasingState.GetSharedVariable(context.Nodes[1]); // Get the rows in the solver that represent the KCL equations var rowA = biasingState.Map[_variableA]; var rowB = biasingState.Map[_variableB]; _elements = new ElementSet <double>(biasingState.Solver, new MatrixLocation[] { // The Y-matrix elements new MatrixLocation(rowA, rowA), new MatrixLocation(rowA, rowB), new MatrixLocation(rowB, rowA), new MatrixLocation(rowB, rowB) }, new int[] { // The right-hand side vector elements rowA, rowB }); }
/// <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)); }
/// <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.Nodes.CheckNodes(2); var state = context.GetState <IBiasingSimulationState>(); _variables = new OnePort <double>(state, context); _elements = new ElementSet <double>(state.Solver, _variables.GetMatrixLocations(state.Map)); }
/// <summary> /// Initializes a new instance of the <see cref="OnePort{T}"/> struct. /// </summary> /// <param name="factory">The factory.</param> /// <param name="context">The context.</param> /// <exception cref="ArgumentNullException">Thrown if <paramref name="context"/> is <c>null</c>.</exception> /// <exception cref="NodeMismatchException">Thrown if <paramref name="context"/> does not define exactly 2 nodes.</exception> public OnePort(IVariableFactory <IVariable <T> > factory, IComponentBindingContext context) { context .ThrowIfNull(nameof(context)) .Nodes.CheckNodes(2); Positive = factory.GetSharedVariable(context.Nodes[0]); Negative = factory.GetSharedVariable(context.Nodes[1]); }
/// <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) { context.Nodes.CheckNodes(2); _complex = context.GetState <IComplexSimulationState>(); _variables = new OnePort <Complex>(_complex, context); _elements = new ElementSet <Complex>(_complex.Solver, _variables.GetMatrixLocations(_complex.Map)); }
/// <summary> /// Initializes a new instance of the <see cref="Noise"/> class. /// </summary> /// <param name="context">The binding context.</param> /// <exception cref="ArgumentNullException">Thrown if <paramref name="context"/> is <c>null</c>.</exception> public Noise(IComponentBindingContext context) : base(context) { var state = context.GetState <IComplexSimulationState>(); _thermal = new NoiseThermal("r", state.GetSharedVariable(context.Nodes[0]), state.GetSharedVariable(context.Nodes[1])); }
/// <summary> /// Initializes a new instance of the <see cref="Noise"/> class. /// </summary> /// <param name="context">The context.</param> /// <exception cref="ArgumentNullException">Thrown if <paramref name="context"/> is <c>null</c>.</exception> public Noise(IComponentBindingContext context) : base(context) { _state = context.GetState <INoiseSimulationState>(); _rs = new NoiseThermal("rs", ComplexVariables.Positive, ComplexVariables.PosPrime); _id = new NoiseShot("id", ComplexVariables.PosPrime, ComplexVariables.Negative); _flicker = new NoiseGain("flicker", ComplexVariables.PosPrime, ComplexVariables.Negative); }
/// <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>(); var method = context.GetState <IIntegrationMethod>(); _capCharge = method.CreateDerivative(); }
/// <summary> /// Initializes a new instance of the <see cref="Temperature"/> class. /// </summary> /// <param name="context">The context.</param> /// <exception cref="ArgumentNullException">Thrown if <paramref name="context"/> is <c>null</c>.</exception> public Temperature(IComponentBindingContext context) : base(context) { context.ThrowIfNull(nameof(context)); _temperature = context.GetState <ITemperatureSimulationState>(); ModelParameters = context.ModelBehaviors.GetParameterSet <ModelParameters>(); ModelTemperature = context.ModelBehaviors.GetValue <ModelTemperature>(); Parameters = context.GetParameterSet <Parameters>(); }
/// <summary> /// Initializes a new instance of the <see cref="Frequency"/> class. /// </summary> /// <param name="context">The binding context.</param> /// <exception cref="ArgumentNullException">Thrown if <paramref name="context"/> is <c>null</c>.</exception> public Frequency(IComponentBindingContext context) : base(context) { ModelParameters = context.ModelBehaviors.GetParameterSet <ModelParameters>(); Behavior = context.Behaviors.GetValue <IMosfetBiasingBehavior>(); _complex = context.GetState <IComplexSimulationState>(); Variables = new MosfetVariables <Complex>(context, _complex); _elements = new ElementSet <Complex>(_complex.Solver, Variables.GetMatrixLocations(_complex.Map)); }
/// <summary> /// Initializes a new instance of the <see cref="TwoPort{T}"/> struct. /// </summary> /// <param name="factory">The factory.</param> /// <param name="context">The context.</param> public TwoPort(IVariableFactory <IVariable <T> > factory, IComponentBindingContext context) { context.Nodes.CheckNodes(4); Right = new OnePort <T>( factory.GetSharedVariable(context.Nodes[0]), factory.GetSharedVariable(context.Nodes[1])); Left = new OnePort <T>( factory.GetSharedVariable(context.Nodes[2]), factory.GetSharedVariable(context.Nodes[3])); }
/// <summary> /// Initializes a new instance of the <see cref="Frequency"/> class. /// </summary> /// <param name="context">The binding context.</param> /// <exception cref="ArgumentNullException">Thrown if <paramref name="context"/> is <c>null</c>.</exception> public Frequency(IComponentBindingContext context) : base(context) { ModelParameters = context.ModelBehaviors.GetParameterSet <ModelParameters>(); Behavior = context.Behaviors.GetValue <IMosfetBiasingBehavior>(); _complex = context.GetState <IComplexSimulationState>(); Variables = new MosfetVariables <Complex>(Name, _complex, context.Nodes, !ModelParameters.DrainResistance.Equals(0.0) || !ModelParameters.SheetResistance.Equals(0.0) && Behavior.Parameters.DrainSquares > 0, !ModelParameters.SourceResistance.Equals(0.0) || !ModelParameters.SheetResistance.Equals(0.0) && Behavior.Parameters.SourceSquares > 0); _elements = new ElementSet <Complex>(_complex.Solver, Variables.GetMatrixLocations(_complex.Map)); }
/// <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>(); _biasing = context.GetState <IBiasingSimulationState>(); _contPosNode = _biasing.Map[_biasing.GetSharedVariable(context.Nodes[2])]; _contNegNode = _biasing.Map[_biasing.GetSharedVariable(context.Nodes[3])]; _branchEq = _biasing.Map[Branch]; _elements = new ElementSet <double>(_biasing.Solver, null, new[] { _branchEq }); Signal = new DelayedSignal(1, Parameters.Delay); }
/// <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, null, new[] { _br1, _br2 }); Signals = new DelayedSignal(2, Parameters.Delay); }
/// <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) { context.Nodes.CheckNodes(2); _biasing = context.GetState <IBiasingSimulationState>(); _time = context.GetState <ITimeSimulationState>(); _variables = new OnePort <double>(_biasing, context); _elements = new ElementSet <double>(_biasing.Solver, _variables.GetMatrixLocations(_biasing.Map), _variables.GetRhsIndices(_biasing.Map)); var method = context.GetState <IIntegrationMethod>(); _qcap = method.CreateDerivative(); }
/// <summary> /// Initializes a new instance of the <see cref="Temperature"/> class. /// </summary> /// <param name="context">The context.</param> /// <exception cref="ArgumentNullException">Thrown if <paramref name="context"/> is <c>null</c>.</exception> public Temperature(IComponentBindingContext context) : base(context) { context.ThrowIfNull(nameof(context)); // Get parameters Parameters = context.GetParameterSet <Parameters>(); if (context.ModelBehaviors != null) { _mbp = context.ModelBehaviors.GetParameterSet <ModelParameters>(); } // Connections _temperature = context.GetState <ITemperatureSimulationState>(); }
/// <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.Nodes.CheckNodes(2); var state = context.GetState <IBiasingSimulationState>(); _iteration = context.GetState <IIterationSimulationState>(); Variables = new DiodeVariables <double>(Name, state, context); Elements = new ElementSet <double>(state.Solver, Variables.GetMatrixLocations(state.Map), Variables.GetRhsIndicies(state.Map)); }
/// <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); // Get parameters Parameters = context.GetParameterSet <Parameters>(); Parameters.CalculateDefaults(); BiasingState = context.GetState <IBiasingSimulationState>(); _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])]; Internal1 = BiasingState.CreatePrivateVariable(Name.Combine("int1"), Units.Volt); _int1 = BiasingState.Map[Internal1]; Internal2 = BiasingState.CreatePrivateVariable(Name.Combine("int2"), Units.Volt); _int2 = BiasingState.Map[Internal2]; Branch1 = BiasingState.CreatePrivateVariable(Name.Combine("branch1"), Units.Ampere); _br1 = BiasingState.Map[Branch1]; Branch2 = BiasingState.CreatePrivateVariable(Name.Combine("branch2"), Units.Ampere); _br2 = BiasingState.Map[Branch2]; BiasingElements = new ElementSet <double>(BiasingState.Solver, new MatrixLocation(_pos1, _pos1), new MatrixLocation(_pos1, _int1), new MatrixLocation(_int1, _pos1), new MatrixLocation(_int1, _int1), new MatrixLocation(_int1, _br1), new MatrixLocation(_br1, _int1), new MatrixLocation(_neg1, _br1), new MatrixLocation(_br1, _neg1), new MatrixLocation(_pos2, _pos2), new MatrixLocation(_pos2, _int2), new MatrixLocation(_int2, _pos2), new MatrixLocation(_int2, _int2), new MatrixLocation(_int2, _br2), new MatrixLocation(_br2, _int2), new MatrixLocation(_neg2, _br2), new MatrixLocation(_br2, _neg2), // These are only used to calculate the biasing point new MatrixLocation(_br1, _pos1), new MatrixLocation(_br1, _pos2), new MatrixLocation(_br1, _neg2), new MatrixLocation(_br2, _br1), new MatrixLocation(_br2, _br2)); }
/// <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) { var state = context.GetState <IBiasingSimulationState>(); var br = state.Map[Branch]; _time = context.GetState <ITimeSimulationState>(); _elements = new ElementSet <double>(state.Solver, new[] { new MatrixLocation(br, br) }, new[] { br }); var method = context.GetState <IIntegrationMethod>(); _flux = method.CreateDerivative(); }
/// <summary> /// Initializes a new instance of the <see cref="Noise"/> class. /// </summary> /// <param name="context">The binding context.</param> /// <exception cref="ArgumentNullException">Thrown if <paramref name="context"/> is <c>null</c>.</exception> public Noise(IComponentBindingContext context) : base(context) { _state = context.GetState <INoiseSimulationState>(); _properties = context.ModelBehaviors.GetValue <ModelTemperature>().Properties; var d = Variables.Drain; var s = Variables.Source; var dp = Variables.DrainPrime; var sp = Variables.SourcePrime; _rd = new NoiseThermal("rd", d, dp); _rs = new NoiseThermal("rs", s, sp); _id = new NoiseThermal("id", dp, sp); _flicker = new NoiseGain("flicker", dp, sp); }
/// <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) { _complex = context.GetState <IComplexSimulationState>(); _variables = new TwoPort <Complex>(_complex, context); 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]; _elements = new ElementSet <Complex>(_complex.Solver, new MatrixLocation(pos, contPos), new MatrixLocation(pos, contNeg), new MatrixLocation(neg, contPos), new MatrixLocation(neg, contNeg)); }