1 Introduction

Quantum optimal control theory (QOCT) [1,2,3] allows one to exploit the knowledge of a system to suitably shape, both in time and space, an external perturbation able to control the system itself to achieve a desired response (e.g. a specific excited state, a specific product in a chemical reaction, a desired many-body quantum state, etc.). In this approach, the optimal laser pulse is calculated a priori from the assumed system’s Hamiltonian [4,5,6,7,8,9]; such a strategy has been applied in several fields ranging from photochemistry to quantum gate synthesis [4, 5, 7, 8, 10,11,12,13,14,15,16] and, specifically for our interest, ab initio calculations and femtosecond experiments on systems with complex multidimensional potential energy surfaces, allowing identifying specific Hamiltonian information and optimal laser pulses, as well as to bring the system into the desired target state [17,18,19]. Applications of optimal control theory in single-molecule spectroscopy studies are of great interest, and quantum optimal control theory has been successfully applied to gas phase molecules. Nevertheless, less efforts have been devoted to broadening the possible external environment conditions (e.g. presence of a solvent) for molecular systems to be studied, which would allow the experimental applications to be increased, which can benefit from such laser pulse optimization procedure. Some studies focused on targeting specific vibronic molecular states in condensed phases using density matrix theory to introduce dissipative coupling with an external bath [11, 20, 21], and on accounting for fluctuations in molecular geometry due to electrostatic interaction with the molecular dipoles of the solvent [11, 22]; our efforts have instead been devoted to include the effect of the environment in the optimization problem. We developed a theory for optimal control of molecules immersed in a solvent, where the optimal control problem must account for both the interaction of the molecular system with the external control field and the polarization interaction of the same system with the external medium (i.e., the so-called reaction field problem) [23]. We extended the well-established Rabitz algorithm [6, 8, 9], which returned very satisfactory results, with an accuracy similar to that obtained in vacuo [23].

In this paper, we modified and extended our approach to systems in which the molecule is in proximity of the plasmonic nanostructure (i.e., a metal nanoparticle (NP)). We chose this system because plasmon resonances of metal nanoparticles give rise to the so-called optical nanoantenna effect, locally enhancing the field within the nanoscale and giving rise to new phenomena, such as surface-enhanced Raman scattering, surface-enhanced infrared absorption, and metal-enhanced fluorescence [24]. This work may also be of interest for optimal control of polaritonic chemistry systems [25,26,27,28,29], promising to manipulate the photochemistry of molecules [30, 31]. Nanoparticles properties are particularly interesting when coupled to ultrafast lasers, which can be optimized via quantum optimal control, as they might be able to probe and manipulate photochemical phenomena at a single-molecule level, such as excited-state dynamics, high-harmonic generation, and photosynthetic energy-transfer pathways. Inverse design of the entire system (including the nature and shape of the nanoparticle) has been recently proposed [32].

Here we treat the metal NP as a polarizable continuum body with a realistic shape, characterized by an empirical frequency-dependent dielectric function. NP is described through PCM-NP [33, 34], an extension of the polarizable continuum model (PCM) [35], in its time-dependent version [36].

All calculations were performed with the TDPlas software [36], and we implemented an interface between our optimal control software (OCpy [37]) and TDPlas, which are now able to share information at each time step of propagation.

As already mentioned, in our implementation for the study of solvated systems the optimization was performed relying on the theoretical approach proposed by Rabitz’s group; here we explored a different optimization procedure, which we already used to transfer the study of optimal control problems on quantum computers [38]. Due to the promising performance of machine learning in the field of multiparameter optimization, we chose to adopt a machine learning optimization scheme, notably a genetic algorithm (GA), that has a long tradition in quantum optimal control [39,40,41]. During the development of the genetic optimizer, we compared the performance of the genetic algorithm with both Rabitz theory and other optimization procedures with very satisfactory results [38]. We therefore decided to apply the same optimization procedure to the problem in hand, to avoid the need for a new theoretical extension of the Rabitz algorithm for the specific case of metal nanoparticles and any other future application. The comparison between Rabitz and GA optimizers applied to this specific system, where the presence of the nanoparticle amplification effect allows for smaller optimal fields, made us realize that minimizing the field intensity without losing the performance on the population transfer is the more complex part of the optimization. For this reason, a specific strategy was tested to minimize the field within GA.

The paper is organized as follows: In Sect. 2, we present the theoretical formalism; in particular, in Sect. 2.1 we review a suitable form of the QOCT for isolated molecules; in Sect. 2.1.1 we briefly explain the structure of a genetic algorithm and how it is applied to our particular case; the treatment of the effect of nanoparticles on the molecule when influenced by and external field is presented in Sect. 2.2. Then, we provide details on the computational approaches (section 3), and we present the numerical results (Sect. 4). Conclusions are given in Sect. 5.

2 Theory

2.1 Quantum optimal control theory with genetic algorithms

Quantum optical control theory (QOCT) has been actively developed since the mid-1980s [4, 5, 7]. Generally speaking, the problem deals with the evolution of a dynamical quantum system under the influence of a suitably shaped laser pulse, capable of driving the system from an initial state at \(t = 0\) where \(\psi (0) = \psi _0\) to a final state \(\psi (T) = \psi _T\) corresponding to a chosen final time \(t = T\). The final state should maximize the expectation value of a chosen operator \(\hat{O}\). In this work, we will focus on the particular case of optimal population transfer: given a molecular system in the initial state, we look for the shape of the laser pulse of length \(t=T'\) capable of maximizing the population of a specific target excited state. Note that in general \(T'\) is taken to be equal to T (i.e., the target state is obtained at the end of the pulse), but here we are considering the more general case of \(T>T'\), i.e., the target state should be obtained at a later stage than the end of the pulse. As will be clear in the numerical section, this is a requirement to accommodate for the field dynamics induced by the nanoparticle dielectric response. In other words, we allow for time-nonlocal effect of the laser pulse on the system dynamics. The optimal field can be obtained maximizing the following unconstrained objective functional.

$$\begin{aligned} J[{\textbf {a}}] = \langle \psi _{{\textbf {a}}}(T) | \hat{O} | \psi _{{\textbf {a}}}(T) \rangle - \int _0 ^{T'} \alpha (t) |E_{{\textbf {a}}}(t)|^2 dt \end{aligned}$$
(1)

Here \(\hat{O} = | \Psi \rangle \langle \Psi |\) is the projector operator on the excited target state \(| \Psi \rangle\) and the second term is a penalization factor that discourages the optimization algorithm to move towards high-fluency fields; \(|\psi _{{\textbf {a}}}(T)\rangle\) stands for the value of the state vector whose evolution is driven by a field \(\bar{E}_{{\textbf {a}}}(t)\) and the vector a specifies the set of control parameters. Finally, the time-dependent factor \(\alpha (t)\) modulates the penalty and allows one to enforce a given envelope of the laser pulse, which can be needed, e.g., when the optimal problem has to be solved for a particular experimental set-up. The value of \(\alpha (t)\), which in this paper is always set equal to a constant to facilitate comparison and comprehension of the results, is one of the parameters that allows one to choose the balance between the importance of maximizing the excited-state population and minimizing the field.

The molecule is treated quantum-mechanically, and the time-dependent Schrödinger equation for the system is:

$$\begin{aligned} { i} \frac{\partial \psi (t)}{\partial t} = [ \hat{H} - \bar{E}_{{\textbf {a}}}(t)\cdot {\hat{\bar{\mu }}}]\psi (t) \end{aligned}$$
(2)

where \(\hat{H}\) is the system Hamiltonian without the interaction with the external field, \(\bar{E}_{{\textbf {a}}}(t)\) is the external control field, and \(\hat{\bar{\mu }}\) is the electric dipole operator of the molecule. As we are interested in studying the polarization effect of plasmonic NP on the molecule, here \(\hat{H}\) implicitly includes the electrostatic interaction between NP and the molecule. Details on how to write this term of the Hamiltonian are given in Sect. 2.2. Equation 2 is explicitly written in the length gauge (other gauges are also possible) [42]. Note that atomic units are used throughout this work. Different approaches are available to optimize the objective functional J (Eq. 1) with different pros and cons depending on the system under study and the purpose of optimization [2]. A notable example is represented by the well-established Rabitz algorithm [8], which we have already adopted to solve optimal control problems for systems of molecules in vacuo and in solution and which shows excellent convergence properties in both cases [23]. With the purpose of applying optimal control theory to different systems and environments, we decided to adopt a different optimization procedure from the one proposed by Rabitz, relying on the broad and established field of machine learning (ML) in general and the genetic algorithm (GA) in particular. Although we developed the GA optimizer to solve optimization problems on quantum computers, where the Rabitz procedure does not allow us to exploit the peculiar characteristic of such hardware, the ML approach can be easily applied to the problem of molecule in proximity to plasmonic nanoparticles. If we had used the Rabitz theory in our system, we should have theoretically derived specific evolutionary equations for the new system Hamiltonian \(\hat{H}\), similarly to what we did for the study of solvated molecules [23], and then implemented them in our software. On the other hand, GA does not need any specific derivation for the new environment, as the optimization procedure is the same regardless of the Hamiltonian. In the following, we briefly review the structure of a genetic algorithm.

2.1.1 Genetic algorithms

The term genetic algorithms is due to the inspiration these optimization strategies draw from the process of developing new species that takes place in nature [43]. Given a function f(a) (the fitness function) to be maximized depending on the variables collected in the vector a, the idea is to generate (either by an educated guess or at random) different sets a (each of which is termed an individual ), thus forming a population of individuals, carrying only the best ones (that is, those that maximize the fitness f(a)) to the next generation (that is, optimization iteration) until an optimal result is obtained. The new generation of individuals is obtained from the previous one by applying three operations: i) selection (the process of selecting the individuals on whose parameters the next generation will be built), ii) recombination (two individuals are chosen randomly between the selected ones and their amplitudes are mixed to give a new set a) and iii) mutation (values of the parameters within each individual are randomly modified following some predefined rules). Despite the number of choices needed to set up an evolutionary procedure, most of the optimization problems are robust with respect to a large interval of values for the parameters a, with the difference between different choices translating mainly in a faster or slower convergence towards the optimal solution. Details on our specific choices for these processes are given in Sect. 3.

To implement the procedure, we need to define the set of control parameters a\(^I\) that explicitly define the shape of the external perturbation (the field) for each individual I to optimize the evolution of our system. To obtain such a parametric dependence, we wrote the laser pulse as:

$$\bar{E}_{{\mathbf{a}}}^{I} (t) = \sum\limits_{\alpha } {\bar{u}_{\alpha } } \left[ {a_{{0,\alpha }}^{I} + \sum\limits_{j}^{M} {a_{{j,\alpha }}^{I} } {\text{sin}}\left( {\frac{{j\pi t}}{T}} \right)} \right]{\text{ }}$$
(3)

where \(\bar{u}_{\alpha }\) is a unit vector with direction specified by the index \(\alpha\) running over the three Cartesian components. Here, the field takes the form of a sum over different harmonics with frequency \(\omega _j = \frac{j\pi }{T}\), where T is the time duration of the laser pulse. The subscript a emphasizes the parametric dependence on the set of amplitudes, which ultimately are our set of control parameters. We chose to use predetermined \(\omega _j\) values corresponding to Fourier frequencies, which have the advantage of describing a field which starts and ends at zero (provided it has no constant component \(a_0\)), thus more easily obtained with an experimental apparatus. Moreover, if a specific frequency range has to be considered due to particular experimental limitations, this is easily accomplished by choosing the terms to include in the summation of Eq. 3. To perform the optimization, each of the generated individuals is rated according to its fitness. In our case, it is easy to see how the fitness function corresponds to the functional J. It may be worth noticing that alternative optimization algorithms implemented the optimization of frequencies and amplitudes, to allow one to reach the global optimal solution [44]. Due to the simple structure of genetic algorithms, it would have been possible to include the frequencies in the optimization procedure, at the price of increasing the number of optimization parameters. Beware that in optimizing frequencies, the main and more expensive difference with respect to our procedure is not searching for their final optimal values but rather their final optimal number. As a matter of fact, with a fixed number of frequencies, if the amplitude of one of them does not influence the electronic excitation, as often is the case, it is anyway difficult for the genetic algorithm to set its amplitude to zero, as it should happen to minimize the field intensity. Practically, that frequency(ies) will show small but different from zero amplitudes, which increase the final intensity of the field and worsen the overall optimization procedure, in a way that is similar to an overfitting problem. Similarly, optimizing the frequencies values together with the amplitudes setting their fixed number a priori would end in having a very dense range of frequencies corresponding to the values that affect the final result more, all with amplitudes different from zero. To partially solve this issue without greatly increasing the complexity of the algorithm, we added a fourth step after the selection, recombination and mutation processes where the amplitudes have a probability \(P_0\) to be set to 0. This probability is the second parameter, together with the value of \(\alpha\) in Eq. 1, which allows us to work specifically to minimize the field. The third parameter, which, similarly to \(P_0\) exists only in genetic optimization, is the maximum absolute value allowed for the amplitudes, which acts as a boundary of the explored space.

Our purpose was to find a simple algorithm capable of providing satisfactory results for our specific system. It is always true that, when necessary, different parameters and evolution strategies can be adopted.

2.2 Polarizable model for plasmonic nanoparticle

The electrostatic problem related to the interaction between the NP and the molecule is treated through PCM-NP, whose details are reported in previous works [36, 45]. Here, we briefly summarize the main features of the model used to write the final interaction Hamiltonian in eq. (2) we need to implement the genetic algorithm. The electrostatic problem is formulated in terms of the apparent surface charge density defined on the nanoparticle surface; such density is determined by an integral equation that can be solved through discretization of the surface into small finite elements called tesserae within the boundary element method (BEM) [34]. The NP is characterized by a frequency-dependent dielectric function that can be included by analytical equations as the Drude–Lorentz’s or the Debye’s [36] or by the empirical one [45]. This approach has been successfully applied to investigate localized surface plasmons for nontrivial geometries [33, 34, 45,46,47,48,49]. Computing the polarization charges on each tessera allows us to calculate the effect of the NP polarization on the molecule. (More details are given later.)

From a theoretical viewpoint, we can often describe localized surface plasmons and the associated electric field enhancement with classical electromagnetic modeling, neglecting however quantum [50] and nonlocal effects [51]. The metal nanoparticle is treated as a continuum body polarizable within the quasi-static approximation (i.e., in the limit of the electric field wavelength much larger than the NP), describing the NP with the PCM-NP model [34] an extension of the polarizable continuous model (PCM) [35]. The quasi-static approximation implies that retardation effects are not included, which is a valid assumption for small nanoparticles when the interaction between different parts of the NP is almost instantaneous [52, 53]. In this case, Maxwell equations reduce to a time-dependent Poisson equation for an electrostatic potential whose gradient provides the electric field. Upon the dimension of the NP increasing toward the electromagnetic field wavelength, the quasi-static description is worsening in accuracy and retardation effect needs to be included. In these conditions, one has to solve the complete set of Maxwell equations, as proposed by Mie [54, 55] for spherical NPs.

This model provides a suitable framework for performing quantum mechanical calculations including polarization effects on the molecule due to the presence of a nearby NP and has been also extended to layered surfaces [56]. When the system is under the influence of an external electrostatic perturbation, the metal NP is polarized by both the external field itself and the electromagnetic field generated by the time-varying electronic charge density of the molecule. As a response, the nanoparticle generates two electric fields, called, respectively, the reflected (or scattered) field \(\bar{E}_\mathrm{{ref}}\) and the polarization field \(\bar{E}_\mathrm{{pol}},\) [57, 58] that act on the molecule (see Fig. 1).

Fig. 1
figure 1

Sketch of the electric fields acting on a molecule close to a nanoparticle. \(\bar{E}_{inc}\) is the incident electric field associated with the control laser pulse; \(\bar{E}_\mathrm{{ref}}\) is the result of the “reflection” (scattering) of such incident field by the nanoparticle and \(\bar{E}_\mathrm{{pol}}\) is the electric field produced by the polarization induced in the nanoparticle by the oscillating molecular charge density. The surface discretization of the nanoparticle is also shown; the center of each mesh element (tessera) i is occupied by a point charge \(q_{ref,i}\) acting as a source of \(\bar{E}_\mathrm{{ref}}\) and a point charge \(q_{pol,i}\) acting as a source of \(\bar{E}_\mathrm{{pol}}\) (see the text for their definitions)

In the quasistatic limit, these fields are associated with electrostatic potentials generated on the surface of the NP [33, 42]. Following the standard integral equation formalism and the boundary elements method (IEF-BEM), these two electrostatic potentials can be written as originated by a set of reflected charges \(\varvec{q}_\mathrm{{ref}}(t)\) due to the incident electric field and polarization charges \(\varvec{q}_\mathrm{{pol}}(t)\) that account for the presence of a nearby molecule. The frequency-dependent PCM-NP equations for the charges generated on the surface tesserae are written as:

$$\begin{aligned} {\textbf {q}}_\mathrm{{pol}}(\omega )= {} {\textbf {Q}}(\omega ) {\textbf {V}}(\omega ) \end{aligned}$$
(4)
$$\begin{aligned} {\textbf {q}}_\mathrm{{ref}}(\omega )= {} {\textbf {Q}}(\omega ) {\textbf {V}}_{inc}(\omega ) \end{aligned}$$
(5)

where \({\textbf {Q}}(\omega )\) accounts for the positions of the tesserae, their area, and the metal dielectric function, \({\textbf {V}}(\omega )\) is the potential generated on the tesserae by the component of the molecular charge distribution oscillating at the frequency \(\omega\) (as a result of the combined action of the incident, reflected and polarization fields) and \({\textbf {V}}_{\rm{inc}}(\omega )\) is the analogous potential associated, in the quasi-static approximation, with the incident electric field \(\bar{E}_{\rm{inc}}(\omega )\). Charges \(\varvec{q}_\mathrm{{ref}}\) and \(\varvec{q}_\mathrm{{pol}}\) are located in the geometric centers of the tesserae in which the surface of NP is discretized [33]. The calculation of the time-dependent charges requires a model to describe the dielectric function of the NP; different models are available, and in this paper we adopted both the Drude–Lorentz (DL) equation for the dielectric function which reads: [59]

$$\begin{aligned} \epsilon (\omega ) = 1 + \frac{A}{\omega _0^2-\omega ^2-i\gamma \omega } \end{aligned}$$
(6)

and an empirical dielectric function modeled on experimental data [36, 45, 60]. Based on a free electron treatment of metal conduction, the DL model is adequate but does not fully conform to the dielectric properties of realistic metallic NP media [61]. The main drawback of the DL model is that it includes a single electronic transition, while real metal involves free-electron behaviors as well as (in general) multiple interband transitions. For this reason, we used the DL model to perform some tests on a two-level system, while for the final calculations we decided to use a different model we developed, which allows the study of plasmonic NPs that feature any general and physically sound dielectric function, relying only on the knowledge of discrete values of the frequency-dependent, complex dielectric function \(\varepsilon (\omega )\), e.g., coming from measurements or ab initio calculations [45].

Independently from the form of the dielectric function, the NP-molecule interaction is described by an additional term in the Hamiltonian that includes the electromagnetic interaction with the reflected field \(\bar{E}_\mathrm{{ref}}\) and the polarization field \(\bar{E}_\mathrm{{pol}}\). If we make explicit these two terms and their dependence from the charges, Eq. 2 becomes:

$$\begin{aligned} { i} \frac{\partial \psi (t)}{\partial t} = [ \hat{H}^{0} + (\varvec{q}_\mathrm{{ref}}(t) + \varvec{q}_\mathrm{{pol}}(t)) \cdot \varvec{\hat{V}} - \bar{E}_{{\textbf {a}}}(t)\cdot {\hat{\bar{\mu }}}]\psi (t) \end{aligned}$$
(7)

where the time dependence of the charges on the NP surface is obtained by the Fourier transform of equation 4 [36, 45]. Here, \(\hat{H}^{0}\) is the Hamiltonian of the isolated molecule, \(\hat{\varvec{\mu }}\) is the dipole operator, \(\varvec{\hat{V}}\) is a vector operator representing the electrostatic potential of the molecule at the representative points on the surface of the NP where the apparent charges \(\varvec{q}_\mathrm{{ref}}\) and \(\varvec{q}_\mathrm{{pol}}\) are also located. In particular, \(\varvec{q}_\mathrm{{pol}}\) depends on the electrostatic potential originating from the molecule at all previous instants, which causes a nonlinear and nonlocal time evolution problem [60]. The theory behind the calculation of the charges can be found in [36, 45]. Once we are able to calculate the charges and write the Hamiltonian, the evolution of the wavefunction is also determined, and we can perform the optimization thanks to the genetic algorithm without further theoretical derivations.

3 Computational approach

3.1 Molecule and nanoparticle descriptions

N-methyl-6-quinolone (MQ) is an interesting system with peculiar photophysical properties [62], already studied in the framework of optimal control in vacuo [63] and solvent [23]. As stated in these studies, the electrical pulse to excite this system to the first excited state must be very short (approximately 6 fs.) to avoid nuclear relaxation. A \(\pi\) -pulse (i.e., a light pulse able to take all the ground-state population in the excited state for a two-level system) [9] of such duration was shown to be ineffective in obtaining the desired selectivity in the target excited state. Optimal control in vacuo already proved to solve this issue in Ref. [63], and we have already extended this result to the solvent case using Rabitz optimization coupled with PCM theory [23]. Here, proximity of a nanoparticle does not allow the system to be optimized in times shorter than 6 fs, as the amplification effect of the nanoparticle has its own damping time, related to the nature (e.g., the DL damping rate \(\gamma\)) and size of the nanoparticle and the position of the molecule. During that time, even if the external pulse intensity is 0, the molecule still feels the nanoparticle reflected field and consequently evolves. Nevertheless, we chose this system because it allows us to compare the results and performances obtained with those obtained in vacuo and solvent. Specific choices regarding the system and the amplification, depending on the desired results, will be studied in future work.

The MQ structure is obtained by relaxing the geometry with Gaussian G09 [64] using a 6-31 G(d) basis set at the Hartree–Fock level of theory. The two NPs considered in this work are a silver nanorod 10 nm long and a silver nanoellipsoid with semiaxes equal to 3 nm and 5 nm, see Fig. 2. Both NPs have a larger dimension along the x-axes, and the aromatic rings of the molecule lie in the xy plane with the closest C atom at a distance of around 2.5 Å from the surface of the NP. The portion of the NP surface closer to the molecule has been refined with smaller tesserae in order to improve the description of the NPs in the most relevant region. The NPs mesh has been generated with gmsh [65] discretizing the rod surface with 610 tesserae and the ellipsoid surface with 760 tesserae. The Rakic [66] dielectric function has been parametrized to be used in calculations, as detailed in ref. [45]. In the preliminary test on the two-level system, we described the dielectric function of an elliptical NP with the Drude–Lorentz model [36] with parameters specifically crafted for the test we were performing (Sect. 4).

Fig. 2
figure 2

a Mesh of the ellipsoidal NP close to the MQ molecule, and b mesh of the nanorod close to the MQ molecule

The CIS excited electronic states of MQ in the presence of the nanoparticle reaction (i.e., image) field have been calculated with a locally modified version of GAMESS [67]. The many-electron basis set \(|\Phi _I\rangle\) is limited to the Hartree–Fock ground state and to the lowest 10 CIS excited states determined in the presence of the nanoparticle reaction field. To check the suitability of using 10 excited states, we performed some test optimal control procedures with 15 excited states, and the results obtained were equivalent in terms of both the optimal field and the final state of the molecule.

3.2 Wavefunction evolution under the external laser pulse

The duration of the external laser pulse \(T'\) is set equal to 250 a.u., i.e. \(\approx 6\) fs. Due to the persistent oscillating polarization of the nanoparticle, propagation is carried out without an external field until the nanoparticle field acting on the molecule vanishes, \(t=T\) being the overall propagation time. The additional time \(T-T'\) is different depending on the shape of the nanoparticle and the model used to describe its electrostatic behavior. Details on the different choices are given in Sect. 4. In our implementation, the wavefunction \(\psi (t)\) is propagated through a second-order Euler method. For the large systems (10 states), the propagation timestep for calculations in vacuo, both with Rabitz and genetic optimizer, was kept fixed at 0.01 a.u. (i.e. \(\approx 2\cdot 10^{-4}\) fs) while, since calculations performed for the nanoparticle systems are computationally more demanding, in this case, we decided to perform the optimization with a timestep of 0.1 a.u. to fasten the procedure and obtain a reasonable estimate of the optimal field. We then restarted the calculation using the optimized field with a final timestep of 0.01 a.u. Our results show that the field obtained with the first time step is also optimized for the calculations with timestep 0.01 a.u. and that the calculations performed with dt = 0.1 a.u. are a reliable approximation of our final result. For this reason, since we performed a series of tests on a two-level system (Sec. Results) to discuss the amplification effect of the nanoparticle, we kept the timestep fixed at 0.1 a.u.. Other, more robust, propagation methods are possible (e.g., operator splitting technique in Ref. [63]); nevertheless, the choice of Euler propagator was done to keep the procedure as simple as possible and focus on the extension to the nanoparticle environment.

3.3 Genetic algorithm optimization

Concerning the mimicking of the evolution process, as discussed in Sect. 2.1, three main traits are usually considered: selection, recombination, and mutation, each amenable to different computational choices. We briefly describe such choices in the following. A more detailed description is given in [38]. Moreover, as stated in Sect. 2.1.1, we added a fourth step which allows one to set to zero the amplitudes that we perform after mutation.

Selection This step can be implemented in GA in different ways [40, 68]; we chose to build the next generation on top of the best individuals.

Recombination Two individuals are randomly chosen between the selected ones, and their amplitudes are mixed to give a new vector. In our algorithm, each amplitude in the final new vector has a probability of 0.5 coming from one or the other parent. As a consequence, recombining the same two individuals a second time does not give the same child.

Mutation In our implementation, mutation is performed with a certain probability by adding a random number to each amplitude of each individual. Each random number is extracted from a Gaussian distribution specified by a value of mean \(\mu\) and standard deviation \(\sigma\). While we kept \(\mu\) = 0, we varied the value of \(\sigma\) for different optimization runs to ensure a sufficient exploration of the parameter landscape and then a convergence towards a final result.

Frequencies optimization As already mentioned, it is very difficult for the standard algorithm to eliminate useless frequencies by setting their amplitudes to zero. For this reason, after mutation, each frequency was given a probability \(P_0\) to be set to zero. In principle, this step slows the optimization process, as it is completely independent from any system information learned in the previous iterations, which means that amplitudes of useful frequencies are sometimes set to zero and the corresponding individual is then discarded in the next selection step. Nevertheless, our tests demonstrate that, in our case, this step improves the overall optimization results without slowing the optimization procedure.

The number of individuals was kept fixed at 80. At each iteration, 20 individuals were selected and recombined into random couples to generate a new set of 20 individuals. For the 10 states calculations, we performed two subsequent optimization runs (and a third single propagation at a smaller timestep for the nanoparticle system), which, respectively, favor exploration of the landscape and convergence towards the optimized solution. The value of the standard deviation \(\sigma\) in the mutation step depends on other optimization parameters (see next paragraph); generally speaking, \(\sigma\) must be smaller during convergence than during exploration. For the two-level system, where the purpose was to study the amplification effect, we performed only the exploratory run. Although in calculations performed with the Rabitz algorithm the only way to control the field intensity is through the parameter \(\alpha (t)\), when using genetic optimization it is also possible to impose a threshold for the absolute value of the field amplitudes, as an effective way to limit the field intensity and speed up the convergence to the desired result. To show the effects of this choice, we performed calculations with different values for the maximum amplitudes, both for the system in vacuo and with the nanoparticle. The mutation parameter \(\sigma\) was set always one order of magnitude smaller than the amplitude limit for the exploration run and two order of magnitude smaller for the convergence run, a simple choice that allows comparison of results on different systems. Finally, in the implementation it is also possible to choose between three different shapes for \(\alpha (t)\) and to impose different values of the penalization factor \(\alpha _0\), which can be useful if the purpose is to reproduce the behavior of a specific experimental apparatus [23].

The comparison between Rabitz and genetic optimizers in vacuo was made with a constant value of \(\alpha (t) = 10\) a.u. as this was the best result obtained with the Rabitz optimizer [23]. In the other calculations, where we compare genetic optimizations in different environments and with different values of the maximum amplitude limit, we kept \(\alpha (t) = 1\) a.u.. Finally, as explained in the previous section, in genetic optimization, there is a final step after mutation that sets the amplitudes equal to 0 with a certain probability \(P_0\). In all the calculations, \(P_0\) is set equal to 0.1 besides the comparison in vacuo between Rabitz and genetic optimizations, where \(P_0\) = 0 to facilitate the comparison.

The shape of the field for the genetic algorithm is the one in Eq. 3, and starting amplitudes were initialized randomly in the desired range. The shape of the field for the Rabitz optimization is free, and the starting shape is a constant field of amplitude (0.01, 0.01, 0.01) a.u. [23].

These particular choices of iterations and parameters for the optimization procedure were made specifically for the problem under study, with the main purpose of allowing a straightforward comparison between different calculations, and do not claim to be general or optimal. The procedure and parameters can be modified and improved to fit specific problems [38].

4 Results and discussion

In this section, we present numerical applications of the QOCT-PCM-NP method to the study of laser pulse for the optimal population of selected excited states of MQ in proximity of two nanoparticles of different shapes: an ellipsoid and a rod.

Results comparing optimization performed in vacuo with the Rabitz and the genetic algorithms can be found in the Supporting Information. Overall, the two algorithms give very similar performances, and we feel confident to use the GA moving to the study of more complex systems.

4.1 2-level system

Here we present a set of results obtained on the MQ molecule considering only the ground state and the first excited state. In all these calculations, we describe the electrostatic of the nanoparticle with the Drude–Lorentz model and craft its parameters (A and \(\omega _0\) mainly, see Eq. (6)) in such a way that the plasmonic frequency of the nanoparticle is resonant (or not) with the excitation energy of the molecule. The purpose is to verify the amplification effect of the nanoparticle comparing the results obtained for the system in vacuo and the two systems with and without resonance between the nanoparticle plasmon frequency and the molecule. \(\omega _0=0\) a.u. (reducing the DL model to the Drude model) has been chosen in all cases. From Fig. 3, we can understand the behavior of the system and the effect of the nanoparticle. In Fig. 3a, we plotted the x component of the scattered field of the nanoparticle under the influence of the optimized external field in the resonant case; we oriented the MQ molecule in such a way that the 0 to 1 transition moment is along the x direction, and both the ellipsoid and the rod are oriented with the main axes also along x. After optimization, the x component of the laser pulse field is the strongest, even if the optimal field is nonzero also in the y and z components, and it is also the one in which the scattered field lasts for longer time. In Fig. 3b, the behavior of the two-state population during propagation for the system with the nanoparticle and the plasmonic frequency resonant with the molecular excitation is shown.

Remarkably, the laser field lasts 250 a.u. (\(\approx\) 6 fs), but Fig. 3a) shows how the nanoparticle scattered field is active up to 700 a.u. (\(\approx\) 17 fs) and how, accordingly, populations continue to evolve in time under its influence. We can interpret this behavior, due to the dielectric polarization dynamic of the nanoparticle, as a time nonlocality of the light pulse effects. This is rather peculiar to the system under investigation and of interest for quantum optimal control theory.

To take into account such nonlocality effects, we propagated the system for 750 a.u., which means 250 a.u. (\(\approx\) 6 fs) with the external field active plus 500 a.u. (\(\approx\) 12 fs) after the external field is ended. We do the same for both the resonant and nonresonant systems, as the nanoparticle field influences the molecule in both cases. As it is possible to see from the populations plot in Fig. 3b, when the field amplitudes are given a higher limit, the enhancement effect of the nanoparticle is unessential to achieve the optimization target. The latter could be easily achieved in 250 a.u. (\(\approx\) 6 fs) but, as the chosen propagation time is longer, the population oscillates while the algorithm tries to reduce the field. In other words, for high-intensity pulses the presence of the nanostructure makes the optimization process less straightforward. On the contrary, when the field is forced to be smaller, the NP amplification is fully exploited and the optimal result is obtained only after the entire 250 plus 500 a.u..

Fig. 3
figure 3

a x component of nanoparticle reflected field obtained with the 0.005 a.u. threshold for the amplitude absolute values. The corresponding incident field (not shown) is identically null from t=250 a.u. on. b QM excited state population for a propagation done with the optimized fields obtained with 0.005 a.u. and 0.001 a.u. thresholds for the amplitudes absolute values

In Table 1, results with different amplitudes are compared. While with amplitude limit of 0.005 a.u. (and larger) the optimizations reach a satisfactory result for the three environments, with maximum amplitude 0.001 a.u., it is the presence of the nanoparticle which allows one to reach the desired final state, while the optimization fails in vacuo. This is in agreement with the behavior of the population in Fig. 3 which, as we said, needs all the 750 a.u. time span to reach the excited state. As a consequence, the time needed by the system to reach the optimal population follows the time scale of the local field generated by the NP rather than the incident field time duration. Therefore, including retardation effects on the dynamics of the NP polarization may be significant in the optimization process when quasi-static conditions are not satisfied, since the local field generated by the NP can have additional timescales. Finally, for amplitudes values below 0.0005 a.u. only the system where the NP plasmon is in resonance with the molecular excitation succeeds in reaching the target state. This is an important demonstration of the role of the resonant condition and the NP enhancement.

Table 1 Optimization results for MQ in vacuo and close to a plasmonic nanoparticle with different constraints on the maximum absolute values of the field amplitudes

Finally, concerning the field constraints, in the resonant case it is easy to see how, when the amplitudes are allowed to be up to 0.005 a.u., the final field intensity is more than one order of magnitude larger than in the other two cases. As we said, even if in principle the optimization should reduce the field, practically the useless components of the field (e.g. the ones along z in this case) have amplitude values different from 0, fluctuating within a small range of values. As we mentioned, to reduce this problem, we introduced a further step in our optimization, which set the amplitudes to 0 with a certain probability. Its effect is evident in the case of the 0.001 a.u. constraint: results for the same optimization with the same number of iterations without the additional optimization step are shown in brackets in Table 1, and it is possible to see how the results on the excited state population are the same, while the field fluency is much larger (0.0005 a.u. vs. 0.0001 a.u.). This means that with this choice of strategy involving the additional optimization step, we do not lose performance (i.e. the result on the population is the same in the same number of iterations), but we improve the result on the field. For this reason, we adopted the same strategy in the study of the entire system.

Fig. 4
figure 4

Schematic summary of the calculations performed

4.2 10 level system

Here we finally compare the results obtained for the system optimized in vacuo and close to two nanoparticles of different shapes, elliptic and rod-like. To facilitate comprehension and comparison between the different calculations, we report in Fig. 4a schematic summary of the calculations performed. While in the previous section we discussed the first two systems presented (MQ in vacuo and close to an elliptic NP described with Drude-Lorentz model for the dielectric function, Table 1), in this section we are going to describe the results obtained with the empirical model for the dielectric function of Ag on the ellipsoid and rod-like NP systems (Table 2). Similarly to what we did for the two-level system, we want to propagate the system under the influence of the external field and the NP scattered field. We preliminary observe that neither the silver rod nor the silver ellipsoidal NPs have the longitudinal plasmon resonance frequency matching the molecular excitation energies, since the former is around 2\(-\)2.2 eV while the latter is around 3eV. Yet, both NPs have interband transitions at such energies, that, without providing essential enhancements, can moderately affect the local field. In particular, plotting the NP scattered fields one finds that the ellipsoidal and rod-like NPs behave differently, with the scattered field of the rod lasting almost three times the ellipsoid one: for this reason the optimization (propagation) will be carried for 250 + 1000 a.u (\(\approx\) 30 fs) for the ellipsoid and 250 + 3000 a.u. (\(\approx\) 80 fs) for the rod.

Fig. 5
figure 5

QM excited state population for a propagation done with the optimized fields obtained with the 0.002 a.u. threshold for the amplitude maximum value for a) ellipsoid and b rod-shaped NP

Both for the ellipsoid and the rod we also try to shape the field to obtain the optimal solution in 6 fs instead than 30 or 80 fs, to see what happens if we do not exploit the NP amplification which takes place after the external field ends. In the latter case, the numerical results reported in Table 2 are the population value after 6 fs with the optimal field. It must be clear that if we carry on the propagation of the same system, the value of the population keeps evolving under the influence of the NP-scattered field; we did not report the final value (i. e. the convergence one, when the scattered field of the NP vanishes) as the optimal (maximum) value of the population is the one obtained at the end of the optimization. The purpose of this calculations is to allow a comparison with the optimization performed with longer times.

Table 2 Optimization results for MQ close to plasmonic nanoparticles in the shape of an ellipsoid and a rod with different constraints on the maximum absolute values of the field amplitudes

In Fig. 5a, we plotted the population during the 1250 a.u. (30fs) propagation with the optimized field in the case of the ellipsoid NP with maximum amplitude 0.002 a.u.. The optimization works perfectly exploiting the NP amplification effect, as can be seen comparing this result with the one obtained for the 250 a.u. (6 fs) optimization (dashed line in Fig. 5a), which reach a maximum population of 0.73. In Table 2, results for the two optimization done imposing an amplitude limit of 0.005 a.u. are also presented, showing how, similarly to what happens in the 2-level system, in this case the amplitude limit allows a successful optimization result on the final population both for the 6 fs and 30 fs optimizations (250 a.u. vs. 250+1000 a.u.), at the price of a larger value of the optimized field.

The result on the rod, on the other hand, is quite different (Figs. 5b and 2). Imposing 0.005 a.u. as limit for the amplitudes allows to optimize the field both at the shorter and longer time scales, but in both cases the optimization happens in the first 250 a.u. (\(\approx\) 6 fs), which means that the NP-scattered field is not exploited in the last 3000 a.u.. Moreover, if we ask for amplitudes smaller than 0.002 a.u. the optimization in longer time performs definitely worst than the short one, with the additional optimization time that worsen the optimization process. Apparently, the controllability of the rod system by the 250 a.u. laser pulse on the long time scale is limited, at least is less than what happens for the ellipsoid. To provide a rational to this behavior, in Fig. 6 we plot the Fourier transform of the sum of the optimized incident field with the NP-reflected field in the absence of the MQ molecule. For the ellipsoid, the results of the maximum amplitude equal to 0.002 a.u. is used. Since this provides unsatisfactory results for the rod, for the latter we use the maximum amplitude equal to 0.005 a.u. case. The vertical line is the position of the MQ first-level excitation energy. It is easy to see how in the ellipsoid case the NP field (although not the plasmonic one, responsible for the peak around 2 eV) is resonant with the transition, while this is not true for the rod, explaining the different behavior of the two systems.

Fig. 6
figure 6

Fourier transform of the x component of the optimal field for the ellipsoid and rod-shaped NP. For the ellipsoid, the case with maximum amplitude 0.002 a.u. is considered, for the rod the larger maximum amplitude of 0.005 a.u. is instead considered. In both cases, the duration of the pulse \(T'=250\) a.u., while \(T=250+1000\) a.u. for the ellipsoid and \(T=250+3000\) a.u. for the rod. The red line is the energy of the MQ first-level transition

5 Conclusions

In this study, we extended the QOCT to the case of molecules close to plasmonic nanostructures. We have used a model where the molecule is treated with a quantum chemistry approach, keeping thus all its complexity, and the nanoparticle is described through its empirical frequency-dependent dielectric function. Both the reflected (also named scattered) and the image fields due to the nanoparticle are included in our treatment. The present work extends the recently developed QOCT-PCM [23] to the PCM-NP modeling of the nanoparticle in the time domain [69]. To solve the QOCT problem, here we rely on a gradient-free optimizer based on genetic algorithm, whose performances have been benchmarked against the standard Rabitz’s algorithm for molecules in vacuo and in solution [23]. The advantage of the approach is that it can be directly applied to the target goal function (the population of a given electronic excited state) without the need to derive a new goal functional accounting for the mutual molecular wavefunction and nanoparticle polarization time evolution at each step.

The results show that indeed the investigated systems can be controlled leading to the selective population of a target excited state. The scattered field generated by the nanoparticle can be beneficial to this goal: when the plasmonic resonance matches the molecular excitation frequency, smaller incident field intensities are needed than in vacuo or outside resonance. Our results also highlighted how, in the presence of plasmonic nanoparticles, the electronic dynamics should be followed for a time related to the plasmon lifetime rather than for the pulse duration only. In other words, the control pulse is not optimize to provide the desired target immediately after its end, but rather to set the following plasmon+molecule dynamics to reach the desired results to a later time, when the plasmon has fully decayed and cannot affect anymore the molecular electronic dynamics. Plasmonic lifetimes are typically within 1-10fs, which then set the minimal time scale for the QOC process to occur, even for shorter control pulses. We would like to remark that the theory presented here neglects two phenomena that may be relevant. The first is that we are neglecting the possible decoherence of the molecular electronic state during the wavefunction evolution. This is common to many QOC approaches, and it is justified as long as the dynamics is short compared to electronic decoherence times; existing estimates (tens of fs) [70] show that this is an achievable regime, but the interaction with the plasmon may reduce the coherence time. The second is that the presented theory is semiclassical with respect to the plasmonic description, i.e., it does not account for the quantized nature of plasmons. When the molecular population in the excited state is sensibly different from 0 (which is certainly the case at some point in the QOC process), its plasmon-induced decay is not correctly accounted for (M.Romanelli, G. Dall’Osto and S. Corni, in preparation). Again, this is not a problem only as long as the plasmon-induced decay is long compared to the QOC process. Overall, the present work contributes to extend the theoretical and computational tools available for quantum optimal control theory, towards still largely unexplored setups.