Class Simulation
A template for any simulation.
Implements
Inherited Members
Namespace: SpiceSharp.Simulations
Assembly: SpiceSharp.dll
Syntax
public abstract class Simulation : ParameterSetCollection, IEventfulSimulation, ISimulation, IStateful, IBehavioral, IParameterSetCollection, IParameterSet
Constructors
Simulation(string)
Initializes a new instance of the Simulation class.
Declaration
protected Simulation(string name)
Parameters
Type | Name | Description |
---|---|---|
string | name | The name of the simulation. |
Exceptions
Type | Condition |
---|---|
ArgumentNullException | Thrown if |
See Also
Properties
Behaviors
Gets all behavior types that are used by the class.
Declaration
public virtual IEnumerable<Type> Behaviors { get; }
Property Value
Type | Description |
---|---|
IEnumerable<Type> | The behaviors. |
See Also
EntityBehaviors
Gets the entity behaviors.
Declaration
public IBehaviorContainerCollection EntityBehaviors { get; }
Property Value
Type | Description |
---|---|
IBehaviorContainerCollection | The entity behaviors. |
See Also
Name
Gets the name of the ISimulation.
Declaration
public string Name { get; }
Property Value
Type | Description |
---|---|
string | The name. |
See Also
States
Gets all the states that the class uses.
Declaration
public virtual IEnumerable<Type> States { get; }
Property Value
Type | Description |
---|---|
IEnumerable<Type> | The states. |
See Also
Statistics
Gets the statistics.
Declaration
public SimulationStatistics Statistics { get; }
Property Value
Type | Description |
---|---|
SimulationStatistics | The statistics. |
See Also
Status
Gets the current status of the ISimulation.
Declaration
public SimulationStatus Status { get; }
Property Value
Type | Description |
---|---|
SimulationStatus | The current status. |
See Also
Methods
CreateBehaviors(IEntityCollection)
Creates all behaviors for the simulation.
Declaration
protected virtual void CreateBehaviors(IEntityCollection entities)
Parameters
Type | Name | Description |
---|---|---|
IEntityCollection | entities | The entities. |
Exceptions
Type | Condition |
---|---|
ArgumentNullException | Thrown if |
See Also
CreateStates()
Creates all the simulation states for the simulation.
Declaration
protected abstract void CreateStates()
See Also
Execute()
Executes the simulation.
Declaration
protected abstract void Execute()
Exceptions
Type | Condition |
---|---|
SpiceSharpException | Thrown if the simulation can't continue. |
See Also
Finish()
Finish the simulation.
Declaration
protected abstract void Finish()
See Also
GetState<S>()
Gets the state of the specified type.
Declaration
public virtual S GetState<S>() where S : ISimulationState
Returns
Type | Description |
---|---|
S | The type, or |
Type Parameters
Name | Description |
---|---|
S | The simulation state type. |
Exceptions
Type | Condition |
---|---|
TypeNotFoundException | Thrown if the simulation state is not defined on this instance. |
See Also
OnAfterExecute(AfterExecuteEventArgs)
Raises the AfterSetup event.
Declaration
protected virtual void OnAfterExecute(AfterExecuteEventArgs args)
Parameters
Type | Name | Description |
---|---|---|
AfterExecuteEventArgs | args | The EventArgs instance containing the event data. |
See Also
OnAfterSetup(EventArgs)
Raises the AfterSetup event.
Declaration
protected virtual void OnAfterSetup(EventArgs args)
Parameters
Type | Name | Description |
---|---|---|
EventArgs | args | The EventArgs instance containing the event data. |
See Also
OnAfterUnsetup(EventArgs)
Raises the AfterUnsetup event.
Declaration
protected virtual void OnAfterUnsetup(EventArgs args)
Parameters
Type | Name | Description |
---|---|---|
EventArgs | args | The EventArgs instance containing the event data. |
See Also
OnAfterValidation(EventArgs)
Raises the AfterValidation event.
Declaration
protected virtual void OnAfterValidation(EventArgs args)
Parameters
Type | Name | Description |
---|---|---|
EventArgs | args | The EventArgs instance containing the event data. |
See Also
OnBeforeExecute(BeforeExecuteEventArgs)
Raises the BeforeExecute event.
Declaration
protected virtual void OnBeforeExecute(BeforeExecuteEventArgs args)
Parameters
Type | Name | Description |
---|---|---|
BeforeExecuteEventArgs | args | The BeforeExecuteEventArgs instance containing the event data. |
See Also
OnBeforeSetup(EventArgs)
Raises the BeforeSetup event.
Declaration
protected virtual void OnBeforeSetup(EventArgs args)
Parameters
Type | Name | Description |
---|---|---|
EventArgs | args | The EventArgs instance containing the event data. |
See Also
OnBeforeUnsetup(EventArgs)
Raises the BeforeUnsetup event.
Declaration
protected virtual void OnBeforeUnsetup(EventArgs args)
Parameters
Type | Name | Description |
---|---|---|
EventArgs | args | The EventArgs instance containing the event data. |
See Also
OnBeforeValidation(EventArgs)
Raises the BeforeValidation event.
Declaration
protected virtual void OnBeforeValidation(EventArgs args)
Parameters
Type | Name | Description |
---|---|---|
EventArgs | args | The EventArgs instance containing the event data. |
See Also
OnExport(ExportDataEventArgs)
Raises the ExportSimulationData event.
Declaration
protected virtual void OnExport(ExportDataEventArgs args)
Parameters
Type | Name | Description |
---|---|---|
ExportDataEventArgs | args | The ExportDataEventArgs instance containing the event data. |
See Also
Rerun()
Reruns the ISimulation with the previous behaviors.
Declaration
public virtual void Rerun()
See Also
Run(IEntityCollection)
Runs the ISimulation on the specified IEntityCollection.
Declaration
public virtual void Run(IEntityCollection entities)
Parameters
Type | Name | Description |
---|---|---|
IEntityCollection | entities | The entities. |
See Also
TryGetState<S>(out S)
Tries to get a state of the specified type.
Declaration
public virtual bool TryGetState<S>(out S state) where S : ISimulationState
Parameters
Type | Name | Description |
---|---|---|
S | state | The state. |
Returns
Type | Description |
---|---|
bool |
|
Type Parameters
Name | Description |
---|---|
S | The simulation state type. |
See Also
UsesBehavior(Type)
Checks if the class uses the specified behavior.
Declaration
public virtual bool UsesBehavior(Type behaviorType)
Parameters
Type | Name | Description |
---|---|---|
Type | behaviorType |
Returns
Type | Description |
---|---|
bool |
|
See Also
UsesBehaviors<B>()
Checks if the class uses the specified behaviors.
Declaration
public virtual bool UsesBehaviors<B>() where B : IBehavior
Returns
Type | Description |
---|---|
bool |
|
Type Parameters
Name | Description |
---|---|
B | The behavior type. |
See Also
UsesState<S>()
Checks if the class uses the specified state.
Declaration
public virtual bool UsesState<S>() where S : ISimulationState
Returns
Type | Description |
---|---|
bool |
|
Type Parameters
Name | Description |
---|---|
S | The simulation state type. |
See Also
Validate(IEntityCollection)
Validates the input.
Declaration
protected abstract void Validate(IEntityCollection entities)
Parameters
Type | Name | Description |
---|---|---|
IEntityCollection | entities | The entities. |
Exceptions
Type | Condition |
---|---|
ArgumentNullException | Thrown if |
ValidationFailedException | Thrown if the validation failed. |
See Also
Validate(IRules, IEntityCollection)
A default implementation for validating entities and behaviors using the specified rules.
Declaration
protected void Validate(IRules rules, IEntityCollection entities)
Parameters
Type | Name | Description |
---|---|---|
IRules | rules | The rules. |
IEntityCollection | entities | The entities. |
Exceptions
Type | Condition |
---|---|
ValidationFailedException | Thrown if the validation failed. |
See Also
Events
AfterExecute
Occurs after the simulation has executed.
Declaration
public event EventHandler<AfterExecuteEventArgs> AfterExecute
Event Type
Type | Description |
---|---|
EventHandler<AfterExecuteEventArgs> |
See Also
AfterSetup
Occurs after the simulation is set up.
Declaration
public event EventHandler<EventArgs> AfterSetup
Event Type
Type | Description |
---|---|
EventHandler<EventArgs> |
See Also
AfterUnsetup
Occurs after the simulation is destroyed.
Declaration
public event EventHandler<EventArgs> AfterUnsetup
Event Type
Type | Description |
---|---|
EventHandler<EventArgs> |
See Also
AfterValidation
Occurs after the simulation has validated the input.
Declaration
public event EventHandler<EventArgs> AfterValidation
Event Type
Type | Description |
---|---|
EventHandler<EventArgs> |
See Also
BeforeExecute
Occurs before the simulation starts its execution.
Declaration
public event EventHandler<BeforeExecuteEventArgs> BeforeExecute
Event Type
Type | Description |
---|---|
EventHandler<BeforeExecuteEventArgs> |
See Also
BeforeSetup
Occurs before the simulation is set up.
Declaration
public event EventHandler<EventArgs> BeforeSetup
Event Type
Type | Description |
---|---|
EventHandler<EventArgs> |
See Also
BeforeUnsetup
Occurs before the simulation is destroyed.
Declaration
public event EventHandler<EventArgs> BeforeUnsetup
Event Type
Type | Description |
---|---|
EventHandler<EventArgs> |
See Also
BeforeValidation
Occurs before the simulation starts validating the input.
Declaration
public event EventHandler<EventArgs> BeforeValidation
Event Type
Type | Description |
---|---|
EventHandler<EventArgs> |
See Also
ExportSimulationData
Occurs when simulation data can be exported.
Declaration
public event EventHandler<ExportDataEventArgs> ExportSimulationData
Event Type
Type | Description |
---|---|
EventHandler<ExportDataEventArgs> |