<!-- DO NOT EDIT. -->
<!-- THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. -->
<!-- TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: -->
<!-- "auto_examples/readers_writers/plot_data_file_reader.py" -->
<!-- LINE NUMBERS ARE GIVEN BELOW. -->

#### NOTE
[Go to the end](#sphx-glr-download-auto-examples-readers-writers-plot-data-file-reader-py)
to download the full example code.

<a id="sphx-glr-auto-examples-readers-writers-plot-data-file-reader-py"></a>

# Data File Reader

The `DataFileParser` handles LAMMPS data files containing complete system definitions.
The [`UniverseSequence`](../../api/pylimer_tools_cpp.UniverseSequence.html.md#pylimer_tools_cpp.UniverseSequence) provides a convenient way to have these data files read
into the [`Universe`](../../api/pylimer_tools_cpp.Universe.html.md#pylimer_tools_cpp.Universe) objects.

<!-- GENERATED FROM PYTHON SOURCE LINES 10-57 -->
```Python
import os
from pathlib import Path

from pylimer_tools_cpp import UniverseSequence


def _find_fixtures_dir() -> Path:
    for cur in (
        [Path(__file__).resolve().parent] if "__file__" in globals() else []
    ) + [Path.cwd()]:
        for p in [cur] + list(cur.parents):
            candidate = p / "tests" / "pylimer_tools" / "fixtures"
            if candidate.is_dir():
                return candidate
    return Path("tests/pylimer_tools/fixtures").resolve()


_fixtures_dir = _find_fixtures_dir()
base_structure_path = str(_fixtures_dir / "structure")

# Load a single data file
data_file = os.path.join(
    base_structure_path,
    "melt_83_a_100.structure.out",
)
one_universe_seq = UniverseSequence()
one_universe_seq.initialize_from_data_sequence([data_file])
universe = one_universe_seq.at_index(0)

# Load multiple data files as a sequence
sequence = UniverseSequence()
sequence.initialize_from_data_sequence(
    [
        os.path.join(
            base_structure_path,
            "3d-diamond-lattice_10x10x10_a_3_d_0.85_imperfect.structure.out",
        ),
        os.path.join(
            base_structure_path,
            "3d-diamond-lattice_10x10x10_a_3_d_0.85_v_0.V-fixed.structure.out",
        ),
    ]
)
for universe in sequence:
    print(f"Loaded universe with {universe.get_nr_of_atoms()} atoms")
```

```none
Loaded universe with 56000 atoms
Loaded universe with 56000 atoms
```

<!-- GENERATED FROM PYTHON SOURCE LINES 58-63 -->

Please note that the `hybrid` and `tdpd` atom styles are not fully supported.

If your data files don’t hint the atom style in the line that starts with “Atom”,
you should specify it manually, see [`read()`](../../api/pylimer_tools_cpp.DataFileReader.html.md#pylimer_tools_cpp.DataFileReader.read)
and [`set_data_file_atom_style()`](../../api/pylimer_tools_cpp.UniverseSequence.html.md#pylimer_tools_cpp.UniverseSequence.set_data_file_atom_style).

**Total running time of the script:** (0 minutes 0.130 seconds)

<a id="sphx-glr-download-auto-examples-readers-writers-plot-data-file-reader-py"></a>

[`Download Jupyter notebook: plot_data_file_reader.ipynb`](_downloads/93aa26584f03b408b54ca2c467d7bbdb/plot_data_file_reader.ipynb)

[`Download Python source code: plot_data_file_reader.py`](_downloads/74dcca5ad9c0401b9b61a9e8c9109c8c/plot_data_file_reader.py)

[`Download zipped: plot_data_file_reader.zip`](_downloads/e4a1487c3b3f0dd65efc967aadcf2767/plot_data_file_reader.zip)

[Gallery generated by Sphinx-Gallery](https://sphinx-gallery.github.io)
