# Reaction Nanoscopy of Ion Emission from Sub-wavelength Propanediol Droplets

Philipp Rosenberger  Department of Physics, Ludwig-Maximilians-Universität
Munich, D-85748 Garching, Germany  Max Planck Institute of Quantum Optics,
D-85748 Garching, Germany  Corresponding authors, e-mails:
<EMAIL_ADDRESS><EMAIL_ADDRESS>Ritika Dagar
Department of Physics, Ludwig-Maximilians-Universität Munich, D-85748
Garching, Germany  Max Planck Institute of Quantum Optics, D-85748 Garching,
Germany  Wenbin Zhang  Department of Physics, Ludwig-Maximilians-Universität
Munich, D-85748 Garching, Germany  Max Planck Institute of Quantum Optics,
D-85748 Garching, Germany  State Key Laboratory of Precision Spectroscopy,
East China Normal University, Shanghai 200241, China  Arijit Majumdar
Department of Mechanical Engineering, Stanford University, Stanford, CA 94305,
USA  Marcel Neuhaus  Department of Physics, Ludwig-Maximilians-Universität
Munich, D-85748 Garching, Germany  Max Planck Institute of Quantum Optics,
D-85748 Garching, Germany  Matthias Ihme  Department of Mechanical
Engineering, Stanford University, Stanford, CA 94305, USA  SLAC National
Accelerator Laboratory, Menlo Park, CA 94025, USA  Boris Bergues  Department
of Physics, Ludwig-Maximilians-Universität Munich, D-85748 Garching, Germany
Max Planck Institute of Quantum Optics, D-85748 Garching, Germany  Matthias F.
Kling  Department of Physics, Ludwig-Maximilians-Universität Munich, D-85748
Garching, Germany  Max Planck Institute of Quantum Optics, D-85748 Garching,
Germany  Department of Applied Physics, Stanford University, Stanford, CA
94305, USA  SLAC National Accelerator Laboratory, Menlo Park, CA 94025, USA
Corresponding authors, e-mails<EMAIL_ADDRESS><EMAIL_ADDRESS>
###### Abstract

Droplets provide unique opportunities for the investigation of laser-induced
surface chemistry. Chemical reactions on the surface of charged droplets are
ubiquitous in nature and can provide critical insight into more efficient
processes for industrial chemical production. Here, we demonstrate the
application of the reaction nanoscopy technique to strong-field ionized
nanodroplets of propanediol (PDO). The technique’s sensitivity to the near-
field around the droplet allows for the in-situ characterization of the
average droplet size and charge. The use of ultrashort laser pulses enables
control of the amount of surface charge by the laser intensity. Moreover, we
demonstrate the surface chemical sensitivity of reaction nanoscopy by
comparing droplets of the isomers 1,2-PDO and 1,3-PDO in their ion emission
and fragmentation channels. Referencing the ion yields to gas-phase data, we
find an enhanced production of methyl cations from droplets of the 1,2-PDO
isomer. Density functional theory simulations support that this enhancement is
due to the alignment of 1,2-PDO molecules on the surface. The results pave the
way towards spatio-temporal observations of charge dynamics and surface
reactions on droplets in pump-probe studies.

##  1 Introduction

Over recent years, it has been repeatedly demonstrated that chemical reactions
on charged droplets can be orders of magnitude more efficient compared to bulk
reactions [1, 2, 3, 4, 5]. This makes charged droplets a possible candidate
for the origin of prebiotic polymers [6, 7, 8] and relevant for the chemical
and pharmaceutical industry [9, 10]. The underlying mechanisms responsible for
the accelerated reactions are, however, still debated. While earlier studies
suggested solvent evaporation as the main explanation for the enhancement [11,
12, 13], recent studies emphasize the role of the droplet surface [1, 14, 15].
The surface gives rise to high molecular concentrations and a high degree of
molecular alignment [16, 17, 6, 7, 8], a high charge density and acidity [18,
19, 20], as well as a strong electric field [21, 22, 23]. While all of these
effects are important factors in the acceleration of chemical reactions,
elucidating their individual contributions is still a subject of active
research [4, 23].

In experimental studies, charged droplets are usually generated from
electrospray ionization sources. Despite the widespread use of such sources,
the ion emission mechanisms from electrospray-generated droplets are still not
fully understood [24, 25]. A major reason is the complexity of the
electrospray ionization mechanism itself. Electrospray droplets have wide
distributions in both size and charge that strongly depend on the electrospray
source [24, 26]. In combination with solvent evaporation, droplets generated
by electrospray may become unstable as their size becomes smaller and their
charge approaches the Rayleigh limit [27]:

$q_{R}=\pi\sqrt{8\gamma\varepsilon_{0}d^{3}},$ (1)

where $\gamma$ is the surface tension, $d$ is the droplet diameter, and
$\varepsilon_{0}$ is the vacuum permittivity. Due to this complexity, a
simpler injection system with a more well-defined initial state is beneficial
for the study of droplet chemistry.

This is addressed by the application of reaction nanoscopy to droplets. The
technique holds great potential for the control and direct observation of
nanodroplet surface reactions and may help to elucidate the mechanisms behind
the enhancement of reaction rates. Reaction nanoscopy enables the measurement
of the three-dimensional momentum distribution of ions generated by a strong
laser pulse from the surface of an isolated nanosystem injected into ultra-
high vacuum (see Figure 1a). For solid silica nanoparticles, it was
demonstrated that the laser-induced proton emission strongly correlates with
the optical near-field distribution on the particle surface [28, 29], and that
the emission region on the surface can be controlled on a nanometer scale by
tailored laser fields [30]. The technique was recently shown to provide
information about surface chemistry in a study on the formation of trihydrogen
cations from water-covered isolated silica nanoparticles [31].

Extending these prior investigations, the objective of this work is to
demonstrate the application of reaction nanoscopy to the liquid phase using
polydisperse droplets of PDO as the model system. We analyze the ion spectra
from 1,2-PDO and 1,3-PDO targets, and demonstrate that reaction nanoscopy's
near-field sensitivity is preserved for droplets allowing in-situ
characterization of the droplets size and charge. The droplet-specific
reaction nanoscopy data indicate a high relevance of fragment protonation for
the generation and emission of ions. Furthermore, by comparing the single-
molecule fragmentation of the PDO isomers to the ions emitted from the PDO
droplets, we find that the molecular alignment on the surface of 1,2-PDO
droplets enhances the production of CH${}_{3}^{+}$ ions. This interpretation
is confirmed by density functional theory (DFT) calculations.

##  2 Experimental

Fig. 1:  a: Droplet source and reaction nanoscope. The propanediol (PDO)
droplet source consists of an atomizer operated with argon (Ar), an impactor,
a damping volume (1 l), and a high-efficiency particulate air (HEPA) filter.
An aerodynamic lens (AL) was used to inject a collimated aerosol stream into
the reaction nanoscope where the droplets were ionized in the focus of the
laser (polarization along $y$). The electrons and ions were directed to their
detectors by an electric field generated by a high voltage (HV). b: Electron
signal distribution. The signal is the time integral of the voltage pulse from
the $e^{-}$ detector. c: The pulse symbol indicates the propagation direction
($x$) and the polarization direction ($y$) and of the laser. c-e: Field
enhancement factors calculated from the Mie solution [32] as a function of
position in the $x$-$y$ plane for 1,2-PDO droplets at the origin with
different diameters $d$. The angle $\alpha_{\rm max}$ is the angle of maximum
field enhancement at a distance of 1 Å from the droplet surface.

###  2.1 Laser system

We used a home-built laser system based on optical parametric chirped-pulse
amplification [33]. The system features a central wavelength of 2 $\mu$m, a
maximum pulse energy of 100 $\mu$J, a pulse duration of 25 fs and a repetition
rate of 100 kHz. The pulse energy was adjusted by a combination of a broadband
half-wave plate and a wire-grid polarizer. The pulses were compressed by
maximizing the ion count rate detected in the reaction nanoscope while
changing the dispersion with a pair of fused silica wedges. Inside the
nanoscope, the pulses were back-focused using a spherical silver mirror with a
focal length of 75 mm. The peak intensity in the interaction region reached up
to 5$\times$1013 W/cm2.

###  2.2 Droplet source

In order to investigate the influence of the molecular structure on the ion
emission from the droplet surface, we compared droplets of 1,2-PDO (Thermo
Scientific, 99.5 %) and 1,3-PDO (Thermo Scientific, 99 %). Since both liquids
are highly hygroscopic, all experiments were carried out with samples from
freshly opened bottles. The droplet source is shown in Figure 1a. We produced
a polydisperse PDO-argon aerosol using an atomizer (TSI inc., model 3076) with
20 psi (1.4 bar) of argon pressure for 1,3-PDO. In order to aerosolize
1,2-PDO, a pressure of 30 psi (2.1 bar) was required. The polydispersity was
reduced by an impactor (TSI inc., part no. 1035900) with an aperture of 0.71
mm (TSI inc., part no. 390170) and a gap of 2 mm. As instructed by the
atomizer manual, a 1 l bottle was used after the impactor to dampen flow
instabilities and to collect excess PDO from the impactor. After the damping
volume, a high-efficiency particulate air (HEPA) filter connected to the
aerosol line on the inlet side and to ambient air on the outlet side was used
to ensure a pressure of 1 atm inside the line. The pressure of 1 atm is
required at the inlet of the aerodynamic lens, which was used to introduce the
aerosol stream into the ultra-high vacuum of the reaction nanoscope. The
aerodynamic lens collimated the droplet stream and further reduced the
polydispersity [34]. The lens assembly was followed by three stages of
differential pumping to minimize the gas load in the experimental chamber. The
average size of the nanodroplets was determined to be (590$\pm$50) nm (see
results section).

###  2.3 Reaction nanoscopy with droplets

The reaction nanoscopy technique was described in previous publications [28,
29, 31, 30, 35]. Briefly, a strong laser pulse ionizes a nanoscale target and
the released ions and electrons are forced towards detectors on opposing ends
of a spectrometer by a static homogeneous electric field, as shown in Figure
1a. The ion detection and momentum reconstruction schemes are the same as for
the reaction _microscopy_ technique [36], where the ion recoil momentum is
reconstructed from the time-of-flight and the arrival position of the ions,
which are detected by a combination of a microchannel plate stack with a
delay-line anode.

Fig. 2:  a: Time-of-flight spectra (in mass units) for ions generated from
single gas-phase molecules (blue) and on the surface of droplets (orange)
obtained from a single measurement with 1,2-PDO at a laser intensity of
approx. 5$\times$1013 W/cm2. The insets i and ii contain a zoomed-in and
normalized view of the mass ranges indicated by the dashed boxes. The mass of
the PDO molecule (or PDO+ ion) is $m=76\,$u. b: Same as panel a using 1,3-PDO
as the target. Gas-phase and droplet data were separated based on the electron
signal (see Figure 1b). The droplet data was further cleaned from gas-phase
ions by removing ions with a small deflection from the center of the ion
detector along the polarization direction of the laser. pseudo-color plots:
Position-resolved (along polarization direction $y$) time-of-flight histograms
for ions with high electron signal. Only the counts outside the white-shaded
regions ($|y|>11$ mm) are contained in the droplet histograms of panel a and
b. The time-of-flight histogram for counts with $|y|\leq 11$ mm is practically
identical to the gas-phase case (see supplementary material).

The electron detector of the reaction nanoscope is a channeltron electron
multiplier. The voltage signal from the channeltron is time-integrated for
every laser shot and used as a measure of the number of emitted electrons. The
integrated electron signal is used to assign all ions of a laser shot to
either the ionization of a single gas-phase molecule or to the ionization of a
droplet (see Figure 1b). A small or zero value is indicative of a gas-phase
ionization event, whereas a large value corresponds to the ionization of a
droplet, which releases many electrons. The ideal threshold value is
determined by a gas-only measurement in the absence of droplets. This
categorization of laser shots helps to remove pure gas-phase ionization events
from the droplet data. However, due to the partial evaporation of the droplets
in vacuum and the large focal volume compared to the droplet size, the
ionization of a droplet is frequently accompanied by ions from single
molecules. These are identified by a comparison with the gas-phase data, and
are rejected based on their arrival position on the detector as shown in
Figure 2 and the supplementary material.

##  3 Theoretical

To interpret the experimental results, we performed DFT calculations for the
minimum energy configuration for bulk 1,2-PDO and 1,3-PDO. The simulations
were performed with VASP [37, 38], which uses the plane wave DFT formulation
[39]. The exchange correlation term is handled using the Perdew-Burke-
Ernzerhof functional [40], and the Projector Augmented Wave method [41] is
used to represent the interaction between atom cores and electrons. To
describe the interface at the droplet surface, we consider a planar slab of
molecules, neglecting curvature effects on the equilibrium interface structure
owing to the large droplet radius. The simulation cell is
8Å$\times$90Å$\times$12Å in dimension and has periodic boundaries along the
direction of the surface interface. Along the surface-normal direction, we
approximate the liquid phase by six layers of molecules with rotational
symmetry around the center of the simulation cell. See the supplementary
material for more details. The symmetry constraint is used for an unambiguous
definition of the droplet-vacuum interface. The edge length of the cell in the
normal direction is kept sufficiently large to avoid any effect of
periodicity. A 7$\times$1$\times$7 $\Gamma$-centered mesh is used to sample
the Brillouin zone. For energy minimization, the energy convergence criterion
is set to ${10}^{-6}$ eV and the norm of the forces acting on the ions is less
than 0.01 eV/Å.

Fig. 3:  Intensity-dependent proton emission from polydisperse droplets. a:
The pulse symbol indicates the propagation direction ($x$) and the
polarization direction ($y$) and of the laser. a-d: Proton momentum histograms
for the plane $p_{x}$-$p_{y}$ for different laser intensities. The momenta are
given in atomic units (au). e-h: Distributions of the final proton emission
angle $\alpha_{f}$ with respect to the laser propagation axis in the $x$-$y$
plane, defined as $\alpha_{f}=\arctan(|p_{y}|/p_{x})$, as indicated in panel
d. h: The dashed vertical line shows the mean (83∘) of a Gaussian fit (dashed
curve) to the angular distribution, representing the most likely proton
emission angle.

##  4 Results and Discussion

###  4.1 Intensity-dependent near-field response

The time-of-flight spectra for typical measurements of 1,2-PDO and 1,3-PDO are
shown in Figure 2. While we observe a multitude of fragments, we will first
concentrate our analysis on the most abundant species in the droplet spectra,
the protons, and discuss the other fragments in detail in the later sections.
The high abundance of protons is analogous to previous reaction nanoscopy
studies on solid, monodisperse nanoparticles [28, 29, 31, 35]. These studies
demonstrated that the local near-field on the particle surface and the angular
distribution of the proton yield were highly correlated and that the birth
angles on the particle surface are practically identical with the final proton
detection angles [30].111The birth and detection angles have to be defined in
the same coordinate system with the center of the particle at the origin. The
same effect would be expected for a _monodisperse_ stream of nanodroplets. In
our experimental setup, however, the droplet size distribution is not easily
controllable. It is determined by the atomizer (see, for example, Ref. [42]),
the size selective elements further downstream (the impactor and the
aerodynamic lens) and the evaporation of molecules from the droplet surface
due to the ultra-high vacuum of the instrument. Since the optical response of
a sub-wavelength nanosphere (particle or droplet) strongly depends on its size
(Figure 1c-e), and the proton emission is a highly non-linear process, the
proton angular distribution in reaction nanoscopy follows the near-field
distribution [28]. In order to investigate how this affects the averaged
proton momentum spectra for the polydisperse droplet stream, we carried out a
series of measurements on 1,2-PDO at different laser intensities. Panels a-d
of Figure 3 contain the corresponding momentum distribution of protons emitted
from PDO droplets. At low intensity, we find that the protons are mostly
emitted in the forward direction along the laser propagation direction
($p_{x}>0$), and that there is only a minor contribution of protons emitted
along the polarization direction of the laser ($p_{y}$) which is distributed
in two lobes and symmetric with respect to $p_{y}=0$. This dipolar part of the
emission pattern becomes more dominant as the intensity is increased, shifts
to higher momenta (Figure 3b,c) and eventually stabilizes (Figure 3d).
Simultaneously, the relative strength of the momentum component in the forward
direction diminishes. We interpret this observation in terms of the difference
between the maximum field enhancement factors of droplets of different sizes.
As shown for a set of exemplary sizes in Figure 1c-e, the field enhancement
factor increases with increasing droplet size. In combination with the highly
nonlinear process of strong-field ionization and proton emission [28, 35],
this causes a size-selectivity as a function of laser intensity where
ionization and ion emission only take place on the larger droplets in the size
distribution when the intensity is low. That larger droplets (with diameters
on the order of the laser wavelength), however, only make up a small fraction
of the aerosol stream is seen in the high-intensity measurement (Figure 3d)
where their contribution is negligible.

###  4.2 Droplet size characterization

The fact that the main peak of the proton momentum distribution stabilizes for
laser intensities above approx. 3$\times$1013 W$/$cm2 suggests that, beyond
this point, a significant majority of droplet sizes in the aerosol stream are
ionized and emitting ions. As shown in the bottom panels of Figure 3, the peak
of the angular distribution in the $p_{x}$-$p_{y}$ plane stays at a constant
value of $\alpha_{f}=83^{\circ}$ in this regime. Based on the one-to-one
mapping between an ion's birth angle and its final angle [30], we can perform
an angle-based estimate of the most prominent droplet size in the aerosol
stream. On a droplet, the most likely birth angle $\alpha_{\rm max}$ of an ion
is simply determined by the point of maximum field enhancement on the
surface(see Figure 1c-e). For a certain range of droplet diameters, the angle
$\alpha_{\rm max}$ can be related to the droplet size, as shown in Figure 4a.
The relation between the angle $\alpha_{\rm max}$ and the droplet diameter is
obtained from the Mie-Solution of Maxwell's equations (see, for instance,
Refs. [32, 43]) for PDO spheres of different sizes. Carrying out this size
estimation with the experimental data taken at a laser intensity of approx.
4.0$\times$1013 W$/$cm2, we obtain a mean droplet diameter of $\langle
d\rangle=(590\pm 50$) nm. The error of $\Delta d=\pm 50\,$nm was determined
based on an uncertainty of $\Delta\alpha_{f}=\pm 2^{\circ}$ for the
determination of the peak of the proton angular distribution (see Figure 3h).

Fig. 4:  Droplet characterization. a: Relation between the droplet diameter
$d$ and $\alpha_{\rm max}$ calculated from the Mie solution by numerical
optimization. The color of the line indicates the max. field enhancement for
every droplet diameter. The shaded region in gray indicates the estimate of
the most frequent droplet size in our experiment ($(590\pm 50)\,$nm) based on
the angular distribution of proton momenta (Figure 3h). See main text for
details. b: The black solid line shows the relation between ion energy and
droplet charge for a homogeneous charge distribution. The color map shows the
measured distribution of proton energies (below the line) and the
corresponding estimate for the droplet charges (above the line). The red
dashed-dotted line indicates the Rayleigh charge limit $q_{R}$ for a 1,2-PDO
droplet with a diameter of 590 nm.  Fig. 5:  Isomer comparison of the
fragmentation channels for gas-phase PDO and PDO droplets. a: The ion yield
from gas-phase 1,2-PDO and 1,3-PDO for selected fragments. The data was
obtained by filtering the droplet measurements on events with a low electron
signal. The yield is normalized to the total number of counts after filtering.
b: The same measurements as in panel a filtered on droplet events (high
electron signal). The data is normalized to the total number droplet ions,
i.e. ions with a high electron signal. The raw data for panels a and b can be
found in the supplementary material. The blue rectangles mark the
CH${}_{3}^{+}$ ion for which we find a significant difference between the gas-
phase and droplet data. We attribute this to the molecular alignment of the
PDO molecules on the droplet surface (see text for details). Panels c and d
present density functional theory results for the molecular alignment of both
isomers. Only the top three layers are shown. The gray dotted lines represent
hydrogen bonds.

###  4.3 Droplet charge and stability

The results presented here demonstrate that the concepts of reaction nanoscopy
with solid nanoparticles can also be applied to droplets. This suggests that
in the range of intensities investigated here, the physics of the ion emission
process from droplets are comparable to the case of solid nanospheres. Solid
nanoparticles are, however, very stable and can hold a high (surface) charge
without disintegrating. In contrast, for droplets this is not necessarily the
case and may require different modeling.

The stability of charged droplets can be determined from the Rayleigh charge
limit (see Eq. (1)). Its derivation is based on the idea that the maximum
amount of charge a droplet can hold is limited by its surface tension. Once
the Coulomb energy $E_{C}=q^{2}/8\pi\varepsilon_{0}R$ of a droplet with radius
$R$ exceeds the surface energy $E_{S}=4\pi\gamma R^{2}$ (with surface tension
$\gamma$) by a factor of two ($E_{C}>2E_{S}$), the droplet is no longer stable
and will start fragmenting into smaller droplets [44, 45]. Even though the
Rayleigh limit does not provide an exact criterion as to when droplet fission
sets in [46], droplet charges far below and above the limit can be safely
called stable or unstable, respectively. Evaluating the stability of the
droplets in our experiment requires knowledge about their total surface
charge. Since the final ion energy measured with the reaction nanoscope is
dominated by the Coulomb repulsion of the ions from the charge on the surface
[28, 29], a charge estimate can be directly obtained from:

$q=E4\pi\varepsilon_{0}R/e.$ (2)

Here, $E$ is the ion energy obtained from measured ion momentum. We neglected
the inhomogeneous charge distribution due to the near-field and assumed a
homogeneously charged droplet instead. The assumption of a homogeneous charge
density overestimates the total droplet charge, which is acceptable for
determining droplet stability as long as the estimated charge turns out to be
below the Rayleigh limit.

In Figure 4b, we show a charge estimate using the energy distribution of
protons emitted from 1,2-PDO droplets. We find that the distribution of
droplet charges is centered at approximately 6000 e and does not overlap with
the Rayleigh charge limit for a 590 nm PDO droplet of $q_{R}\approx$16000 e.
We therefore conclude that the droplets studied here did not undergo droplet
fission after the ionization by the laser pulse.

We observed slightly different energy distributions for different ion species
and therefore used the most energetic ions, the protons, as an upper limit for
determining the droplet stability.

###  4.4 Ion emission: gas-phase vs. droplet

The use of droplets for reaction nanoscopy comes at the advantage that the
material of bulk and surface are identical which makes the origin of the
emitted ions unambiguous. For solid particles, this is in general not the case
[35]. Besides, the reaction nanoscope can be used for studying single
molecules in the gas-phase allowing for a direct comparison to the ion
generation and emission from the droplet. We next discuss this comparison and
then focus on isomer-related effects. We restrict the discussion to
unambiguously identifiable ion species. The design of the reaction nanoscope
as a momentum imaging spectrometer results in wide time-of-flight
distributions for energetic ions, which leads to overlapping times-of-flight
spectra for ions with similar $m/q$-values. This is illustrated by the
fragments at masses close to $m=28$ u (C2H${}_{n}^{+}$ and CHnO+) and $m=45$ u
(C3H${}_{n}^{+}$ and C2HnO+) in Figure 2 where the exact number of H atoms
cannot be determined. We excluded such ambiguous species from our analysis.

Figure 5 shows the relative ion yields for gas-phase PDO (panel a) and PDO
droplets (panel b). As mentioned above, the high abundance of protons in the
droplet ion spectra is a feature that was also observed in reaction nanoscopy
studies with (water-covered) silica nanoparticles [28, 31]. We believe that
the strong proton signal from droplets is the consequence of the ionization of
the droplet by the ultrashort few-cycle laser pulse. Within a very short
period of time, the droplet is left in a highly charged non-equilibrium state
and the remaining electrons redistribute. A comparison of the
electronegativities of the constituents of PDO [47] suggests that proton
emission is favorable for the reduction of surface charge and the minimization
of the total energy of the droplet.

Another abundant ion in the droplet data is the H${}_{2}^{+}$ molecular ion.
While it is likely also produced from gas-phase PDO to some extent, the signal
is below the noise floor, which is why it is not listed in Figure 5a. We
assume that the production of H${}_{2}^{+}$ is greatly enhanced by the proton-
rich environment around the nanoparticle surface after the ionization. As for
the protons, the H${}_{2}^{+}$ molecular ion has been observed in reaction
nanoscopy experiments on solid nanoparticles [31]. This supports the
hypothesis that its production is rather related to the proton-rich
environment on the charged nanosurface than the specific material of the
nanosphere. Our observation of protonated PDO molecules ($m=77$ u) from
droplets is also consistent with this hypothesis. In fact, for the droplets,
the emission of protonated PDO outweighs the emission of PDO+ ions by far.

Finally, we analyze two fragmentation channels of PDO+ that are strongly
related to each other as they only differ by the final placement of a proton.
These are the loss of a neutral water molecule from PDO+ (resulting in $m=58$
u) and the emission of an H3O+ ion ($m=19$ u). Independent of the specific PDO
isomer, we find that the ratio between H2O-loss and H3O+ ion production
decreases when going from the gas-phase to the droplet. This means that the
emission of neutral water molecules becomes less favorable on the droplet,
while the emission of H3O+ (i.e. protonated water) increases. This finding is
also consistent with a proton-rich environment at the droplet surface which
influences the ion generation and the dissociation pathways.

These results demonstrate that many of the ion fragments observed in reaction
nanoscopy on droplets appear to be generated similarly to positive-mode
electrospray ions, where protonation is known to be the main ion generation
mechanism [48].

###  4.5 Isomer comparison

The two isomers under investigation, 1,2-PDO and 1,3-PDO show overall a
similar fragmentation behavior for both, the gas-phase and the droplet ion
data. However, the production of one fragment, namely CH${}_{3}^{+}$, is
greatly enhanced for 1,2-PDO droplets as compared to droplets of the other
isomer. For the gas-phase data, the ratio of the relative yields of
CH${}_{3}^{+}$ from 1,2-PDO and 1,3-PDO is about 2:1 (Figure 5a, blue
rectangle). The lower production of CH${}_{3}^{+}$ from 1,3-PDO in this case
is likely a consequence of the absence of a methyl group in the 1,3-PDO
isomer, which makes the production of CH${}_{3}^{+}$ a more complex process as
compared to 1,2-PDO. A more pronounced difference between the two isomers is
observed in the droplet ion data. The CH${}_{3}^{+}$ yield ratio between the
isomers increases to a ratio of 6:1 for droplet ion emission compared to the
gas-phase case (Figure 5b, blue rectangle).

To better understand this effect, we carried out density functional theory
calculation for both isomers. Figure 5c shows the minimum energy configuration
of the 1,2-PDO interface obtained from DFT. We observe that the methyl groups
are pointing away from the interface towards the vacuum side. The three
topmost layers of the simulation cell are shown in the inset of Figure 5c
where the grey dotted lines represent the hydrogen bonding between neighboring
molecules. The equilibrium configuration is a result of a steric effect
between the methyl groups, which raises the energy, and hydrogen bonding
between OH groups, which stabilizes the system. These two effects compete with
each other, resulting in the methyl groups pointing outward. See the
supplementary material for further details on the steric effect in 1,2-PDO.
The equilibrium interface for 1,3-PDO is shown in Figure 5d. Unlike its
isomer, 1,3-PDO forms a linear chain, linked by hydrogen bonds between the OH
groups.

These theoretical results suggest that the experimentally observed difference
in the CH${}_{3}^{+}$ production from both isomers and especially the
enhancement for droplets is a direct consequence of the molecular alignment on
the droplet surface and the intermolecular hydrogen bonds.

##  5 Conclusion

In this study, we have demonstrated that the reaction nanoscopy technique can
be applied to examine the properties and the chemical composition of droplets.
Using droplets of propanediol, we have characterized the average droplet size
in our experiment by measuring the near-field tilt using the correlation
between the ion emission and the optical near-field on the droplet surface. We
have shown that the measured ion energy can be used to estimate the droplet
charge. We find that in all experiments, the total droplet charges were
significantly lower than the Rayleigh limit, indicating stable conditions at
the instance of ion emission. In addition to the physical characterization of
the droplets as a whole, we have analyzed the relative yield of ions emitted
from propanediol droplets and gas-phase propanediol. We found evidence for a
strong influence of the proton-rich droplet surface on the emitted ion
species. Moreover, we observed a threefold increase of the CH${}_{3}^{+}$
production on 1,2-propanediol droplets compared to 1,3-propanediol droplets.
Density functional theory revealed that this enhancement can be explained by
the molecular alignment of 1,2-propanediol molecules on the droplet surface.
These results show that reaction nanoscopy is a versatile tool for studying
ion emission from laser-ionized droplets. With its combination of spatial
resolution due to the near-field sensitivity and time resolution due to the
use of ultrashort-laser pulses, reaction nanoscopy may enable the spatio-
temporal observation of surface reactions on droplets in the future, opening
up new possibilities beyond conventional methods like electrospray mass
spectrometry.

#### Author contributions:

P.R., R.D. and W.Z. carried out the experiments. P.R. analyzed the
experimental data. A.M. provided the DFT calculations. M.N. operated the laser
system. P.R. and A.M. drafted the manuscript. M.I., B.B., and M.F.K.
supervised and coordinated the project. All authors reviewed the manuscript
and contributed to its completion.

The authors thank A.J. Feinberg for proofreading the manuscript and M. Graßl
for his feedback on the figures.

The experiments were carried out at LMU, where the work was supported by the
German Research Foundation (DFG). M.F.K. is grateful for partial support by
the Max Planck Society via the Max Planck Fellow program. M.F.K.’s work at
SLAC is supported by the U.S. Department of Energy, Office of Science, Basic
Energy Sciences, Scientific User Facilities Division and by the Chemical
Sciences, Geosciences, and Biosciences division with award DE-SC0063. W.Z.
acknowledges support from the Alexander von Humboldt Foundation and the
MULTIPLY fellowship program under the Marie Skłodowska-Curie COFUND Action.
A.M. and M.I. acknowledge the support by the U.S. Department of Energy, Basic
Energy Sciences, Gas Phase Chemical Physics program with award DE-SC0021129.

## References

  * [1] Jae Kyoo Lee, Shibdas Banerjee, Hong Gil Nam and Richard N. Zare  ``Acceleration of reaction in charged microdroplets''  In _Quarterly Reviews of Biophysics_ 48.4 Cambridge University Press, 2015, pp. 437–444  DOI: 10.1017/S0033583515000086
  * [2] Xin Yan, Ryan M. Bain and R. Cooks  ``Organic Reactions in Microdroplets: Reaction Acceleration Revealed by Mass Spectrometry''  In _Angewandte Chemie International Edition_ 55.42, 2016, pp. 12960–12972  DOI: 10.1002/anie.201602270
  * [3] Yin-Hung Lai, Shyam Sathyamoorthi, Ryan M. Bain and Richard N. Zare  ``Microdroplets Accelerate Ring Opening of Epoxides''  In _Journal of the American Society for Mass Spectrometry_ 29.5 American Society for Mass Spectrometry. Published by the American Chemical Society. All rights reserved., 2018, pp. 1036–1043  DOI: 10.1007/s13361-018-1908-z
  * [4] Manuel F. Ruiz-Lopez, Joseph S. Francisco, Marilia T.. Martins-Costa and Josep M. Anglada  ``Molecular reactions at aqueous interfaces''  In _Nature Reviews Chemistry_ 4.9, 2020, pp. 459–475  DOI: 10.1038/s41570-020-0203-2
  * [5] Benjamin J. Burris and Abraham K. Badu-Tawiah  ``Enzyme-Catalyzed Hydrolysis of Lipids in Immiscible Microdroplets Studied by Contained-Electrospray Ionization''  In _Analytical Chemistry_ 93.38, 2021, pp. 13001–13007  DOI: 10.1021/acs.analchem.1c02785
  * [6] Elizabeth C. Griffith and Veronica Vaida  ``In situ observation of peptide bond formation at the water-air interface''  In _Proceedings of the National Academy of Sciences_ 109.39, 2012, pp. 15697–15701  DOI: 10.1073/pnas.1210029109
  * [7] Christopher M. Dobson, G. Ellison, Adrian F. Tuck and Veronica Vaida  ``Atmospheric aerosols as prebiotic chemical reactors''  In _Proceedings of the National Academy of Sciences_ 97.22, 2000, pp. 11864–11868  DOI: 10.1073/pnas.200366897
  * [8] Ariel G. Gale, Tuguldur T. Odbadrakh, Benjamin T. Ball and George C. Shields  ``Water-Mediated Peptide Bond Formation in the Gas Phase: A Model Prebiotic Reaction''  In _Journal of Physical Chemistry A_ 124.20 American Chemical Society, 2020, pp. 4150–4159  DOI: 10.1021/acs.jpca.0c02906
  * [9] Honggang Nie, Zhenwei Wei, Lingqi Qiu, Xingshuo Chen, Dylan T. Holden and R. Cooks  ``High-yield gram-scale organic synthesis using accelerated microdroplet/thin film reactions with solvent recycling''  In _Chemical Science_ 11 The Royal Society of Chemistry, 2020, pp. 2356–2361  DOI: 10.1039/C9SC06265C
  * [10] Xiaoqin Zhong, Hao Chen and Richard N. Zare  ``Ultrafast enzymatic digestion of proteins by microdroplet mass spectrometry''  In _Nature Communications_ 11.1, 2020, pp. 1049  DOI: 10.1038/s41467-020-14877-x
  * [11] Abraham K. Badu-Tawiah, Dahlia I. Campbell and R. Cooks  ``Accelerated C–N Bond Formation in Dropcast Thin Films on Ambient Surfaces''  In _Journal of the American Society for Mass Spectrometry_ 23.9 American Society for Mass Spectrometry. Published by the American Chemical Society. All rights reserved., 2012, pp. 1461–1468  DOI: 10.1007/s13361-012-0394-y
  * [12] Ryan M. Bain, Christopher J. Pulliam and R. Cooks  ``Accelerated Hantzsch electrospray synthesis with temporal control of reaction intermediates''  In _Chemical Science_ 6 The Royal Society of Chemistry, 2015, pp. 397–401  DOI: 10.1039/C4SC02436B
  * [13] Marion Girod, Encarnacion Moyano, Dahlia I. Campbell and R. Cooks  ``Accelerated bimolecular reactions in microdroplets studied by desorption electrospray ionization mass spectrometry''  In _Chemical Science_ 2 The Royal Society of Chemistry, 2011, pp. 501–510  DOI: 10.1039/C0SC00416B
  * [14] Brett M. Marsh, Kiran Iyer and R. Cooks  ``Reaction Acceleration in Electrospray Droplets: Size, Distance, and Surfactant Effects''  In _Journal of The American Society for Mass Spectrometry_ 30.10, 2019, pp. 2022–2030  DOI: 10.1007/s13361-019-02264-w
  * [15] Yafeng Li, Xin Yan and R. Cooks  ``The Role of the Interface in Thin Film and Droplet Accelerated Reactions Studied by Competitive Substituent Effects''  In _Angewandte Chemie International Edition_ 55.10, 2016, pp. 3433–3437  DOI: 10.1002/anie.201511352
  * [16] Hanqing Xiong, Jae Kyoo Lee, Richard N. Zare and Wei Min  ``Strong Concentration Enhancement of Molecules at the Interface of Aqueous Microdroplets''  In _Journal of Physical Chemistry B_ 124.44, 2020, pp. 9938–9944  DOI: 10.1021/acs.jpcb.0c07718
  * [17] Yousung Jung and R.. Marcus  ``On the Theory of Organic Catalysis “on Water”''  In _Journal of the American Chemical Society_ 129.17, 2007, pp. 5492–5502  DOI: 10.1021/ja068120f
  * [18] Taghi Sahraeian, Dmytro S. Kulyk and Abraham K. Badu-Tawiah  ``Droplet Imbibition Enables Nonequilibrium Interfacial Reactions in Charged Microdroplets''  In _Langmuir_ 35.45, 2019, pp. 14451–14457  DOI: 10.1021/acs.langmuir.9b02439
  * [19] Shibdas Banerjee and Richard N. Zare  ``Syntheses of Isoquinoline and Substituted Quinolines in Charged Microdroplets''  In _Angewandte Chemie International Edition_ 54.49, 2015, pp. 14795–14799  DOI: 10.1002/anie.201507805
  * [20] Kai-Hung Huang, Zhenwei Wei and R. Cooks  ``Accelerated reactions of amines with carbon dioxide driven by superacid at the microdroplet interface''  In _Chemical Science_ 12 The Royal Society of Chemistry, 2021, pp. 2242–2250  DOI: 10.1039/D0SC05625A
  * [21] Hanqing Xiong, Jae Kyoo Lee, Richard N. Zare and Wei Min  ``Strong Electric Field Observed at the Interface of Aqueous Microdroplets''  In _Journal of Physical Chemistry Letters_ 11.17, 2020, pp. 7423–7428  DOI: 10.1021/acs.jpclett.0c02061
  * [22] Victor Kwan and Styliani Consta  ``Bridging electrostatic properties between nanoscopic and microscopic highly charged droplets''  In _Chemical Physics Letters_ 746, 2020, pp. 137238  DOI: 10.1016/j.cplett.2020.137238
  * [23] Hongxia Hao, Itai Leven and Teresa Head-Gordon  ``Can electric fields drive chemistry for an aqueous microdroplet?''  In _Nature Communications_ 13.1, 2022, pp. 280  DOI: 10.1038/s41467-021-27941-x
  * [24] Conner C. Harper, Daniel D. Brauer, Matthew B. Francis and Evan R. Williams  ``Direct observation of ion emission from charged aqueous nanodrops: effects on gaseous macromolecular charging''  In _Chemical Science_ 12 The Royal Society of Chemistry, 2021, pp. 5185–5195  DOI: 10.1039/D0SC05707J
  * [25] Lars Konermann, Elias Ahadi, Antony D. Rodriguez and Siavash Vahidi  ``Unraveling the Mechanism of Electrospray Ionization''  In _Analytical Chemistry_ 85.1, 2013, pp. 2–9  DOI: 10.1021/ac302789c
  * [26] Christian Lübbert and Wolfgang Peukert  ``Characterization of Electrospray Drop Size Distributions by Mobility-Classified Mass Spectrometry: Implications for Ion Clustering in Solution and Ion Formation Pathways''  In _Analytical Chemistry_ 93.38, 2021, pp. 12862–12871  DOI: 10.1021/acs.analchem.1c00727
  * [27] Lord Rayleigh F.R.S.  ``XX. On the equilibrium of liquid conducting masses charged with electricity''  In _The London, Edinburgh, and Dublin Philosophical Magazine and Journal of Science_ 14.87 Taylor & Francis, 1882, pp. 184–186  DOI: 10.1080/14786448208628425
  * [28] Philipp Rupp et al.  ``Few-cycle laser driven reaction nanoscopy on aerosolized silica nanoparticles''  In _Nature Communications_ 10.1, 2019, pp. 4655  DOI: 10.1038/s41467-019-12580-0
  * [29] Philipp Rosenberger et al.  ``Near-Field Induced Reaction Yields from Nanoparticle Clusters''  In _ACS Photonics_ 7.7, 2020, pp. 1885–1892  DOI: 10.1021/acsphotonics.0c00823
  * [30] Wenbin Zhang et al.  ``All-optical nanoscopic spatial control of molecular reaction yields on nanoparticles''  In _Optica_ 9.5 Optica Publishing Group, 2022, pp. 551–560  DOI: 10.1364/OPTICA.453915
  * [31] M. Alghabra et al.  ``Anomalous formation of trihydrogen cations from water on nanoparticles''  In _Nature Communications_ 12.1, 2021, pp. 3839  DOI: 10.1038/s41467-021-24175-9
  * [32] Gustav Mie  ``Beiträge zur Optik trüber Medien, speziell kolloidaler Metallösungen''  In _Annalen der Physik_ 330.3, 1908, pp. 377–445  DOI: 10.1002/andp.19083300302
  * [33] M. Neuhaus et al.  ``10 W CEP-stable few-cycle source at 2 $\mu$m with 100 kHz repetition rate''  In _Optics Express_ 26.13 OSA, 2018, pp. 16074–16085  DOI: 10.1364/OE.26.016074
  * [34] H. Bresch  ``Photoionisation von freien Aerosolpartikeln mit Synchrotronstrahlung'', 2007, pp. 74  DOI: 10.17169/refubium-6727
  * [35] Philipp Rosenberger et al.  ``Imaging elliptically polarized infrared near-fields on nanoparticles by strong-field dissociation of functional surface groups''  In _European Physical Journal D_ 76.6 Springer ScienceBusiness Media LLC, 2022  DOI: 10.1140/epjd/s10053-022-00430-6
  * [36] J Ullrich, R Moshammer, A Dorn, R Dörner, L Ph H Schmidt and H Schmidt-Böcking  ``Recoil-ion and electron momentum spectroscopy: reaction-microscopes''  In _Reports on Progress in Physics_ 66.9 IOP Publishing, 2003, pp. 1463–1545  DOI: 10.1088/0034-4885/66/9/203
  * [37] G. Kresse and J. Hafner  ``Ab initio molecular dynamics for liquid metals''  In _Physical Review B_ 47 American Physical Society, 1993, pp. 558–561  DOI: 10.1103/PhysRevB.47.558
  * [38] Jürgen Hafner  ``Ab-initio simulations of materials using VASP: Density-functional theory and beyond''  In _Journal of Computational Chemistry_ 29.13, 2008, pp. 2044–2078  DOI: 10.1002/jcc.21057
  * [39] Frank Jensen  ``Introduction to Computational Chemistry, 3rd Edition''  John Wiley & Sons, 2017
  * [40] John P. Perdew, Kieron Burke and Matthias Ernzerhof  ``Generalized Gradient Approximation Made Simple''  In _Physical Review Letters_ 77 American Physical Society, 1996, pp. 3865–3868  DOI: 10.1103/PhysRevLett.77.3865
  * [41] P.. Blöchl  ``Projector augmented-wave method''  In _Physical Review B_ 50 American Physical Society, 1994, pp. 17953–17979  DOI: 10.1103/PhysRevB.50.17953
  * [42] Evelyne A. Parmentier, Grégory David, Pablo Corral Arroyo, Simone Bibawi, Kıvanç Esat and Ruth Signorell  ``Photochemistry of single optically trapped oleic acid droplets''  In _Journal of Aerosol Science_ 151, 2021, pp. 105660  DOI: 10.1016/j.jaerosci.2020.105660
  * [43] Craig F. Bohren and Donald R. Huffman  ``Absorption and Scattering of Light by Small Particles''  John Wiley & Sons, Ltd, 1998, pp. 82–129  DOI: 10.1002/9783527618156.ch4
  * [44] Lars Konermann  ``A Simple Model for the Disintegration of Highly Charged Solvent Droplets during Electrospray Ionization''  In _Journal of the American Society for Mass Spectrometry_ 20.3, 2009, pp. 496–506  DOI: 10.1016/j.jasms.2008.11.007
  * [45] U. Näher, S. Bjørnholm, S. Frauendorf, F. Garcias and C. Guet  ``Fission of metal clusters''  In _Physics Reports_ 285.6, 1997, pp. 245–320  DOI: 10.1016/S0370-1573(96)00040-3
  * [46] Denis Duft, Tobias Achtzehn, Rene Müller, Bernd A. Huber and Thomas Leisner  ``Rayleigh jets from levitated microdroplets''  In _Nature_ 421.6919, 2003, pp. 128–128  DOI: 10.1038/421128a
  * [47] Leland C. Allen  ``Electronegativity is the average one-electron energy of the valence-shell electrons in ground-state free atoms''  In _Journal of the American Chemical Society_ 111.25 American Chemical Society (ACS), 1989, pp. 9003–9014  DOI: 10.1021/ja00207a003
  * [48] Shibdas Banerjee and Shyamalava Mazumdar  ``Electrospray ionization mass spectrometry: a technique to access the information beyond the molecular weight of the analyte''  In _International Journal of Analytical Chemistry_ 2012 Hindawi Publishing Corporation, 2012, pp. 282574  DOI: 10.1155/2012/282574


2Ai, School of Technology, IPCA, Barcelos, Portugal and
https://ambs.zbr.ptasimoes@ipca.pthttps://orcid.org/0000-0001-6961-2660 CRACS,
INESC-Porto LA, Portugal and uniMAD, ESMAD, P.PORTO, Portugal and
http://www.ricardoqueiros.com
ricardoqueiros@esmad.ipp.pthttps://orcid.org/0000-0002-1985-6285 Alberto
Simões and Ricardo Queirós <ccs2012> <concept>
<concept_id>10010405.10010489</concept_id> <concept_desc>Applied computing
Education</concept_desc> <concept_significance>500</concept_significance>
</concept> </ccs2012> [500]Applied computing Education This work was partly
founded by Portuguese national funds (PIDDAC), through the FCT – Fundação para
a Ciência e Tecnologia and FCT/MCTES under the scope of the project
UIDB/05549/2020. John Q. Open and Joan R. Access 2 42nd Conference on Very
Important Topics (ICPEC 2020) ICPEC 2020 CVIT 2016 December 24–27, 2016 Little
Whinging, United Kingdom 42 23

# On the Nature of Programming Exercises

Alberto Simões  Ricardo Queirós

###### Abstract

There are countless reasons cited in scientific studies to explain the
difficulties in programming learning. The reasons range from the subject’s
complexity, the ineffective teaching and study methods, to psychological
aspects such as demotivation. Still, learning programming often boils down to
practice on exercise solving. Hence, it is essential to understand that the
nature of a programming exercise is an important factor for the success and
consistent learning.

This paper explores different approaches on the creation of a programming
exercise, starting with realizing how it is currently formalized, presented
and evaluated. From there, authors suggest variations that seek to broaden the
way an exercise is solved and, with this diversity, increase student
engagement and learning outcome. The several types of exercises presented can
use gamification techniques fostering student motivation. To contextualize the
student with his peers, we finish presenting metrics that can be obtained by
existing automatic assessment tools.

###### keywords:

Programming Exercises, Computer Science, Automatic Evaluation, Programming
Challenges

###### keywords:

computer programming learning, programming exercises, gamification

##  1 Introduction

There is an unanimity regarding the difficulties founded in the teaching-
learning process of computer programming. These difficulties are emphasized
mainly in introductory teaching, where novice students often lack the
knowledge of fundamental programming constructs. Another explanation is that
students, despite being familiar with the constructs, lack the ability of
“problem solving” [9]. Other studies focus on social aspects, since novice
students usually have their introductory programming classes in one of the
most difficult periods of their life, that is, at the beginning of a higher
education course in computer science, coinciding with a period of transition
and instability in their life. There are even authors who consider that the
programming courses are not well located in standard computer programming
degrees curricula [1, 2].

In recent years, computer programming training environments appeared with the
goal of helping users to learn programming. The methodology used focus on
solving problems from scratch. Nevertheless, initiating the resolution of a
program can be frustrating and demotivating if the student does not know where
and how to start. Based on this fact, some training environments appeared with
the support for skeleton programming which facilitates a top-down design
approach, where a partially functional system with complete high-level
structures is available. So, the student needs only to progressively complete
or update the code to meet the requirements of the problem. Despite its
promising results, there are few environments that vary their exercise types
in order to motivate novice students and keep them focused.

This paper starts by presenting the life cycle of a programming exercise: how
it is formalized, how it is presented to the student and how a student’s
solution is evaluated. Then, the study explores other ways to challenge the
student avoiding the “create from scratch” assignment.

The rest of the paper is structured as follows: Section 2 explores the current
state regarding programming exercise formalization and evaluation. Follows
Section 3 where different approaches to construct a programming exercise are
analyzed. Finally, the main contributions of the paper and possible paths for
future developments are presented.

##  2 Programming Exercises

The way a programming exercise is formalized and evaluated is crucial for
computer programming practice. In the following subsections we discuss both.

###  2.1 Formalization

Until two decades ago, programming assignments were created and presented to
students in a _ad hoc_ fashion. The increasing popularity of programming
contests worldwide resulted in the creation of several contest management
systems. At the same time Computer Science courses use programming exercises
to encourage the practice of programming. The interoperability between these
type of system is becoming a topic of interest in the scientific community. In
order to address these interoperability issues several formats to represent
computer science exercises were developed [6]. As notable examples we can
found KATTIS [3],
FreeProblemSet111https://github.com/davideuler/freeproblemset, Mooshak
Exchange Format [4], PExIL [7] and YAPeXIL.

The majority of the formats, despite the syntactically differences, adhere to
the same logic in terms of structure. They are based in a XML manifest file
referring several types of resources such as problem statements (e.g. PDF or
HTML documents), images, input/output test files, validators (static or
dynamic) and solution implementations. Recently, the YAPExIL, based on PExIL,
break these similarities changing the serialization format to JSON and
supporting different types of programming exercises such as solution
improvement, bug fix, gap filling, block sorting, and spot the bug222These
types of problems will be discussed in depth in Section 3..

In terms of semantics, all the formats allow the inclusion of:

  * •

metadata: data providing information about the exercise. Usually used for
discovery actions in repositories;

  * •

instructions: text that is presented to the student (e.g., statement,
instructions, skeleton code). This data is commonly presented to the student
in playground (or training) environments;

  * •

tests: data which is used by the assessment tools to evaluate the student’s
code. The most common data in this category is a set of tests (usually as
input/output pairs) and a working solution;

  * •

tools: tools that the author may use to generate data (e.g. feedback and tests
generators, plagiarism tools).

In Fig. 1 the four facets and potential tools which will consume the facet
data are presented.

Figure 1: Anatomy of a programming exercise.

###  2.2 Evaluation

The standard way of evaluating a program is to compile it and then execute it
with a set of test cases, comprised of pairs of input/output files. The
submitted program is accepted if it compiles without errors and the output of
each run is what is expected. This is called of dynamic evaluation.

Another approach, is using static evaluation tools that, instead of executing
the student’s code and injecting input data, analyzes the code and a
predefined set of metrics is computed. In this context, the presence of a
particular keyword or code block, the style of the code (e.g. variable naming
convention), the presence of comments or even the application of a certain
algorithm can be verified. For this type of analysis _linters_ , or other
static analysis tools are generally used.

There are several systems that fits on this category such as
DOMJudge333https://www.domjudge.org/, Mooshak444https://mooshak.dcc.fc.up.pt/,
PC2555https://pc2.ecs.csus.edu/ and DMOJ666https://dmoj.ca/.

Most of these systems are contest management systems in the web. They allow
the creation of creating problems, whose solutions can be written in different
programming languages, and have mechanisms to judge automatically the
solutions providing (web)interfaces for teams, the jury and the general
public. Some of them (Mooshak and DOMJudge) also provide a REST API to allow
their internal functions to be used in other scenarios. All of them are free
and open source making them easy to adapt for each one needs.

##  3 Types of Programming Exercises

There are different approaches to create a programming exercise, depending on
what is asked as task for the student, but also in the way the assignment is
evaluated and graded. In this section we will first present the different ways
a programming exercise can be presented to the student, and what are the main
goals of that exercise, and their pros and cons. In some cases examples of
application will be discussed. It is followed by an overview of different ways
an exercise can be graded, according to the objective. Finally, we will also
discuss different ways to give feedback to the students about their
performance.

###  3.1 Exercise types

While a programming exercise can be presented in very different ways, there
are some that are traditional and widely used, while some other are rarely
applied. These types of exercise not only present a different challenge to the
student, but also can be more or less adequate for some specific type of
evaluation. And, unfortunately, some types of exercises can take some time for
the teacher to prepare.

#### Code from Scratch

This is the common approach. Easy for the teacher to prepare, as only a
statement of a problem is needed. A test suite to evaluate the student’s
answer is needed just in the case of using an automatic evaluation tool.

For the students, they have a blank sheet, and they will need to code from
scratch. In the student’s point of view, this is the worst problem situation.
Just like a writer or a painter, they may have the blank page syndrome. There
is no indication of where to start. Students can start focusing on the main
algorithm to solve the problem, but some students will start with the
auxiliary/irrelevant code that is needed, and try to focus later (and probably
too late) in the code that the teacher wants to evaluate.

In some situations, like when teaching Object Oriented Programming (for
example using Java or C#), and particularly in the first classes, asking the
student to write a static class to be able to write a static main function is
counter intuitive, and breaks the Object Orientation logic.

#### Code Skeleton

To alleviate the blank page syndrome, and make the student focus on the piece
of code being evaluated, the solution is to present a code skeleton, with some
blanks to fill in. These can be simple function calls up to complete function
or method bodies. Depending on the way this type of problem is presented to
the student, the main part of the application might be hidden, and the student
will never see the big picture. While this can seem like a bad thing, the fact
that the student can focus is a great benefit. The skeleton programs will
accelerate the beginning of exercises resolution and facilitate their problem
understanding. With the structure included, students can now focus on the core
of the problem and abstract their foundations.

As for the teacher, further work is needed. Teachers will need to write the
code skeleton, and present the students with a clear interface, knowing
exactly what is available at that point in the program. For complex exercises,
teachers might need to write a full solution before being able to understand
what pieces of code are to be developed by the student.

#### Fill the Blanks

Similar to the previous approach, but with smaller blank sections. Students
will not need to write full lines or blocks of code, but rather fill in some
portions of it. These blanks can be open, allowing the student to write
whatever they want, or a predefined list, asking the students to use one of
the provided options to fill the blank.

This second approach can be interesting if the students do not have the
possibility to run the code, and are presented with very similar options, that
will force to really understand what they are performing, without being able
to test the code.

In fact, asking students to solve programming tasks without the ability to
compile or run their code is relevant, as current compilation times are so
fast, that students tend to try all the options/combinations possible for a
specific algorithm in order to find the right answer (brute force
programming).

#### Code Baseline

While in the previous approach the teacher will leave concrete instructions on
what code needs to be written, with a code baseline, students will have access
to a fully working solution. This working solution might solve the problem for
specific values, and students will need to work their code to get a better
solution.

This approach is very useful for (but not limited to) teaching how to
implement machine learning tools. The teacher can include a solution with a
precision baseline, asking the students to accomplish better.

Having a fully working solution, students feel more comfortable as they do not
need to write their code from scratch, and feel empowered, as they have a
working solution. Nevertheless, to start changing the code to get better
results, students will need to understand the provided code, and that can be a
challenging task, especially if the supplied code is not well documented, or
the student is not directed to the code function he needs to change.

As a side benefit from this approach, gamification is implicit. If there is
feedback on how well the student’s solution is performing, they will quickly
try to beat their friends solutions.

#### Find the Bug

In this type of exercise the student is asked to merely find the bug (or bugs)
for a presented solution. These exercises are used to make students understand
an algorithm logic. If the students are in a condition where they cannot
compile and test the solution, this is a very interesting approach, as the
student is not asked to fix the code.

#### Buggy Code

Students do not like to rewrite code, trying to make it faster, more elegant,
bug free or more generic. The “Find the Bug” type of exercise is a good way to
force students to read other’s code, understand it, and change it. They are
provided a buggy solution, and need to fix it.

The types of bugs introduced in the solution can be of different type
accordingly with the exercise objectives:

  * •

compilation errors: specific syntactic problems are present, like wrong
variable types, missing castings, wrong function names, parameter order, etc.

  * •

logic errors: the algorithm has serious flaws, and the student needs to detect
them. If properly created, these errors can be useful to force the student to
understand specific details of an algorithm.

  * •

solution errors: the algorithm is mostly working, but have some problems in
corner cases. This is similar to the “Baseline” approach, but rather than
trying to raise the coverage, precision or accuracy of the solution, the
student is asked to make the buggy code work on specific test cases.

#### Compiling Errors

With the spread of intelligent IDEs, students get used to look to the code
suggestions, and very little to the compiler output. An interesting exercise
to force students to look and understand how compilers analyse the code, and
how they report syntax errors, is to present the student with a snippet of
code with a syntax error, and the compiler message. This would be especially
interesting if the code snippet is not possible to compile isolated (it uses
unknown methods) and if the implementation goal is not described. This will
force the student to look carefully to the error message, and to parse the
code himself.

#### Code Interpretation

Just like reading compilation error logs, students lack the ability to
understand code. A simple approach to force students to read and interpret an
algorithm is to present the student with a snippet of code, and a set of
options of behaviour. The behaviour can be a description of the algorithm
goal, or just information about compilation error messages, or faulty
behavior. This kind of exercise is interesting if the code is done in a way
the student is not able to copy it and run in a compiler to test it, for
example, using non defined functions described by text.

#### Keyword Use

This option is an add-on to some specific type of exercises, like the
implementation of code from scratch or the development of a specific function
or line of code. In this add-on, the teacher specifies the use of a specific
keyword. As an example, the teacher may require the student to use a map
function for a functional style solution to a specific problem, instead of
implementing it as a loop. The main problem on this approach is the automatic
evaluation, because it can not be just a pattern match, as students might use
comments to put there the keyword, or include the keyword in void context,
where it does not affect the behaviour of the code. Therefore, the better
approach is to instrument the original function in order to log what was its
input, and test there it was implemented correctly. The ability to do this
kind of instrumentation will depend largely on the used programming language.

###  3.2 Exercise gamification modes

If different types of exercise test the students knowledge in different
situations, gamification increases motivation, challenging their knowledge.
Gamification can be introduced just with a ranking on the number, on how many
problems were solved by each student, or by assigning (different) points to
(different) problems. But this is a rather limited approach to Gamification.
Gamification can be used to challenge students to solve a solution in a
specific way, and therefore, being not just useful for motivation, but also
for learning [8].

We will discuss how different approaches of gamification can be used to foster
learning, and defy students.

#### Slender / Golf

Instead of just grading a solution accordingly with their result, evaluate the
number of characters, instructions, or lines used to solve the problem. In
some programming language communities like the Perl Community [5] this is seen
like a sport, known as Golf or Golfing.

While this challenge is funny, it can be counterproductive. Shorter solutions
are usually ugly, difficult to maintain, and explore obscure details of the
host programming language. Therefore, while this kind of evaluation can be
used with students, it should not be their main goal.

#### Sprinter

Efficiency is something students should understand and be able to reach.
Teaching them Program Complexity is tedious and non attractive. But if
students are challenged to write a fast solution for a problem, they will need
to understand the efficiency of different algorithms and data structures in
order to score.

If the solutions are run on a specific hardware (like a server responsible for
evaluating the answers), the teacher can prepare a good solution, time it, and
define a threshold execution time, forcing students to get their running time
below that value.

#### Economic

Parallel to the Sprinter approach, students are rewarded by the amount of
memory they use. Nowadays, given the large amount of memory available on
personal computers, students do not have the care to use and reuse memory.

For instance, when teaching the C programming language, it is hard to teach
students when they can free memory. This leads to solutions where memory is
never freed. Computing the maximum amount of memory used by the solution
application during a complete run can be used as a mechanism to motivate
students to try to free up memory whenever they do not need it.

#### Sedulous

Students with learning difficulties can demotivate easily, as they see other
students being able to accomplish working and probably fast and economic
solutions. Rewarding students that attempt to solve a problem more than a
fixed amount of tries can be motivational. Of course that the grading system
should be able to understand if those are honest attempts or if the student is
just trying to send always one wrong solution just to be rewarded.

#### Scout

Provides a bonus reward when the student makes several tests to check his
solution, before submitting. This is not something that can be easily
accounted for automatically. A good alternative is to give a bonus to the
student if it passes all the tests with the first submitted solution.

#### Meticulous

Sometimes there are different ways to accomplish a working solution, and the
number of lines, the code efficiency or amount of used memory is not enough to
distinguish the chosen solution approach. With this in mind, teachers can
define a set of specific keywords or function/methods that will give a bonus
to the student’s solution.

The main problem for this solution is the possibility of cheating. If the
student gets aware that a specific keyword is being checked, he might just
write that keyword in a comment, or in a void context, where it is not exactly
being used as it should. A way to circumvent this cheating approach is to hide
to the student how the grading system works, or to define a wrapper to the
functions being tested, that evaluate how they are being used in the student’s
solution.

###  3.3 Exercise Statistics

In the previous section we presented some ways to grade students accordingly
with different factors that do not relate necessarily with the correctness of
the solution. Teachers might not want to use all of those grading approaches
at the same time. Nevertheless, computing statistics on some of the presented
factors, and showing them to the students can work, indirectly, as
gamification.

Thus, it is suggested to add solution metrics regarding each problem submitted
solutions. Follow some simple examples:

  * •

Average Solution Time: how much time a student takes to prepare a solution,
starting from the moment the problem description was seen, up to a good
solution to be submitted. This will allow students to understand how they
relate with their mates, and will allow the teacher to understand how his
students problem solving abilities are.

  * •

Wrong Attempts Average: how many attempts (in average) a student performs,
before getting the solution accepted. If this number is high, students might
not have understood the problem correctly, or they are trying at force to get
a solution, instead of really thinking in a good approach.

  * •

Least Memory Used: who is the student having the solution using less memory
for each problem.

  * •

Shortest Execution Time: who is the student having the fastest solution.

  * •

Average Execution Time: what is the average execution time for a specific
problem solutions.

##  4 Conclusions

Learning programming is a difficult task. Many reasons have been shared among
the scientific community. However, it is important not to forget, that
learning programming requires constant practice. In programming, this practice
boils down to solving exercises, often from scratch. While this could be
simple for average and expert students, for novice students this approach can
negatively affect his performance in the course and, consequently, increase
their demotivation. Therefore, this paper describes several types of exercises
in order to cover different learning profiles and enhance new skills. This
diversity is seen by the authors as beneficial to not making the challenges
tedious for more advanced students and to support novice students to
consolidate their skills.

As future work, the authors will try to explore simple ways to facilitate the
process of changing an exercise type through standard and non-language
dependent techniques.

## References

  * [1] Anabela Gomes, Cristiana Areias, Joana Henriques, and António José Nunes Mendes.  Aprendizagem de programação de computadores: dificuldades e ferramentas de suporte.  Revista Portuguesa de Pedagogia, 42:161–179, 2008.
  * [2] Tony Jenkins.  On the difficulty of learning to program.  In 3rd Annual LTSN-ICS Conference, pages 53–58, 2002.
  * [3] Kattis.  Kattis, 2019.  accessed on Jan 2020.  URL: https://open.kattis.com/.
  * [4] José Paulo Leal and Fernando Silva.  Mooshak: A web-based multi-site programming contest system.  Softw. Pract. Exper., 33(6):567–581, May 2003.  URL: https://doi.org/10.1002/spe.522, doi:10.1002/spe.522.
  * [5] Jon Orwant.  Games Diversions & Perl Culture: Best of the Perl Journal.  O’Reilly Media, 2004.
  * [6] Ricardo Queirós and José Paulo Leal.  Babelo - an extensible converter of programming exercises formats.  TLT, 6(1):38–45, 2013.  URL: https://doi.org/10.1109/TLT.2012.21, doi:10.1109/TLT.2012.21.
  * [7] Ricado Queirós and Jose Paulo Leal.  Making programming exercises interoperable with PExIL.  In Jose Carlos Ramalho, Alberto Simões, and Ricardo Queirós, editors, Innovations in XML Applications and Metadata Management: Advancing Technologies, pages 38–56. IGI Global, 2013.
  * [8] Jakub Swacha, Ricardo Queirós, José Carlos Paiva, and José Paulo Leal.  Defining requirements for a gamified programming exercises format.  In Imre J. Rudas, János Csirik, Carlos Toro, János Botzheim, Robert J. Howlett, and Lakhmi C. Jain, editors, Knowledge-Based and Intelligent Information & Engineering Systems: Proceedings of the 23rd International Conference KES-2019, Budapest, Hungary, 4-6 September 2019, volume 159 of Procedia Computer Science, pages 2502–2511. Elsevier, 2019.  URL: https://doi.org/10.1016/j.procs.2019.09.425, doi:10.1016/j.procs.2019.09.425.
  * [9] Jacqueline L. Whalley, Raymond Lister, Errol Thompson, Tony Clear, Phil Robbins, P. K. Ajith Kumar, and Christine Prasad.  An australasian study of reading and comprehension skills in novice programmers, using the bloom and solo taxonomies.  In Proceedings of the 8th Australasian Conference on Computing Education - Volume 52, ACE ’06, page 243–252, AUS, 2006. Australian Computer Society, Inc.