The qocttools code performs optimization calculations on quantum systems using optimal control theory. The problem that it solves is the following: given a system governed by a Hamiltonian whose precise form can be tuned through the variation of some control parameters, and given a user-defined merit function of the system trajectory, what are the values of those parameters that lead to the time evolution that maximizes the merit function? The code permits to work on generic systems, and uses either Schrödinger's or Lindblad's equation in order to deal with closed or open systems, respectively. It may also use the tools of Floquet formalism when dealing with periodic perturbations. It is written in Python, and the user can interface with it by preparing driver Python scripts that define the model, and load the appropriate qocttools modules. It is open and free software, and also relies on open and free widely used libraries and packages, such as QuTiP (to handle the quantum model definition and manipulation), and NLopt (to perform the optimizations). Program summaryProgram Title:qocttoolsCPC Library link to program files:https://doi.org/10.17632/49z3vydmwk.1Developer's repository link:https://gitlab.com/acbarrigon/qocttoolsCode Ocean capsule:https://codeocean.com/capsule/7560215Licensing provisions: GPLv3Programming language: PythonNature of problem: When a quantum system can be driven by external perturbations, one may be interested in finding the form of those perturbations that lead to a certain behavior. For example, driving the system from its ground to a given excited state, maximizing the value of some observable, etc. This can be interpreted as an inverse spectroscopy: the goal is not to predict the reaction of a piece of matter to an external probe or perturbation (e.g. an electromagnetic field), but instead to predict the precise shape of the perturbation that leads to a given predefined reaction. This problem may be posed for closed systems evolving coherently, or in the context of open quantum systems, in the presence of an environment. Also, when considering periodic perturbations, the problem may be formulated in the language of quantum Floquet theory.Solution method: This code implements the fundamental equations of quantum optimal control theory [1], the mathematical framework that addresses the problem described above. It (1) handles both closed or open quantum systems; (2) allows the user to specify any form for the target function (the one that is to be optimized, and encodes the desired system behavior), as it may be specified through any user-defined Python function; (3) allows the user to specify general parameterized forms for the control functions, and to set bounds and constraints on those parameters; (4) implements formulas, based on the adjoint method in most cases, for the computation of the gradient of the target functions with respect to the control parameters, as these gradients are the key tools for an efficient optimization, and (5) interfaces to a generic optimization library (NLopt), that permits to perform the optimization with numerous different algorithms, allowing for the use of bounds and linear or nonlinear constraints.