## Materials

The refractive properties of a homogeneous `Material` can be specified through two different functions:

- `RefractiveMaterial`, based on the refractive index,
- `MaterialBySLD`, based on the scattering length density (SLD).

`RefractiveMaterial` is equally suitable for X-rays or neutrons. However, it does not account for the wavelength dependence of the refractive index. This leads to incorrect results if there is too much spread in the incoming wavelength, as is regularly the case in neutron time-of-flight experiments.

`MaterialBySLD` is intended for neutron experiments with significant wavelength spread. Refractive indices as function of wavelength are computed internally from constant SLDs.

##### Material by refractive index

A `Material` can be created through

    material = ba.RefractiveMaterial("name", delta, beta)

where `name` is the arbitrary name of the material associated with its complex refractive index $n = 1 - \delta + i\beta$.

Optionally, the constructor takes an additional magnetization argument.

##### Material by scattering length density

A `Material` can also be created through

    <material> = ba.MaterialBySLD("name", sld_real, sld_imag)

Here `sld_real` and `sld_imag` are the real and imaginary parts of the material scattering length density (SLD) according to the following convention (Sears 1992):

$$SLD = sld_{real} - i \cdot sld_{imag}$$

In this convention, the imaginary part of the SLD must be nonnegative.

SLD units are inverse square angstroms: $ \overset{\circ}{A^{-2}} $.

Optionally, the constructor takes an additional magnetization argument.

Magnetization units are ampere per meter: $ A/m $.

SLD values for a wide variety of materials can be calculated with numerous online SLD-calculators, e.g. these ones:

- sld-calculator.appspot.com
- SLD calculator by NIST

The first of these returns values in inverse square angstroms, which are also the input units for `MaterialBySLD`. Thus the SLD values found with the calculator can be directly copied and pasted into a BornAgain script.

##### Default = Vacuum

Both `RefractiveMaterial` and `MaterialBySLD` can be created with empty constructors:

    material = ba.RefractiveMaterial()
    # or
    material = ba.MaterialBySLD()

In this case the “default” material is created, i.e. a material with the name `vacuum`, zero SLD/refractive index and zero magnetization.

##### Restrictions and Limitations

Although `MaterialBySLD` and `RefractiveMaterial` are interchangeable in the case of neutron experiments with fixed wavelength, they must not be used together in one sample.

`MaterialBySLD` does not account for causes of damping other than nuclear absorption. In particular, incoherent and inelastic scattering are neglected. Usually, such extra damping would change the imaginary part of the refractive index only little compared with the real part; neglecting it therefore should have no big effect upon simulation results.

- Introduction
  - Functionality overview
  - Architectural overview

- Install or build
  - Install Python
    - Python on Linux
    - Python on Windows
    - Python on Mac
    - Python modules
  - Install BornAgain
    - Linux
    - Windows
    - MacOS
    - Development snapshot
  - Build BornAgain
    - Unix
      - Install third-party software
      - Get the source
      - Build and install BornAgain
      - Run a first simulation
    - Windows

- Graphical user interface
  - Quick Start
  - GUI overview
  - Fitting in the GUI

- Python scripting
  - Run a script
  - Understand the syntax
  - Fitting
  - Upgrading

- Reference
  - Simulation model
    - Simulation classes
      - Specular
        - Example
      - Scattering
        - Examples
          - GISAS
          - without DWBA terms
          - with specular peak
          - SAS
          - Polarized SANS
          - Monte-Carlo
      - Off-specular
        - Off-specular
      - Depth probe
        - Examples
          - Thin film
          - Transmitted modulus
          - Resonator
    - Common settings
      - Background
      - Options
        - Monte-Carlo
        - # threads
        - Average materials
        - Include specular
      - Progress monitor
  - Instrument model
    - Beam
      - Footprint
      - Beam divergence
    - Scan
      - TOF reflectometry
      - TOF resolution
      - Beam Angular Spread
      - Beam Wavelength Spread
    - Detectors
      - SphericalDetector
      - 2d detector resolution
      - Offspec detector
    - Neutron polarization
      - Spin asymmetry example
    - Examples
      - 2D detector resolution
      - Neutron polarization
        - Magnetic layer
        - Ditto, realistic instrument
        - Polarized scattering
  - Sample model
    - Materials
      - Magnetization
    - Sample
      - Layer
      - LayerStack
      - Layout
    - Roughness
      - Interface model
      - Transient
      - Cross-correlation
      - Examples
        - GISAS
        - Reflectivity
    - Particles
      - Form factor
        - Hard particles
          - Bipyramid4
          - Box
          - CantellatedCube
          - Cone
          - Cylinder
          - Dodecahedron
          - EllipsoidalCylinder
          - HemiEllipsoid
          - HorizontalCylinder
          - Icosahedron
          - PlatonicOctahedron
          - PlatonicTetrahedron
          - Prism3
          - Prism6
          - Pyramid2
          - Pyramid3
          - Pyramid4
          - Pyramid6
          - Sphere
          - SphericalSegment
          - Spheroid
          - SpheroidalSegment
          - TruncatedCube
        - Ripples
          - Bar ripple
          - Cosine ripple
          - Sawtooth ripple
        - Soft particles
          - FuzzySphere
          - Gauss
        - Custom formfactor
      - Composite particles
        - Core and shell
        - Compound particle
        - Mesocrystal
      - Examples
        - Compound particle
        - Core and shell
        - Crossing an interface
        - Mesocrystal
        - Rotation example
        - Dense cylinders
        - Dense hemispheres
        - Uncorrelated mixture
        - Polydispersity
    - Particle assemblies
      - Grating
        - 1D lattice
        - Cosine ripples in a lattice
        - Triangular ripples in a lattice
      - 2D lattice
        - Square lattice
        - Lattice orientation distribution
        - Finite square lattice
        - Lattice with basis
        - Multi-layer lattice
        - Position variance
      - Radial paracrystal
      - 2D paracrystal
      - Others
        - Size-distribution model: decoupling approximation
        - Size-distribution model: local monodisperse approximation
        - Size-distribution model: size-spacing coupling approximation
  - Model modifiers
    - Rotation
    - Distributions
  - Data types
    - Class Datafield
      - Export
      - Find intensity peaks
    - SLD profile
      - SLD profile with rough interfaces
      - SLD profile with a sliced particle layer
  - Plotting
    - Functions
    - Configuration
    - Heat map
    - LaTeX markup
    - Export
    - Plot axes in different units
  - Fitting
    - Data import
      - TIFF
    - Minimizer settings
    - Multiple datasets
    - Examples
      - Fitting with masks
      - Custom objective function
      - Fitting along slices
      - GISAS 2D fits
      - Experiment at GALAXI
      - Find background
      - Minimizer settings
      - Bayesian Sampling
      - Consecutive fitting
      - Considering uncertainties
      - External minimizer
      - External minimizer: plotting
      - Simultaneous fit of two datasets
      - Spin asymmetry fit example
      - Reflectometry: Fit Pt layer
      - Reflectometry: Fit honeycomb

- Literature
  - Babonneau2010
  - Babonneau2013
  - Croset2021
  - Lazzari2002
  - Lazzari2006
  - Pospelov2020
  - Renaud2009
  - Sears1992
  - Wuttke2021

- How to
  - Get announcements
  - Solve known problems
    - Set Python environmental variables under Windows
  - Request help or report bugs
  - Cite BornAgain

- Developers' corner
  - Configure
    - Build
    - Pyenv
  - Develop
    - Manual checks
    - Debug
    - Webdoc
    - Code analyses
  - Release
    - Manual GUI test