## Install on Windows

#### Install Python environment

As a prerequisite, Python must be installed, see Python on Windows.

#### Install BornAgain as a Python package

To install BornAgain as a pure Python package (for scripting only, no GUI), download and install the latest BornAgain Python wheel from the PyPI repository:

    $ python -m pip install bornagain

#### Install full BornAgain (GUI and Python scripting)

To install full BornAgain (GUI app and Python module), download an installer from https://bornagainproject.org/ext/files/23.0. The installer should be chosen accordingly to the Python minor version installed on the destination machine, for example `BornAgain-23.0-python3.12-win64.exe`.

After downloading the installer, double click the `.exe` file and follow the instructions on the screen.

Use the BornAgain icon located on the desktop to start the GUI. Refer to Using graphical user interface section for a basic overview of GUI functionality.

The corresponding Python wheel is included in the folder `C:/<Bornagain installation path>/share/BornAgain/wheel/` and can be installed via a the following command:

    $ python -m pip install C:/<Bornagain installation path>/share/BornAgain/wheel/share/BornAgain/wheel/*.whl

### Troubleshooting

Frequent problems include the following:

- BornAgain.exe cannot start
- How many Python distributions are installed on the system?
- Does the Python interpreter version matches the BornAgain installation?

#### BornAgain.exe cannot start

This message appears on running `BornAgain.exe` if BornAgain cannot find Python libraries.

If Python is correctly installed on the system according to Install Python environment, check if it discoverable by the system. Open command line or PowerShell and type

    $ python

If Python interpreter has not started, then its installation directory is not in system `PATH`. Open

`Edit the system environment variables` -> `Environment variables` -> `System variables` -> `Path` -> `Edit`

and add Python installation directory to the end

Note that the directory of the Python executable can be found via the following Python command:

    $ python -c "import os,sys; print(os.path.dirname(os.path.realpath(sys.executable)));"

#### How many Pythons are installed on the system?

Having more than one Python interpreter installed on the system may cause subtle errors. Managing their co-existence is possible, but may require special skills. It may be preferable to uninstall all Python versions but one.

#### Does the Python interpreter version match the BornAgain installation?

BornAgain is a `64-bit` application and requires a `64-bit` Python3 installed on the system.

The Python version number (major.minor), indicated in the BornAgain installer name (e.g. `BornAgain-23.0-python3.12-win64.exe`) must match the Python installation on your system.

- 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