Simulation of an electrical oscillator supplying a resistor through a half-wave rectifier#
Author: Pascal Denoyelle, September 22, 2005
You may refer to the source code of this example, found here.
There is also a PDF version of this document, viewable online here.
Description of the physical problem : electrical oscillator with half-wave rectifier#
In this sample, a LC oscillator initialized with a given voltage across the capacitor and a null current through the inductor provides the energy to a load resistance through a half-wave rectifier consisting of an ideal diode (see fig 1: Electrical oscillator with half-wave rectifier).

fig 1: Electrical oscillator with half-wave rectifier#
Only the positive wave of the oscillating voltage across the LC is provided to the resistor. The energy is dissipated in the resistor resulting in a damped oscillation.
Definition of a general abstract class of NSDS : the linear time invariant complementarity system (LCS)#
This type of non-smooth dynamical system consists of :
a time invariant linear dynamical system (the oscillator). The state variable of this system is denoted by
.a non-smooth law describing the behaviour of the diode as a complementarity condition between current and reverse voltage (variables (
) )a linear time invariant relation between the state variable
and the non-smooth law variables ( )
Dynamical system and Boundary conditions#
Remark:
In a more general setting, the system’s evolution would be described by a DAE :
with
matrices constant over time (time invariant system), source terms functions of time and , a term coming from the non-smooth law variables : with constant over time. We will consider here the case of an ordinary differential equation : and an initial value problem for which the boundary conditions are
.
Relation between constrained variables and state variables#
In the linear time invariant framework, the non-smooth law acts on the
linear dynamical system evolution through the variable
Definition of the Non Smooth Law between constrained variables#
It is a complementarity condition between y and
The formalization of the electrical oscillator with half-wave rectifier into the LCS#
The equations come from the following physical laws :
the Kirchhoff current law (KCL) establishes that the sum of the currents arriving at a node is zero,
the Kirchhoff voltage law (KVL) establishes that the sum of the voltage drops in a loop is zero,
the branch constitutive equations define the relation between the current through a bipolar device and the voltage across it
Refering to fig 1: Electrical oscillator with half-wave rectifier, the Kirchhoff laws could be written as:
while the branch constitutive equations for linear devices are:
and last the “branch constitutive equation” of the ideal diode that is no more an equation but instead a complementarity condition:
This is illustrated in fig 2: Non-smooth and smooth characteristics of a diode, where the left-hand sketch displays the ideal diode characteristic and the right-hand sketch displays the usual exponential characteristic as stated by Shockley’s law.

fig 2: Non-smooth and smooth characteristics of a diode#
Dynamical equation#
After rearranging the previous equations, we obtain:
that fits in the frame of ref{sec-def-NSDS} with
and
Relations#
We recall that the
from the dynamical equation (Dynamical equation).
Rearranging the initial set of equations yields:
as the second equation of the linear time invariant relation with
Non Smooth laws#
There is just the complementarity condition resulting from the ideal diode characteristic:
Description of the numerical simulation: the Moreau’s time-stepping scheme#
Time discretization of the dynamical system#
The integration of the ODE over a time step
The left-hand term is
Right-hand terms are approximated this way:
is approximated using a -methodsince the second integral comes from independent sources, it can be evaluated with whatever quadrature method, for instance a
-methodthe third integral is approximated like in an implicit Euler integration
By replacing the accurate solution
Assuming that
An intermediate variable
Thus the calculus of
Time discretization of the relations#
It comes straightforwardly:
Time discretization of the non-smooth law#
It comes straightforwardly:
Summary of the time discretized equations#
These equations are summarized assuming that there is no source term and simplified relations as for the electrical oscillator with half-wave rectifier.
Numerical simulation#
The integration algorithm with a fixed step is described here :
Algorthm 1: Integration of the electrical oscillator with half-wave rectifier through a fixed Moreau time stepping scheme
Require:
Require: Time parameters
and for the integration Require: Initial value of inductor voltage
Require: Optional, initial value of inductor current
(default: 0)
// Dynamical system specification
// Relation specification
// Construction of time independent operators
Require:
invertible // Non-smooth dynamical system integration
for
to do end for
Comparison with numerical results coming from SPICE models and algorithms#
We have used the SMASH simulator from Dolphin to perform a simulation of this circuit with a smooth model of the diode as given by Shockley’s law , with a classical one step solver (Newton-Raphson) and a choice between backward-Euler and trapezoidal integrators.
Characteristic of the diode in the SPICE model#
fig 3: Diodes characteristics from SPICE model (N=0.25, N=1) depicts the static

fig 3: Diodes characteristics from SPICE model
The stiff diode is close to an ideal one with a threshold of 0.2 V.
Simulation results#
fig 4: SMASH and SICONOS simulation results with backward Euler integration, 10 μs time step displays a comparison of the SMASH and SICONOS results with a backward Euler integration and a fixed time step of 10 μs. A stiff diode model was used in SMASH simulations. For fig 5: SMASH and SICONOS simulation results with trapezoidal integration, 10 μs time step, a trapezoidal integrator was used, yielding a better accuracy. One can notice that the results from both simulators are very close. The slight differences are due to the smooth model of the diode used by SMASH, and mainly to the threshold of around 0.2 V. Such a threshold yields small differences in the conduction state of the diode with respect to the ideal diode.

fig 4: SMASH and SICONOS simulation results with backward Euler integration, 10 μs time step#

fig 5: SMASH and SICONOS simulation results with trapezoidal integration, 10 μs time step#