### Simulation methods

The water meniscus formation inside the container is studied using a 2D lattice gas model that has been extensively used to study water properties, including gas-liquid transition and density anomalies. This model has been also used to describe the geometry features of the water meniscus formed between an AFM tip and a substrate [9]. The fluid is represented by a 2D square lattice with a spacing of 0.3 nm. In the model, we may assume thermal and phase equilibrium with a bulk reservoir, specified by a temperature *T* and a chemical potential *μ*. These quantities are directly related to the relative humidity *R*_{
h
} through the expression *R*_{
h
}=exp(*μ*−*μ*_{
c
})/*k*_{B}*T*, being *k*_{B} the Boltzmann constant and *μ*_{c} the critical chemical potential. We have performed a (*V*,*T*,*μ*) Monte Carlo (MC) numerical simulation at laboratory conditions, *T*=293 K, assuming that each lattice site (*i*,*j*) was either occupied with a water molecule *ρ*(*i*,*j*)=1 (liquid phase) or empty *ρ*(*i*,*j*)=0 (gas phase). The quantity *ρ*(*i*,*j*) is the occupation number of a given site (*i*,*j*). Each water-occupied site interacts with its (occupied) neighbor sites with an attractive energy *∈* = 9 kJ/mol. This value has been chosen in order to use a model able to fit the value of the water critical temperature. The interaction of tip and nanocontainer with a water molecule involves an interaction energy given by *b*_{
T
}=−56 kJ/mol (hydrophilic character). The substrate has a repulsive interaction with water given by |*b* *s*| = 46 kJ/mol (hydrophobic character). The conditions considered correspond to equilibrium bulk evaporation. The concrete expression of the Hamiltonian we have considered is reported in [5] and includes water-water, water-tip, and water-substrate terms. For a given set of geometrical parameters and physical conditions (temperature and humidity), an approximate shape of the water meniscus is obtained from an averaging procedure involving hundreds of different configurations. Water density average at each lattice site (0<<*ρ*(*i*,*j*)><1) was calculated after the statistical methodology described in [4]. Once <*ρ*(*i*,*j*)> was known for every site of the 2D square lattice, the effective refractive index *n*(*i*,*j*) at a given site is calculated, assuming that there is a linear dependence (*n*(*i*,*j*)=1+0.33<*ρ*(*i*,*j*)>) between the refractive index and the average water density [10]. This methodology allows to determine the meniscus shape as well as the associated refractive index map for a given set of parameters (tip-sample distance, temperature, and humidity).

The local refractive index *n*(*i*,*j*) determines the propagation of the optical signal through the tip-sample-substrate system. The propagation of the electromagnetic radiation was studied by means of a 2D finite difference time domain (FDTD) simulation, based on Yee algorithm [11]*], with a perfect matching layer as boundary condition [*[12]. Transverse Magnetic to the z direction fundamental mode is propagated through the dielectric coated fiber guide with frequency *ν*=3.77×10^{15} Hz (*λ*=500 nm). Radiated intensity, at transmission, is integrated at a plane surface, acting as light collector, located at a distance *D*=100 nm from the substrate. In our study, all intensities are normalized to that one obtained without any substrate. Since the lattice parameter used in the MC simulations is too small for being considered in feasible FDTD simulations, a larger integration lattice constant is required. In order to match FDTD lattice constant with the one used in the lattice gas simulation, a lattice step of 0.9 nm was considered for the FDTD simulations. In this way, the refractive index for each FDTD node was obtained by averaging those local refractive index values corresponding to the water nodes included within the FDTD cell. General assumptions were taken into account for the simulation. Indeed, all water necks calculated at equilibrium were considered to be stable during the typical times associated to the wave propagation; furthermore, we have neglected SNOM probe oscillations near the sample. In addition, water heating processes are not considered since radiation wavelength is far from those corresponding to water absorption bands.