BornAgain can compute depth-dependent material profiles from a sample model.
The scattering length density (SLD) profile is returned by
ba.materialProfileSLD. Magnetization components are returned by
ba.magnetizationProfile.
Both functions return z coordinates together with the profile values:
n_points = 400
z_min, z_max = ba.defaultMaterialProfileLimits(sample)
z_sld, sld = ba.materialProfileSLD(sample, n_points, z_min, z_max)
z_mag_x, mag_x = ba.magnetizationProfile(sample, "X", n_points, z_min, z_max)
Here sample is a user-defined sample model. The string argument of
magnetizationProfile selects one component, "X", "Y", or "Z".
The z range can be chosen explicitly or obtained from
ba.defaultMaterialProfileLimits(sample).
The output values are NumPy arrays:
z_sld and z_mag_x, arrays of z values in nm,sld, an array of complex SLD values in
$ \mathrm{\AA}^{-2} $,mag_x, an array of magnetization values in $ A/m $.The output can be plotted e.g. with the MatPlotLib command
matplotlib.pyplot.plot(z_sld, np.real(sld))
For full examples, see