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

#### NOTE
[Go to the end](#sphx-glr-download-auto-examples-network-generator-plot-save-network-py)
to download the full example code.

<a id="sphx-glr-auto-examples-network-generator-plot-save-network-py"></a>

# Save Generated Network

This example shows how to save a generated polymer network to a LAMMPS data file.

<!-- GENERATED FROM PYTHON SOURCE LINES 8-32 -->
```none
Network saved to: generated_structures/polymer_network.data
```

<br/>
```Python
from pathlib import Path

from pylimer_tools_cpp import AtomStyle, DataFileWriter, MCUniverseGenerator

# Generate network
generator = MCUniverseGenerator(45, 45, 45)
# ... configure and generate ...
universe = generator.get_universe()

# Create output directory
output_dir = Path("generated_structures")
output_dir.mkdir(exist_ok=True)

# Write LAMMPS data file
writer = DataFileWriter(universe)
writer.config_include_angles(True)
writer.config_reindex_atoms(True)
writer.config_atom_style(AtomStyle.ANGLE)

output_file = output_dir / "polymer_network.data"
writer.write_to_file(str(output_file))

print(f"Network saved to: {output_file}")
```

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

<a id="sphx-glr-download-auto-examples-network-generator-plot-save-network-py"></a>

[`Download Jupyter notebook: plot_save_network.ipynb`](_downloads/1f64c9ed17f112e3d009ed280ded35d8/plot_save_network.ipynb)

[`Download Python source code: plot_save_network.py`](_downloads/5e91197866341219775aac427914548d/plot_save_network.py)

[`Download zipped: plot_save_network.zip`](_downloads/bd8ad86d696ec0726e28eff8654eaa8c/plot_save_network.zip)

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