+++
title = "Particles"
weight = 50
+++

## Particle class

##### Usage

Create a particle from a material and a form factor:

```python
particle = ba.Particle(material, formfactor)
```

To put independent particles on a layer, wrap the particle in a 2D structure
and deposit or suspend that structure:

```python
structure = ba.Dilute2D(density, particle)

layer = ba.Layer(material, thickness)
layer.deposit2D(structure)
```

For particles with spatial correlations, use structures such as
`Crystal1D`, `Crystal2D`, `FiniteCrystal2D`, or `RadialParacrystal` instead
of `Dilute2D`.

##### Vertical placement

`deposit2D` places the bottom of the particle structure at the layer's bottom
interface. `suspend2D` places the top of the structure at the layer's top
interface.

For non-default placement, translate the particle before adding it to a
structure:

```python
particle.translate(0, 0, z_shift)
```

If `z_shift > 0`, then the particle is translated upwards.

##### Create a Particle instance

The `particle` in the above code snippet can be a simple or a composite
particle.

To create a simple particle, use

```python
particle = ba.Particle(material, formfactor)
```

For the constructor arguments, see sections [Material](/ref/sample/material)
and [Formfactor](/ref/sample/particle/ff).

To create a composed particle, see
- [CoreShellParticle](composition/core-shell),
- [Compound](composition/compound),
- [Mesocrystal](composition/meso).

[Magnetization](/ref/sample/material/magnetization) is supported as a material
property.

##### Set location and orientation

To translate any particle, simple or composite, use either the vectorial form

```python
from bornagain import R3
translation = R3(x, y, z)
particle.translate(translation)
```

or

```python
particle.translate(x, y, z)
```

To change the orientation, use code like

```python
rotation = ba.RotationEuler(alpha, beta, gamma)
rotation = ba.RotationX(angle)  # alternative
particle.rotate(rotation)
```

For more information on the argument, see [Rotation](/ref/other/rotation).

Translations and rotations may be applied in any order. They are commutative.
