  In this paper, we propose a systematic closed-loop approach to provide
optimal dynamic ancillary services with converter-interfaced generation systems
based on local power grid perception. In particular, we structurally encode
dynamic ancillary services such as fast frequency and voltage regulation in the
form of a parametric transfer function matrix, which includes several
parameters to define a set of different feasible response behaviors, among
which we aim to find the optimal one to be realized by the converter system.
Our approach is based on a so-called "perceive-and-optimize" (P&O) strategy:
First, we identify a grid dynamic equivalent at the interconnection terminals
of the converter system. Second, we consider the closed-loop interconnection of
the identified grid equivalent and the parametric transfer function matrix,
which we optimize for the set of transfer function parameters, resulting in a
stable and optimal closed-loop performance for ancillary services provision. In
the process, we ensure that grid-code and device-level requirements are
satisfied. Finally, we demonstrate the effectiveness of our approach in
different numerical case studies based on a modified Kundur two-area test
system.
