Introduction

CALFEM is a Python package for finite element applications. This manual concerns mainly the finite element functions, but it also contains descriptions of some often-used Python functions.

The finite element analysis can be carried out either interactively or in a batch-oriented fashion. In the interactive mode, the functions are evaluated one by one in an interactive Python session. In the batch-oriented mode, a sequence of functions is written in a file named .py file and evaluated by calling a python interpreter with the filename as an argument. The batch-oriented mode is a more flexible way of performing finite element analysis because the .py file can be written in an ordinary editor. This way of using CALFEM is recommended because it gives a structured organization of the functions. Changes and reruns are also easily executed in the batch-oriented mode.

To use the CALFEM package, it must first be imported. This is done by the command:

import calfem.core as cfc

The function of this package is then available with the prefix cfc. So the function spring1e is called as cfc.spring1e.

Plot functions are available in the calfem.vis_mpl package. To use these functions, this package must also be imported:

import calfem.vis_mpl as cfv

The these functions are then called with the prefix cfv. So the function eldraw is called as cfv.eldraw.

A command line typically consists of functions for vector and matrix operations, calls to functions in the CALFEM finite element library, or commands for workspace operations. An example of a command line for a matrix operation is:

C = A + B.T

where the two-by-two matrices A and B are added together, and the result is stored in matrix C. The matrix B.T is the transpose of B. In Python, the transpose operator is denoted by a T.

An example of a call to the element library is:

Ke = cfc.spring1e(ep)

where the two-by-two element stiffness matrix \({\mathbf{K}}^e\) for a spring element is computed and stored in the variable Ke. The input argument is given within parentheses ( ) after the name of the function and is in this case ep, containing the spring stiffness \(k\). Some functions have multiple input arguments and/or multiple output arguments. For example:

L, X = cfc.eigen(K, M)

computes the eigenvalues and eigenvectors of a pair of matrices K and M. The output variables, the eigenvalues \(\lambda\), stored in the vector L and the corresponding eigenvectors stored in the matrix X are separated by commas. The input arguments are given inside the parentheses ( ) and also separated by commas.

The statement:

help(function)

provides information about the purpose and syntax for the specified function.

The available functions are organized in groups as follows. Each group is described in a separate chapter.

Groups of functions

General purpose commands

For managing variables, workspace, output etc.

Matrix functions

For matrix handling

Material functions

For computing material matrices

Element functions

For computing element matrices and element forces

System functions

For setting up and solving systems of equations

Statement functions

For algorithm definitions

Graphics functions

For plotting