viernes, 30 de marzo de 2012

Nonlinearities in structural mechanics

Two years have already gone in the preparation of this thesis and now it seems in order to pass to the next part: the study of stochasticity.
Altogether with the preparation of our next article I am already summarizing and setting things up for the account for uncertainties in the structural design.
For such purpose, and after so much research into elasticity, dynamics and numerical methods, I have done the following scheme where most of the nonlinearities (which not surprisingly are often associated to randomness) can be fit into.
The scheme is based on the ubiquitous "Governing Equations" that serve as basis for every mechanician.
  • System's internal balance equations (Statics or dynamics)
    • Nonlinear damping
  • Constitutive equations (Material)
    • Plasticity
    • Viscosity
    • Creeping
    • Hiperelasticity
  • Kinematic equations (Geometry)
    • Large deformations with small strains
    • Large strains
    • Buckling
    • Instability
  • Boundary conditions
    • Forces
      • Pressure
      • Loads
      • Wind
      • Waves
      • Friction
    • Displacements
      • Contact
      • Link rupture
In the following months I will try to expand this list at the same time as I will try to understand how these nonlinearities are tackled in a deterministic manner.

The main point of my thesis is that stochastic methods are way more suitable for this purpose than deterministic ones...we will see...:)

Soon I will be getting back to my loved Ljubljana for a while, far from noisy Barcelona...

jueves, 9 de febrero de 2012

The Rayleigh-Ritz method explained for humans


Preliminaries
At last, I feel ready to explain the key concept needed to follow the steps in the Finite Element Method: the notion of STRAIN ENERGY!
The problem with this concept is that is as simple as it looks, ergo all the attached complications must come from somewhere else...
For the animation below I have chosen a classic spring to illustrate the concept (yes I know, is also a classic example...). Could have been anything else capable of storing energy, as a phone battery or a dam, but this seems more adequate given we are talking about structures.
The graph (click on it to see it moving) represents the relation between the applied force to stretch the spring and the actual displacement of the spring. So far, this is pure Hooke's law from secondary school (F=Kx)...
Also, the area that gets shadowed when the spring gets "tensioned" is, in mathematical terms, an integral of the drafted curve.
Displacement e vs Force F on a spring
of elastic material. Shaded area represents
stored strain energy. When pulled with
a force F its tip deforms an amount e.
When released it pulls back with the
same force F.
Given this particular, although very common case of a material (an elastic one), there is a straight tilted part in the curve that is called "elastic domain". If one keeps pulling the spring further then we still wouldn't break it, but instead we cannot expect it to recover its initial shape. The spring has plastified and we are in the horizontal part of the graph...but that is another story.
So, this "triangle" underneath the tilted part has an area, an integral, a scalar value in squared centimeters. The value of such integral is, not in centimeters but in N per meter or Joules (we are comparing force vs displacement), so is an Energy!


Applied force on the tip F vs potential energy
Displacement e vs potential energy


 And the shape of its curve, against the same displacement e or force F (click the animations) happens to be that of a parable (wasn't it obvious?)...
Well, and so far for the basics. Let's now think of a solid beam or column and put it in the place of our spring. When loaded, it would deform, would store elastic energy in its material ready to be released as soon as the applied force leaves. Normally things tend not to greedily accumulate energy but just the opposite. In Nature, a state of balance is that where things store a minimum amount of potential energy.
This basic principle in general applies for almost everything in life, and always does in physics. A drop of water in a cloud that has absorbed thermal energy and stored some of it as potential energy would release this as soon as it can, becoming rain when there is a lot of them, a capacitor in a circuit or even the adapter of a laptop store a differential of potential that make them useful, etc. This is the famous principle of minimum total potential energy (not to be mistaken with the principle of minimum energy, which also applies but in other fields).

Relating strain energies and forces

The way engineers have found a beam or column or piece of metal can store energy is by means of five types of loading: axial, bending, torsion, direct shear and traverse shear. Actually this is the way they have found they can stress things. As for every stress there should be associated a strain and hence some potential energy, this is tantamount as to say that they store energy. Though disputable, this is a convention and so we will accept it in the absence of a better one.
Resume of the strain energies associated to each type of applied force in engineering. Traverse shear has been omitted as is generally neglected.
 The good thing about this convention is that the job of assimilating stored potential energies for each type has already been done for us and put up in the shape of a formula. The table above gives the relation for each one of them in relation to the applied force and in relation to the caused strain.
The compressed beam under axial force F stores energy U of a value according to the formula.

The same beam, under flexural bending moment.

Similarly for shear

...and now for torsion
 The Rayleigh-Ritz method

And now we have all the concepts and are ready to work.
The Rayleigh–Ritz method (after Walther Ritz and Lord Rayleigh-Wikipedia), is considered a variational method. This is so because it is based in the calculus of variations. When applied to structural mechanics the varying value is the value of the strain potential energy, that is to be equilibrated against the work done by the external forces.
What we will try to do is to find what is the configuration, the state of the beam or group of beams, where the total energy of the system "external forces + internal stresses" gives a lowest value for the value of the energy.

It has eight fairly simple steps (this is also arguable, but this is how I understand it best) which I will try to picture as clearly as possible:

Step 1: Define the internal stored energy function (always an integral from the table above or a combination of them) and the external (a function of the caused displacement times the applied force).
The internal strain energy is the sum of all the possible combinations of internal strains from the table above
The external applied energy is the result of multiplying the external forces by the displacement

Step 2: Arbitrarily and happily (well, almost...) choose one function where the dimensions of the beam and the variable in the internal stored energy function get related. Multiply it by a dummy parameter (we will call it u overlined). The function chosen v is an approximation, so we overline it also to denote this.
The "dummy function" we will introduce into the energy formula can be any from above. The more elaborated, the higher the precision.
Two possibilities of approximation functions (without the U parameter). It is known that beams deflect quadratically.

Step 3: Solve, by means of integral calculus, the integral in step 1 with the chosen function in step 2. This will provide a relation between the dummy parameter and the internal energy. For the example below, where normally only bending moment is considered:
Laterally loaded beam
 
Internal strain energy due to the weight on the tip is given here as a function of the angle of rotation of the beam, but also is generally rounded as the second derivative of the displacement (v'').
Obtention of the second derivative of the "dummy" function

A very important remark: it is assumed from the beginning that the result will not be accurate!!

Step 4: Do the same for the external applied energy.
The "dummy" function and its second derivative substituted into the potential strain (Ui) and the external (Ue) energies.
Step 5: Add the two energies in order to get the total energy of the system, V (column internal + external forces)

Step 6: Applying the theorem of minimum total potential energy, the derivative of the total energy with respect to the parameter must be 0.

                                  

Step 7: Get the value of the parameter from the equation above.

Step 8: Substitute its value in the step 2 to get the real function of the displacement.

                                      

And that is it. For whatever value of x along the beam now we have a value of the deflection. Unfortunately the approximation chosen v(x)=u1(x/l)^2 is not very accurate, so a calculated displacement of the tip would diverge at least 25% from the analytical...but that is another story...
The most difficult steps are actually 1 and 2, where one should memorize the functions in order to master the method. The rest is easy algebra and very simple first order derivatives.
The Rayleigh-Ritz method eventually evolved into the nowadays ubiquitous Finite Element (did you recognize the shape function there?).

Well, I really hope this helps anyone who reads it as much as it helped me to write it...

Enjoy!

martes, 31 de enero de 2012

A brief summary on the stiffness method for structural engineering

Well, another year has gone by, and it has been a while since the last post. Life in Barcelona is being quite busy, so I am not dealing very well with my updates...This doesn't mean I am not researching, but apparently the topics I am getting to are deeper and deeper, so conclusions are getting harder to write...

The following is a summary of what I found here: www.civil.iitb.ac.in/~sghosh/CE317/history-stiffness-method.pdf

It is authored by the famous Zienkiewicz, so it must be a warranty of rigor. Out of it I have written my own summary, on pure chronological order, that goes as follows:


  • 1862: Glebsch, Alfred wrote an algorithm for 3D trusses where no moments were involved. The models one would get out of it is as putting lots of springs connected by pins.
  • 1883: Saint Venant, Andre wrote an article with comments on Glebsch's methodology.
  • 1880: Manderla, Heinrich proposed an iterative method for the solution of the set of equations involved in pin-jointed trusses
  • 1892: Mohr, Otto introduced the notion of "secondary stresses". He was referring to the moments. They were called secondary then as in steel and iron trusses the main ones were axial.
  • 1910: Richardson provided the study of the stresses in a dam by means onf the Airy stress function.
  • 1914: Bendixsen, Axel published a method similar to the slope deflection for structures with internal hyperstaticity.
  • 1915: Wilson&Money proposed the slope deflection method, apparently unaware of Bendixsen's.
  • 1922: Ĉaliŝev gave an iterative solution of successive approximations for frames without side-sway.
  • 1930: Cross, Hardy published his famous method for redistributing unbalanced moments according to the internal stiffnesses of the composing bars. This provided the engineer with the necessary joint rotations.
  • 1932: Grinter wrote a method for multi-story frames with side-sway called "method of successive corrections"
  • 1935: Southwell tackled the problem of the constraints in a similar manner giving his famous method of "systematic relaxation of constraints", commonly known as dynamic relaxation.
  • 1941: Courant, Richard explained his "variational methods for the solution of problems of equilibrium and vibrations". As he was a mathematician, the practical application of his work results still of some difficulty.
  • 1943: McHenry in U.S. and Hrenikoff in Canada proposed a lattice analogy for the solution of stress problems so that continuum could be represented as a set of beams.
  • 1944: Kron, Gabriel provided a complete algorithm in matrix form for 3D frames. In the 1930s it became fashionable to show the whole process of solving the linear equations in this systematic manner.
  • 1954: Argyris wrote his "Energy theorems ans structural analysis", a comprehensive presentation of both the force and the displacement method for complicated airplane structures.
  • 1967: Zienkiewicz presented his summary of the "Finite Element Method in structural Mechanics".

sábado, 26 de noviembre de 2011

Tetrahedra discretization of a beam

In this post I will introduce the advances of the last weeks regarding the discretization into tetrahedra of a beam with Grasshopper's VB component.

Rotations about an arbitrary axis
An important part of the research has been devoted to the topic of 3d rotation, as for locating the sub-nodes of the beam appropiately we need to transform the beam's local coordinates with respect of its axis into the actual world's coordinates for Rhino to interpret.
The most popular way to make it are rotation matrices (here there is a thorough explanation on how), but also quaternions have been contemplated and still not fully discarded. Apparently rotation matrices present some numerical drifting problems when utilized for many time steps, as well as other problems that quaternions solve quite easily (mentioned here).

Tetrahedra subdivision
The beam is defined by two points arbitrarily located in 3d space. These points define a director vector and also a distance.
The remaining geometric properties (height h and width b) in the attached code have been assimilated to a percentage of the lenght. Also the number of segments s has been hardcoded to be proportional to the width but it could be anything else.
The attached code uses two functions: one for coordinate transformation by means of transformation matrices and another for matrix multiplication. The rest of the subroutine simply locates points along the beam according to the width b, the height h and the segment separation s.



The image above shows how the beam is discretized into nodes located at the edges. Each segment gives place to five embedded tetrahedron (right).
Local axes of the beam will be later utilized for the matter integration.

Code
Private Sub RunScript(ByVal ni As Point3d, ByVal nj As Point3d, ByVal angle As Double, ByRef geom As Object)
    'This code was written by Rabindranath Andujar, Jordi Casabo, Jaume Roset, Vojko Kilar and Simon Petrovcic with the purposes
    'of the development of Rabindranath Andujar's Phd Thesis "Stochastic Simulation and Lagrangian dynamics applied to Structural
    'Design"
    'Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License,
    'Version 1.3 Or any later version published by the Free Software Foundation; With no Invariant Sections, no Front-Cover Texts,
    'And no Back-Cover Texts.

    'This code is intended to facilitate a tetrahedric discretization of a beam provided two points (initial and final). It should
    'serve to be inserted into a wider matter integration code (FEM/FVM/MSS, etc) for which nodal coordinates, topological table
    'and material properties are eventually given.

    Dim L As Double 'lenght of the beam
    Dim s As Double 'space between divisions
    Dim b As Double 'width of the beam
    Dim h As Double 'height of the beam
    Dim u,v,w As Double 'components of the director vector of the beam
    Dim lines As New list(Of rhino.geometry.line) 'geometric representation of the beam
    Dim Nodes As New List(Of rhino.geometry.point3d) 'geometric nodes of the beam, where matter will be integrated
    Dim n As Integer 'number of nodes
    Dim i As Integer 'auxiliar index
    Dim line As Rhino.Geometry.Line 'auxiliar instantiation variable
    Dim Node As rhino.geometry.point3d 'Auxiliar coordinates for the shape of the beam

    'The components of the director vector of the beam are the difference between the initial and the final points
    u = nj.X - ni.X
    v = nj.y - ni.y
    w = nj.z - ni.z

    ' The lenght of the beam is the norm of the vector
    L = math.Sqrt(u * u + v * v + w * w)
    'We have chosen arbitrarily here a height h=10% of the lenght, width b=60% of the height and spacing a portion of the width
    h = L * 0.1
    b = h * 0.6
    n = int(L / b)
    s = L / n

    'The nodes located in the vertices of the section are positioned along the beam by means of matrix
    'transformations with respect to the director vector and the initial point of the beam.
    'The function TransformCoordinates serves such purpose.
    'u,v,w coordinates enter divided by the lenght of the beam in order to operate with a normalized vector.
    'The angle parameter represents the rotation of the section around the longitudinal axis (local x)

    ' local z axis
    '    |
    '    |   angle of rotation along x local axis
    '    |  /
    '  *---*
    ' h| |/|
    ' -|-+-|---local y axis
    '  | | |
    '  *---*
    '    b
    For i = 0 To n
      'Top left corner of the beam section
      Node = TransformCoordinates(ni.X, ni.Y, ni.Z, -b / 2, h / 2, S * i, u / L, v / L, w / L, angle)
      'Then we collect their values into Rhino Point3Ds
      Nodes.Add(Node)
      'Top right corner of the beam section
      Node = TransformCoordinates(ni.X, ni.Y, ni.Z, b / 2, h / 2, S * i, u / L, v / L, w / L, angle)
      'Then we collect their values into Rhino Point3Ds
      Nodes.Add(Node)
      'Lower right corner of the beam section
      Node = TransformCoordinates(ni.X, ni.Y, ni.Z, b / 2, -h / 2, S * i, u / L, v / L, w / L, angle)
      'Then we collect their values into Rhino Point3Ds
      Nodes.Add(Node)
      'Lower left corner of the beam section
      Node = TransformCoordinates(ni.X, ni.Y, ni.Z, -b / 2, -h / 2, S * i, u / L, v / L, w / L, angle)
      'Then we collect their values into Rhino Point3Ds
      Nodes.Add(Node)
    Next i

    'This loop repeats the cross section of the beam (a b x h rectangle) using the vertices previously collected
    'along a beam defined by an initial and a final points.
    'Also the longitudinal edges of the prism are iterated for every segment of beam.
    For i = 0 To nodes.Count - 8 Step 4
      'Four sides of the section
      Line = New Rhino.Geometry.Line(nodes(i), nodes(i + 1))
      Lines.Add(Line)
      Line = New Rhino.Geometry.Line(nodes(i + 1), nodes(i + 2))
      Lines.Add(Line)
      Line = New Rhino.Geometry.Line(nodes(i + 2), nodes(i + 3))
      Lines.Add(Line)
      Line = New Rhino.Geometry.Line(nodes(i + 3), nodes(i))
      Lines.Add(Line)
      'Longitudinal segments of the edges
      Line = New Rhino.Geometry.Line(nodes(i), nodes(i + 4))
      Lines.Add(Line)
      Line = New Rhino.Geometry.Line(nodes(i + 1), nodes(i + 5))
      Lines.Add(Line)
      Line = New Rhino.Geometry.Line(nodes(i + 2), nodes(i + 6))
      Lines.Add(Line)
      Line = New Rhino.Geometry.Line(nodes(i + 3), nodes(i + 7))
      Lines.Add(Line)
    Next i

    'Here we iterate in order to make the outer longitudinal diagonals and the inner cross sectional ones
    'On each segment we have to change the direction, so they are alternated. It was carefully done, as the
    'final purpose is to create the edges of tetrahedra that do not overlap.
    'To such end, diagonals change every two segments in outer faces as in inner cross sectional connections.
    For i = 1 To nodes.Count - 4 Step 8
      'Top faces
      Line = New Rhino.Geometry.Line(nodes(i), nodes(i + 5))
      Lines.Add(Line)
      Line = New Rhino.Geometry.Line(nodes(i + 5), nodes(i + 8))
      Lines.Add(Line)
      'Right side faces
      Line = New Rhino.Geometry.Line(nodes(i + 2), nodes(i + 5))
      Lines.Add(Line)
      Line = New Rhino.Geometry.Line(nodes(i + 5), nodes(i + 10))
      Lines.Add(Line)
      'Bottom faces
      Line = New Rhino.Geometry.Line(nodes(i + 2), nodes(i + 3))
      Lines.Add(Line)
      Line = New Rhino.Geometry.Line(nodes(i + 3), nodes(i + 10))
      Lines.Add(Line)
      'Left side faces
      Line = New Rhino.Geometry.Line(nodes(i), nodes(i + 3))
      Lines.Add(Line)
      Line = New Rhino.Geometry.Line(nodes(i + 3), nodes(i + 8))
      Lines.Add(Line)

      'Sectional diagonals
      Line = New Rhino.Geometry.Line(nodes(i), nodes(i + 2))
      'Lines.Add(Line)
      Line = New Rhino.Geometry.Line(nodes(i + 3), nodes(i + 5))
      'Lines.Add(Line)
    Next i
    'And the final section to close the prism: perimetral and diagonal lines
    Line = New Rhino.Geometry.Line(nodes(nodes.count - 4), nodes(nodes.count - 3))
    Lines.Add(Line)
    Line = New Rhino.Geometry.Line(nodes(nodes.count - 3), nodes(nodes.count - 2))
    Lines.Add(Line)
    Line = New Rhino.Geometry.Line(nodes(nodes.count - 2), nodes(nodes.count - 1))
    Lines.Add(Line)
    Line = New Rhino.Geometry.Line(nodes(nodes.count - 1), nodes(nodes.count - 4))
    Lines.Add(Line)
    'Diagonal goes from the last node to the node in the opposite side of the section
    Line = New Rhino.Geometry.Line(nodes(nodes.count - 1), nodes(nodes.count - 3))
    Lines.Add(Line)
    'Finally everything is delivered to Rhino for visualization
    Geom = Lines
  End Sub 
  Function TransformCoordinates(a As Double, b As Double, c As Double, x As Double, y As Double, z As Double, u As Double, v As Double, w As Double, Alpha As Double) As rhino.Geometry.Point3d
    'This function returns a Rhino.Geometry.Point3d rotated around an arbitrary axis.
    'The initial point of the beam is defined by a,b and c coordinates
    'Point's coordinates to be transformed are x,y,z
    'The axis is defined by the u,v,w coordinates, which should be normalized
    'Angle is provided in the Alpha parameter
    Dim CAlpha As Double 'Auxiliar variable for storing the cosine of the rotation around the axial axis
    Dim SAlpha As Double 'Auxiliar variable for storing the sine of the rotation around the axial axis
    Dim d As Double 'Auxiliar variable for storing the sine of the rotation around the y axis
    Dim Vector(3) As Double 'Auxiliar Vector to store and make the neccessary operations
    Dim Point As rhino.Geometry.Point3d 'The returned instance of a modified Point3d

    'Initialize variables
    Vector(0) = x
    Vector(1) = y
    Vector(2) = z
    Vector(3) = 1
    d = math.Sqrt(v ^ 2 + w ^ 2)
    CAlpha = math.Cos(Alpha)
    SAlpha = math.Sin(Alpha)

    'The translation matrix moves the point to the a,b,c coordinates
    Dim Transl(,) As Double = { _
      {1, 0, 0, a}, _
      {0, 1, 0, b}, _
      {0, 0, 1, c}, _
      {0, 0, 0, 1}}
    'Rotation matrix along the world's x axis
    Dim Rotx(,) As Double = { _
      {1, 0, 0, 0}, _
      {0, w/d, v/d, 0}, _
      {0, -v/d, w/d, 0}, _
      {0, 0, 0, 1}}
    'Rotation matrix along the beam's y axis
    Dim Roty(,) As Double = { _
      {d, 0, u, 0}, _
      {0,1, 0, 0}, _
      {-u, 0, d, 0}, _
      {0, 0, 0, 1}}
    'Rotation matrix along the world's z axis
    Dim Rotz(,) As Double = { _
      {CAlpha, -SAlpha, 0, 0}, _
      {SAlpha, CAlpha, 0, 0}, _
      {0, 0, 1, 0}, _
      {0, 0, 0, 1}}

    'Each transformation is made sequentially as a matrix-vector product
    Vector = MultiplyMatrixVector(Rotz, Vector)
    Vector = MultiplyMatrixVector(Roty, Vector)
    Vector = MultiplyMatrixVector(Rotx, Vector)
    Vector = MultiplyMatrixVector(Transl, Vector)

    'And eventually data is returned into the auxiliar point3d
    Point.X = Vector(0)
    Point.y = Vector(1)
    Point.z = Vector(2)
    Return point
  End Function
  Function MultiplyMatrixVector(Matrix(,) As Double, Vector() As Double) As Double()
    'This function returns the product of a matrix times a vector.
    'Matrix column number must be the same as vector's components number:
    '

    '                | |             | |
    '  |       |     | |             | |
    'M=|  mxn  | , V=|n|   ===>  M·V=|n|
    '  |       |     | |             | |
    '                | |             | |
    '
    Dim i,j As Integer 'Auxiliar indexes
    Dim n As Integer 'Matrix's column number
    Dim VAux() As Double 'Auxiliar temporary vector

    'Vector's size is reset to the number of matrix's columns
    n = Ubound(Matrix, 1)
    ReDim VAux(n)
    'In this loop we proceed to the summation of the products of the matrix terms times the
    'corresponding vector terms.
    'First we iterate by the columns
    For i = 0 To n
      'And then by each term of the vector
      For j = 0 To n
        'Auxiliar vector accumulates the products in the corresponding index
        Vaux(i) = Vaux(i) + Matrix(i, j) * Vector(j)
      Next j
    Next
    'And then we return the resulting vector
    Return Vaux
  End Function