---
title: "We should be relaxing cell params too"
url: "https://ouro.foundation/posts/mmoderwell/we-should-be-relaxing-cell-params-too"
id: "01988461-93c4-7316-8a4d-d593a19a70f4"
type: "post"
---

# We should be relaxing cell params too

Post by @mmoderwell in #materials-science (all) · 2025-08-07

- Asset id: `01988461-93c4-7316-8a4d-d593a19a70f4`
- Page: https://ouro.foundation/posts/mmoderwell/we-should-be-relaxing-cell-params-too

# We should be relaxing cell params too

Most tutorials you find out there will show just atom position optimization. Depending on where you got your input CIF, this is likely wrong.

Let's look at an example from my new crystal generation API with PyXtal.

On the left we keep the cell fixed and optimize only the atomic positions.

> Embedded file: [Fe12Mn2Bi2 (P6_3/mcm) - relaxation animation](https://ouro.foundation/files/mmoderwell/fe12mn2bi2-p6-3-mcm-relaxation-animation)

On the right we optimize both cell parameters and atomic positions.

> Embedded file: [Fe12Mn2Bi2 (P6_3/mcm) - relaxation animation 1](https://ouro.foundation/files/mmoderwell/fe12mn2bi2-p6-3-mcm-relaxation-animation-1)

Same starting crystal, but a different end result (structure optimization is an energy minimization task, so the less negative here the better).

- First: -116.060 eV
- Second: -120.90 eV

The only difference was the relaxation configuration. In the first we keep the cell fixed and optimize only the atomic positions. In the second we optimize both cell parameters and atomic positions.

## Why does this matter so much?

If you only optimize atomic positions, you're essentially forcing atoms to find their "best" arrangement within a box that might be the wrong size or shape. You could be relaxing positions already within a constrained unit, increasing potential energy and perhaps falsely indicating a structure's lack of stability.

This could lead to:

- Discard a perfectly stable material as "unstable"
- Get completely wrong band gaps (metallic vs semiconducting)
- Calculate incorrect formation energies for phase stability
- Generate invalid phonon spectra showing imaginary frequencies

When we generate a candidate structure via random search, ML model, or any of the other options out there, we're getting a structure that needs optimization on both cell and atoms.

## When to use what

- **Fixed cell (atoms only):** When you have known experimental cell parameters, studying defects/surfaces with bulk constraints, or intentionally investigating strain effects
- **Full relaxation (atoms + cell):** Everything else – especially any generated or predicted structures

I've updated the relaxation endpoints in my Materials API to do this by default now. Give them a try here:

> Embedded route: [Relax a crystal structure](https://ouro.foundation/routes/mmoderwell/relax-a-crystal-structure)

> Embedded route: [Relax a crystal structure with animation](https://ouro.foundation/routes/mmoderwell/relax-a-crystal-structure-with-animation)

## We live and we learn

Unfortunately, I think a lot of the work we've done so far has been affected by the subtle difference of not relaxing cell params. Not every structure, but I bet a lot of them. All these structures we've seen with really high formation energies and assumed unstable, might actually be more stable than we thought! By doing this now we are actually making the search easier for ourselves.

Moving forward, we should make sure to do full relaxation on generated structures.

## Assets in this post

- [Fe12Mn2Bi2 (P6_3/mcm) - relaxation animation](https://ouro.foundation/files/mmoderwell/fe12mn2bi2-p6-3-mcm-relaxation-animation) (file, id `6376e8ae-2a8c-42da-a902-5b1ed42478cf`)
- [Fe12Mn2Bi2 (P6_3/mcm) - relaxation animation 1](https://ouro.foundation/files/mmoderwell/fe12mn2bi2-p6-3-mcm-relaxation-animation-1) (file, id `7fab8393-7660-4aef-bf63-27e9d2eb1422`)
- [Relax a crystal structure](https://ouro.foundation/routes/mmoderwell/relax-a-crystal-structure) (route, id `d040d3b6-faad-40cf-9d7c-999a5c769ed8`)
- [Relax a crystal structure with animation](https://ouro.foundation/routes/mmoderwell/relax-a-crystal-structure-with-animation) (route, id `8659406b-bd11-419a-9ab3-cf3534511b6b`)
