---
title: "Generate crystal structures with MatterGen and magnetic density conditioning"
description: "Generate a batch of candidate inorganic crystal structures biased toward a target DFT magnetic density. This route is useful for exploring magnetic materials when composition is not fixed. Returns a ZIP archive of CIF files; controls sample count and strengthens or relaxes the property conditioning."
url: "https://ouro.foundation/routes/mmoderwell/generate-crystal-structures-with-mattergen-and-magnetic-density-conditioning"
id: "1126f5a0-bc42-4a76-a51d-ca9a903fcc06"
type: "route"
---

# Generate crystal structures with MatterGen and magnetic density conditioning

Route by @mmoderwell in #materials-science (all) · runs in the background · Free

- Asset id: `1126f5a0-bc42-4a76-a51d-ca9a903fcc06`
- Page: https://ouro.foundation/routes/mmoderwell/generate-crystal-structures-with-mattergen-and-magnetic-density-conditioning

Generate a batch of candidate inorganic crystal structures biased toward a target DFT magnetic density. This route is useful for exploring magnetic materials when composition is not fixed. Returns a ZIP archive of CIF files; `batch_size` controls sample count and `guidance_factor` strengthens or relaxes the property conditioning.

## Inputs

- No input assets: the body below is the whole request.

## Body parameters

Send only the ones you mean to change; the defaults are tuned.

| Name | Type | Default | Description |
| --- | --- | --- | --- |
| batch_size | integer | 8 | Number of structures to generate in each batch |
| guidance_factor | number | 2 | Diffusion guidance factor. Higher values produce samples th… |
| **magnetic_density** (required) | number |  | Target magnetic density value in units of Angstrom^-3 |

## Run it

From an agent connected to Ouro MCP (`https://mcp.ouro.foundation/mcp`):

```
execute_route(route_id="1126f5a0-bc42-4a76-a51d-ca9a903fcc06", body={"magnetic_density":0}, wait=false)
```

From Python (`pip install ouro-py`):

```python
from ouro import Ouro

ouro = Ouro()  # reads OURO_API_KEY
action = ouro.routes.execute("1126f5a0-bc42-4a76-a51d-ca9a903fcc06", body={"magnetic_density":0})
```

The call returns an action id at once. Read the result with `get_action(id=..., wait=true)` over MCP, or `ouro action wait <id>` from the CLI.
