Benutzer:Dirk Huenniger/mordredTechnical

Aus Wikibooks

Introduction[Bearbeiten]

The goal of this document is to describe the algorithms used in the mordred program. Mordred is a tool for mechanical engineering. Mordred calculates the movement as well as the forces of a mechanism. So mordred has to solve two problems a geometric one, to find out how the mechanism looks like at a certain time, as well as a static one to calculate the forces that act at each points in the mechanism.

Basic Data-Structures[Bearbeiten]

First of all we need to have a structure in which we can describe any mechanism. This structure is called Mechanism for simplicity. A Mechanism is carrying several collections of other structures, which we will discuss in the following paragraphs.

Node[Bearbeiten]

A node is a point in two dimensional space, it has two attributes called x and y, which represent coordinates. Many other objects refer to a node in order to define the spacial position. For example any external force that acts on the mechanism, is actually acting on a specific node of the mechanism. All Nodes needed to define the mechanism are stored in a List called nodes in any Mechanism

Line[Bearbeiten]

A Line is a connection between two nodes. So it has got two public attributes called start and end which refer to the two nodes it is connecting. The start- and endpoint of each line are fixed to there respective nodes, although the line as a whole can rotate around the node if the nodes are moving. Still the distance of these two nodes is usually fixed to the length of the line. An exception are lines with an elongation attribute that is different from null. The length of those lines changes during the movement of the mechanism. But the way it changes is clearly defined by the Elongation Object, referred to by the elongation attribute. An other example are lines with an telescope attribute that is different from null. These Lines are telescopic, that is the length is not predetermined, it is calculated as distance between the two nodes it is connecting. A since the length of a telescope line is variable it can not carry any force in this direction, although this is possible in the perpendicular direction.

There are two methods in a Line called getStiffStart and getStiffEnd which return nodes. These nodes are created each time these methods are called, so two nodes returned by two subsequent calls of the same method will usually not compare as equal. That the == Operator as well as the method will return false. We will postpone the purpose of these somehow virtual nodes, until we discuss the question of how we can fix angels, or to put it in an other way, how to make things stiff.

Each Mechanism has got a List called lines that contains all lines needed to define the mechanism.

Bearing[Bearbeiten]

A bearing is a structure that fastens a node. It can either fix it in horizontal or in vertical direction or in both directions. This explains its three public attributes node, fixedX and fixedY it is zero. A bearing can transfer a force to the mechanism in the directions in which it is fixed. Each Mechanism has got a List called bearings that contains all bearings needed to define the mechanism.

Force[Bearbeiten]

A force is an external force acting on a particular node of the mechanism. It has got two components, for the direction x and y. So there are two public attributes x and y. Furthermore there is a public attribute node referring to the node, the force is action upon. Each Mechanism has got a List called forces that contains all forces needed to define the mechanism.

Fusion[Bearbeiten]

A Fusion represents are fixed joint between two lines. You can imagine them to be welded together. Geometrically a fusion fixes the angle between two lines, statically it allows transfer of angular momentum between the two lines. I has got only one public attribute called lines. It is a List of Line that always has got exactly two elements, the two lines is is connecting. There is a public method called getCommonNode that return the node at which both lines are joint together. Each Mechanism has got a List called Fusion that contains all fusions needed to define the mechanism.


Elongation[Bearbeiten]

An elongation is an attribute that a Line can have. If it is present it means that the line will become longer in the course of time. It has got one public attribute called elongation that defines the maximum additional length of the line. If a Line hasn't got an elongation, the elongation property of the Line is null otherwise it refers to an Elongation object.

Telescope[Bearbeiten]

A telescope is an attribute that a Line can have. If it is present it means that the line is telescopic. That means that is does not have a predetermined length, so it fits itself to the length that is available. So it can become shorter or longer that its original distance. Furthermore it can not take any force in the direction of its length, but it can in the perpendicular direction. If a Line hasn't got a telescope, the telescope property of the Line is null otherwise it refers to a Telescope object.

The geometric Problem[Bearbeiten]

The geometric problem is about calculating the motion of the mechanism. Imagine there is a hydraulic cylinder in the mechanism that slowly moves, the whole mechanism will also start to move, and the geometric problem is about finding out how it moves. Our solution to it is rewriting it into an algebraic one and solving it numerically. So we put up a couple of equations and use an algorithm called Newton's method. The only variables of the geometric problem are the x and y coordinates of the nodes. In the following sections we will discuss which equations we put up. We start with a mechanism in its so called static position. That is the position in which the mechanism was drawn. For this situation we already know to solution (since we know the positions of the nodes in the mechanism, essentially they were provided by the user). We are looking for a solution at a later point of time, when the mechanism has moved (usually because of the elongation properties of some lines, which we can imagine as hydraulic cylinders). We call the solution we are looking for dynamic position. All symbols we use refer to the dynamic position, unless we use a hat on them, in this case they refer to the static position. So refers to the dynamic position, and refers to the static position. Of course all quantities of the static position are already known. So quantities with a hat don't count as variables, but those one without a hat do. Because of the way the Newton method is implemented we write all equation so that the right side of the equation is zero. This may not be the most beautiful way of writing things down, but it is a practical one. The geometrical problem is solved in the class Mechanic in the package geometry. The most interesting line of code is:

Term sEx=new Sum(nE.x,new Product(dE,dxEn));

So finally we have a proof for sEx in a mechanical system.


Bearing Equations[Bearbeiten]

A bearing that is fixed in x direction can't move in x direction. So its x position in the dynamic position is the same as in the same as in the static position. We refer to the node, the bearing is attached to with n and thus can write.

For a bearing fixed in y direction we got respectivly:

Line Equations[Bearbeiten]

For lines without any special properties we have got the conservation of length. The length is given by Pythagoras formula:

and accordingly for the static position:

The conservation of length can be written as:

Telescopic Lines[Bearbeiten]

For telescopic lines the length is not predetermined, so there is no equation for the conservation of length

Elongation Lines[Bearbeiten]

For elongation lines the length is predetermined, but not equal to the length in the static position. The is a time dependent offset, to be added. Let the offset be . Then we can write the equation of length:

Fusions[Bearbeiten]

In the geometrical problem fusions are fixed angles between lines. Basically you could think of attacking this problem using the atan function. The Problem is that tan is not defined for certain angles, furthermore there is a problem with uniqueness that gave rise to the atan2 function. So we decided for an other approach. We add virtual nodes along the line and fix the distance between these virtual nodes. This is illustrated in the next figure:

The original nodes are shown as big circles. The virtual nodes are shown as small circles. The added length constraint is shown as dashed line. Of couse the fusion is fusing both shown lines at the lowest node. The virtual nodes shall have a distance of 1/4 of the length of the line from the start or end nodes of the line. Were length refers to the length in the static position. This obviously means that the distance between two virtual nodes of the same line is 1/2 of the length of the line, in the static length. But in the dynamic position this can be violated. Still the distance from a virtual node to its closest end- or start- node is 1/4 of the static length. So the virtual Nodes move along with the start or end nodes of the line. This is why we can fix the angle between two lines connected at a particular node, by fixing the distance between the two virtual nodes close by.

We will now discuss how to find the position of the virtual nodes in terms of equations. In the static position we know the coordinates of the virtual nodes. We denote the virtual node close to the start node of the line l1 as:

Where sS stands for stiff Start. Accordingly we denote the virtual node close to the end node by:

Where sE stands for stiff End.

We also define an additional quantity:

So it is the distance from the start node to the virtual node close to it. We also note that

We furthermode note that:

That is this distances do not change, not even if we switch to the dynamic position. We furthermore define:

This is the normalized vector pointing from the start to the end.

then we define the coordinates for the virtual node as:

We have very similar equations for the virtual node close to the end node too, which you may look up in the source.

Fixing Condition[Bearbeiten]

The condition to fix an angle can be written as:

Here we assumed that the node at which we are fusing is the start node of l1 as well as the start node of l2. The equations for the other cases look very similar.

The Static Problem[Bearbeiten]

The second problem Mordred has to care about is the calculations of forces in a mechanism. For the existence of a solution it is necessary that the system is statically determinate. The basic assumption is that the mechanism is not accelerating, neither translational, nor rotationally. And this is true for each line and each node in the mechanism too. So we have that the sum of forces acting on a particular line is zero, as well as that the sum of angular momenta with respect to a particular point is zero. Since the spacial extend of a node is zero, we only have the equilibrium of forces for nodes. The equilibrium of angular momenta is always satisfied.

Variables in the static problem[Bearbeiten]

Variables for Lines[Bearbeiten]

For each line we have the forces acting on both ends of the line, in x- as well as y- direction. Introducing some notation for line l1 we got :

Bearing Reaction Forces[Bearbeiten]

Clearly we got bearing reaction Forces, that is the forces caused by the bearings. For the Bearing b1 we got:

here we assumed that the bearing is fixed in x- as well y- direction, in the other cases some of the forces are zero, and thus don't need to be calculated.

Fusions[Bearbeiten]

As each fusion can transfer an angular momentum from one line to an other one, we has to introduce a variable to model this transfer. So for a fusion f1 we got:

Equations in the Static Problem[Bearbeiten]

Nodes[Bearbeiten]

For Nodes we got that the sum of external forces acting on that node is equal to the sum of forces caused by the mechanism acting on that node. The Forces cause by the mechanism are the forces of the lines. So forces like . For the (vector of) force acting on a particular node of a particular line we write , where represents the particular line am the node. For the external force acting on a node we write . So we got:

The first of these equations might in a particular case be written as (looking only at the x component):

Where force4 represents a particular external force acting on that node.

Lines[Bearbeiten]

For a line l1 we can write the equilibrium of forces:

an similarly for the y component.


Angular Momenta[Bearbeiten]

We calculate the equilibrium of angular momenta using the start node of line l1 as center of rotation.

Where we used the following abbreviations:

Furthermore we used the term f5.M to represent the angular momentum that is transferred by fusion f5. We have to note that this angular Momentum has to be counted positively in one equation of equilibrium of momentum only in the one of the other line it is connected to it has to be counted negatively.

Telescope Equations[Bearbeiten]

For telescopic lines we have to ensure, that the force in the line is perpendicular to the line itself, since the definition of a the telescopic line says that it can not transfer any force in its direction. So we can write:

Where we used the fact that you can define perpendicular by requiring the dot product to be zero.