AutoPoly is a comprehensive Python package for generating polymer structures and preparing them for molecular dynamics simulations using LAMMPS and Moltemplate.
AutoPoly provides tools for:
- Polymer Structure Generation: Create atomistic polymer models with various topologies and tacticity
- Force Field Integration: Seamless integration with OPLS-AA and LOPLS force fields
- LAMMPS Preparation: Generate complete LAMMPS input files and data structures
- Bead-Spring Models: Simplified coarse-grained polymer models for quick simulations
- File Management: Automated organization of simulation files and outputs
- Linear Polymers: Standard linear chain structures
- Ring Polymers: Circular polymer topologies
- Custom Sequences: User-defined monomer sequences
- Atactic: Random stereochemistry
- Isotactic: All monomers with same stereochemistry
- Syndiotactic: Alternating stereochemistry
- OPLS-AA: All-atom force field for accurate simulations
- LOPLS: Lipid-optimized force field variant
- Custom Parameters: Support for modified force field parameters
- Monomer Bank: Centralized monomer template library
- Output Organization: Structured file organization
- Error Handling: Comprehensive validation and error reporting
- Python 3.7+
- LAMMPS (for simulations)
- Moltemplate (for structure generation)
# Clone the repository
git clone <repository-url>
cd AutoPoly
# Install the package
pip install -e .
from AutoPoly import System, Polymer, Polymerization
# Create system
system = System(out="my_polymer")
# Define polymer
polymer = Polymer(
ChainNum=10,
Sequence=["ethylene"],
DOP=100,
topology="linear",
tacticity="atactic"
)
# Generate structure
polymerization = Polymerization(
name="ethylene_polymer",
system=system,
model=[polymer]
)
from AutoPoly import BeadSpringPolymer, System
# Create system
system = System(out="bead_spring")
# Generate bead-spring polymer
bead_polymer = BeadSpringPolymer(
name="test_polymer",
system=system,
n_chains=5,
n_beads=20,
topology="linear"
)
# Generate LAMMPS files
bead_polymer.generate_data_file()
# Create ring polymer
ring_polymer = Polymer(
ChainNum=5,
Sequence=["styrene"],
topology="ring",
tacticity="atactic"
)
# Generate with polymerization
polymerization = Polymerization(
name="ring_styrene",
system=system,
model=[ring_polymer]
)
AutoPoly/
├── AutoPoly/
│ ├── __init__.py # Package initialization
│ ├── system.py # System management
│ ├── polymer.py # Polymer definition
│ ├── polymerization.py # Core polymerization logic
│ ├── bead_spring.py # Bead-spring models
│ ├── conf.py # Configuration settings
│ ├── logger.py # Logging utilities
│ └── extern/ # External dependencies
│ ├── Monomer_bank/ # Monomer templates
│ ├── moltemplate/ # Moltemplate files
│ └── rdlt.py # LAMMPS data utilities
├── examples/ # Usage examples
├── tests/ # Test suite
└── docs/ # Documentation
Manages file paths and directory operations for polymer simulations.
system = System(out="output_directory")
Defines polymer properties including topology, tacticity, and monomer sequences.
polymer = Polymer(
ChainNum=10, # Number of chains
Sequence=["monomer"], # Monomer sequence
DOP=100, # Degree of polymerization
topology="linear", # "linear" or "ring"
tacticity="atactic" # "atactic", "isotactic", "syndiotactic"
)
Core class for generating polymer structures using Moltemplate.
polymerization = Polymerization(
name="project_name",
system=system,
model=[polymer],
is_lopls=False # Use LOPLS force field
)
Simplified bead-spring model generator for coarse-grained simulations.
bead_polymer = BeadSpringPolymer(
name="model_name",
system=system,
n_chains=5,
n_beads=20,
topology="linear"
)
Configure logging levels in conf.py
:
LOG = {
'ROOT_LEVEL': logging.INFO,
'CONSOLE_LEVEL': logging.INFO,
'FILE_LEVEL': logging.INFO,
'TO_FILE': False
}
Set output directory in conf.py
:
OUT_PATH = os.path.join(os.path.expanduser("~"))
from AutoPoly import System, Polymer, Polymerization
system = System(out="polyethylene")
polymer = Polymer(ChainNum=10, Sequence=["ethylene"], DOP=50)
polymerization = Polymerization(name="PE", system=system, model=[polymer])
polymer = Polymer(
ChainNum=5,
Sequence=["styrene"],
topology="ring",
tacticity="atactic"
)
polymerization = Polymerization(name="ring_PS", system=system, model=[polymer])
polymer = Polymer(
ChainNum=10,
Sequence=["ethylene", "propylene"],
DOP=100,
tacticity="syndiotactic"
)
AutoPoly generates the following files:
system.data
: Atom coordinates and connectivitysystem.in.settings
: Force field parameterssystem.in.charges
: Atomic chargessystem.in
: LAMMPS input scriptsystem.in.init
: Initialization script
project_name/
├── moltemplate/ # Intermediate files
├── input/ # Input templates
├── output/ # LAMMPS files
└── logs/ # Log files
-
Monomer Not Found
- Check monomer bank path in
extern/Monomer_bank/
- Verify monomer file names match sequence
- Check monomer bank path in
-
Moltemplate Errors
- Ensure Moltemplate is properly installed
- Check monomer .lt file syntax
- Verify force field parameter files
-
File Permission Errors
- Check write permissions for output directory
- Ensure sufficient disk space
Enable detailed logging:
from AutoPoly.conf import LOG
LOG['ROOT_LEVEL'] = logging.DEBUG
LOG['TO_FILE'] = True
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests
- Submit a pull request
This project is licensed under the BSD License - see the license.md
file for details.
If you use AutoPoly in your research, please cite:
@software{autopoly2024,
title={AutoPoly: Automated Polymer Generation and Simulation Package},
author={Wu, Zhenghao},
year={2024},
url={https://github.com/your-repo/autopoly}
}
For questions and support:
- Check the documentation
- Review example files
- Open an issue on GitHub
- Contact the maintainers
- Moltemplate developers for the structure generation framework
- LAMMPS developers for the molecular dynamics engine
- OPLS-AA force field developers