Example: Connected springs ------------------------------------- This example is from the CALFEM manual (exs1.py). **Purpose:** Show the basic steps in a finite element calculation. **Description:** The general procedure in linear finite element calculations is carried out for a simple structure. The steps are: * define the model * generate element matrices * assemble element matrices into the global system of equations * solve the global system of equations * evaluate element forces Consider the system of three linear elastic springs, and the corresponding finite element model. The system of springs is fixed in its ends and loaded by a single load F. To make it convenience, we follow notation in "Fundamentals of Finite Element Analysis" by David Hutton, where square is symbol for nodes, circle is for element, and U is for (global) nodal displacement. Capital letter shows global variables while small letter follows local variables. .. image:: images/exs1-1-rev1.png We begin our FEM computation by importing required modules .. literalinclude:: ../../examples/exs_spring.py :lines: 16-17 The computation is initialized by defining the topology matrix Edof, containing element numbers and global element degrees of freedom. All input to CALFEM is NumPy arrays. Topology is defined by index 1, i.e., the first row represents the first element bounded by node 1 and node 2. Hence we write .. literalinclude:: ../../examples/exs_spring.py :lines: 20-24 the initial global stiffness matrix `K` (3x3) and load force `f` containing zeros, .. literalinclude:: ../../examples/exs_spring.py :lines: 27-28 Element stiffness matrices are generated by the function spring1e. The element property `ep` for the springs contains the spring stiffnesses k and 2k respectively, where k = 1500. .. literalinclude:: ../../examples/exs_spring.py :lines: 30-43 The output is printed as follows:: Stiffness matrix K: [[ 3000. -3000. 0.] [-3000. 7500. -4500.] [ 0. -4500. 4500.]] and the load/force vector f (3x1) with the load F = 100 in position 2 (Note that Python indexes from 0, hence f[1] corresponds to edof 2). .. literalinclude:: ../../examples/exs_spring.py :lines: 46 The element stiffness matrices are assembled into the global stiffness matrix K according to the topology. `bc` is an array of prescribed degrees of freedom. Values to be specified are specified in a separate array. If all values are 0, they don't have to be specified. The global system of equations is solved considering the boundary conditions given in bc. .. literalinclude:: ../../examples/exs_spring.py :lines: 49-56 output: :: Displacements a: [[0. ] [0.01333333] [0. ]] Reaction forces Q: [[-40.] [ 0.] [-60.]] Element forces are evaluated from the element displacements. These are obtained from the global displacements `a` using the function extract. .. literalinclude:: ../../examples/exs_spring.py :lines: 59-61 The spring element forces at each element are evaluated using the function spring1s. .. literalinclude:: ../../examples/exs_spring.py :lines: 68-70 Output: :: Element forces N: N1 = 40.0 N2 = -20.0 N3 = -40.0