I/O¶
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 | |
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)
¶
Write a GROMACS include topology (.itp) file for a Specie.
.. warning:: GROMACS output is experimental. Unit conversions and dihedral mappings have been validated for OPLS-AA molecules generated by LigParGen, but other force fields or atom styles may need adjustments. Use with care and verify the output against a reference.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
specie
|
Specie
|
The molecular species to write. |
required |
filename
|
str
|
Output filename. Defaults to |
None
|
Source code in mdinterface/io/gromacswriter.py
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 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 | |
mdinterface.io.gromacswriter.write_gromacs_top(universe, itp_files, filename='system.top', system_name='MD System')
¶
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'
|
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 | ============================================