Tutorial:Basic QOCT
If you set CalculationMode
= opt_control, you will be attempting to solve
the Quantum Optimal Control Theory (QOCT) equations. This tutorial introduces the basic theoretical concepts of
QOCT, as well as the procedure to perform basic QOCT calculations with Octopus.
If you already know QOCT, you can skip the Theoretical Introduction.
Contents
Theoretical Introduction
The QOCT can be formulated in the following way:
We consider a quantum mechanical system, governed in a temporal interval by the Hamiltonian . The Hamiltonian depends parametrically on a "control parameter" . In the cases we are concerned with, this is the temporal shape of an external electromagnetic field, typically the temporal shape of a laser pulse. This Hamiltonian drives the system from one specified initial state to a final state , according to Schrödinger's equation:
We now wish to find the optimal control parameter such that it maximizes a given objective, which in general should be expressed as a functional, of the full evolution of the state. This search must be constrained for two reasons: One, the control parameter must be constrained to physical values  that is, the laser field cannot acquire unlimitedly large values. Two, the evolution of the state must obviously follow Schrödinger equation.
These considerations are translated into mathematical terms by prescribing the maximization of the following functional:
 is the objective functional. In this basic tutorial, we will be concerned with the case in which it depends only on the value of the state at the end of the propagation, . Moreover, the functional is the expectation value of some positivedefinite operator :
 should constrain the values of the control parameter. Typically, the idea is to maximize the objective while minimizing the fluence:
 The constant is usually called penalty.
 The maximization of must ensure the verification of Schrödinger's equation:
 The auxiliary state plays the role of a Lagrangian multiplier.
In order to obtain the threesome that maximizes this functional we must find the solution to the corresponding Euler equation. The functional derivation leads to the QOCT equations:
Population target: scheme of Zhu, Botina and Rabitz
An important case in QOCT is when we want to achieve a large transition probability from a specific initial state into a final target state. That is, the operator is the projection onto one given target state, :
As observed by Zhu, Botina and Rabitz^{[1]}, for this case one can use an alternative definition of :
This alternative definition has the virtue of decoupling the equations for and :
These are the equation that we are concerned with in the present example.
The asymmetric double well: preparing the states
We are now going to solve the previous equations, for the case of attempting a transition from the ground state of a given system, to the first excited state. The system that we have chosen is a onedimensional asymmetric double well, characterized by the potential:
Let us fix the parameter values to and . The ground state of this system may be obtained with Octopus running the following inp file:
CalculationMode
= gsDimensions
= 1FromScratch
= yesBoxShape
= sphereSpacing
= 0.1Radius
= 8.0TheoryLevel
= independent_particles %Species
"AWD1D"  species_user_defined  potential_formula  "1/64*(x)^41/4*(x)^2+1/256*(x)^3"  valence  1 % %Coordinates
"AWD1D"  0 %ExtraStates
= 1EigensolverTolerance
= 1.0e6EigensolverMaxIter
= 1000Mixing
= 1.0MixingScheme
= linear
Note that we have set ExtraStates
=1 because we want to get the first excited state, in order to be able to do QOCT later (the objective will be the maximum population of this state).
In this way we obtain the first two (single particle) states for this system. It is useful to make a plot with the results, together with the potential. If you do this, you should the curves depicted in Fig. 1. Observe how the ground state is localized in the left well (which is, not surprisingly, deeper), whereas the first excited state is localized in the right well. We are going to attempt to transfer the wavepacket from one side to the other. The energies of these two states are 0.6206 a.u. and 0.4638, respectively.
Note that, in order to plot the functions, you will have to add to the inp file the variables Output
and OutputFormat
.
Running Octopus in QOCT mode
We now run the code with the following inp file:
ExperimentalFeatures
= yesDimensions
= 1FromScratch
= yesCalculationMode
= opt_control #  # Grid # BoxShape
= sphereSpacing
= 0.1Radius
= 8.0 #  # System #  %Species
"ADW1D"  species_user_defined  potential_formula  "1/64*(x)^41/4*(x)^2+1/256*(x)^3"  valence  1 % %Coordinates
"ADW1D"  0 %TheoryLevel
= independent_particles #  # TD RUN Parameters #  stime = 100.0 dt = 0.01TDPropagator
= aetrsTDExponentialMethod
= taylorTDExponentialOrder
= 4TDLanczosTol
= 5.0e5TDMaxSteps
= stime/dtTDTimeStep
= dt #  # OCT parameters # OCTPenalty
=1.0OCTEps
= 1.0e6OCTMaxIter
= 50OCTInitialState
= oct_is_groundstateOCTTargetOperator
= oct_tg_gstransformation %OCTTargetTransformStates
0  1 %OCTScheme
= oct_zbr98OCTDoubleCheck
= yes # # Laser field = Initial guess # ampl = 0.06 freq = 0.157 %TDExternalFields
electric_field  1  0  0  freq  "envelope_function" % %TDFunctions "envelope_function"  tdf_cw  ampl % # # Output #Output
= wfsOutputFormat
= axis_xTDOutput
= laser + td_occup
Let us go through some of the key elements of this inp file:
 The first part of the file is just a repetition of the basic information already given in the inp file for the ground state calculation: definition of the system through the
Species
block, specification of the mesh, etc.
 Each QOCT run consists of a series of backwardforward propagations for both and ; the variables in the section "TD Run parameters" specify how those propagations are done. It is especially important to set the total time of the propagation, which fixes the interval mentioned above in the QOCT problem definition.
 The next section ("OCT parameters") define the particular way in which OCT will be done:

OCTScheme
is the particular OCT algorithm to be used. For this example, we will use the one suggested by Zhu, Botina and Rabitz^{[1]}. This choice is "oct_zbr98". 
OCTMaxIter
sets a maximum number of iterations for the the ZBR98 algorithm. Each iterations involves a forward and a backward propagation of the wavefunction. 
OCTEps
sets a convergence threshold for the iterative scheme. This iterative scheme can be understood as a functional that processes an input control parameter and produces an output control parameters , Upon convergence, input and output should converge and the iterations stopped. This will happen whenever
is smaller thanOCTEps
. Note that this may never happen; there is no convergence guarantee. 
OCTPenalty
sets the penalty parameter described previously. 
OCTInitialState
should specify the initial states from which the propagation starts. In most cases this will just be the ground state of the system  this is the case for this example. The value "oct_is_groundstate" means that. 
OCTTargetOperator
sets which kind of target operator (, with the notation used above) will be used. As mentioned before, for this example we will be using a very common kind of target: the projection onto a target state: . This is set by doingOCTTargetOperator
= oct_tg_gstransformation. This means that the target state is constructed by taking a linear combination of the spinorbitals that form the ground state. The particular linear combination to be used is set by the blockOCTTargetTransformStates
. 
OCTTargetTransformStates
. This is a block. Each line of the code refers to each of the spin orbitals that form the state the system; in this example we have a oneparticle problem, and therefore one single spinorbital. This spin orbital will be a linear combination of the spinorbitals calculated in the previous groundstate run; each of the columns will contain the corresponding coefficient. In our case, we calculated two spinorbitals in the ground state run, therefore we only need two columns. And our target state is simply the first excited state, so the first column (coefficient of the ground state orbital) is zero, and the second column is one. 
OCTDoubleCheck
simply asks the code to perform a final propagation with the best field it could find during the QOCT iterative scheme, to check that it is really working as promised.
 The next section ("Laser field = Initial guess") simply specifies which is the initial laser field to be used as "initial guess". It is mandatory, since it not only provides with the initial guess for the "control parameter" (which is simply a real function that specifies the temporal shape of the timedependent external perturbation), but also specifies what kind of external perturbation we are talking about: an electric field with x, y or z polarization, a magnetic field, etc.
 Finally, we would like to do cute plots with our results, so we add an "Output" section. This only applies if we have set
OCTDoubleCheck
=yes, since the code does not plot anything during the propagations performed in the QOCT iterations. The variables given will permit us to plot the shape of the wavefunction during the propagation, as well as the timedependent electric field and the projection of the propagating wave function onto the ground state and first excited state.
Even if this is a simple onedimensional system, the run will take a few minutes because we are doing a lot of propagations. You will see how, at each iteration, some information is printed to standard output, e.g.:
****************** Optimal control iteration # 12 ****************** => J1 = 0.87422 => J = 0.54580 => J2 = 0.32842 => Fluence = 0.32842 => Penalty = 1.00000 => D[e,e'] = 1.66E04 **********************************************************************
The meaning of each number should be clear from the notation that we have introduced above. By construction, the algorithm is "monotonously convergent", meaning that the value of should increase. This does not guarantee that the final value of will actually approach one, which is our target (full overlap with the first excited state), but we certainly hope so.
At the end of the run it will do a "final propagation with the best field" (usually the one corresponding to the last iteration). For this example, you will get something like:
*************** Final propagation with the best field **************** => J1 = 0.94926 => J = 0.61505 => J2 = 0.33420 => Fluence = 0.33420 **********************************************************************
So we almost achieved a full transfer: .
Analysis of the results
The run will create a directory called optcontrol (among others). In it there is a file called convergence that contains the convergence history of the QOCT run, i.e. the values of the relevant functionals at each QOCT iteration. It is useful to make a plot with these values; you can see the result of this in Fig. 2. Observe the monotonous increase of . Also, in this case, the functional (which is, in fact, the one we are really interested in) grows and approaches unity  although the final limit will not be one, but in this case something close to 0.95.
You may want to get the laser pulses used at each iteration, you can do so by setting the variable OCTDumpIntermediate
.
There is also a directory called initial, useful to plot the initial state; a directory called target, that contains the target state; and a directory called final that contains the state at the end of the propagation corresponding to the last QOCT iteration. Fig. 3 is a plot constructed with the information contained in these directories. Note that while the initial and target states have no imaginary part, the final propagated wavefunction is complex, and therefore we have to plot both the real and the imaginary part.
In the directories laser.xxxx you will find a file called cp which contains the control parameter for the corresponding QOCT iteration. Another file, called Fluence informs about the corresponding fluence. The format of file cp is simple: first column is time, second and third column are the real and imaginary part of the control parameter. Since is defined to be real in our formulation, the last column should be null. Finally, the directory laser.bestJ1 will obviously contain the control parameter corresponding to the iteration that produced the best .
References
 ↑ ^{1.0} ^{1.1} W. Zhu, J. Botina and H. Rabitz, J. Chem. Phys. 108, 1953 (1998)