SUMMARYIn molecular mechanics, the formalism of the finite element method can be exploited in order to analyze the behavior of atomic structures in a computationally efficient way. Based on the atom-related consideration of the atomic interactions, a direct correlation between the type of the underlying interatomic potential and the design of the related finite element is established. Each type of potential is represented by a specific finite element. A general formulation that unifies the various finite elements is proposed. Arbitrary diagonal-and cross-terms dependent on bond length, valence angle, dihedral angle, improper dihedral angle and inversion angle can also be considered. The finite elements are formulated in a geometrically exact setting; the related formulas are stated in detail. The mesh generation can be performed using wellknown procedures typically used in molecular dynamics. Although adjacent elements overlap, a double counting of the element contributions (as a result of the assembly process) cannot occur a priori. As a consequence, the assembly process can be performed efficiently line by line. The presented formulation can easily be implemented in standard finite element codes; thus, already existing features (e.g. equation solver, visualization of the numerical results) can be employed. The formulation is applied to various interatomic potentials that are frequently used to describe the mechanical behavior of carbon nanotubes. The effectiveness and robustness of this method are demonstrated by means of several numerical examples.