Introduction

    This program simulates the response of a resonant filter to an input signal.

The Model

    A resonant filter is a circuit composed of an inductor with inductance L, a resistor with resistance R, and a capacitor with capactiance C.

A known input voltage Vin is applied, and the response voltage Vout is measured.

    The equation that governs the circuit can be determined by applying Kirchoff's Laws. Assume that the measuring device draws no current, and let the current that flows across the resistor, capacitor, and inductor be called I. Then

At the same time, we know that

Thus, if we substitute the second of these into the first, we obtain the following second order differential equation for the output voltage Vout

The Controls

Entries marked with a can be expanded to give more information by clicking on them.

Inductance, Capacitance and Resistance

Each of these values has a slider which varies the value between the minimum and maximum values.

You can change the values of the maximum and minimum by simply changing the values in the appropriate edit boxes.

You can also change the value of these parameters directly by entering the desired value in the edit box, however the value entered must be between the given maximum and minimum value for that parameter.

The inductance and capacitance must both be positive, otherwise the equation reduces to a first order problem. You can set the resistance to zero, though this is non-physical and the forcing term R Vin is zero.

Initial Data

You can enter the initial value of the output signal and its derivative at t = 0.

Each of these values has a slider which varies the value between the minimum and maximum values.

You can change the values of the maximum and minimum by simply changing the values in the appropriate edit boxes.

You can also change the value of these parameters directly by entering the desired value in the edit box, however the value entered must be between the given maximum and minimum value for that parameter.

Input Signal

For simplicity it is assumed that the input signal is a sum of at most three sinusoids.

Each sinusoid has the form where the amplitude is A, the frequency is ω, and the phase shift is Φ.

The amplitude of each input signal can be adjusted between 0 and 1.

The frequency of each input signal can be adjusted between 0 and 5.

The phase shift of each input signal can be adjusted between 0 and 2π. Note that the number in the edit box is to be multiplied by π, so that the value in the box varies between 0 and 2.

Numerical Method

You can choose from two different numerical methods to compute the solution- a Runge-Kutta method of order 4, and a Runge-Kutta-Fehlberg method of order 4.

By pressing the change button, the user can select from the two different methods.

The Runge-Kutta Method

The Runge-Kutta method of order 4 is the usual method seen in most elementary differential equations texts.

The user can select the step size used in the method by pressing the change button and modifying the appropriate edit box in the resulting dialog.

The Runge-Kutta-Fehlberg method

The Runge-Kutta-Fehlberg method is a fourth-order, adaptive method.

It uses a Runge-Kutta method of order 5 to estimate the error in a Runge-Kutta method of order 4. It does this using only six evaluations per time step.

After each iteration, the time step is adjusted up or down to control the error.

The algorithm used in the program is based on the algorithm provided in Numerical Analysis, sixth edition, by R. L. Burden & J. D. Faires.

The user specifies the initial step size, a minimum step size, a maximum step size, and an error tolerance.

If the maximum step size is too large, the graph can look "jumpy" as the gap in time between grid points where the solution is computed becomes large relative to the difference in time between adjacent pixels on the graph.

If, in the process of computing the solution, the error control requires the use of a step size below the minimum step size, a warning will be issued, and the minimum step size will be used.

End Time

The end time determines the length of time that the simulation will proceed.

The end time is chosen by moving the slider, and lies between 0 and 50.

You can adjust the viewing area for the input graphs and output graphs independently of the choice of the end time.

The end time can not be decreased below the step size chosen for the simulation.

Preferred Frequency

For a given sinusoidal input voltage, the ratio |Vout / Vin | is called the gain of the filter. The gain depends upon the precise frequency of the input voltage. The frequency that maximizes the gain is called the preferred frequency.

Details

Suppose that Vin = e2πjωt where j2 = -1. Then we can look for a solution of the form Vout = G e2πjωt where |G| is the gain.

Direct calculation shows that
                                    

To find the maximum of |G|, it is easiest to find the minimum of |G-1|. Since
                                    
we see that
                                    
and one can see by inspection that the minimum occurs when
                                    

The Graphs

 

The input graph shows the input signal Vin. It is the sum of the three input signals that the user can control.

The output graph shows the output signal Vout.

The windows for the input signal and the output signal can be resized.

The scale on the graphs can be changed by selecting the change scale item on the menu.

The scale on the input graph need not be the same as the scale on the output graph.

The limits shown in the graph are indicated at the bottom of each graph.

Changes in the scale will be overridden if the simulation end time is changed.

The maximum time shown in the graphs can not be greater than the current simulation time.

Demonstrations

    Aside from showing the solution to the second order differential equation that describes the resonant filter, there are two other useful demonstrations that this software can perform.

    First, it is known that solutions of a second order differential equation with constant coefficients and a sinusoidal forcing term break up into two components- a transient solution and a steady state solution. Simply sliding the bars for the initial data shows quite clearly the presence of a transient solution that depends on the initial data, and a steady state solution that is unaffected by changes in the initial data.

    As a second demonstration, choose three different input signals of different frequencies. Set the resistance to a low value, and slide either the inductance or capacitance values so that the preferred frequency varies across the frequencies of your input signals. You will be able to visually pick out the frequencies that correspond to the initial frequencies. It is a nice demonstration of a primitive method for tuning a radio.

About

 

This demonstration was originally conceived as a student project in our class Scientific Modeling and Simulation, taught at Towson University. This is an interdisciplinary class which teaches mathematical modeling, numerical methods and computer programming using C++ and MFC.

In our class, we provided the students with a class that provided initial data that was the sum of two sinusoids. The frequencies of the sinusoids however, were unknown to the students. They wrote a program to determine the frequencies of the unknown sinusoids.

This work, and the work of developing the course Scientific Modeling and Simulation has been supported by the National Science Foundation, through grand DUE-9952625.

This program is distributed with the source code. The program was written in C++ using MFC. Feel free to re-use the source code, but note that I am a mathematician by trade, not a computer programmer. If you find it useful, please let me know.

This has been written by
        Mike O'Leary
        Department of Mathematics
        Towson University
        Towson, MD 21252
        moleary@towson.edu

Comments and suggestions for improvement are especially welcome.