Numerical integration works iteratively, that means you start at a statex(t) and perform a time-step of length dtto obtain the approximate state x(t+dt). There existmany different methods to perform such a time-step each of which has acertain order q. If the order of a method is qthan it is accurate up to term dt q that means theerror in x made by such a step is dt q+1.odeint provides several steppers of different orders, see.Some of steppers in the table above are special: Some need the Jacobianof the ODE, others are constructed for special ODE-systems like Hamiltoniansystems.
We will show typical examples and use-cases in this tutorial andwhich kind of steppers should be applied. The basic stepper just performs one time-step and doesn't give you anyinformation about the error that was made (except that you know it is oforder q+1). Such steppers are used with constant stepsize that should be chosen small enough to have reasonable small errors.However, you should apply some sort of validity check of your results (likeobserving conserved quantities) because you have no other control of theerror. The following example defines a basic stepper based on the classicalRunge-Kutta scheme of 4th order. The declaration of the stepper requiresthe state type as template parameter. The integration can now be done byusing the integrateconst ( Stepper, System, state, starttime, endtime, stepsize ) function from odeint:rungekutta4 stepper; integrateconst ( stepper, harmonicoscillator, x, 0.0, 10.0, 0.01 );This call integrates the system defined by harmonicoscillatorusing the RK4 method from t=0 to 10with a step-size dt=0.01 and the initial conditiongiven in x. The result,x(t=10) is stored in x(in-place).
What is the abbreviation for Numeric Controlled Oscillator? What does NCO stand for? NCO abbreviation stands for Numeric Controlled Oscillator.
Each stepper defines a dostepmethod which can also be used directly. So, you write down the above exampleasconst double dt = 0.01; for ( double t = 0.0; t. To improve the numerical results and additionally minimize the computationaleffort, the application of a step size control is advisable. Step sizecontrol is realized via stepper algorithms that additionally provide anerror estimation of the applied step.
Odeint provides a number of suchErrorSteppers and we will show their usageon the example of expliciterrorrk54ck- a 5th order Runge-Kutta method with 4th order error estimation and coefficientsintroduced by Cash and Karp.typedef rungekuttacashkarp54 errorsteppertype;Given the error stepper, one still needs an instance that checks the errorand adjusts the step size accordingly. In odeint, this is done by ControlledSteppers. For the rungekuttacashkarp54stepper a controlledrungekuttastepper exists which can be used viatypedef controlledrungekutta controlledsteppertype; controlledsteppertype controlledstepper; integrateadaptive ( controlledstepper, harmonicoscillator, x, 0.0, 10.0, 0.01 );As above, this integrates the system defined by harmonicoscillator,but now using an adaptive step size method based on the Runge-Kutta Cash-Karp54 scheme from t=0 to 10 withan initial step size of dt=0.01 (will be adjusted)and the initial condition given in x. The result, x(t=10),will also be stored in x (in-place).In the above example an error stepper is nested in a controlled stepper.This is a nice technique; however one drawback is that one always needsto define both steppers. One could also write the instantiation of thecontrolled stepper into the call of the integrate function but a completeknowledge of the underlying stepper types is still necessary.
![Controlled Controlled](/uploads/1/2/5/5/125509697/583169030.jpg)
Another pointis, that the error tolerances for the step size control are not easilyincluded into the controlled stepper. Both issues can be solved by usingmakecontrolled:integrateadaptive ( makecontrolled ( 1.0e-10, 1.0e-6 ), harmonicoscillator, x, 0.0, 10.0, 0.01 );makecontrolled can beused with many of the steppers of odeint. The first parameter is the absoluteerror tolerance epsabs and the second is the relativeerror tolerance epsrel which is used during the integration.The template parameter determines from which error stepper a controlledstepper should be instantiated. An alternative syntax of makecontrolled isintegrateadaptive ( makecontrolled ( 1.0e-10, 1.0e-6, errorsteppertype ), harmonicoscillator, x, 0.0, 10.0, 0.01 );For the Runge-Kutta controller the error made during one step is comparedwith epsabs + epsrel.
( a x. x + a dxdt. dt. dxdt ).If the error is smaller than this value the current step is accepted, otherwiseit is rejected and the step size is decreased. Note, that the step sizeis also increased if the error gets too small compared to the rhs of theabove relation. The full instantiation of the controlledrungekuttawith all parameters is thereforedouble abserr = 1.0e-10, relerr = 1.0e-6, ax = 1.0, adxdt = 1.0; controlledsteppertype controlledstepper ( defaulterrorchecker ( abserr, relerr, ax, adxdt ) ); integrateadaptive ( controlledstepper, harmonicoscillator, x, 0.0, 10.0, 0.01 );When using makecontrolledthe parameter a x and a dxdt areused with their standard values of 1.In the tables below, one can find all steppers which are working withmakecontrolled and makedenseoutput which is the analogfor the dense output steppers.
The resonant frequency in the voltage controlled oscillator is controlled by input voltage. It produces a periodic signal, with the input voltage control related to the level of the frequency of the signal. A tuning element called a varactor diode is used in voltage controlled oscillators. With the help of clean direct current voltage applied to the varactor diode, the oscillator is tuned to vary the net capacitance provided to the circuit.Depending on the waveform, voltage controlled oscillators are categorized into harmonic oscillators and relaxation oscillators.
Harmonic or linear oscillators are comprised of a resonator and amplifier and produce a sinusoidal waveform. An LC-tank oscillator is a harmonic oscillator.
Relaxation oscillators produce a sawtooth waveform and require only minimal external components to produce a wide range of operational frequencies. Harmonic oscillators show better frequency stability with respect to external factors like noise, temperature and power. There is better accuracy with respect to frequency control as well in harmonic oscillators. However, they are less suited for monolithic integrated circuit technology, but much better suited for relaxation oscillators.
![Oscillator Oscillator](/uploads/1/2/5/5/125509697/219680678.png)
Moreover, relaxation oscillators can provide a wide range of operational frequencies.