The field of applications for smart structures based on piezoelectric devices is manifold. An advantage of this technology is that one can construct spatially distributed devices. This fact requires special control techniques to use the additional freedom for the design of the overall system. The structures under consideration are composite beams and plates consisting of a large number of thin layers of laminae with and without piezoelectric properties that can be well described by Lagrangian systems. Furthermore, there exists a wide range of controller design methods. To apply this machinery, one has to derive the potentials and energy functions related to the piezoelectric structures, which is a laborious task for more complex structures. But this task can be perfectly performed by a computer algebra system. Therefore, this contribution deals with the application of the Lagrangian formalism to the modeling and design of smart piezoelectric structures, and the implementation of the proposed approach in a computer algebra system.