Extracting viscoelastic material parameters using an atomic force microscope and static force spectroscopy

Atomic force microscopy (AFM) techniques have provided and continue to provide increasingly important insights into surface morphology, mechanics, and other critical material characteristics at the nanoscale. One attractive implementation involves extracting meaningful material properties, which demands physically accurate models specifically designed for AFM experimentation and simulation. The AFM community has pursued the precise quantification and extraction of rate-dependent material properties, in particular, for a significant period of time, attempting to describe the standard viscoelastic response of materials. AFM static force spectroscopy (SFS) is one approach commonly used in pursuit of this goal. It is capable of acquiring rich temporal insight into the behavior of a sample. During AFM-SFS experiments the cantilever base approaches samples with a nearly constant velocity, which is manipulated to investigate different timescales of the mechanical response. This manuscript seeks to build upon our previous work and presents an approach to extracting useful linear viscoelastic information from AFM-SFS experiments. In addition, the basis for selecting and restricting the model parameters for fitting is discussed from the perspective of applying this technique on a practical level. This work begins with a guided discussion that develops a fit function from fundamental laws, continues with conditioning a raw SFS experimental dataset, and concludes with the fit and prediction of viscoelastic response parameters such as storage modulus, loss modulus, loss angle, and compliance. These steps constitute a complete guide to leveraging AFM-SFS data to estimate key material parameters, with a series of detailed insights into both the methodology and supporting analytical choices.


AFM SFS Viscoelastic Parameter Inversion Script (MATLAB)
The scripts included in this directory will perform the data conditioning and analysis required to fit viscoelastic model parameters to Atomic Force Microscope (AFM) Static Force Spectroscopy (SFS) datasets. They have been submitted as supplemental materials for a manuscript, titled "Extracting Viscoelastic Material Parameters using an Atomic Force Microscope and Static Force Spectroscopy". For further details on the methods and analytical justifications, please direct your attention to that paper.

Running the Script
First, the primary MATLAB script (ParameterExtraction.m) must be opened and run.
Second, the user will be prompted to select the directory where their AFM SFS files reside. These files must either follow one of the pre-programmed formats, or the user must implement an additional "case" for the switch functions on lines 45 and 83. The filenames must contain the approach velocity, position number, and run number for that particular dataset. For example, when using one of the builtin naming conventions, the filenames could be formatted as such:  FD_Point Number_Run Number_Velocity.ibw  ELopez_Point Number_Run Number_Velocity.ibw  ELopezSim_Point Number_Run Number_Velocity.txt The underscore-separation and variable location must be kept consistent. In addition, the user should replace periods "." in the velocity with hyphens "-" to separate integers from decimals. If a different filetype needs to be used, the user must evaluate which functions are available in MATLAB natively or on the MATLAB exchange to open that filetype and extract the raw data.
The purpose for including ELopez and ELopezSim is for the user to utilize supplemental data and simulation files provided by Lopez et al. with their manuscript, which can be found on Github here.
A test directory has been included here (/TestFiles/), which contains properly formatted filenames for experiments with an approach velocity of 1000 nm/s.

Settings
Currently, the script generates figures but does not save them programmatically. There are a variety of points where the authors have included "saveas" and "savefig" functions to allow users to save their matlab figures in a local directory, called TempFigs. If the user does not wish to save in TempFigs, an alternative link must be provided to these functions and the directory must already exist before running the script.
Once the data has been initally conditioned and then plotted for clarity, the user will be prompted to enter a series of values:

"Please enter the radius of the indenter in nanometers"
This value must be an integer, and be in the range 0 < r < 10,000.
If the input is not valid (for this and other settings), the user will be prompted to enter a new, valid setting. For a 10 nm tip radius, the user would simply type "10" and hit enter to continue.

"Please enter the number of voigt terms you would like to use (1-5)"
This value must be an integer, and be in the range 1 <= n <= 5. This script has been geared towards utilizing a generalized voigt series for fitting. While it is certainly possible to implement the cases for additional terms, it would require additional customization of the models and knowledge of how to program nested anonymous functions for use with lsqcurvefit().
"Would you like to run this file for each Voigt term number below your selection? (i.e. for 5-term, this will run for 1, 2, 3, and 4 terms, too) (y/n)" This value must be a character, and be either "y" or "n".
If active ("y"), the simulation will run for each number of voigt terms up to and including the input given for the previous setting. Essentially, if the user specified 5 voigt terms previously and activated this setting, the simulation would run for 1 term, 2 terms, and so on until 5 terms had been simulated. The data for each fitting would be saved in a separate matlab file (.mat format) for analysis in MATLAB later.
"Would you like to skip any numbers? If so, please enter them in array form here, or use empty brackets ([])"