Show / Hide Table of Contents

Class Simulation

A template for any simulation.

Inheritance
object
ParameterSet
ParameterSetCollection
Simulation
BiasingSimulation
Implements
ISimulation
IStateful
IBehavioral
IParameterSetCollection
IParameterSet
Inherited Members
ParameterSetCollection.GetParameterSet<P>()
ParameterSetCollection.TryGetParameterSet<P>(out P)
ParameterSetCollection.ParameterSets
ParameterSetCollection.SetParameter<P>(string, P)
ParameterSetCollection.TrySetParameter<P>(string, P)
ParameterSetCollection.GetProperty<P>(string)
ParameterSetCollection.TryGetProperty<P>(string, out P)
ParameterSetCollection.CreateParameterSetter<P>(string)
ParameterSetCollection.CreatePropertyGetter<P>(string)
object.Equals(object)
object.Equals(object, object)
object.GetHashCode()
object.GetType()
object.MemberwiseClone()
object.ReferenceEquals(object, object)
object.ToString()
Namespace: SpiceSharp.Simulations
Assembly: SpiceSharp.dll
Syntax
public abstract class Simulation : ParameterSetCollection, 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 name is null.

Fields

Actions

The bits that are reserved for actions.

Declaration
public const int Actions = -65536
Field Value
Type Description
int

AfterExecute

Represents the action after each execution.

Declaration
public const int AfterExecute = 524288
Field Value
Type Description
int

AfterSetup

Represents the action after setting up behaviors.

Declaration
public const int AfterSetup = 65536
Field Value
Type Description
int

AfterValidation

Represents the action after validating.

Declaration
public const int AfterValidation = 131072
Field Value
Type Description
int

BeforeExecute

Represents the action before each execution.

Declaration
public const int BeforeExecute = 262144
Field Value
Type Description
int

Exports

The bits that are reserved for exports.

Declaration
public const int Exports = 65535
Field Value
Type Description
int

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.

CurrentRun

Gets the index of the current simulation run.

Declaration
public int CurrentRun { get; }
Property Value
Type Description
int

EntityBehaviors

Gets the entity behaviors.

Declaration
public IBehaviorContainerCollection EntityBehaviors { get; }
Property Value
Type Description
IBehaviorContainerCollection

The entity behaviors.

Name

Gets the name of the ISimulation.

Declaration
public string Name { get; }
Property Value
Type Description
string

The name.

Repeat

If set, the simulation is repeated. The property is automatically reset at the start of an execution.

Declaration
public bool Repeat { get; set; }
Property Value
Type Description
bool

States

Gets all the states that the class uses.

Declaration
public virtual IEnumerable<Type> States { get; }
Property Value
Type Description
IEnumerable<Type>

The states.

Statistics

Gets the statistics.

Declaration
public SimulationStatistics Statistics { get; }
Property Value
Type Description
SimulationStatistics

The statistics.

Status

Gets the current status of the ISimulation.

Declaration
public SimulationStatus Status { get; }
Property Value
Type Description
SimulationStatus

The current status.

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 entities is null.

CreateStates()

Creates all the simulation states for the simulation.

Declaration
protected abstract void CreateStates()

Execute(int)

Executes the simulation.

Declaration
protected abstract IEnumerable<int> Execute(int mask)
Parameters
Type Name Description
int mask

A bit mask for simulation export identifiers.

Returns
Type Description
IEnumerable<int>
Exceptions
Type Condition
SpiceSharpException

Thrown if the simulation can't continue.

Finish()

Finish the simulation.

Declaration
protected abstract void Finish()

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 null if the state isn't used.

Type Parameters
Name Description
S

The simulation state type.

Exceptions
Type Condition
TypeNotFoundException

Thrown if the simulation state is not defined on this instance.

Rerun(int)

Reruns the ISimulation with the previous behaviors. Only one enumerable can run at any given time.

Declaration
public virtual IEnumerable<int> Rerun(int mask = 65535)
Parameters
Type Name Description
int mask

A bit mask for simulation export identifiers.

Returns
Type Description
IEnumerable<int>

An enumerable that yields a type identifier every time new simulation data is available.

Run(IEntityCollection, int)

Runs the ISimulation on the specified IEntityCollection. Only one enumerable can run at any given time.

Declaration
public virtual IEnumerable<int> Run(IEntityCollection entities, int mask = 65535)
Parameters
Type Name Description
IEntityCollection entities

The entities.

int mask

A bit mask for simulation export identifiers.

Returns
Type Description
IEnumerable<int>

An enumerable that yields a type identifier every time new simulation data is available.

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

true if the state exists; otherwise false.

Type Parameters
Name Description
S

The simulation state type.

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

true if the class uses the behavior; otherwise false.

UsesBehaviors<B>()

Checks if the class uses the specified behaviors.

Declaration
public virtual bool UsesBehaviors<B>() where B : IBehavior
Returns
Type Description
bool

true if the class uses the behavior; otherwise false.

Type Parameters
Name Description
B

The behavior type.

UsesState<S>()

Checks if the class uses the specified state.

Declaration
public virtual bool UsesState<S>() where S : ISimulationState
Returns
Type Description
bool

true if the class uses the state; otherwise false.

Type Parameters
Name Description
S

The simulation state type.

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 entities is null.

ValidationFailedException

Thrown if the validation failed.

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.

Implements

ISimulation
IStateful
IBehavioral
IParameterSetCollection
IParameterSet

Extension Methods

Documentation.ParameterValues<T>(IParameterSet, bool)
Documentation.Parameters(IParameterSet)
Documentation.ParameterValues<T>(IParameterSetCollection, bool)
Documentation.Parameters(IParameterSetCollection)
SimulationHelper.GetComplexCurrent(ISimulation, Reference)
SimulationHelper.GetComplexProperty(ISimulation, Reference, string)
SimulationHelper.GetComplexVoltage(ISimulation, Reference)
SimulationHelper.GetComplexVoltage(ISimulation, Reference, Reference)
SimulationHelper.GetCurrent(ISimulation, Reference)
SimulationHelper.GetProperty(ISimulation, Reference, string)
SimulationHelper.GetVoltage(ISimulation, Reference)
SimulationHelper.GetVoltage(ISimulation, Reference, Reference)
SimulationHelper.RunToEnd(ISimulation, IEntityCollection, IDictionary<int, Action>)
SimulationHelper.TryGetComplexCurrent(ISimulation, Reference, out Complex)
SimulationHelper.TryGetComplexProperty(ISimulation, Reference, string, out Complex)
SimulationHelper.TryGetComplexVoltage(ISimulation, Reference, Reference, out Complex)
SimulationHelper.TryGetComplexVoltage(ISimulation, Reference, out Complex)
SimulationHelper.TryGetCurrent(ISimulation, Reference, out double)
SimulationHelper.TryGetProperty(ISimulation, Reference, string, out double)
SimulationHelper.TryGetVoltage(ISimulation, Reference, Reference, out double)
SimulationHelper.TryGetVoltage(ISimulation, Reference, out double)
Utility.ThrowIfNull<T>(T, string)

See Also

ParameterSetCollection
ISimulation
In this article
Back to top Generated by DocFX