Convert Utility
X-axis conversion utilities for ReaxKit plots and analyses.
This module provides helpers for converting iteration indices to alternative x-axis representations such as simulation frames or physical time, based on information read from a ReaxFF control file.
Typical use cases include:
- plotting observables versus simulation time instead of iteration number
- switching between iteration, frame, and time axes in workflows
- automatically choosing appropriate time units (fs, ps, ns)
convert_xaxis(iters, xaxis, control_file='control')
Convert iteration indices to a different x-axis representation.
Supported target axes include iteration number, frame index, and physical simulation time. When converting to time, the function automatically selects appropriate units (fs, ps, or ns) based on the total time span.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
iters
|
array - like
|
Iteration indices to convert. |
required |
xaxis
|
(iter, frame, time)
|
Target x-axis representation. |
'iter'
|
control_file
|
str
|
Path to the ReaxFF control file used to determine the time step. |
'control'
|
Returns:
| Type | Description |
|---|---|
tuple[ndarray, str]
|
Converted x-axis values and a human-readable axis label. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If the requested x-axis is unknown or the time step cannot be determined from the control file. |
Examples:
>>> x, label = convert_xaxis(iters, "time")
>>> x, label = convert_xaxis(iters, "frame")