-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathIdealDiodeModel.cs
More file actions
44 lines (39 loc) · 1.41 KB
/
Copy pathIdealDiodeModel.cs
File metadata and controls
44 lines (39 loc) · 1.41 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
using SpiceSharp.Behaviors;
using SpiceSharp.Entities;
using SpiceSharp.ParameterSets;
using SpiceSharp.Simulations;
using SpiceSharpParser.CustomComponents.IdealDiodes;
namespace SpiceSharpParser.CustomComponents
{
/// <summary>
/// Parser-side model container for LTspice-style ideal diode parameters.
/// </summary>
public class IdealDiodeModel : Entity<IdealDiodeParameters>
{
/// <summary>
/// Initializes a new instance of the <see cref="IdealDiodeModel"/> class.
/// </summary>
/// <param name="name">The model name.</param>
public IdealDiodeModel(string name)
: base(name)
{
}
/// <inheritdoc />
public override void CreateBehaviors(ISimulation simulation)
{
var behaviors = new BehaviorContainer(Name);
var context = new BindingContext(this, simulation, behaviors);
behaviors.Add(new IdealDiodeModelBehavior(context));
simulation.EntityBehaviors.Add(behaviors);
}
private sealed class IdealDiodeModelBehavior : Behavior, IParameterized<IdealDiodeParameters>
{
public IdealDiodeModelBehavior(IBindingContext context)
: base(context)
{
Parameters = context.GetParameterSet<IdealDiodeParameters>();
}
public IdealDiodeParameters Parameters { get; }
}
}
}