  We investigate the optimal charging processes for several models of quantum
batteries, finding how to maximize the energy stored in a given battery with a
finite-time modulation of a set of external fields. We approach the problem
using advanced tools of optimal control theory, highlighting the universality
of some features of the optimal solutions, for instance the emergence of the
well-known Bang-Bang behavior of the time-dependent external fields. The
technique presented here is general, and we apply it to specific cases in which
the energy is both pumped into the battery by external forces (direct charging)
or transferred into it from an external charger (mediated charging). In this
article we focus on particular systems that consist of coupled qubits and
harmonic oscillators, for which the optimal charging problem can be explicitly
solved using a combined analytical-numerical approach based on our optimal
control techniques. However, our approach can be applied to more complex
setups, thus fostering the study of many-body effects in the charging process.
