Differential equations and mechanics - part 1

About the writer: Harvey Morehouse is a contractor/consultant with many years of experience using circuit analysis programs. His primary activities are in Reliability, Safety, Testability and Circuit Analysis. He may be reached at harvey.annie@verizon.net. Simple questions for which I know the answer are free. Complex questions, especially where I am ignorant of the answers, are costly!!!

Summary: SPICE is ideally suited for the numerical solution of differential equations. Several methodologies of arriving at a solution to a differential equation, or a set of simultaneous differential are discussed. The emphasis in this article is in modeling a differential equation directly.

Methods of Differential Equation Solution:

There are at least three methods for the solution of differential equations using SPICE. The first is to, after of course having such a set of differential equations in hand, is to utilize SPICE functional elements to create a circuit which will behave in the appropriate manner which can be simulated (solved).

The second method is to transform the differential equation into an equation in 's', the complex variable, which can be then manipulated. Having created an expression for the desired output, the resultant expression(s) may be used in SPICE 's' parameter elements as part of a circuit that may be simulated (solved).

The third method is to bypass the implicit differential equation generation altogether and instead create a topological model, using familiar primitive elements known to SPICE. The interactions of and within the topological model, with proper stimulus and when constructed properly, enable the circuit to be simulated (solved). This is of course exactly what is done when one creates a schematic and simulates it.

Unfortunately, for Electrical Engineers, there are no familiar mechanical model elements in standard libraries for them to use, and they are usually unfamiliar with the equivalences between electrical and mechanical systems. Consequently the incorporation of mechanical elements into a model causes great difficulties for ten.

Likewise mechanical engineers, with the same unfamiliarity and no mechanical elements, have a difficulty in using SPICE to solve systems of mechanical elements.

Method two is occasionally useful, however it involves a solution in the frequency domain as stated. Now one can of course model 's' parameters functions using elements useful in the time domain, such as creating behavioral models of integrators, differentiators and so on. In this case, save for errors in the creation of these behavioral models (and of course some internal SPICE errors), the solutions will be in almost every case be interchangeable, and both a time and frequency domain solution will be possible.

Method three is most interesting. It will be covered in a subsequent paper, however, the intent is to create a symbology and convention which will allow mechanical systems to be modeled in a simple graphical methodology as for electrical schematics.

This paper will be concerned with Method one.

METHOD One- Differential equation modeling:

It is, for this method, immaterial what system of measurements are used as long as they were correct and conformable in the creation of the differential equations. Details of HOW to create the specific differential equations for a given system are considered out of scope here. What is in scope here is how to solve such equations however arrived at, using SPICE.

The differential equation to be modeled is:

K1y'' + K2y' +K3y = F

In this equation, F is the externally applied force, y is the displacement, y' is the velocity, and y'' the acceleration. The equation actually models a mass of K1, a frictional force of K2, a spring restoring force of K3, with an external force of F applied. The mass is suspended by a spring, and is connected to a dashpot. The force is applied to the mass.

The classical method for solving this equation is to integrate both sides of the equation until all the derivatives are gone. Then, one solves for the dependent variable, 'y' in this case. The result is:

Y = 1/K1 * int{int{F}} - K3/K1 * int{int{y}} - K2/K1 *int{y}

Here 'int{} implies the integral of the argument, with both 'y' and 'F' being functions of time. To model this in SPICE one first assumes the value of 'y' is known. One then integrates it to get the value of 'int{y}', and again to get the 'int{int{y}}.

One then multiplies these values by the appropriate coefficients and sums them. A final input to the summer is the double integral of F. The resultant model is as shown in Figure 1 following:


Figure 1
Differential equation solution model

Devices A1, A2, A5 and A6 are standard Xspice integrator blocks in the library, with a slight modification to make their function more apparent. With a little drawing ingenuity a nicer graphic representation could be made of these, and also for blocks A3 and A4, which are also standard Xspice models in the library. The gain of A3 is -K2/K1, and the gain of A4 is -K3/K1.

The only nonstandard block is the summer. The library only includes a 2-input summer, consequently I created a 3 input device. The device does not include individual gain and offset terms, but these could easily be provided if needed. The device could also be modified to sum more input signals.

Given that K1 = 4, K2 = 5, K3 = 20 and F is a step starting at time zero lasting for 8 seconds with an amplitude of 4 volts, the response of the system is shown in Figure 2 following:


Figure 2
Differential equation solution for position

For reference purposes, the model for the summer is as shown in Figure 3 following:


Figure 3
3 input summer behavioral model

The netlist for this device is:

NLDE & Mechanics1-2.ckt
************************
* B2 Spice
************************
* B2 Spice default format (same as Berkeley Spice 3F format)


***** main circuit
B1 N4 N5 v = v(n1) + v(n2) + v(n3)


.OPTIONS gmin = 1E-12 reltol = 1E-4 itl1 = 500 itl4 = 500
+ rshunt = 1G
.TRAN 10u 20m 0 1u uic
.IC
.END

This model could easily be expanded to include more inputs. With a little more work, it could be parameterized and individual gains and offsets added to each of the input voltages.

An astute reader might ask the question, where are the constants of integration? In this case they were set, or rather, left at zero. If they were desired or needed, one could add them to the outputs of each integration block in an added summer block.

Another reader might question why not model the equation using differentiators rather than integrator blocks? One could, however, differentiators do accentuate sudden input changes at their output, and create convergence problems. In many cases it would work.

To model a system described by two second-order differential equations, one would arrive at model similar to two of the systems in Figure 1, one perhaps in y1 and the other in y2. However, generally one would have a force term as an input, although they both could, depending on the system being modeled. And the model for each equation would have two terms from the other equation model. This is shown in reference 1 for those persons interested. Reference 2 shows another set of coupled differential equations that were modeled.

The astute reader might notice that what was illustrated was a linear differential equation. To model a differential equation in general, where the various terms in y and each derivative may contain coefficients that are also functions of time, is more difficult. When one integrates the differential equations, normally to eliminate the derivatives, these terms themselves also must be integrated if they are other than constants with time. It can get hairy very quickly.

Conclusions:

As has been shown many times, SPICE can be a useful tool for arriving at the numerical solution of differential equations. The problem is that many mechanical systems are difficult for the typical EE to model in SPICE, either as differential equations or using electrical devices. Mechanical engineers also have similar difficulties.

The second article of this series will attempt to alleviate this largely by the simple artifice of creating new symbols of existing devices, which when scaled in familiar units and interconnected will enable the solution of the underlying differential equations in the same manner by which SPICE finds solutions to the underlying differential equations represented by an interconnected set of electrical devices. Some spice vendors do just this, most notably Intusoft.


References:


1. Spectrum-Soft Newsletter, Fall 98. http://www.spectrum-soft.com/news/fall98/differ.shtm

2. Ansoft Gene and Meme solutions using SPICE, http://www.anasoft.co.uk/replicators/competitionmath/spiceevolution.html


 

 

 


Beige Bag Software, Inc., 623 W. Huron, Suite 2, Ann Arbor, MI, 48103
(phone) 734.332.0487 (fax) 734.332.0392 (email) info@beigebag.com
© 2005-2008 Beige Bag Software, Inc