/// <summary> /// Continues the simulation. /// </summary> /// <param name="simulation">The time-based simulation</param> /// <param name="delta">The initial probing timestep.</param> public override void Continue(TimeSimulation simulation, ref double delta) { // Modify the timestep delta = Math.Min(delta, MaxStep); // Handle breakpoints if (Time.Equals(Breakpoints.First) || Breakpoints.First - Time <= MinStep) { // Cut integration order Order = 1; // Limit the next timestep var mt = Math.Min(_saveDelta, Breakpoints.Delta); delta = Math.Min(delta, 0.1 * mt); // Spice will divide the first timestep by 10 if (BaseTime.Equals(0.0)) { delta /= 10.0; } // Don't go below MinStep without reason delta = Math.Max(delta, 2.0 * MinStep); } else if (Time + delta >= Breakpoints.First) { Break = true; _saveDelta = delta; delta = Breakpoints.First - Time; } base.Continue(simulation, ref delta); }
public GeData(BaseTime n) : this(C4dApiPINVOKE.new_GeData__SWIG_13(BaseTime.getCPtr(n)), true) { if (C4dApiPINVOKE.SWIGPendingException.Pending) { throw C4dApiPINVOKE.SWIGPendingException.Retrieve(); } }
/// <summary> /// Evaluates whether or not the current solution can be accepted. /// </summary> /// <param name="simulation">The time-based simulation.</param> /// <param name="newDelta">The next requested timestep in case the solution is not accepted.</param> /// <returns> /// <c>true</c> if the time point is accepted; otherwise, <c>false</c>. /// </returns> /// <exception cref="SpiceSharp.CircuitException">Timestep {0:e} is too small at time {1:e}".FormatString(newDelta, BaseTime)</exception> public override bool Evaluate(TimeSimulation simulation, out double newDelta) { // Spice 3f5 ignores the first timestep if (BaseTime.Equals(0.0)) { newDelta = IntegrationStates[0].Delta; return(true); } var result = base.Evaluate(simulation, out newDelta); // Limit the expansion of the timestep newDelta = Math.Min(Expansion * IntegrationStates[0].Delta, newDelta); // Limit the maximum timestep if (newDelta > MaxStep) { newDelta = MaxStep; } // If the timestep is consistently made smaller than the minimum timestep, throw an exception if (newDelta <= MinStep) { // If we already tried if (_oldDelta <= MinStep) { throw new CircuitException("Timestep {0:e} is too small at time {1:e}".FormatString(newDelta, BaseTime)); } newDelta = MinStep; } return(result); }
/// <summary> /// Accepts a solution at the current timepoint. /// </summary> public virtual void Accept() { // Store the accepted solution State.Solution.CopyTo(States.Value.Solution); // When just starting out, we want to copy all the states to the previous states. if (BaseTime.Equals(0.0)) { foreach (var istate in States) { istate.Delta = Parameters.MaxStep; States.Value.State.CopyTo(istate.State); } } // Accept all the registered states foreach (var state in RegisteredStates) { state.Accept(); } // Clear the breakpoints while (Time > Breakpoints.First) { Breakpoints.ClearBreakpoint(); } Break = false; }
public void SetTimeRight(CCurve seq, BaseTime t) { C4dApiPINVOKE.CKey_SetTimeRight(swigCPtr, CCurve.getCPtr(seq), BaseTime.getCPtr(t)); if (C4dApiPINVOKE.SWIGPendingException.Pending) { throw C4dApiPINVOKE.SWIGPendingException.Retrieve(); } }
public void SetTime(int id, BaseTime b) { C4dApiPINVOKE.BaseContainer_SetTime(swigCPtr, id, BaseTime.getCPtr(b)); if (C4dApiPINVOKE.SWIGPendingException.Pending) { throw C4dApiPINVOKE.SWIGPendingException.Retrieve(); } }
public void AnimateObject(BaseList2D op, BaseTime time, ANIMATEFLAGS flags) { C4dApiPINVOKE.BaseDocument_AnimateObject(swigCPtr, BaseList2D.getCPtr(op), BaseTime.getCPtr(time), (int)flags); if (C4dApiPINVOKE.SWIGPendingException.Pending) { throw C4dApiPINVOKE.SWIGPendingException.Retrieve(); } }
public void SetLoopMaxTime(BaseTime t) { C4dApiPINVOKE.BaseDocument_SetLoopMaxTime(swigCPtr, BaseTime.getCPtr(t)); if (C4dApiPINVOKE.SWIGPendingException.Pending) { throw C4dApiPINVOKE.SWIGPendingException.Retrieve(); } }
public void SetBaseTime(BaseTime v) { C4dApiPINVOKE.GeData_SetBaseTime(swigCPtr, BaseTime.getCPtr(v)); if (C4dApiPINVOKE.SWIGPendingException.Pending) { throw C4dApiPINVOKE.SWIGPendingException.Retrieve(); } }
public void Min_Max__Arg_Is_Not_Deterministic_With_Different_Seed() { var max = BaseTime.AddYears(1); Assertion.IsNotDeterministic( i => new DateTimeRandomizer(new Random(i)), x => x.DateTime(BaseTime, max) ); }
public bool Draw(SWIGTYPE_p_GeClipMap map, BaseTime clip_left, BaseTime clip_right) { bool ret = C4dApiPINVOKE.CTrack_Draw(swigCPtr, SWIGTYPE_p_GeClipMap.getCPtr(map), BaseTime.getCPtr(clip_left), BaseTime.getCPtr(clip_right)); if (C4dApiPINVOKE.SWIGPendingException.Pending) { throw C4dApiPINVOKE.SWIGPendingException.Retrieve(); } return(ret); }
public bool AnimateTrack(BaseDocument doc, BaseList2D op, BaseTime tt, int flags, SWIGTYPE_p_Bool chg) { bool ret = C4dApiPINVOKE.CTrack_AnimateTrack__SWIG_1(swigCPtr, BaseDocument.getCPtr(doc), BaseList2D.getCPtr(op), BaseTime.getCPtr(tt), flags, SWIGTYPE_p_Bool.getCPtr(chg)); if (C4dApiPINVOKE.SWIGPendingException.Pending) { throw C4dApiPINVOKE.SWIGPendingException.Retrieve(); } return(ret); }
public bool SetTime(BaseTime t, GvRun r) { bool ret = C4dApiPINVOKE.GvPort_SetTime(swigCPtr, BaseTime.getCPtr(t), GvRun.getCPtr(r)); if (C4dApiPINVOKE.SWIGPendingException.Pending) { throw C4dApiPINVOKE.SWIGPendingException.Retrieve(); } return(ret); }
public bool SetTimeRightAdjustValue(CCurve seq, BaseTime t) { bool ret = C4dApiPINVOKE.CKey_SetTimeRightAdjustValue(swigCPtr, CCurve.getCPtr(seq), BaseTime.getCPtr(t)); if (C4dApiPINVOKE.SWIGPendingException.Pending) { throw C4dApiPINVOKE.SWIGPendingException.Retrieve(); } return(ret); }
public double GetValue(BaseDocument doc, BaseTime time) { double ret = C4dApiPINVOKE.CTrack_GetValue(swigCPtr, BaseDocument.getCPtr(doc), BaseTime.getCPtr(time)); if (C4dApiPINVOKE.SWIGPendingException.Pending) { throw C4dApiPINVOKE.SWIGPendingException.Retrieve(); } return(ret); }
public bool WriteTime(BaseTime v) { bool ret = C4dApiPINVOKE.HyperFile_WriteTime(swigCPtr, BaseTime.getCPtr(v)); if (C4dApiPINVOKE.SWIGPendingException.Pending) { throw C4dApiPINVOKE.SWIGPendingException.Retrieve(); } return(ret); }
public int TimeDif(BaseTime t2) { int ret = C4dApiPINVOKE.BaseTime_TimeDif(swigCPtr, BaseTime.getCPtr(t2)); if (C4dApiPINVOKE.SWIGPendingException.Pending) { throw C4dApiPINVOKE.SWIGPendingException.Retrieve(); } return(ret); }
public bool RecordKey(BaseList2D op, BaseTime time, DescID id, BaseList2D undo, bool eval_attribmanager, bool autokeying, bool allow_linking) { bool ret = C4dApiPINVOKE.BaseDocument_RecordKey(swigCPtr, BaseList2D.getCPtr(op), BaseTime.getCPtr(time), DescID.getCPtr(id), BaseList2D.getCPtr(undo), eval_attribmanager, autokeying, allow_linking); if (C4dApiPINVOKE.SWIGPendingException.Pending) { throw C4dApiPINVOKE.SWIGPendingException.Retrieve(); } return(ret); }
public BaseTime GetTime(int id, BaseTime preset) { BaseTime ret = new BaseTime(C4dApiPINVOKE.BaseContainer_GetTime__SWIG_0(swigCPtr, id, BaseTime.getCPtr(preset)), true); if (C4dApiPINVOKE.SWIGPendingException.Pending) { throw C4dApiPINVOKE.SWIGPendingException.Retrieve(); } return(ret); }
public bool CollectSounds(SWIGTYPE_p_BaseSound snd, BaseTime from, BaseTime to) { bool ret = C4dApiPINVOKE.BaseDocument_CollectSounds(swigCPtr, SWIGTYPE_p_BaseSound.getCPtr(snd), BaseTime.getCPtr(from), BaseTime.getCPtr(to)); if (C4dApiPINVOKE.SWIGPendingException.Pending) { throw C4dApiPINVOKE.SWIGPendingException.Retrieve(); } return(ret); }
public double GetValue(BaseTime time) { double ret = C4dApiPINVOKE.CCurve_GetValue(swigCPtr, BaseTime.getCPtr(time)); if (C4dApiPINVOKE.SWIGPendingException.Pending) { throw C4dApiPINVOKE.SWIGPendingException.Retrieve(); } return(ret); }
public int MoveKey(BaseTime time, int idx) { int ret = C4dApiPINVOKE.CCurve_MoveKey__SWIG_1(swigCPtr, BaseTime.getCPtr(time), idx); if (C4dApiPINVOKE.SWIGPendingException.Pending) { throw C4dApiPINVOKE.SWIGPendingException.Retrieve(); } return(ret); }
public CKey AddKey(BaseTime time, SWIGTYPE_p_Int32 nidx) { global::System.IntPtr cPtr = C4dApiPINVOKE.CCurve_AddKey__SWIG_0(swigCPtr, BaseTime.getCPtr(time), SWIGTYPE_p_Int32.getCPtr(nidx)); CKey ret = (cPtr == global::System.IntPtr.Zero) ? null : new CKey(cPtr, false); if (C4dApiPINVOKE.SWIGPendingException.Pending) { throw C4dApiPINVOKE.SWIGPendingException.Retrieve(); } return(ret); }
public CKey FindKey(BaseTime time) { global::System.IntPtr cPtr = C4dApiPINVOKE.CCurve_FindKey__SWIG_2(swigCPtr, BaseTime.getCPtr(time)); CKey ret = (cPtr == global::System.IntPtr.Zero) ? null : new CKey(cPtr, false); if (C4dApiPINVOKE.SWIGPendingException.Pending) { throw C4dApiPINVOKE.SWIGPendingException.Retrieve(); } return(ret); }
public CKey AddKeyAdaptTangent(BaseTime time, bool bUndo) { global::System.IntPtr cPtr = C4dApiPINVOKE.CCurve_AddKeyAdaptTangent__SWIG_1(swigCPtr, BaseTime.getCPtr(time), bUndo); CKey ret = (cPtr == global::System.IntPtr.Zero) ? null : new CKey(cPtr, false); if (C4dApiPINVOKE.SWIGPendingException.Pending) { throw C4dApiPINVOKE.SWIGPendingException.Retrieve(); } return(ret); }
/// <inheritdoc/> public void Accept() { if (BaseTime.Equals(0.0)) { foreach (var state in _states) { _states.Value.CopyTo(state); } } foreach (var state in _registeredStates) { state.Accept(); } }
/// <summary> /// Returns the cumulative time based on the given base time and duration iteration /// </summary> /// <param name="iteration">The iteration.</param> /// <returns></returns> public DateTime CumulativeTime(int iteration) { var timeSpan = TimeSpan.Zero; if (iteration >= 0) { for (int i = 0; i <= iteration; i++) { timeSpan = timeSpan.Add(_items[i % _items.Count].Duration); } } return(BaseTime.Add(timeSpan)); }
//internal method to return a collection of Time Zones public TimeZoneCustom[] GetTimeZonesInfo(bool CaterForDST) { List <TimeZoneCustom> timeZones = new List <TimeZoneCustom>(); DateTime currentTimeUTC = BaseTime.ToUniversalTime(); //get a list of all the timezone definitions foreach (TimeZoneInfo tzi in TimeZoneInfo.GetSystemTimeZones()) { TimeZoneCustom tz = new TimeZoneCustom(BaseTime, tzi, CaterForDST); timeZones.Add(tz); } return(timeZones.ToArray()); }
/// <summary> /// Truncates the timestep based on the states. /// </summary> /// <param name="sender">The sender (integration method).</param> /// <param name="args">The <see cref="TruncateEvaluateEventArgs"/> instance containing the event data.</param> protected virtual void TruncateStates(object sender, TruncateEvaluateEventArgs args) { args.ThrowIfNull(nameof(args)); // Don't truncate the first step if (BaseTime.Equals(0.0)) { return; } // Truncate! var newDelta = args.Delta; foreach (var state in TruncatableStates) { newDelta = Math.Min(newDelta, state.Truncate()); } if (newDelta > 0.9 * IntegrationStates[0].Delta) { if (Order < MaxOrder) { // Try increasing the order Order++; args.Order = Order; // Try truncation again newDelta = args.Delta; foreach (var state in TruncatableStates) { newDelta = Math.Min(newDelta, state.Truncate()); } // Increasing the order doesn't make a significant difference if (newDelta <= 1.05 * IntegrationStates[0].Delta) { Order--; args.Order = Order; } } } else { args.Accepted = false; } args.Delta = newDelta; }
public BaseTime GetCuringTime(string timeData) { var result = new BaseTime(); var time = DateTime.Now; var timeNew = DateTime.Now; if (timeData.Length == 4) { timeNew = time.AddYears((Convert.ToInt16(timeData) - time.Year)); result.StartTime = new DateTime(timeNew.Year, 1, 1); result.EndTime = result.StartTime.Value.AddYears(1).AddDays(-1); } if (timeData.Length > 4) { timeNew = Convert.ToDateTime(timeData + "-01 00:00:00"); result.StartTime = new DateTime(timeNew.Year, timeNew.Month, 1); result.EndTime = result.StartTime.Value.AddMonths(1).AddDays(-1); } return(result); }