/// <inheritdoc/> public override void Load() { base.Load(); if (_time.UseDc) { return; } // Initialize _flux.Value = Inductance * Branch.Value; // Allow alterations of the flux if (UpdateFlux != null) { var args = new UpdateFluxEventArgs(Inductance, Branch.Value, _flux); UpdateFlux.Invoke(this, args); } // Finally load the Y-matrix _flux.Integrate(); var info = _flux.GetContributions(Inductance); _elements.Add( -info.Jacobian, info.Rhs ); }
/// <summary> /// Execute behaviour /// </summary> void ITimeBehavior.Load() { // Initialize _flux.ThrowIfNotBound(this).Current = BaseParameters.Inductance * State.Solution[BranchEq]; // Allow alterations of the flux if (UpdateFlux != null) { var args = new UpdateFluxEventArgs(BaseParameters.Inductance, State.Solution[BranchEq], _flux, State); UpdateFlux.Invoke(this, args); } // Finally load the Y-matrix _flux.Integrate(); BranchPtr.Value += _flux.RhsCurrent(); BranchBranchPtr.Value -= _flux.Jacobian(BaseParameters.Inductance); }
/// <summary> /// Setup behavior /// </summary> /// <param name="simulation">Simulation</param> /// <param name="provider">Data provider</param> public override void Setup(Simulation simulation, SetupDataProvider provider) { base.Setup(simulation, provider); if (provider == null) { throw new ArgumentNullException(nameof(provider)); } // Get parameters BaseParameters = provider.GetParameterSet <BaseParameters>(); // Clear all events if (UpdateFlux != null) { foreach (var inv in UpdateFlux.GetInvocationList()) { UpdateFlux -= (EventHandler <UpdateFluxEventArgs>)inv; } } }
/// <summary> /// Bind behavior. /// </summary> /// <param name="simulation">The simulation.</param> /// <param name="context">Data provider</param> public override void Bind(Simulation simulation, BindingContext context) { base.Bind(simulation, context); // Clear all events if (UpdateFlux != null) { foreach (var inv in UpdateFlux.GetInvocationList()) { UpdateFlux -= (EventHandler <UpdateFluxEventArgs>)inv; } } var solver = State.Solver; BranchBranchPtr = solver.GetMatrixElement(BranchEq, BranchEq); BranchPtr = solver.GetRhsElement(BranchEq); var method = ((TimeSimulation)simulation).Method; _flux = method.CreateDerivative(); }
/// <summary> /// Setup behavior /// </summary> /// <param name="provider">Data provider</param> public override void Setup(SetupDataProvider provider) { if (provider == null) { throw new ArgumentNullException(nameof(provider)); } // Get parameters _bp = provider.GetParameterSet <BaseParameters>("entity"); // Get behaviors _load = provider.GetBehavior <LoadBehavior>("entity"); // Clear all events if (UpdateFlux != null) { foreach (var inv in UpdateFlux.GetInvocationList()) { UpdateFlux -= (EventHandler <UpdateFluxEventArgs>)inv; } } }
/// <summary> /// Execute behaviour /// </summary> /// <param name="simulation">Time-based simulation</param> public override void Transient(TimeSimulation simulation) { if (simulation == null) { throw new ArgumentNullException(nameof(simulation)); } var state = simulation.RealState; // Initialize _flux.Current = _bp.Inductance * state.Solution[_branchEq]; // Allow alterations of the flux if (UpdateFlux != null) { UpdateFluxEventArgs args = new UpdateFluxEventArgs(_bp.Inductance, state.Solution[_branchEq], _flux, state); UpdateFlux.Invoke(this, args); } // Finally load the Y-matrix _flux.Integrate(); BranchPtr.Value += _flux.RhsCurrent(); BranchBranchPtr.Value -= _flux.Jacobian(_bp.Inductance); }