/// <summary> /// Initializes a new instance of the <see cref="Biasing"/> class. /// </summary> /// <param name="context">The binding context.</param> /// <exception cref="ArgumentNullException">Thrown if <paramref name="context"/> is <c>null</c>.</exception> public Biasing(IComponentBindingContext context) : base(context) { var state = context.GetState <IBiasingSimulationState>(); _config = context.GetSimulationParameterSet <BiasingParameters>(); _iteration = context.GetState <IIterationSimulationState>(); _args = new MosfetContributionEventArgs(_contributions); context.TryGetState(out _time); context.TryGetState(out _method); _variables = new MosfetVariables <double>(context, state); // Get matrix pointers _elements = new ElementSet <double>(state.Solver, _variables.GetMatrixLocations(state.Map), _variables.GetRhsIndices(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.Nodes.CheckNodes(3); BiasingParameters = context.GetSimulationParameterSet <BiasingParameters>(); _iteration = context.GetState <IIterationSimulationState>(); context.TryGetState(out _time); context.TryGetState(out _method); DrainPrime = BiasingState.GetSharedVariable(context.Nodes[0]); _drainNode = BiasingState.Map[DrainPrime]; _gateNode = BiasingState.Map[BiasingState.GetSharedVariable(context.Nodes[1])]; SourcePrime = BiasingState.GetSharedVariable(context.Nodes[2]); _sourceNode = BiasingState.Map[SourcePrime]; if (ModelParameters.DrainResistance > 0) { DrainPrime = BiasingState.CreatePrivateVariable(Name.Combine("drain"), Units.Volt); } _drainPrimeNode = BiasingState.Map[DrainPrime]; if (ModelParameters.SourceResistance > 0) { SourcePrime = BiasingState.CreatePrivateVariable(Name.Combine("source"), Units.Volt); } _sourcePrimeNode = BiasingState.Map[SourcePrime]; _elements = new ElementSet <double>(BiasingState.Solver, new[] { 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), new MatrixLocation(_drainNode, _drainNode), new MatrixLocation(_gateNode, _gateNode), new MatrixLocation(_sourceNode, _sourceNode), new MatrixLocation(_drainPrimeNode, _drainPrimeNode), new MatrixLocation(_sourcePrimeNode, _sourcePrimeNode) }, new[] { _gateNode, _drainPrimeNode, _sourcePrimeNode }); }
/// <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)); Parameters = context.GetParameterSet <IndependentSourceParameters>(); _iteration = context.GetState <IIterationSimulationState>(); context.TryGetState(out _method); Waveform = Parameters.Waveform?.Create(_method); if (!Parameters.DcValue.Given) { // No DC value: either have a transient value or none if (Waveform != null) { SpiceSharpWarning.Warning(this, Properties.Resources.IndependentSources_NoDcUseWaveform.FormatString(Name)); Parameters.DcValue = new GivenParameter <double>(Waveform.Value, false); } else { SpiceSharpWarning.Warning(this, Properties.Resources.IndependentSources_NoDc.FormatString(Name)); } } // Connections _biasing = context.GetState <IBiasingSimulationState>(); context.TryGetState(out _method); _variables = new OnePort <double>(_biasing, context); Branch = _biasing.CreatePrivateVariable(Name.Combine("branch"), Units.Ampere); var pos = _biasing.Map[_variables.Positive]; var neg = _biasing.Map[_variables.Negative]; var br = _biasing.Map[Branch]; _elements = new ElementSet <double>(_biasing.Solver, new[] { new MatrixLocation(pos, br), new MatrixLocation(br, pos), new MatrixLocation(neg, br), new MatrixLocation(br, neg) }, new[] { br }); }
/// <summary> /// Initializes a new instance of the <see cref="Biasing"/> class. /// </summary> /// <param name="context">The binding context.</param> /// <exception cref="ArgumentNullException">Thrown if <paramref name="context"/> is <c>null</c>.</exception> public Biasing(IComponentBindingContext context) : base(context) { var state = context.GetState <IBiasingSimulationState>(); _config = context.GetSimulationParameterSet <BiasingParameters>(); _iteration = context.GetState <IIterationSimulationState>(); _args = new MosfetContributionEventArgs(_contributions); context.TryGetState(out _time); context.TryGetState(out _method); _variables = new MosfetVariables <double>(Name, state, context.Nodes, !ModelParameters.DrainResistance.Equals(0.0) || !ModelParameters.SheetResistance.Equals(0.0) && Parameters.DrainSquares > 0, !ModelParameters.SourceResistance.Equals(0.0) || !ModelParameters.SheetResistance.Equals(0.0) && Parameters.SourceSquares > 0); // Get matrix pointers _elements = new ElementSet <double>(state.Solver, _variables.GetMatrixLocations(state.Map), _variables.GetRhsIndices(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)); Parameters = context.GetParameterSet <Parameters>(); _biasing = context.GetState <IBiasingSimulationState>(); _iteration = context.GetState <IIterationSimulationState>(); _variables = new OnePort <double>(_biasing, context); context.TryGetState <IIntegrationMethod>(out _method); Waveform = Parameters.Waveform?.Create(context); // Give some warnings if no value is given if (!Parameters.DcValue.Given) { // no DC value - either have a transient value or none SpiceSharpWarning.Warning(this, Waveform != null ? Properties.Resources.IndependentSources_NoDcUseWaveform.FormatString(Name) : Properties.Resources.IndependentSources_NoDc.FormatString(Name)); } _elements = new ElementSet <double>(_biasing.Solver, null, _variables.GetRhsIndices(_biasing.Map)); }