Skip to content

Polymer Solution (PEO + water)

This tutorial mixes the Polymer and Molecule classes in one system: poly(ethylene oxide) chains solvated in 200 explicit water molecules. PEO/water is a classic biocompatible polymer solution (hydrogels, drug delivery, battery electrolytes).

You will learn:

  • How to pass polymers and molecules together in generate(system, name, [...])
  • The two SMILES conventions side by side: wildcards for the polymer, plain SMILES for the solvent
  • Why GAFF is a convenient single force field for mixed organic systems

The script

#!/usr/bin/env python3
"""
Example: PEO Chains in Explicit Water — a Polymer Solution
===========================================================

Demonstrates mixing the Polymer and Molecule classes in a single system:
poly(ethylene oxide) chains solvated in explicit water. PEO/water is a
classic biocompatible polymer solution (hydrogels, drug delivery,
battery electrolytes).

  - Polymer: complement SMILES with [*] wildcards, chain_num + sequence
  - Molecule: regular SMILES, Count
  - Both are passed together as generate(system, name, [polymer, solvent])

Force field: GAFF covers both components; Gasteiger charges are assigned
automatically. For production runs consider AM1-BCC/RESP charges and a
water-specific model if quantitative aqueous properties matter.

Requires: pip install -e .  (from the AutoPoly repo root)
"""

from AutoPoly import System, Molecule, Polymer, generate

# Complement SMILES for PEO (methyl-terminated, matching the other examples)
PEO_FIRST = "CCO[*]"
PEO_MIDDLE = "[*]CCO[*]"
PEO_LAST = "[*]CCO"

DOP = 20
sequence = [PEO_FIRST] + [PEO_MIDDLE] * (DOP - 2) + [PEO_LAST]

system = System(out="peo_solution")

peo = Polymer(
    chain_num=5,
    sequence=sequence,
    topology="linear",
    tacticity="atactic",
)

water = Molecule(
    Count=200,
    Smiles="O",
    Name="water",
)

generate(
    system,
    "peo_water",
    [peo, water],   # polymer + solvent in one box
    force_field="gaff",
)

print()
print("Done! LAMMPS input files written to peo_solution/peo_water/")
print(f"System: 5 PEO chains (DOP={DOP}) + 200 water molecules")
print()
print("Note: the box is built at a low density to allow overlap-free")
print("placement. Equilibrate with NPT compression to reach the target")
print("density before production runs.")

Run it

cd examples
python example_peo_solution.py

Charges and water models

Gasteiger charges are assigned automatically. For production runs, consider AM1-BCC/RESP charges and a water-specific model if quantitative aqueous properties matter — see Force Fields.

Variations to try

  • Change the water count to tune concentration
  • Swap water for ethanol (Smiles="CCO") or a benzene/THF mixture
  • Scale up: more chains, longer PEO — but equilibrate carefully (low initial density, staged NPT)