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

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

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

# Simple Crosslinked Network

Here’s a minimal example of creating a crosslinked polymer network:

<!-- GENERATED FROM PYTHON SOURCE LINES 8-50 -->
```none
Generated network with 4100 atoms
```

<br/>
```Python
import os
from pylimer_tools_cpp import DataFileWriter, MCUniverseGenerator

# Create generator for a 50x50x50 simulation box
generator = MCUniverseGenerator(50.0, 50.0, 50.0)

# Set random seed for reproducibility
generator.set_seed(12345)

# Set mean bead-to-bead distance
generator.set_bead_distance(1.0)

# Add crosslinking sites
generator.add_crosslinkers(100, 4)  # 100 crosslinkers of functionality 4

# Add polymer chains
generator.add_strands(
    nr_of_strands=200,  # 200 polymer chains
    strand_lengths=[20 for _ in range(200)],  # 20 beads per chain
)

# Crosslink polymer strands
generator.link_strands_to_conversion(
    crosslinker_conversion=0.925,  # 92.5% of crosslinker sites used
)

# Get the generated network
universe = generator.get_universe()

# Set masses, e.g. for LAMMPS
universe.set_masses({1: 1.0, 2: 2.0})

print(f"Generated network with {universe.get_nr_of_atoms()} atoms")

# Save the universe to a file
writer = DataFileWriter(universe)

if not os.path.exists("generated_structures"):
    os.makedirs("generated_structures")

writer.write_to_file("generated_structures/simple_crosslinked_network.data")
```

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

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

[`Download Jupyter notebook: plot_simple_crosslinked_network.ipynb`](_downloads/81342f99548b60c95d06fcd36cbc0ee3/plot_simple_crosslinked_network.ipynb)

[`Download Python source code: plot_simple_crosslinked_network.py`](_downloads/b28d6fc36f311ddc7d4f334b91304cee/plot_simple_crosslinked_network.py)

[`Download zipped: plot_simple_crosslinked_network.zip`](_downloads/85193cfcf0390c0fa2f5105480298a32/plot_simple_crosslinked_network.zip)

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