Replaces a CHARMM-style restart file with current simulation state. More...
Public Member Functions | |
| None | __init__ (self, FilePath path, int|None report_frequency=None) |
| Constructs and owns a native restart writer. | |
| None | close (self) |
| Releases the owned concrete C handle and clears its base view. | |
Public Member Functions inherited from apocharmm.subscriber.Subscriber | |
| ctypes.c_void_p | subscriber_handle (self) |
| Returns the borrowed C base-subscriber pointer. | |
| None | setReportFrequency (self, int report_frequency) |
| Sets the native reporting interval. | |
| int | getReportFrequency (self) |
| Returns the native reporting interval. | |
Replaces a CHARMM-style restart file with current simulation state.
Construction immediately creates or truncates the text output. During propagation, each scheduled native update rewrites the complete file with current context state and supported-integrator state. Box lengths and coordinates use angstroms, velocities use angstroms per AKMA time unit, and average temperature uses kelvin.
Native updates support CudaNoseHooverIntegrator, CudaLangevinPistonIntegrator, and CudaLangevinThermostatIntegrator. Device-backed state is copied to host, and each transfer synchronizes the current CUDA device.
The wrapper owns the concrete C handle. Its subscriber_handle property is a borrowed view into that handle. Use the object as a context manager or call close() through the wrapper; never destroy the borrowed view.
| None apocharmm.restart_subscriber.RestartSubscriber.__init__ | ( | self, | |
| FilePath | path, | ||
| int | None | report_frequency = None |
||
| ) |
Constructs and owns a native restart writer.
path is converted with os.fsencode() through the package helper and copied by native construction. Accepted path objects are str, bytes, os.PathLike[str], and os.PathLike[bytes]. The original Python object is retained in _path, but native file access does not borrow it.
report_frequency=None selects the native default of 1000 steps. An explicit ordinary Python int must fit a signed 32-bit C int and be positive. Boolean values follow Python integer conversion: True becomes one and False is rejected by native validation.
| [in] | path | Filesystem path to create or truncate. It must encode to a nonempty native path; when the path has a nonempty parent path, that parent path must exist. Encoded bytes are passed as a null-terminated C string, so an embedded null byte truncates the path observed by native code. |
| [in] | report_frequency | Optional positive, dimensionless number of propagated steps between restart replacements. |
| TypeError | If path is not accepted by os.fsencode(), or an explicit frequency cannot be compared with integer bounds or converted by ctypes.c_int. |
| UnicodeEncodeError | If the platform filesystem encoding cannot encode a string path. |
| ValueError | If an explicit frequency is outside the signed 32-bit C int range. |
| ApoCharmmError | With native status APO_STATUS_INVALID_ARGUMENT if native construction rejects the path or frequency, or APO_STATUS_RUNTIME_ERROR if file opening, allocation, base-view conversion, or an unexpected native exception fails. |
| RuntimeError | If a native function reports success but returns a null concrete or base handle. |
Reimplemented from apocharmm.subscriber.Subscriber.
| None apocharmm.restart_subscriber.RestartSubscriber.close | ( | self | ) |
Releases the owned concrete C handle and clears its base view.
The inherited close operation is idempotent. On the first call it invokes apo_restart_subscriber_destroy, then this override clears the borrowed subscriber_handle regardless of whether the concrete handle had already been released.
None. RuntimeError. CudaIntegrator.unsubscribe(self) before closure. Native unsubscription requires the borrowed base view that this method clears.