material - Material

Material Description of a solid block of material.
Mixture Mixed block of material.
SLD Unknown composition.
Vacuum Empty layer
Scatterer A generic scatterer separates the lookup of the scattering factors from the calculation of the scattering length density.
ProbeCache Probe proxy for materials properties.

Reflectometry materials.

Materials (see Material) have a composition and a density. Density may not be known, either because it has not been measured or because the measurement of the bulk value does not apply to thin films. The density parameter can be fitted directly, or the bulk density can be used, and a stretch parameter can be fitted.

Mixtures (see Mixture) are a special kind of material which are composed of individual parts in proportion. A mixture can be constructed in a number of ways, such as by measuring proportional masses and mixing or measuring proportional volumes and mixing. The parameter of interest may also be the relative number of atoms of one material versus another. The fractions of the different mixture components are fitted parameters, with the remainder of the bulk filled by the final component.

SLDs (see SLD) are raw scattering length density values. These should be used if the material composition is not known. In that case, you will need separate SLD materials for each wavelength and probe.

air (see Vacuum) is a predefined scatterer transparent to all probes.

Scatter (see Scatterer) is the abstract base class from which all scatterers are derived.

The probe cache (see ProbeCache) stores the scattering factors for the various materials and calls the material sld method on demand. Because the same material can be used for multiple measurements, the scattering factors cannot be stored with material itself, nor does it make sense to store them with the probe. The scattering factor lookup for the material is separate from the scattering length density calculation so that you only need to look up the material once per fit.

The probe itself deals with all computations relating to the radiation type and energy. Unlike the normally tabulated scattering factors f’, f’’ for X-ray, there is no need to scale by probe by electron radius. In the end, sld is just the returned scattering factors times density.

class refl1d.material.Material(formula=None, name=None, use_incoherent=False, density=None, natural_density=None, fitby='bulk_density', value=None)[source]

Bases: refl1d.material.Scatterer

Description of a solid block of material.


formula : Formula

Composition can be initialized from either a string or a chemical formula. Valid values are defined in periodictable.formula.

density : float | g·cm-3

If specified, set the bulk density for the material.

natural_density : float | g·cm-3

If specified, set the natural bulk density for the material.

use_incoherent = False : boolean

True if incoherent scattering should be interpreted as absorption.

fitby = ‘bulk_density’ : string

Which density parameter is the fitting parameter. The choices are bulk_density, natural_density, relative_density or cell_volume. See fitby() for details.

value : Parameter or float | units depends on fitby type

Initial value for the fitted density parameter. If None, the value will be initialized from the material density.

For example, to fit Pd by cell volume use:

>>> m = Material('Pd', fitby='cell_volume')
>>> m.cell_volume.range(1,10)
Parameter(Pd cell volume)
>>> print("%.2f %.2f"%(m.density.value, m.cell_volume.value))
12.02 14.70

You can change density representation by calling material.fitby(type).

fitby(type='bulk_density', value=None)[source]

Specify the fitting parameter to use for material density.

type : string

Density representation

value : Parameter

Initial value, or associated parameter.

Density type can be one of the following:

bulk_density : g·cm-3 or kg/L
Density is bulk_density
natural_density : g·cm-3 or kg/L
Density is natural_density / (natural mass/isotope mass)
relative_density : unitless
Density is relative_density * formula density
cell_volume : 3
Density is mass / cell_volume

The resulting material will have a density attribute with the computed material density in addition to the fitby attribute specified.


Calling fitby replaces the density parameter in the material, so be sure to do so before using density in a parameter expression. Using bumps.parameter.WrappedParameter for density is another alternative.

class refl1d.material.Mixture(base, parts, by='volume', name=None, use_incoherent=False)[source]

Bases: refl1d.material.Scatterer

Mixed block of material.

The components of the mixture can vary relative to each other, either by mass, by volume or by number:

Mixture.bymass(base,M1,F1,M2,F2...,name='mixture name')
Mixture.byvolume(base,M1,F1,M2,F2...,name='mixture name')

The materials base, M1, M2, M3, ... can be chemical formula strings or material objects. In practice, since the chemical formula parser does not have a density database, only elemental materials can be specified by string. Use natural_density will need to change from bulk values if the formula has isotope substitutions.

The fractions F2, F3, ... are percentages in [0,100]. The implicit fraction F1 is 100 - (F2+F3+...). The SLD is NaN when F1 < 0).

name defaults to

classmethod bymass(base, *parts, **kw)[source]

Returns an alloy defined by relative mass of the constituents.

Mixture.bymass(base,M1,F2,...,name=’mixture name’)

classmethod byvolume(base, *parts, **kw)[source]

Returns an alloy defined by relative volume of the constituents.

Mixture.byvolume(M1,M2,F2,...,name=’mixture name’)


Compute the density of the mixture from the density and proportion of the individual components.


Adjustable parameters are the fractions associated with each constituent and the relative scale fraction used to tweak the overall density.


Return the scattering length density and absorption of the mixture.

class refl1d.material.SLD(name='SLD', rho=0, irho=0)[source]

Bases: refl1d.material.Scatterer

Unknown composition.

Use this when you don’t know the composition of the sample. The absorption and scattering length density are stored directly rather than trying to guess at the composition from details about the sample.

The complex scattering potential is defined by \(\rho + j \rho_i\). Note that this differs from \(\rho + j \mu/(2 \lambda)\) more traditionally used in neutron reflectometry, and \(N r_e (f_1 + j f_2)\) traditionally used in X-ray reflectometry.

Given that \(f_1\) and \(f_2\) are always wavelength dependent for X-ray reflectometry, it will not make much sense to uses this for wavelength varying X-ray measurements. Similarly, some isotopes, particularly rare earths, show wavelength dependence for neutrons, and so time-of-flight measurements should not be fit with a fixed SLD scatterer.

class refl1d.material.Vacuum[source]

Bases: refl1d.material.Scatterer

Empty layer

name = 'air'
class refl1d.material.Scatterer[source]

Bases: object

A generic scatterer separates the lookup of the scattering factors from the calculation of the scattering length density. This allows programs to fit density and alloy composition more efficiently.


the Scatterer base class is extended by _MaterialStacker so that materials can be implicitly converted to slabs when used in stack construction expressions. It is not done directly to avoid circular dependencies between model and material.


Return the scattering length density expected for the given scattering factors, as returned from a call to scattering_factors() for a particular probe.

class refl1d.material.ProbeCache(probe=None)[source]

Probe proxy for materials properties.

A caching probe which only looks up scattering factors for materials which it hasn’t seen before. Note that caching is based on object id, and will fail if the material object is updated with a new atomic structure.

probe is the probe to use when looking up the scattering length density.

The scattering factors need to be retrieved each time the probe or the composition changes. This can be done either by deleting an individual material from probe (using del probe[material]) or by clearing the entire cash.

scattering_factors(material, density)[source]

Return the scattering factors for the material, retrieving them from the cache if they have already been looked up.