Mathematica Journal
Volume 10, Issue 1


In This Issue
Trott's Corner
New Products
New Publications
News Bulletins
New Resources

Download This Issue 

About the Journal
Editorial Policy
Staff and Contributors
Back Issues
Contact Information

Elements--An Object-Oriented Approach to Industrial Software Development
Gerd Baumann
Michal Mnuk


Car on a Bumpy Road

The problem considered here is a practical application originating from the early phase of a car design process. Engineers in the automotive business have to know in advance how a new car will react under certain environmental conditions. In the sequel, we discuss a procedure for building a model that provides basic information on the behavior of a car at the very beginning of its design. In this early stage of the process, very little information on the new car is available and thus it is sufficient to reduce the model to the most essential properties of the car. These properties can include the mass distribution on a chassis, that is, the location of the engine and other heavy components like the fuel tank, batteries, gear box, and so on. Another essential feature in this early design phase is the undercarriage. In our model, these components are combined into a multibody system interacting by forces with each other and with the environment. Knowing the preliminary behavior of the new car, the next step is to improve the model over several iterations to incorporate more details about the interacting components. Here, we restrict our considerations to the very beginning of the design process and demonstrate how an object-oriented approach can be used to model different components in a transparent way.

Figure 1 shows the simplified one-dimensional mechanical model of a car moving on a bumpy road. In principle, the car consists of three main components: the two axes and the car body. We assume that the two axes are coupled to the chassis by a dashpot and a spring. In addition to the translation, we allow a narrow rotation of the body. The wheels are in contact with the road (this interaction is modeled by introducing springs and dampers representing the two tires). The symbols shown in the figure have the following meaning: , with , with , , and are the physical and geometric parameters of the system. The and denote force and damping constants, are the wheel and chassis masses, and and determine the center of the mass of the chassis. is the inertia moment of the chassis. The dynamical coordinates denoted by , , and describe the vertical and angular motion of the car. The acting external forces on the car are due to bumps in the road and gravity. Now, the whole system can be described by Newton's equations.

Figure 1. A simplified version of a real car. The model uses a multi-body system with spring and damper interactions. The components of the car are the axis, the car body, wheels, and the road as elements.

These equations are given for the coordinates by

where are the acting forces. One of the main problems in car design is to estimate how the total system will react under different forces, different damping parameters, different velocities, different environment conditions, and so on. These questions are partially answered in the following subsections. The complete examination of all these inquiries would exceed the space available for this article. Hence, we will restrict our consideration to a few examples.

To attack the physical and mathematical aspects we first identify classes that would capture the essence of this problem. If we look at the equations of motion and at Figure 1, it seems natural to divide the car into three main classes: the body, the axes, and the environment.

Class Definitions

The problem can be split into the following classes: the general setup class, the car body, the axes, the car itself, and some tools needed to carry out the simulation. The simulation class that provides graphical output refers to other classes that serve as a basis for the computation required to produce the output.

General Setup

The general setup is concerned with geometric properties and the influence of the environment, such as the external force characterized here by four bumps in the road.


The class Body consists solely of geometric and physical parameters of the car body. This class also includes the initial conditions for displacement, angle, and velocity.


The common properties of the two axes are collected in the class CarAxis. This class contains only parameters: force and damping constants together with initial conditions for the equations of motion.

In the next step we define classes for the front and rear axes. The front axis consists solely of a method to generate the equation of motion for the axis by considering the acting forces.

The rear axis is generated in the same way by taking the relations specific to this component into account.


Finally, after setting up classes for the body and axes, we define a class to describe the car. This class incorporates parameters as well as methods to combine information from different components.


Having the classes for all physical components available, we need a tool to carry out the simulation. The following classes provide an efficient simulation of the model and generate a graphical representation of the results.

If we wish to see the motion of the car, it is convenient to declare a special class for making animations.


Up to this point, nothing more than a framework was defined in which the computation can be carried out. The classes represent essentially only templates for creating the real and calculation objects. In order to set up the simulation, we have to generate objects and specify their properties. The car is generated by a modular process incorporating the distinguished objects. At this point, it is apparent that we have a great advantage in designing a specific car compared to traditional approaches in simulation. For example, we can define different objects for axes and use them in different simulations as parameters of the underlying model. Components (objects) of the same type can be exchanged without causing any harm to the system. In the sequel, we demonstrate how this process is carried out.


First, we create the body by calling the method new of the class Body. All properties except zFunName and betaFunName will have their default valued specified in the class declaration.

The actual properties of the body can be checked by


Next, objects for the axes are created. The front axis is defined with a mass of ; the function representing the displacement of the center of the wheel attached to this axis is denoted by .

The properties of the axis can be printed by

Since no values for the damping and the force constant were given in the call to new, these properties are initialized with values specified in the class declaration.

A second version of the front axis with a stiffer damping is derived in the following line. Here, and were given different initial values.

For the rear axis, we just use the default settings. The coordinate of elongation is denoted by .

A check of parameters shows the default values.


Having all necessary components available, it is easy to generate the car by incorporating the defined objects into a common model. The car object is defined by

It consists of the front axis, the rear axis, and the body. We want to stress that object-oriented design allows the behavior of the model to be modified very easily by changing different components or their properties. Hence, if an engineer has access to a collection of different bodies, axes, and other objects, he would be able to create and test many different car designs without needing to adapt the model.


A simulation object is created from the class MakeSimulation. The simulation can be performed with any object of the class Car that is assigned to the property car in the call to the method new.

Finally, the actual simulation is initiated by calling the simulate method of the class MakeSimulation. The inputs for this function are just the starting and end points of the simulation interval. The result is four plots for the coordinates of the axes, the body, and the rotation angle of the body. All quantities are plotted versus the simulation time.

Now the hard work for an engineer starts. If he is interested in an optimization of the elongations, he must change the properties of the car in the simulation. How to achieve the best result and how to select the best strategy depends on the experience of the individual engineer. However, within an object-oriented simulation environment, he has the flexibility to incorporate his thoughts in a quick and transparent way. For example, he can change some parameters of the front axis to achieve a better performing car.

Or he can replace the whole front axis by one with a smoother damper.

And so on (the output of the previous line was suppressed due to space limits). However, a clever engineer will resort to some optimization strategies that can be carried out by an additional class in the development environment (not shown here). In this article, we considered only manual computations to demonstrate the simulation steps.

Finally, if the results are to be presented at meetings, the behavior of the optimized car can be shown online as an animation using different simulation models or strategies. The generation of an animation object and the animation itself is started with

The flip chart movie is suppressed in the printed version. However, the notebook version of this article shows you the movement of the car body and the wheels.

This example demonstrated that the object-oriented approach to modeling is very efficient and transparent to the user. It divides the process of modeling into two phases. In the first phase, the model and its components are implemented. In the optimization phase, the parameters of the model satisfying certain criteria are found. Both phases benefit from the availability of predefined components (objects). Using the classical approach, minor structural changes (e.g., using a different axis) require modifications by the model builder. This, in turn, may have made a subsequent verification step necessary. In contrast, the object-oriented approach allows this to be done much more easily. A new component (e.g., an axis) can be added or exchanged without affecting the soundness of the model. This fact is of crucial importance in the industrial environment where models contain a huge number of parameters. It is necessary to have a clear and well-founded procedure to handle them. If the process to manage and work with models is clearly specified, results can be obtained more quickly, they are more predictable, and comprehensible.

Dynamics in Poisson-Hamilton Manifolds

Another example of an application of Elements in a mathematical context is the definition of operators and manifolds for Poisson-Hamiltonian systems. The problem here can be stated as follows: A set of generalized coordinates and momenta in connection with a Hamiltonian defines a Hamiltonian manifold. This manifold is also known as the phase space governed by the Hamiltonian. We assume that in addition to coordinates and momenta an additional function generating the dynamics exists. This function is usually the Hamiltonian of the system. Having the coordinates and the generating function available, the manifold acquires an algebraic structure. The algebra on the Hamiltonian manifold is generated by the Poisson's bracket. The total Poisson-Hamilton manifold is thus equipped with coordinates, momenta, the Hamiltonian, and the Poisson's bracket.

The question is: How do these entities relate to objects and classes in an object-oriented environment? From a practical point of view, it is necessary to define the Poisson manifold given by the coordinates and momenta associated with the algebraic structure. Thus, one class in the Poisson-Hamilton manifold represents the Poisson bracket with its properties for a given set of coordinates and momenta. The basic algebraic properties which a Poisson bracket has to satisfy are discussed next.

Let us consider two functions and depending on the phase space variables. Using these functions in the Poisson bracket, we can derive some general properties for this kind of bracket defined by

In the following, we use the shorthand notation to represent the Poisson bracket . This notation is used whenever no confusion about the phase space variables can arise. The Poisson bracket possesses the following properties:

If one of the functions or is a constant, the Poisson bracket vanishes

If we have three functions , , and living in the phase space, then the following properties hold:

If one of the two functions or reduces to a phase space variable, the Poisson bracket reduces to the partial derivative of the function with respect to the conjugate coordinate. For example, if is equal to the generalized coordinate or the generalized momentum , the result of the Poisson bracket is

If we chose the coordinates of the phase space for both and , we obtain the fundamental Poisson brackets

These relations of the fundamental Poisson brackets represent the algebraic structure and are the basis of quantum mechanics. Any three functions of the phase space satisfy a special relation, the so-called Jacobi identity

These properties determine the algebraic quality of the Poisson bracket. Especially, linearity, antisymmetry, and the Jacobi identity define the related Lie algebra of the bracket.

Another important property of the Poisson bracket is the ability to derive from two conserved quantities and another conserved quantity

This behavior is known as Poisson's theorem. A direct proof is feasible if we assume that and are independent of time. By replacing the third function in the Jacobi identity by the Hamiltonian of the system, we get

Since and , we find

Thus, the bracket is also a conserved quantity. We note that the application of Poisson's theorem will not always provide new conserved quantities because the number of conserved quantities of a standard mechanical system is finite. It is known that the total number of conserved quantities is given by , if is the degree of freedom in the phase space. Thus, Poisson's theorem sometimes delivers trivial constants or the resulting conserved quantity is a function of the original conserved quantities and . If both cases fail, we gain a new conserved quantity.

It is obvious from the previous definitions and properties that the pure algebraic structure is independent of the phase space variables. Thus we can separate the problem into the algebraic properties (equations (6) through (10)) and the coordinate-specific definition of the PB given by equation (5). This separation is the basis of our class for the Poisson bracket PB.

Poisson Brackets

The following definition of the class PB represents a general definition of the Poisson bracket. This class is determined by the algebraic properties and does not incorporate the coordinates on which it operates. The class definition expresses properties, such as bilinearity, the product relation for each argument of the Poisson bracket, and the calculation of the Poisson expression. The properties implemented represent the algebraic structure of a Lie algebra.

Our aim here is to use a Poisson bracket within Mathematica in the same way as in a textbook. This requires that we first define the Poisson manifold as an object and use this object in our calculations. The following line generates a template for the Poisson bracket combining the Poisson manifold as an object and the algebraic properties of the bracket.

This allows us to proceed in the same way as in mechanics textbooks.

A Simple Poisson Bracket

In the following, we give a few examples of Poisson manifolds and their application to a function defined on them.

The first example describes a two-dimensional manifold in generalized coordinates and . The manifold (object pk) is derived from the class PB.

The properties of this manifold can be printed using

We get the coordinates and depending by default on time .

Now, let us apply the Poisson manifold pk to two functions and depending on and .

The result is the definition of the Poisson bracket given in equation (5) for .

A second example is concerned with the Hamiltonian of a single particle moving in a potential . The application to this Hamiltonian provides us with the momentum .

Another example of a general function depending on both coordinates yields for the coordinate

An additional example deals with a general Hamiltonian and an arbitrary function depending on both coordinates of the manifold.

This result demonstrates that linearity is recognized by the manifold. The next relation represents Jacobi's identity for three functions , , and depending on both coordinates.

Higher-Dimensional Manifolds

The class PB is defined in such a way that it allows creating a general Poisson manifold in -dimensions. To make things easier, let us define a four-dimensional Poisson manifold with coordinates and . The manifold is derived from the class PB and stored in the object pb2.

The properties of this Poisson manifold are

Again, the momenta and coordinates are defined in terms of the independent variable .

Global relations incorporating all coordinates for a two-particle Hamiltonian can be obtained by the following line

The function used as the first argument of the Poisson bracket is a Hamiltonian consisting of two terms for the kinetic energy and a general interaction potential . For another two-dimensional Hamiltonian with a different potential , we find

The following example demonstrates that the Poisson bracket with two identical arguments, here a Hamiltonian, vanishes

So far, we defined the algebraic structure and derived certain types of Poisson manifolds by specifying the phase space variables. However, the knowledge of these manifolds allows us to go a step further to a real application and to introduce Hamilton's equations. Knowing the Poisson manifold, it is straightforward to write down these equations.

Definition of Hamilton's Equations

For a set of generalized coordinates , Hamilton's equations are defined by

This set of equations is related to Poisson's bracket by considering a function in the phase space depending on the phase space coordinates , , and as

The structure of the phase space is governed by Poisson's bracket which can be seen by differentiating with respect to

By inserting Hamilton's equations of motion into this expression we gain

Let us abbreviate by

the Poisson's bracket defined on the phase space spanned by the coordinates and . The subscript denotes the set of variables of the phase space. Using this definition, the temporal change of becomes

Note that this relation allows us to calculate the temporal changes of any function depending on the phase space variables.

We already encountered conserved quantities which have the property that their temporal change vanishes. This vanishing can be expressed by the Poisson bracket in a very convenient way. The conservation of the quantity implies

which is identical with

The previous relations define a connection between a Poisson manifold and a Hamilton system. Thus, the two properties connected by the manifold are denoted as a Poisson-Hamilton (PH) manifold. The equations of motion for any kind of function in this manifold can be derived by means of the Poisson bracket via equation (26).

It is convenient here to define a class for Hamilton's equations which inherits the properties of the Poisson bracket. The properties of the Poisson manifold are equivalent to the properties of the Hamilton manifold.

The following lines define the class HamiltonEquations based on equation (28).

To handle the class for Hamiltonian equations and the derived objects in the same way as in textbooks or in the case of Poisson brackets, we introduce the notation

and define the corresponding palette.

Having these tools available, we can apply the classes to specific problems.

Hamilton's Equations

As a first example, let us examine a PH manifold with a single coordinate and a single momentum. The object defining the PH manifold is created by

Specifying a single particle Hamiltonian by kinetic and potential energies, we can derive the set of Hamilton's equations by applying the manifold to the Hamiltonian.

The result is a system of equations defining the dynamic motion of this particle.

A second example is concerned with a four-dimensional PH manifold. The generalized coordinates and the momenta are primarily given by , , , and .

As an example, let us consider the double pendulum. The Hamiltonian for this system reads

where are the generalized momenta, , are the inertia momenta and the masses of the particles, and are the angles of deviation. The PH manifold ham2 defined earlier does not exactly correspond to the variables used in the Hamiltonian. However, we are able to change the coordinate names by setting the properties of the PH manifold using

Now the PH manifold is defined for the coordinates

The four equations of motion can then be gained by

They represent the dynamics of the double pendulum in the PH manifold. This example demonstrates the fact that using an object-oriented approach, the knowledge of the Hamiltonian, and the coordinates for the manifold suffice to derive the equations of motion in a portion of a second. The ease of use and the close connection to textbook presentations allows for fast manipulation and reliable calculation of results. Besides these examples, many other applications of Elements to similar subjects are ahead.

About Mathematica | Download Mathematica Player
© Wolfram Media, Inc. All rights reserved.