I/O¶
PACKMOL¶
mdinterface.build.box.PackmolError
¶
Bases: RuntimeError
PACKMOL execution or output-processing failure.
Source code in mdinterface/build/box.py
Reading structures¶
mdinterface.io.read.read_lammps_data_file(filename, pbc=False, ato_start_idx=0, is_snippet=False)
¶
Source code in mdinterface/io/read.py
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 | |
mdinterface.io.read.read_lammps_nth_frame(filename, frame=-1)
¶
Read a single frame from a LAMMPS dump file without loading the full trajectory.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
filename
|
str
|
Path to the LAMMPS dump file. |
required |
frame
|
int
|
Frame index. |
-1
|
Returns:
| Type | Description |
|---|---|
Atoms
|
The requested frame as an ASE Atoms object with cell and PBC set. |
Raises:
| Type | Description |
|---|---|
IndexError
|
If the requested frame index is out of range. |
Source code in mdinterface/io/read.py
GROMACS writer¶
Warning
GROMACS output is experimental. Verify results against a reference before production use.
mdinterface.io.gromacswriter.write_gromacs_itp(specie, filename=None, *, include_atomtypes=True)
¶
Write a GROMACS include topology (.itp) file for a Specie.
.. warning:: GROMACS output is experimental and assumes harmonic bonds and angles, four-term OPLS proper torsions, CVFF impropers, geometric LJ mixing, and 0.5 LJ/Coulomb 1-4 scaling. Constraints are not generated.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
specie
|
Specie
|
The molecular species to write. |
required |
filename
|
str
|
Output filename. Defaults to |
None
|
include_atomtypes
|
bool
|
Include atom-type definitions. For multi-species systems, set False
and pass the species to :func: |
True
|
Raises:
| Type | Description |
|---|---|
ValueError
|
If parameters are incomplete, conflicting, or unsupported. |
Source code in mdinterface/io/gromacswriter.py
149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 | |
mdinterface.io.gromacswriter.write_gromacs_top(universe, itp_files, filename='system.top', system_name='MD System', *, species=None)
¶
Write a GROMACS system topology (.top) file.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
universe
|
Universe
|
The assembled system (after SimCell.build()). Used to determine
molecule counts from |
required |
itp_files
|
list of str
|
Basenames of the per-species ITP files to |
required |
filename
|
str
|
Output filename. Default |
'system.top'
|
system_name
|
str
|
Title written in the |
'MD System'
|
species
|
sequence of Specie
|
Species whose atom types are written before the molecule includes.
These ITP files must be written with |
None
|
Source code in mdinterface/io/gromacswriter.py
Logging utilities¶
mdinterface.utils.logger.set_verbosity(level)
¶
Set the log level for the entire mdinterface package.
A single StreamHandler is attached to the mdinterface root logger
(at most once). All child loggers (mdinterface.build.builder,
mdinterface.io.read, etc.) propagate to it automatically.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
level
|
bool, int, or str
|
Small integers map to a simple verbosity scale:
Integers >= 10 are passed directly as Python logging level constants
(e.g. |
required |
Source code in mdinterface/utils/logger.py
mdinterface.utils.logger.log_header(log, title, level=logging.INFO)
¶
Emit a fixed-width section header via log, preceded by a blank line.
The title is left-anchored after === and = fills the rest to
:data:_HEADER_WIDTH characters, so headers align regardless of title
length.
Example
::
from mdinterface.utils.logger import log_header
log_header(logger, "Build")
# [mdi] INFO |
# [mdi] INFO | === Build ================================
Source code in mdinterface/utils/logger.py
mdinterface.utils.logger.log_subheader(log, title, level=logging.INFO)
¶
Emit a fixed-width sub-section header via log.
Same width and left-anchor style as :func:log_header but uses -
as the fill character to indicate a lower level of hierarchy.
Example
::
log_subheader(logger, "Layer [1/4]")
# [mdi] INFO | -- Layer [1/4] ----------------------------
Source code in mdinterface/utils/logger.py
mdinterface.utils.logger.log_banner(log, *lines, level=logging.INFO)
¶
Emit a prominent multi-line banner with = borders.
Each line is centred within :data:_HEADER_WIDTH characters. Intended
for the top-level startup message of a major component (e.g. SimCell).
Example
::
log_banner(logger, "mdinterface :: SimCell", "version 1.5.0")
# [mdi] INFO | ============================================
# [mdi] INFO | mdinterface :: SimCell
# [mdi] INFO | version 1.5.0
# [mdi] INFO | ============================================