Then, ddx_init is a simple wrapper to ddinit which takes also care of allocating Ψ. The calls at lines 6 and 7 are direct to the ddX API and compute the primal and adjoint RHSs. The problem is solved by calling ddrun, which is part of the ddX API, and finally, if the forces are requested, the second contribution is computed by calling multipole_force_terms which is again part of the ddX API. The finalization of the library is done by calling ddx_free, this is a wrapper to deallocate_model and deallocate_state which deallocates also Ψ and the arrays containing the multipoles, centers, and radii.