Differential Equations and Mechanics

By Harvey Morehouse


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

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.


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.


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

Differential Equations and Mechanics: Part 2

Summary: The previous article in this series showed how to model differential equations and arrive at a solution. Reference 1 shows how to create an analogous electrical circuit from a mechanical model. What is desirable, especially for mechanical systems and devices, is to be able to enter these elements into a schematic, as one would do for electrical components, with a minimum of remembering the specific mechanical equivalences for the equivalent electrical devices. By creating new symbology and creating new mechanical devices, one can make the solution of a mechanical system almost as easy a process as modeling an electrical system, using SPICE.

Mechanical System considerations:

Please go to the first article in this series and review the article, paying particular attention to the section 'Mechanical 1 (Force-Current) to Electrical'. Although we will be creating and using mechanical device models that will take care of much of the details, you should have a fair appreciation for how underlying electrical schematics are prepared from a mechanical diagram.

Before defining and creating mechanical device symbols and models, one must first fix the system of units to be used. The familiar ones are the English system (pounds, feet, etc.), the CGS system (centimeter, gram, second, etc.), the MKS (meter, kilogram second, etc.) Additionally, one can model mechanical devices where voltage is analogous to force, or where current is analogous to force.

There are several choices to be made. What shall be done is to choose a single convention, and the user will be required to translate back and forth, external to the model, the units as required. (One could of course define a set of devices for each measuring system, but this would prove cumbersome and confusing.)

In other words, mechanical units, if defined to be in meters in the model, will have to be multiplied by 39.37 to convert this quantity to inches if this is the desired output quantity. The conversion of course can be done in the graphical output by defining custom variables to be plotted with these conversions, or within the schematic by appropriate gain elements modifying the outputs to be plotted. Likewise the rotational quantities will be in units of radians per second, unless modified within the 'schematic' through gain elements or in graphs to convert them.

The relation between electrical quantities can be also based on an equivalency between voltage as a force, or current as a force.

Mechanical system modeling units:

As much if not most of the engineering world is using the MKS system, this seems an obvious choice. Conversions may be easily made external to the new elements or in the graphs as desired.

We will also use current as a force. Voltage is thus a velocity. This choice is somewhat arbitrary.

The quantities to be used within the models are as shown in Table 1 following:


length Meters, m
time Seconds, sec
force newtons, nt
mass Kilograms, Kg
current Amperes, A
voltage Volts, V
angular displacement Radians, r
energy Newton-meters, joules
power Newton-meters/second, joules/second
rotational velocity sec-1 (actually dimensionless-radians/sec)
torque Newton-meters, nt-m
inertia Kg-m2 /sec

Table 1
Units used in models

Table 1 is taken directly from Reference 1. If the portion of the simulation eventually being graphed represents electrical device symbols (voltage or current sources, resistors, inductors and so on), then it is representative of electrical units. Whereas if it related to mechanical devices, using SPICE electrical devices to create a mechanical device with a mechanical symbol, mechanical equivalent units apply.

At this time the transformation of values directly taken from mechanical quantities cannot be done automatically, as in showing the output of a mechanical device in a graph as a value and with a label such as 'force' in newtons. This must be performed manually for the moment. (The possibility of doing this automatically IS being looked at, and may be accomplished at a later time.)

Consequently, for now conversion of the graphed output values and units, unless transformed with elements on the schematic or by means of custom plots where the item(s) to be graphed is (are) multiplied by an appropriate conversion constant, should be interpreted to be in the units shown. To do otherwise would require special symbols for each system of units one used, such as CGS, MKS, English Gravitational and so on.

Until such time as some changes are made within the SPICE program, the interpretation of the graphed output quantities should be fairly well evident from the topology on the 'schematic'. In other words, the 'current' through a 'mass' device's nodes is to be interpreted as a force applied to the mass. The 'voltage' of a 'mass' device is to be interpreted as a velocity. In a like manner, for a 'mass' device, the integral of its voltage represents position, the first derivative acceleration, the second derivative 'yank' and the third derivative 'yerk' if needed.
We need to know what electrical terms, as inputs, outputs or intermediate quantities, represent what mechanical quantities for the devices we add and the circuits we build. Table 2 following, again taken from Reference 1, shows some of the direct equivalences.


Electrical Item
Mechanical Analogy
Voltage, e
Velocity, v
Current, I
Force, f
Resistance, R
Lubricity, 1/B
(inverse friction)
Capacitance, C
Mass, M
Inductance, L
Compliance, 1/K
(inverse spring constant)
Transformer, N1:N2
Lever, L1:L2
Gear ratio, D1:D2

Table 2
Electrical-Mechanical quantity equivalents

Some electrical device and circuit equations and their mechanical analogs (in current-force equivalents) are shown in Table 3 following:

Electrical Equation
Mechanical Analog
e = iR v = f/B

e = L di/dt

I = 1/L ∫e dt

v = (1/K) df/dt

f = K ∫v dt = K x f = M Dv/dt = M a

e = 1/C ∫I dt

i = C de/dt

v = 1/M ∫f dt

f = M dv/dt = M a

Power = e i Power = f v


e1/e2 = N1/N2 = i2/i1


f2/f1 = L1/L2 = v1/v2


F2/f1 = D1/D2 = v2/v1

capacitor stored energy

½ C e2

mass energy

½ M v2

Inductor stored energy

½ L i2

spring stored energy

½ K x2 = ½ K (f/K)2 = ½ f2/K

∑current = 0

∑forces = 0

∑voltage = 0
∑velocities = 0

Table 3
Electrical-Mechanical analogous equations/relations

Tables 2 and 3 are again created from the information in Reference 1.

Some Modeling Considerations:

To fully understand and use mechanical models, one must appreciate and understand the differences between the analogous electrical devices and systems we will be using for modeling mechanical systems, as well as some nuances of the mechanical system. There are potential areas where problems may arise. To be sure we do not get into a situation where the simulation results are incorrect, or the mechanical model is incorrect or simulation difficulties occur due to the resultant analogous electrical system, one must take care.

Normally mass devices have one node connected to ground (this will be later seen in the creation of the 'mg' device). The voltage across this mass will represent its velocity with respect to ground. However, in some cases it may be necessary or desirable to have an ungrounded mass, where its velocity is with respect to a changing reference.

Consider a case of a mass, which was suspended above ground, with a spring and a friction device. This is clearly an mg mass. Now suppose a second mass was suspended from the first mass, with a spring and its own friction device. What is the reference for the first and the second mass?

In a like manner as in the case for masses, two springs (equivalent inductors) should not be placed in parallel without some other mechanical element between them, in series with one or the other spring. In general NO two elements of the same type should be placed directly in series or in parallel, but fortunately these problems do not often occur, but they must be considered. (Note that a real situation might occur where two springs might be placed in parallel, where one has a longer length than the other. This would cause the force to be at one rate during compression until the longer spring has been compressed to the length of the shorter one, and then the resisting force would increase. A single, nonlinear spring model best handles situations such as this. Similar situations might occur for other devices.)

Whenever there are complex models, with several systems of reference, extreme care should be taken in modeling these devices. Fortunately, this is not often the case in the models of most interest to SPICE users, as generally the most common uses would be to model servo systems, but the most general use of mechanical models should allow these special cases to be modeled.

Mechanical Part Models:

There are at least two distinct types of mechanical systems and models that could be created. They represent translational systems, where motion is in one axis, back and forth as it were, and rotational systems, where motion is about an axis. These models can be combined in one simulation, the means or coupling of the 'motions' being a rotational to translational velocity or force converter and/or its complementary device. Situations may arise where one would wish to use, or require models from both types.

A simple example of such a 'mixed' mechanical system might be in the modeling of the control system for an aircraft wing flap. The flap might be driven through a rotating threaded shaft with a follower (similar to a nut on a rotating bolt or machine screw), or by a rack and pinion device. These would provide linear motion to a shaft driving a lever, or bellcrank attached to the flap, which would rotate the flap.

In order to simplify somewhat mechanical system modeling and solution, several mechanical device primitives will be created. Their appearance or symbols will be chosen to visually present 'clues' to their function. Only a few devices will be created here, to keep the article to a reasonable length; the purpose here is to show how one might create the devices and the reasoning behind them.

These new parts will be parameterized parts. This allows us to present descriptions of their underlying electrical characteristics in terms of their desired equivalent mechanical quantities. Thus, for example, one need not remember to give a mechanical force element a value in 'amperes' equivalent to the underlying mechanical device value of 'force' in newtons.

Unit Conversions:

The WEB site of Reference 2 provides many conversion factors. There is much to be said about conversion from one set of units to other systems of measurement. English units do differ in different countries. As another example, one may consider a mass object expressed in 'pounds' or 'kilograms' to be either a mass measurement or a force.

Consider an object on earth that on a scale shows a measurement of one pound. A scale really shows an indication of the force on an object due to the acceleration of gravity. So, if an object on earth is expressed in pounds, is that the weight (or scale measurement) of the object or a measure of its mass?

One may use a term of poundals as an expression of force, together with mass in pounds in which case a one poundal force will accelerate a one pound mass at a rate of one ft per second squared. In the case where gravity is the accelerating force, the earth's gravitational field causes the one-pound mass object to free-fall at about 32.2 ft/sec2, exhibiting an accelerating force of 32.2 poundals. (These values should be converted into MKS units when input into the mechanical devices.)

The most common usage is that a pound as an expression of force (as measured by an earthly scale). In that case a body weighing one pound in the earth's gravitational field will exhibit a mass, expressed in slugs, equal to 1/32.2 slugs. At the same time, in MKS units, its weight (force) would be equal to about 0.4545 Nt and its mass would be about 0.046 Kg.

Unfortunately, most objects in the earth's gravitational field when using MKS units are expressed in units of mass, not weight. One speaks of a body weighing 'x' kg, when in actuality kg is a measure of the mass of a body. If it is referring to weight, that is or should be expressed in Newtons of force to be consistent. One speaks of 2.2 kg equaling one pound, which is meaningless unless one is referring to force equivalents.

Are you confused yet? Here is the rule, at least for common 'earthly' problems. If an object is expressed as being 'x' kg in weight, unless it is specifically stated that is its MASS, assume that it really means its weight (force due to gravity) is 'x' newtons. If its weight is expressed in newtons, assume the person doing the specification knows what they are doing. If an object is expressed in terms of pounds, assume that is a measure of its force, and use its mass in slugs unless it is clear that it is expressing pounds mass, and use poundals force in that case. In any event, all items should be converted into equivalent MKS units for entry into the mechanical devices.

One last item concerns gravity field simulations. Suppose one were modeling the drive characteristics of a Mars Exploration Rover vehicle. Now for simulation purposes, one would need one value to represent its operation in the gravity field of earth, and another in the gravity field of Mars. Fortunately it does not move fast enough to have major aerodynamic effects, but in some cases a situation might arise where it does.

Take care.

Specific Device Models:

A limited number of device models are provided in the following. These will hopefully be added to the standard library. A user is of course free to create and add their own models to the library.

Mechanical 'ground' model:

Mechanical ground serves as a reference point as in the electrical system. It is an 'unmovable' point.

Certain mechanical devices have an inherent 'ground' in them, such as (gm) masses and applied forces (currents). Note that in this case, the velocity of the mass (voltage with respect to ground in electrical terms) is what does the actual 'moving'. Applied forces are most often relative to ground.

The 'ground' itself is unmoving for two reasons. First because any currents entering a ground must somewhere leave, resulting in no net current, and second, in a properly constructed model the ground has no voltage in itself. There are no two terminals where a voltage could appear. Multiple instances of this device are really the same point.

The symbol for mechanical ground is:

Figure 3
Mechanical Ground Symbol

Adding an alternate symbol to the existing ground device can create the mechanical ground symbol, or by creating a new ground device which has this symbol associated with it. Hopefully the folks at B2SPICE will as their choice do one of the other for us, and add it to their standard library. I have chosen to add an alternate symbol to the normal ground symbol.

Simple Translational Force (applied):

An electrical current referenced to mechanical ground most often represents applied force in mechanical systems. But what is meant by the term applied?

An applied force, as the term is used here, is one that is present other than those inherently present or resulting from other elements in the system. As an example, it could be the 'push' given to the mass portion of a model of a gravity powered vehicle on a hill; it could represent the force due to gravity on a suspended mass

As an example of a non-applied force, a compressed or extended spring will exert force on the elements to which it is connected; frictional forces will present a restraining force on the interconnected elements where there is relative motion. An applied force generator will in general NOT represent such forces.

Now a current represents an applied force. But what 'sense' is to be given to this force? By sense it is meant the polarity, or 'sign' associated with its magnitude. And how does the sense of this force relate to the 'sense' or sign of the interconnected elements and their motions?

The applied force generators will be elements that show the 'sense' of the applied force by means on an arrow. There is but one terminal on these elements, and hence a positive force is in the direction of the arrow of these elements. A connected device is one attached to the external terminal of the generator.

A 'push' force will be one which in which a positive magnitude of its force will tend to move connected devices to the right, or downward in their normal orientation. This motion should cause a position change that will be negative. A positive 'pull' force will also be one which tends to move devices to the right, or downward, in their normal orientation.

(Why have 'push' and 'pull' forces? The reason is to enable mechanical models to be drawn easily that shall have a close relationship to typical mechanical system force diagrams. One can draw suspended masses, and show a disturbing forces, a push or pull, and at the same time show a gravitational force on the masses. Because the forces are really currents, one could include them all in one source through summation, although this would not usually be done for reasons of clarity. These separate devices make the SPICE model more understandable and clear and in a form that is visibly understandable to most users.)

Why not have a positive push force move a mass object in a positive direction for a positive magnitude associated with that device? Good question. In many ways this would make more sense. But because EE's draw circuit diagrams with sources on the left, and the arrow associated with its symbol has to point some way, it was arbitrarily chosen to have 'push' and 'pull' forces with a positive sense cause normal motions to be to the right or downwards. There is a little contradiction here, although one could just ignore it altogether and let the user determine what is happening. This is indeed was some SPICE flavors do when they include mechanical models.

Now there are other considerations that need to be considered in the definition of the mechanical elements to be consistent. These will be mentioned in the appropriate mechanical device models, however, to summarize at this time, positive displacements will normally be to the left or upwards, and negative displacements will be to the right or down, with normal component orientations. Note also that if force acts on an object that is constrained to move other than in a collinear direction with the gravitational force, that component in the direction of motion must be resolved outside of the device itself.

Push Force device 'fpush1':

The electrical device model for a 'push force' device is shown in Figure 2 following:

Figure 2
'fpush1' mechanical device model

This device is very simple. It consists of a current generator connected between ground and an output node N1. Because the default motion direction chosen for a 'positive' force causes a mass to move 'down' or to the right, the direction of the current generator is 'downward' toward ground in a circuit constructed with mechanical devices. This will cause the voltage across an equivalent mass device, a capacitor, to be negative going in equivalent mechanical units, for a positive magnitude force applied to a mass. Note that flipping the symbol by 180 degrees does NOT change this. The only way to do this is to reverse the sense of the signal in the equivalent current generator of the mechanical force generator, or in other words use a negative quantity as a parameter of its equivalent current.

This convention was chosen because of the typical practice of placing electrical sources to the left when constructing an equivalent circuit of system. With the convention that mechanical motion to the right or downward is negative, a positive push force has to have this convention.

Now in an electrical diagram the topology is not particularly important, however, to avoid confusion in a mechanical diagram the following rules should be followed:

1. Construct the mechanical force diagram with the force generator fpush1 'pointing' to the right or downward, as it would be in the case of a mechanical system. In that case, a 'positive' level or force would tend to cause the motion of a connected mass to be downward or to the right.
2. IF the applied force is to be upward or to the left, reverse the sense of the signal programmed into the device.

To illustrate this device, even though we do not yet have tested mechanical devices, let us construct a few simple test circuits. The first one represents a mechanical mass acted on by a positive force to the right. There is no friction, no spring, just a force and a mass. The force is applied in a direction to make the mass move to the right. The current generator thus has an input equal to +1 newtons. Refer to Figure 3 following:

Figure 3
Fpush1 test circuit

Here, I1 represents the force generator of a mechanical system, and C1 a connected mass. The mass is 1kg, which makes C1 become a 1 farad mass equivalent, acted upon by a force equal to 1 newton. The force as shown (input to the force generator as a positive quantity), represents a push to the right (or downward where gravity is of no effect). Thus, the velocity of the equivalent mass (represented by capacitor C1) is increasing downward, and its position, the integral of the voltage across C1 is becoming more negative. Performing a transient simulation on this circuit (with the maximum step time set to be 1ms) produces the result shown in Figure 4 following:

Figure 4
Fpush1 test circuit simulation

The items plotted are the position (change) of the mass in meters as a purple curve, velocity of the mass in meters/second as the black trace, and the orange trace as the acceleration of the mass in meters/sec*sec. The position is the integral of the velocity of the mass with respect to time. The velocity of the mass is the voltage across C1. The acceleration of the mass is the derivative of the velocity of the mass.

As a check on the results, we know that:

f = m * a

Substituting 1 newtons force (f) and 1 kg mass (m) into the expression, and solving for acceleration (a), we get a (constant value for acceleration equaling 1 meter/sec*sec, as the curve shows. Knowing that the expression for distance 's' is (with simple constant velocity):

s = v * t

Where v = 1 meter/sec
t = assumed 1 second

We see that that distance traveled in 1 second is indeed 1 meter. It is negative as it is to the right. Were the force to the left, we would input a force with the opposite sense, -1 newtons, and the signs of the results would change. Notice that the outputs are electrical quantities, and that the quantity multiplier 'm' in the 'y' axis scales in the graphed output means milli-units, not meters.

Note that a plot of the force applied (current) is negative or downward. Why is this? This is a consequence of the conventions chosen. It is nice to have the potential energy of the mass decrease as it moves downward in a gravity field. Should we associate a positive elevation of 'x' meters of the mass above ground in a simulation, as the mass moves downward its potential energy will decrease as the elevation (the integral of the voltage across the mass-capacitor decreases. Now we could use a 'positive' current to the right, but then the capacitance would have to be negative to accommodate this. And other elements would have to be similarly altered. It is just simpler to make a convention and to stick with it.

Let us perform one more simulation. Suppose the force was a sine wave, with a magnitude of 1 newton peak value, at a rate of 5 Hz, or 5 cps. Try to guess what would happen first, before examining the result, as shown in Figure 5 following:

Figure 5
Fpush1 test2 circuit simulation

Here, we see some STRANGE results!!!! The orange curve is the position, and it is monotonically decreasing!!! Why is this?

First, we know (I think we know!) that the SPICE simulation of electrical circuits is pretty darn well exact. So, the electrical circuit is behaving EXACTLY as it should. So how do we interpret the results?

The key to understanding the results is that, from an electrical viewpoint, the integral of the voltage across a capacitor, the mechanical analog of a mass's position, is usually of no particular significance to us. Consequently we need to understand what is happening in the mechanical equivalent circuit.

The first half cycle of force pushes the mass to the right, and causes its velocity to increase in magnitude, negatively. During the second half cycle, the rightward/downward velocity is reduced to zero. During this first cycle the mass will have moved rightward/downward, and then its motion stops. But, the mass never moves to the left/upwards. The second cycle will repeat the action, causing more rightward/downward motion. Thus, even though the force is bipolar, and a net zero over a cycle, it will cause a net motion to the right.

The symbols chosen for the fpush1 device is shown in Figure 6 following:

Fpush1 device symbol
Figure 6

No device was created for the 'fpush1' generator, even though a model was created and a symbol chosen. The reason why is that the underlying current generator is a complex SPICE primitive, and it is just too cumbersome to try to pass parameters to this device. What is needed is to duplicate the 'C' code model for the current source (with the sense as shown in Figure 2, and then alter the model description slightly to associate the symbol of Figure 6 with it, as well as altering the text description to associate a force in newtons (equivalent to the underlying electrical quantity of current in amperes). Hopefully this will be done by the folks at B2PICE for use, both in versions 4 and versions 5 of their program.

Pull Force device 'fpull1':

The fpull1 device is almost identical to that of the fpush1. The reason it is added is that it allows the mechanical model symbology to match that of typical force diagrams. It allows a mass to be 'pulled' toward or away from ground in a manner identical to that of the push device.

Assume one were modeling a mechanical system where a mass was subjected to a 'push' downward to an applied force, and also was subjected to a gravitational force 'pulling' it downward. Now one could use two 'push' devices to accomplish this, where one was a gravitational force, and the second represented a gravitational force. Both of these devices would have the same positive 'sense' for their parameters.

Alternately, one could use a 'push' device for the applied force, and a 'pull' device for the gravitational force. The 'sense' of the devices would remain the same in both cases, in that a 'positive' force would tend to move the mass downward or to the right. The symbology for a 'pull' device changes slightly from that of the 'push' device, as the single connection point moves to the left of the symbol instead of to the right.

'fpull 1' device symbol
Figure 7

As the 'fpull1' device uses the same essential circuit as that of the 'fpush1' device, and presents the same modeling difficulties, it is assumed that in the near future the folks at B2SPICE will also create this device.

One could also define at least two other force generators, 'fpush2' and 'fpull2'. The difference between these devices and their previous counterparts would be that the underlying current generator would be a nonlinear current generator, with its 'direction' towards ground. These devices would allow one to create a complex force generator that was a function of other variables within the system being modeled. It is assumed that these devices will also be added at some time to the standard library. Until that time we shall have to be content to use standard current generators to generate 'forces' in our models.


A mass element is used in translational systems. Two fixed mass elements may be created, a 'GMf' element, and an 'UMf' element. ('GMf' implies a Grounded Mass that has a fixed value, whereas 'Umf' implies a floating mass that also has a fixed value). A description of both masses is provided, however only a GMf device will be created here. It is not a difficult task to create an UMf mass device, however. (An 'MGv' and an 'MUv' device - implying a varying mass - would be similar to the preceding devices, but the mass magnitude would be a function of time or some other variable, wherein the underlying 'capacitance' would be variable. These will not be created here for reasons of brevity.)

Why might one need such a variable mass device? Well, one example might be in modeling a rocket. The mass of the rocket will decrease as fuel is expended.

GMf device:

A GMf device is represented by a capacitor, with one end grounded. For the GMf device, the velocity (voltage) of (across) the device is inherently referenced to mechanical (electrical) ground internal to the device. Although two normal interconnection points are provided, from a SPICE equivalent circuit perspective, these are the same point.

The device will be a parameterized device subcircuit model. Its input will be the mass value in kg, and its initial velocity in meters per second.

The underlying electrical circuit of a GMf device is shown in Figure 8 following:

GMf mass equivalent circuit
Figure 8

In this equivalence, the capacitance of C1 in farads is equivalent to the mass of a device in kg. The voltage across the device is its velocity; again with the conventions chosen, a positive force (a positive magnitude force entered into a 'push' force generator) will tend to cause the mass to move downward or to the right. It will exhibit a negative voltage (velocity). That is to say, it will behave as the mass equivalent capacitor C1 in Figures 5 and 6, in the force generator section of this paper.

The presence of voltage source V1 is an artifice to allow two separate connection points (which really are the same) to be present in the device model. V1 (alternately an ammeter, which is really a zero voltage source could have been used) has a value of zero volts allows this to occur.

Resistor R1 is not really required, as normally one would always have two mass connections, but it is added with a large value to preclude problems in unusual simulations or models where only one connection point was used.

The electrical equivalent of the mass, C1 can have an initial voltage (velocity) associated with it. What does this mean in terms of a mechanical simulation? The initial voltage (velocity) of a mass is of course a fixed value that is present at the start of a simulation. It could be of some use in a simulation. A positive initial voltage would imply an initial velocity directed to the left or upward, and a negative initial voltage a velocity to the right or downward.

The energy of a mass body could be of interest. It is assumed here that if the potential energy of the mass is of interest, it can be determined external to the mass device. (In other words, one may define a curve to be graphed equaling the product of the instantaneous height of the mass above the reference and its mass. At the start of the simulation a positive constant representing the mass height above the reference is added to the integral of the mass velocity - the voltage across the equivalent capacitor representing the mass.)

Note that if the motion of the mass is not coincident with the applied force or a gravitational force, the height might not be directly related to the integral of the voltage across the capacitor and could be a non-linear function of its motion.

Where might this be? A mass could be sliding on a curved ramp. Another case would be for a pendulum. In that case the height of the pendulum bobber would be proportional to the sine of its angle of deflection from a vertical position. Thus the gravitational restoring force component (normal to the instantaneous bobber motion) would vary with its position (angle of deflection), as would its change in elevation with angular motion from the vertical position. Many more complex situations are easily imagined.

A simple test circuit where the mass is referenced to ground and fixed in value is shown in Figure 9 following:

Figure 9
GMf mass test circuit

In the test circuit of Figure 9, C1 (MF1) represents a mass of 1 kg. It is acted upon by a rightward/downward pull force of 9.815 newtons representing the force due to gravity, provided by force generator I1 (with its associated ground). V1 as noted previously is a voltage source of 0 volts, providing an 'output' port of N2 (N4) which is the same point as node N1 (N3). The resistor R1 is added to allow the 'output' port to be unconnected in this simple example. As it is very large it does not materially affect the simulation. The capacitor C1 representing the mass is given an initial condition of +1 volt, indicating an upward/leftward initial velocity of 1 meter/second.

A graph of this circuit is shown in Figure 10 following:

Figure 10
Gmf mass test circuit

Here we see that initially the velocity of the mass (v(N1) = v(N2) = v(N3) = v(N4)) is 1 meter/sec, to the left/upward. It is decelerated by the rightward/downward-applied force. The orange curve, the position of the mass, (with no initial height) is at zero, found as the integral of the voltage across C1 (the equivalent mass) with respect to time. The mass moving to the left/upwards is decelerated by the applied force, and reaches its maximum when t = 1 second, when it reaches a maximum height of 0.5 meters. Thereafter it moves downward reaching the initial height at about t = 0.2 seconds when it is zero once again.

Let us now, external to the model, plot the potential energy of the mass. This will be done external to the model, in the graph. (Note that one could add circuit elements to do this, but it is less confusing to do this in the graph).

Assuming first the gravitational acceleration to be equal to 9.815 meters/sec2. The 1kg mass will experience a gravitational force found from the following:

f = m * a = 1 kg* 9.815 meters/sec2 = 9.815 newtons.

The initial height of the mass was 1 meter above ground, consequently we will add (through the graph) 1 meter of height to the position curve, and compute the potential energy of the mass to be:

P.E. = m *g * h = f * H

As the height is the sum of the integral of velocity plus the initial height, the potential energy becomes:

P.E. = f * (xo + integral(v(N2), TIME)

Where x0 = 1 meter, and m = 1kg. Thus at time t = 0 the potential energy should be 1 kg-meter. It should increase until the upward motion stops (the position is at a positive maximum, where the velocity is zero, and the decrease.

Let us add one more curve, the kinetic energy of the mass. This is found as:

KE = ½ m * v2

Making the changes to the plots of Figure 10 as indicated, the graph of the test circuit becomes as shown in Figure 11 following:

Figure 11
GMf mass test2 circuit graph

Figure 11 shows that the initial potential energy is 1 kg-meter as expected. It changes directly with the height of the mass (as we would expect, hence the position and potential energy curves are identical in shape).

Here we see that the position of the mass reflects the starting position. The potential energy of the mass starts off at 1 newton-meters, increases till about 100ms, and then decreases. As the kinetic energy is dependent on the square of the velocity, and although not altogether clear from Figure 11 as shown, it is never zero.

Somewhere between 300 ms, the mass reaches a zero position and then decreases. At about 550 msec the mass reaches the ground level.

UMf device:

For the UMf device, its velocity is taken with respect to its two terminals. The two terminals of the mechanical device would be separately provided. The voltage across the mass device and hence the velocity of the mass would be from one terminal with relation to the other terminal, the reference being the other terminal. The question then arises, how does one determine its velocity with relation to a fixed reference or ground? Carefully!

In most simulations, one would not use such a device. Its use would be in multiple coordinate systems. One example might be where a mass was on a ramp. And on that mass was another mass system that was also capable of motion. It will not be considered here, but such a device could be easily created and added by the user to the library if needed. In that case, the device would simply be the equivalent of an ungrounded capacitor.

LS Linear spring:

A linear spring, used in translational systems is one that exhibits a force, when compressed or extended, proportional to the amount of compression or extension. Its electrical equivalent element is an inductor. The value of the inductance would be the inverse spring compliance, 1/K, where K is expressed in units of meters/newton. The equivalent inductor value would have a value of 1/K henries. Note that this linear spring is infinitely compressible or extendable.

For a linear spring, it basically acts according to the relation:

f = - K * x

For a spring that exerted a force of 0.01 newtons when compressed by 0.1 meters, the equation becomes:

0.01 = - K * 0.1

Rearranging and solving for K, K is equal to - 0.01/0.1 or - 0.1 newtons/meter. An equivalent spring would thus have an (inductance) value of 10 henries equivalent to 10 meters per newton.

The initial current of the equivalent spring is the initial leftward/downward 'push' ('pull') force at N2 (N1) as shown it its normal orientation. Hence a downward force (initial spring extension) should be entered as a positive quantity for its initial current value consistent with previous definitions for the force devices.

The voltage across the equivalent inductor is its velocity of compression (if you really wished to know this!)

The circuit for this device is shown in Figure 12 following:

Figure 12
LS model

Note the arrow. In its normal orientation the arrow indicated the direction of an initial current rightwards or toward ground. A positive value for this initial current (force) follows the direction of the arrow. A test circuit for this device is shown in Figure 13 following:

Figure 13
LS test circuit 1

The spring is initially neither compressed nor extended, hence the initial current (force) is zero amperes (newtons). Of course in this simple circuit it is meaningless - except during the extremely small rise time of both equivalent current generators.

Here we are applying a constant force of 1 newton downward, which is supplied by the current generator I2, to the right/downward. We will be plotting the velocity (the voltage across the equivalent spring, and its integral with time. Before looking at the graph, take a guess at what the results would be. Remember that a spring is massless. What will the velocity be over time? How will the deflection vary with time?

A graph of the test circuit is shown in Figure 14 following:

Figure 14
Linear spring test1 graph

Did you guess correctly? Notice that there is a very large spike in the acceleration (voltage) across (of) the spring. Corresponding to this, the deflection of the spring abruptly changes to about -10 meters, meaning it is compressed by this amount. This figures, as the spring has no mass. From an electrical viewpoint, the current source forces the spring (inductor) current to instantaneously jump to its final value. Of course the current generator will not rise in zero time, hence the results will not be ideal.

Now why do you suppose the position is not exactly 10 meters? Take a guess!
The answer is that the voltage across the inductor is ONLY present when the current is changing. And, this change ONLY occurs during the very small but finite rise time of the current source. IF the current source changed in zero time, from amplitude of zero to 1 ampere, it would represent a unit impulse. This would cause the deflection, the integral of the voltage across the equivalent inductor to equal 10 volts. But of course this cannot be due to the numerical nature of the SPICE solution. And, the circuit is so primitive as to be virtually useless.

Let us now add a mass of 1 kg in series with the spring and generate a curve. The model is shown in Figure 15 following:

Figure 15
Linear spring test1 circuit

Note we are using a ground referenced mass. Given an inductance of 1 Hy and a capacitor of 1 fd, the resonant frequency is 0.050329 Hz, which corresponds to a period of 19.86918 seconds. Here we are applying a step of force of 1 newton, with a 1 ps rise time.

The graph for this circuit is shown in Figure 16 following:

Figure 16
Linear spring test2 graph

We can see that the mass is shock excited by the input force, and does have a period of about 19.9 seconds.

When we make a dashpot device, we will revisit this model with an added dashpot device.

DPL linear dashpot:

A linear dashpot is a device that acts like a friction device. It is another way of denoting a friction element, save that it behaves more like an ideal friction device in that 'stiction' can be essentially zero. An ideal dashpot device is of course independent of gravity, unlike simple friction, which is dependent on the normal force between sliding elements. It is also massless.

Its 'resisting' force is proportional to the voltage (velocity) across its terminals. This corresponds to:

f = K * v

Mechanically, K above is equal to the inverse lubricity of the dashpot, B. The units of B are thus (meters/sec)/newton. Let us define B as 0.1 meters/sec per newton of force applied. Thus the equivalent resistance of the representative electrical device is 10 ohms. This is just a simple resistance. Remember, we will be passing B to the dashpot, which are the familiar mechanical units, whereas the equivalent resistance will be equal to 1/B in ohms.

The model for this LD device is shown in Figure 17 following.

Now, to make a more meaningful test model, let us combine a mass, a spring and two dashpots together with a force generator to make a more meaningful model. This is in fact the system described in reference 1, under the section, Conversion from Electrical to Mechanical 1 -- Visual Method.

The model for this simple mechanical system is shown in Figure 17 following:

Figure 17
Linear Dashpot model

A test circuit for this device is shown in Figure 18 following.

Figure 18
Linear Dashpot test circuit1

The stimulus is once again a step of 1 newton. A graph for this test circuit is shown in Figure 19 following:

Figure 19
Linear Dashpot test circuit1 graph

Here we see that v(n1) = v(n2). The final position of the mass is at -10 meters, as is expected. The dashpot damps the oscillatory motion of the mass.


Several mechanical parts were created useful for simulating, in a similar manner to that of electrical systems, simple mechanical systems. We have decided on conventions that help to ease the interpretation of the results. With some effort and time one could create a fair number of elements, which could simplify the task of analyzing mechanical or electro-mechanical circuits. This will aid in the analysis of electromechanical systems such as servomechanisms.

Some parts which would be useful include friction devices, stiction devices, linear solenoids, rotary solenoids, inertia devices, hysteresis, levers, governors, cams and followers, rotational forces, torsion springs, torsion friction devices, DC motors, AC motors, rotational to linear force converters, linear to rotational force converters, rotational hysteresis devices and others.


As a long overdue postscript, I would like to acknowledge the immense help given to me by Thien Nguyen in the preparation of this and the other little articles I have written that are posted on the RESOURCES section of the B2SPICE web page. Thien has been very helpful to me in the preparation of the articles. He has contributed in proofreading, editing, and most of all in helping to create the models for inclusion in the database. He has been patient with me, and I wish to express my gratitude to him. If the articles, past, present and in the future are useful, Thien deserves much of the credit.

I would like to also express my thanks to Jon Engelbert. I have been working with Jon on some changes to B2SPICE ver 4 and especially ver 5. Some of the changes to come are REALLY exciting to me, and I await them eagerly.

But most of all I wish to thank Jon and all of his staff for working so hard to produce an affordable and very capable product. When I have had a problem, they have been quick to respond. When I griped, they listened. That is one of the nicest things about B2SPICE, the personal attention they give to users.


1. http://www.swarthmore.edu/NatSci/echeeve1/Ref/Analogs/ElectricalMechanicalAnalogs.html#Equations

2. http://www.maribi.com/conversion/low/index.htm