Guest occupancy and cage-related operations in clathrate hydrates.
6_with_guests.py
8_cage_survey.py
6_with_guests.py |
6_with_guests.sh |
6_with_guests.yaml |
=== “6_with_guests.py”
```python
from logging import basicConfig, DEBUG, INFO
import numpy as np
from genice3.genice import GenIce3
from genice3.plugin import Exporter, Molecule
from genice3.cli.options import parse_guest_option, parse_spot_guest_option
# Corresponding CLI command (guest/spot_guest are base options, outside the exporter):
# genice3 "A15[shift=(0.1,0.1,0.1), anion.0=Cl, cation.6=Na, density=0.8]" \
# --rep 2 2 2 \
# --guest A12=me --guest A14=et --spot_guest 0=4site \
# --exporter gromacs :water_model 4site \
# --seed 42 --pol_loop_1 2000 -D
basicConfig(level=INFO)
# Create a GenIce3 instance.
# guests: guest molecules per cage type (raw dict is converted by parse_guest_option).
# spot_guests: guest molecules for specific cages (raw dict is converted by parse_spot_guest_option).
genice = GenIce3(
seed=42,
pol_loop_1=2000,
replication_matrix=np.array([[2, 0, 0], [0, 2, 0], [0, 0, 2]]),
guests=parse_guest_option({"A12": "me", "A14": "et"}),
spot_guests=parse_spot_guest_option({0: "4site"}),
)
# Set the unit cell.
# shift: shift in fractional coordinates.
# anion / cation: replace lattice sites in the unit cell with ions (site index -> ion name). CLI: -a / --anion, -c / --cation
# density: density in g/cm³.
# If cage information is needed, you can use Exporter("cage_survey").dump(genice, file) to output JSON.
genice.set_unitcell("A15", shift=(0.1, 0.1, 0.1), density=0.8)
# Output using the exporter (guest/spot_guest are already set in the GenIce3 instance).
Exporter("gromacs").dump(
genice,
water_model="4site",
)
```
=== “6_with_guests.sh”
```bash
#!/bin/bash
# Generated from 6_with_guests.yaml
python3 -m genice3.cli.genice A15 \
--shift 0.1 0.1 0.1 \
--density 0.8 \
--rep 2 2 2 \
--guest A12=me A14=et \
--spot_guest 0=4site \
--exporter gromacs :water_model 4site \
--seed 42 \
--pol_loop_1 2000
```
=== “6_with_guests.yaml”
```yaml
# Run with GenIce3: genice3 --config 6_with_guests.yaml
# Generated from 6_with_guests.sh
unitcell: A15
shift:
- 0.1
- 0.1
- 0.1
density: 0.8
rep:
- 2
- 2
- 2
guest:
- A12=me
- A14=et
spot_guest: 0=4site
exporter:
gromacs:
water_model: 4site
seed: 42
pol_loop_1: 2000
```
8_cage_survey.py |
8_cage_survey.sh |
8_cage_survey.yaml |
=== “8_cage_survey.py”
```python
"""Example of using ``cage_survey`` for the DOH structure (Python API)."""
from genice3.genice import GenIce3
from genice3.plugin import Exporter
from logging import basicConfig, INFO
# Corresponding CLI command:
# genice3 DOH -e cage_survey
basicConfig(level=INFO)
genice = GenIce3()
genice.set_unitcell("DOH")
Exporter("cage_survey").dump(genice)
```
=== “8_cage_survey.sh”
```bash
#!/bin/bash
# Generated from 8_cage_survey.yaml
python3 -m genice3.cli.genice DOH \
--exporter cage_survey
```
=== “8_cage_survey.yaml”
```yaml
# Run with GenIce3: genice3 --config 8_cage_survey.yaml
# Generated from 8_cage_survey.sh
unitcell: DOH
exporter: cage_survey
```