Problem Set 6 (FEM)

1

Consider the damped wave equation

Take the solution domain to be the interval [0, 1].

(a)

Use the Galerkin method to find an approximating system of differential equations.

We will search for an approximate solution of the form

(where is yet to be determined). From here on out I will just write and ; it is understood that these are functions of time and space, respectively. Thus the damped wave equation becomes

For each basis function , we construct a Galerkin constraint

This may be written as

where

This gives a system of second order linear homogeneous ODEs.

Note that I integrated by parts in order to reduce the order of the highest order derivative of that appears. Practically speaking, this lets us use lower order basis functions, since we can let the higher derivatives be zero. This may seem like cheating — after all, the two expressions are equal, so integrating by parts shouldn’t magically make nonzero. But remember that a lot of commonly used basis functions have discontinuities in their derivatives (or higher derivatives). Hat functions, for instance, have discontinuities in their slopes at their piecewise seams. So though their second derivatives are zero almost everywhere, at those seams the second derivatives are actually delta functions. The discontinuities in slope don’t affect integrals of slope, but the delta functions completely determine integrals involving second derivatives. So integrating by parts can free us from the complication of dealing with the latter.

(b)

Evaluate the matrix coefficients for linear hat basis functions, using elements with a fixed size of h.

I will assume both boundaries are fixed at zero. Thus it’s fine if all hat functions are zero at each boundary. So I will place hat functions evenly spaced at , where . Each hat ranges linearly from 0 to 1, then back down to zero. So for ,

First, let’s compute . From it’s definition, it’s clear that it is a symmetric matrix. And since the hat functions only overlap their immediate neighbors, the only nonzero elements will be those on the diagonal, and one off it. That is, is a symmetric tridiagonal matrix.

First let’s compute the diagonal elements. The dependence on drops out after a change of variables.

Now we compute the off diagonal elements.

By symmetry, . All other elements are zero.

Now we compute . In general, the boundary terms in its definition break its symmetry. However, in this case all our basis functions are zero at the boundary, so we can ignore this term altogether. So like , is a symmetric tridiagonal matrix.

(c)

Now find the matrix coefficients for Hermite polynomial interpolation basis functions, once again using elements with a fixed size of h. A symbolic math environment is useful for this problem.

As discussed in the text, for a cubic polynomial

the values , , , and are given by

So by inverting this matrix, we have a way to determine the coefficients in order to achieve the desired values and slopes at the endpoints.

For each interval of length , we want four polynomials corresponding to the vectors , , , and . We’ll then glue these together to end up with two basis functions per interval. Plugging these in we find that the corresponding polynomials are:

Now for (I find zero-indexing convenient here so that the th basis function is centered at ), define the basis functions

Here’s what they look like. I’ve plotted their first and second derivatives as well.

psi

zeta

Both and disappear at and (as do their derivatives). At , has a value of one and a slope of zero, while has a value of zero and a slope of one. Also note that the th and th basis functions must be defined slightly differently, since their domains must be restricted to the interval [0, 1]. I won’t write this out fully here, but I will take this into account going forward.

In the previous problem, we had to consider the different ways and could overlap. All integrals were zero except when or , resulting in a tridiagonal matrix. The same concerns are at play here, but we also have to consider how our different basis functions interact. So, I’ll compute three matrices , , and as before. These can then be combined as blocks to generate .

All three matrices are tridiagonal. and are symmetric. is not symmetric, since the left half of times the right half of is not the same as the right half of times the left half of . But we do have the symmetry that is the same as . Also the interior diagonal elements of disappear, implying that and are orthogonal. I’ll write out the matrices here for five vertices (including boundaries); for larger systems you’d just stretch them out along the diagonals. I wrote a Python script to compute all the entries, and print out the matrices in .

I’ll assemble as

Now we do the same for . Note that is not , since the boundary terms (from integrating by parts) differ.

As a final note, I didn’t impose any boundary conditions on the system, so as currently stated the resulting system of ODEs is under-determined. To fix the boundaries at zero, one could remove and from the set of basis functions.

2

Model the bending of a beam (equation 9.29) under an applied load. Use Hermite polynomial interpolation, and boundary conditions fixing the displacement and slope at one end, and applying a force at the other end.

I answer this problem using two different sets of basis functions. The first technique uses cubic Hermite interpolation, and is implemented here. The second uses hat functions for the second derivative, integrating these to find the slopes and displacements. It is implemented here.

Cubic Hermite Interpolation

The potential energy of the beam is

Our goal is to find a function that makes stationary. We assume a solution of the form

where the are unknown coefficients and are a set of local basis functions.

Plugging this in,

So

We want all these partial derivatives to be zero. We can write the resulting system of equations as

where

I’ll use the basis functions and as defined in the previous problem. If we use five nodes, the full blocks of look like those below. Also as in the previous problem, is just , so I won’t write it out.

But let’s think about our boundary conditions. Fixing the position and slope on one end of the beam means we’re fixing the coefficients of and . So and are irrelevant, and shouldn’t contribute any equations to our system. As such we basically need to chop the first row off these matrices (or at least and ). However if we do literally that, then we won’t have a square system anymore. So to keep our solver happy we’ll want to replace the missing rows with trivial equations . This means zeroing out the whole row and adding a single one in the right place. (And when we get there, we’ll set to be the desired displacement or slope.) This breaks the symmetry of and , so we’ll want to compute each separately now.

Finally we assemble as

To compute , we need to choose a force distribution. I’ll apply a constant force to a fixed number of nodes near the end of the beam (the first and last only overlap the force region for half their basis functions). So

and is zero for all nodes not experiencing the force. Continuing with a 5 node demo system, I decided to apply the force to the last three nodes, and computed the following vectors.

However we need to alter the first entries of these vectors to specify the boundary conditions. I’ll assume a displacement of zero, and a slope of 1/2.

Finally, setting and , and using numpy’s np.linalg.solve, I obtain a solution.

psi

It’s unexpectedly wobbly. One way to get rid of this is to use only two nodes. But this kinda defeats the purpose of FEM.

psi

We should get a better solution with more elements, which is clearly not the case.

psi

I might have a bug in here somewhere, but regardless I’m unhappy with these basis functions. has a massive discontinuity in its second derivative, which is exactly what matters for the potential energy of the beam. So let’s try something different.

Hat Functions for the Second Derivative

In particular, since the second derivative is what’s most important, let’s model it directly.

We can find by integrating. This produces an expression that’s no longer a sum of local basis functions, but that doesn’t matter for this problem.

Here is a constant of integration that determines the slope at , and is a constant of integration that determines the displacement at . The problem is invariant under translation up and down, so without loss of generality I’ll assume . (If we want to change this later, we just need to add the new to all the displacements we calculate for .) Here are what these basis functions look like.

psi

Side note: another way to develop a suitable set of basis functions would be to use 6th order Hermite interpolation. Then we could produce six shape functions, assembled into three basis functions. The extra degrees of freedom would allow us to ensure continuity for the second derivative, and add another basis function which would control the second derivative at a node. These basis functions would still be local.

Anyway, plugging in our nonlocal basis expansion yields

So

These define our new and . Actually calculating them is very similar to with the previous basis functions, so I’ll only go over the differences. We’re back to using a single basis function, so is the only in town. It ends up symmetric and tridiagonal. Computing requires a good amount of integration so it was handy to use SymPy.

The results are much better.

psi

And now adding more nodes doesn’t make things worse.

psi