profile - Model profile

Microslabs Manage the micro slab representation of a model.
blend blend function
build_mag_profile Convert magnetic segments to a smooth profile.
build_profile Convert a step profile to a smooth profile.
compute_limited_sigma

Scattering length density profile.

In order to render a reflectometry model, the theory function calculator renders each layer in the model for each energy in the probe. For slab layers this is easy: just accumulate the slabs, with the 1-\(\sigma\) Gaussian interface width between the slabs. For freeform or functional layers, this is more complicated. The rendering needs to chop each layer into microslabs and evaluate the profile at each of these slabs.

Example

This example sets up a model which uses tanh to transition from silicon to gold in 20 Å with 2 Å steps.

First define the profile, and put in the substrate:

>>> S = Microslabs(nprobe=1,dz=2)
>>> S.clear()
>>> S.append(w=0,rho=2.07)

Next add the interface. This uses microslabs() to select the points at which the interface is evaluated, much like you would do when defining your own special layer type. Note that the points Pz are in the center of the micro slabs. The width of the final slab may be different. You do not need to use fixed width microslabs if you can more efficiently represent the profile with a smaller number of variable width slabs, but contract_profile() serves the same purpose with less work on your part.

>>> from numpy import tanh
>>> Pw,Pz = S.microslabs(20)
>>> print("widths = %s ..."%(" ".join("%g"%v for v in Pw[:5])))
widths = 2 2 2 2 2 ...
>>> print("centers = %s ..."%(" ".join("%g"%v for v in Pz[:5])))
centers = 1 3 5 7 9 ...
>>> rho = (1-tanh((Pz-10)/5))/2*(2.07-4.5)+4.5
>>> S.extend(w=Pw, rho=[rho])

Finally, add the incident medium and see the results. Note that rho is a matrix, with one column for each incident energy. We are only using one energy so we only show the first column.

>>> S.append(w=0,rho=4.5)
>>> print("width = %s ..."%(" ".join("%g"%v for v in S.w[:5])))
width = 0 2 2 2 2 ...
>>> print("rho = %s ..."%(" ".join("%.2f"%v for v in S.rho[0,:5])))
rho = 2.07 2.13 2.21 2.36 2.63 ...

Since irho and sigma were not specified, they will be zero.

>>> print("sigma = %s ..."%(" ".join("%g"%v for v in S.sigma[:5])))
sigma = 0 0 0 0 0 ...
>>> print("irho = %s ..."%(" ".join("%g"%v for v in S.irho[0,:5])))
irho = 0 0 0 0 0 ...
class refl1d.profile.Microslabs(nprobe, dz=1)[source]

Bases: object

Manage the micro slab representation of a model.

In order to compute reflectivity, we need a series of slabs with thickness, roughness and scattering potential for each slab. Because scattering potentials are probe dependent we store an array of potentials for each probe value.

Some slab models use non-uniform layers, and so need the additional parameter of dz for the step size within the layer.

The space for the slabs is saved even after reset, in preparation for a new set of slabs from different fitting parameters.

add_magnetism(anchor, w, rhoM=0, thetaM=270.0, sigma=0)[source]

Add magnetic layers.

append(w=0, sigma=0, rho=0, irho=0)[source]

Extend the micro slab model with a single layer.

clear()[source]

Reset the slab model so that none are present.

extend(w=0, sigma=0, rho=0, irho=0)[source]

Extend the micro slab model with the given layers.

finalize(step_interfaces, dA, roughness_limit)[source]

Rendering complete.

Call this method after the microslab model has been constructed, so any post-rendering processes can be completed.

In addition to clearing any width from the substrate and the surface surround, this will align magnetic and nuclear slabs, convert interfaces to step interfaces if desired, and merge slabs with similar scattering potentials to reduce computation time.

step_interfaces is True if interfaces should be rendered using slabs.

dA is the tolerance to use when deciding if similar layers can be merged.

roughness_limit is the maximum

interface(I)[source]

Interfaces act to smear the microslabs after the fact. This allows more flexibility than trying to compute the effects of roughness on non-flat layers.

irho

Absorption (10^-6 number density)

ismagnetic
magnetic_profile()[source]

Return a profile representation of the magnetic microslab structure.

microslabs(thickness=0)[source]

Return a set of microslabs for a layer of the given thickness.

The step size slabs.dz was defined when the Microslabs object was created.

This is a convenience function. Layer definitions can choose their own slices so long as the step size is approximately slabs.dz in the varying region.

Parameters:
thickness : float | A

Layer thickness

Returns:
widths: vector | A

Microslab widths

centers: vector | A

Microslab centers

repeat(start=0, count=1, interface=0)[source]

Extend the model so that there are count versions of the slabs from start to the final slab.

This is equivalent to L.extend(L[start:]*(count-1)) for list L.

rho

Scattering length density (10^-6 number density)

sigma

rms roughness (A)

smooth_profile(dz=1)[source]

Return a smooth profile representation of the microslab structure

Nevot-Croce roughness is approximately represented, though the calculation is incorrect for layers with large roughness compared to the thickness.

The returned profile has uniform step size dz.

step_profile()[source]

Return a step profile representation of the microslab structure.

Nevot-Croce interfaces are not represented.

surface_sigma

roughness for the current top layer, or nan if substrate

thickness()[source]

Total thickness of the profile.

Note that thickness includes the thickness of the substrate and surface layers. Normally these will be zero, but the contract profile operation may result in large values for either.

w

Thickness (A)

refl1d.profile.blend(z, rough)[source]

blend function

Given a Gaussian roughness value, compute the portion of the neighboring profile you expect to find in the current profile at depth z.

refl1d.profile.build_mag_profile(z, d, v, blends)[source]

Convert magnetic segments to a smooth profile.

refl1d.profile.build_profile(z, thickness, roughness, value)[source]

Convert a step profile to a smooth profile.

z calculation points thickness thickness of the layers (first and last values ignored) roughness roughness of the interfaces (one less than d) value profile being computed max_rough limit the roughness to a fraction of the layer thickness

refl1d.profile.compute_limited_sigma(thickness, roughness, limit)[source]