anaklasis: a compact software package for model-based analysis of specular neutron and X-ray reflectometry data sets

A new software package (anaklasis) for model-based analysis of specular neutron and X-ray reflectivity is introduced. Key features include a user-friendly compact interfacial model definition scheme and a complete set of methods for co-refining data and estimating parameter uncertainty.

SI0 list structure for model definition Figure SI1: Pictorial representation of Python list hierarchical structure (system/model/layer) for the definition of interfacial systems in anaklasis. The top list structure represents the general case of an interface containing multiple models (patches) that contribute incoherently to the reflectivity. However the most usual case is that of a laterally uniform system (single patch) as shown at the lower left. A simple example of a laterally uniform two-layer system definition is shown in the lower right. Note that the layers n = 0 and n = 3 represent the semi-infinite fronting and backing mediums respectively. Each layer contains six elements i.e. real part of sld (Re sld), imaginary part of sld (Im sld), thickness (d), roughness (σ), solvent volume fraction (solv) and a string description (ds). As described in the main text, the first five elements of the layer list can be either numerical values or strings containing SymPy mathematical expressions involving an arbitrary number of user defined parameters.

SI1 Comparison of NR data with a supported membrane model
With the code below, we calculate the NR from a supported bilayer at the Si/D 2 O interface and perform a comparison with acquired reflectivity data at the MARIA neutron reflectometer (MLZ) (Mattauch et al., 2018). The script structure is essentially the same as when we perform theoretical calculations with the addition of two lines specifying the input data and the units of Q.  ( project , input_file , units , resolution , patches , system , global_param , background , scale , qmax , experror = True , plot = True ) Listing SI1: Python code for NR data comparison with a model of a supported bilayer at the Si/D 2 O interface.
Note that fronting and backing media have infinite thickness and in the script we have used the convention of inserting a zero value (although any other inserted numerical value will not influence the calculations).

SI3 NR calculations for a bimodal polymer brush
Let us consider the case of a bimodal polymer brush i.e. end-grafted polymer chains at a surface. Bimodality refers to the case where two different chain length polymers are grafted with a certain grafting density. In that case the volume fraction profile of the polymer as a function of the distance from the surface (z) can be approximated by a sum of two parabolic profiles (Anastassopoulos et al., 2013) as: where L 1 , L 2 are the extensions and φ 1 , φ 2 the volume fractions of the two brushes, respectively. Note that with the use of the max function we avoid negative values for z larger than the extension of the brushes. If we assume that L 2 > L 1 we may approximate the entire brush layer as a set of 50 slabs of thickness L 2 /50, with an sld equal to the polymer sld and solvent volume fraction profile given by 1 − φ(z). In the following code listing we construct such a brush model, where we additionally set the roughness of the slabs to L 2 /100 in order to smooth the overall profile. # We define the expressio n for the solvent volume fraction within the brush layer expr = '1 -Max ( p1 -( p1 /( p2 ** p5 ) ) *(( p4 /50.0) *( n -1.5) ) ** p5 ,0) -p3 +( p3 /( p4 ** p6 ) ) *(( p4 /50.0) *( n -1.5) ) ** p6 ' # we append 50 " brush " slabs after the SiO2 layer . # Re_sld Im -sld thk rough solv descript io n for i in range (50)

SI4 Polydisperse nanoparticle islands
Here we calculate the reflectivity for a system of polydisperse nanoparticle islands at the solid/liquid interface. As discussed in the main manuscript, assuming that the nanoparticle diameter is distributed normally, the solvent volume fraction of the nanoparticle layer is given by: we may approximate the integral by a sum of the form: with SymPy we may construct an expression based on the above sum using one of the three available summation variables used in anaklasis (ii, jj, kk). Note that the use of the min function ensures that no negative values contribute to the sum.
# append NP layer sliced in 170 slabs . for i in range (170)  Listing SI5: Commented Python code for three-contrast NR refinement from a supported lipid bilayer at the Si / water interface.

SI6 Co-refinement of seven NR curves from a lipid monolayer at the air/water interface
In this section we co-refine neutron reflectivity data of a DSPC lipid monolayer at the air / water interface and at a surface pressure of 30 mN m −1 , acquired by (Hollinshead et al., 2009) and thoroughly reanalysed by (McCluskey et al., 2019, 2020). The input data are: • "d70acmw30.dat" -tail-deuterated DSPC in air-matched water (sld=0.0) • "d83d2o30.dat" -fully-deuterated DSPC in D 2 O • "d83acmw30.dat" -fully-deuterated DSPC in air-matched water (sld=0.0) We model the interface between air and water using a two-layer model as lipid tails / lipid heads, where solvent may partially penetrate only the head layer (so that the tail volume fraction φ t = 1). Since the number density of the head and tail components is the same, we have for the head-layer volume fraction (McCluskey et al., 2019): where t is the layer thickness and V the molecular volume, with subscript h and t corresponding to heads and tails respectively. The sld of the head and tail layer is given by where b is the scattering length. In the following listing, we use multi-parameters in order to set the scattering lengths of heads and tails and the sld of the solvent for each one of the seven input curves. We also use the above expressions for setting the sld and volume fraction profile of the two layers. An inequality is added in the constraints list ensuring that φ h > 0 during the refinement. The free parameters of the model are the overall roughness, V t , V h , d t , d h and the background and scale of the seven curves, adding up to a total of 19 parameters. Listing SI6: Commented Python code for seven-contrast NR refinement from a DSCP lipid monolayer at the air / water interface.

SI13
The refinement gave the following parameter values, σ = 3.15 ± 0.12Å, d h = 8.70 ± 0.08Å, d t = 20.0 ± 0.2Å, V h = 352 ± 6Å 3 and V t = 913 ± 8Å 3 . Through MCMC sampling we also obtain a corner plot where we see no appreciable covariance between any pairs of the parameters.  Listing SI7: Commented Python code for a fit of polarized NR data from Fe-Ni alloy/Au at the silicon/D 2 O interface.