private void ShowTransient() { double step = 1 / (30 * max); double eps = 0.001; double coeff = clone.Coefficient; if (coeff <1 & coeff> 1e-15) { eps *= coeff; } double a = 0; if (min > 0) { a = 1 / min; } Chart.Drawing.Series.SimpleSeries ss = new Chart.Drawing.Series.SimpleSeries(); double t = 0; double ed = 1; double y1 = 0; IDifferentialEquationsSystem sys = clone; int maxm = 0; while (true) { ++maxm; if (maxm > 10000) { break; } double te = t + step; clone.Step(t, te, 1); double y = clone.Output; t = te; ss.AddXY(t, y); double ep = y - coeff; if (!transform.IsStable) { if (t > 10 * a) { break; } } if (Math.Abs(ep) < eps & Math.Abs(ed) < eps & t > (3 * a)) { break; } ed = (y1 - y) / step; y1 = y; } userControlChartTransient.AddSeries(ss, Color.Red); }
/// <summary> /// Deserialization constructor /// </summary> /// <param name="info">Serialization info</param> /// <param name="context">Streaming context</param> protected RationalTransformControlSystemData(SerializationInfo info, StreamingContext conext) : base(info, conext) { system = this; measureString = info.Deserialize <string>("Measure"); reset = () => { }; try { aliasString = info.Deserialize <string>("Alias"); } catch (Exception ex) { ex.ShowError(10); } }
/// <summary> /// Initialization of differential equations system /// </summary> /// <param name="system">The system</param> public static void Initialize(IDifferentialEquationsSystem system) { Array.Copy(system.InitialState, system.State, system.InitialState.Length); }
/// <summary> /// Default constructor /// </summary> public RationalTransformControlSystemData() { system = this; isSerialized = false; reset = () => { }; }