private VoltageSwitchModel CreateVoltageSwitchModel(string name, string parameters) { var model = new VoltageSwitchModel(name); ApplyParameters(model, parameters); return(model); }
public override Context.Models.Model Generate(string id, string type, ParameterCollection parameters, ICircuitContext context) { switch (type.ToLower()) { case "sw": var model = new VoltageSwitchModel(id); SetParameters(context, model, parameters); return new Context.Models.Model(id, model, model.Parameters); case "csw": var model2 = new CurrentSwitchModel(id); SetParameters(context, model2, parameters); return new Context.Models.Model(id, model2, model2.Parameters); case "vswitch": var vSwitchModel = new VSwitchModel(id); SetParameters(context, vSwitchModel, parameters); return new Context.Models.Model(id, vSwitchModel, vSwitchModel.Parameters); case "iswitch": var iSwitchModel = new ISwitchModel(id); SetParameters(context, iSwitchModel, parameters); return new Context.Models.Model(id, iSwitchModel, iSwitchModel.Parameters); } return null; }
/// <summary> /// Create a voltage switch /// </summary> /// <param name="name">Name</param> /// <param name="pos">Positive node</param> /// <param name="neg">Negative node</param> /// <param name="contPos">Controlling positive node</param> /// <param name="contNeg">Controlling negative node</param> /// <param name="modelName">Model name</param> /// <param name="modelParameters">Model parameters</param> /// <returns></returns> VoltageSwitch CreateVoltageSwitch(string name, string pos, string neg, string contPos, string contNeg, string modelName, string modelParameters) { var model = new VoltageSwitchModel(modelName); ApplyParameters(model, modelParameters); var vsw = new VoltageSwitch(name, pos, neg, contPos, contNeg); vsw.SetModel(model); return(vsw); }
/// <summary> /// Create a voltage switch /// </summary> /// <param name="name">Name</param> /// <param name="pos">Positive node</param> /// <param name="neg">Negative node</param> /// <param name="contPos">Controlling positive node</param> /// <param name="contNeg">Controlling negative node</param> /// <param name="modelName">Model name</param> /// <param name="modelParameters">Model parameters</param> /// <returns></returns> VoltageSwitch CreateVoltageSwitch(Identifier name, Identifier pos, Identifier neg, Identifier contPos, Identifier contNeg, Identifier modelName, string modelParameters) { VoltageSwitchModel model = new VoltageSwitchModel(modelName); ApplyParameters(model, modelParameters); VoltageSwitch vsw = new VoltageSwitch(name, pos, neg, contPos, contNeg); vsw.SetModel(model); return(vsw); }
/// <summary> /// Adds the diode model that can be used to define minimum constraints. /// </summary> /// <param name="circuit">The circuit.</param> public static void AddRectifyingModel(IEntityCollection circuit) { if (circuit.Contains(DiodeModelName)) { return; } var model = new VoltageSwitchModel(DiodeModelName); model.Parameters.OnResistance = 1e-6; model.Parameters.OffResistance = 1e9; model.Parameters.Hysteresis = 1e-3; model.Parameters.Threshold = 0.0; circuit.Add(model); }
public override SpiceSharp.Components.Model Generate(string id, string type, ParameterCollection parameters, ICircuitContext context) { SpiceSharp.Components.Model model = null; switch (type.ToLower()) { case "sw": model = new VoltageSwitchModel(id); break; case "csw": model = new CurrentSwitchModel(id); break; case "vswitch": model = new VSwitchModel(id); break; case "iswitch": model = new ISwitchModel(id); break; } if (model != null) { SetParameters(context, model, parameters); } return(model); }