apoCHARMM 1.0.0
High-performance molecular dynamics simulations on GPUs
 
Loading...
Searching...
No Matches
apocharmm.charmm_context.CharmmContext Class Reference

More...

Inherits _ApoObject.

Public Member Functions

None __init__ (self, ForceManager|CharmmPsf force_manager_or_psf, CharmmParameters|None parameters=None)
 Constructs a Python CharmmContext wrapper.
 
None setPrm (self, CharmmParameters parameters)
 Sets the CHARMM parameter set.
 
None setPsf (self, CharmmPsf psf)
 Sets the PSF and imports its atom charges and masses.
 
None setForceManager (self, ForceManager force_manager)
 Sets the ForceManager associated with the context.
 
None setCoordinatesCharges (self, Sequence[Sequence[float]] coordinates_charges)
 Sets coordinates and charges from nested Python rows.
 
None setCoordinates (self, CharmmCrd|Sequence[Sequence[float]] coordinates)
 Sets coordinates from a CharmmCrd or nested Python rows.
 
None setCharges (self, Sequence[float] charges)
 Sets per-atom charges while preserving coordinates.
 
None setVelocitiesInverseMasses (self, Sequence[Sequence[float]] velocities_inverse_masses)
 Sets velocities and inverse masses from nested rows.
 
None setVelocities (self, Sequence[Sequence[float]] velocities)
 Sets velocity components while preserving inverse masses.
 
None setVelocitiesFromCHARMMVelocityFile (self, FilePath path)
 Loads velocities from a CHARMM velocity file.
 
None setMasses (self, Sequence[float] masses)
 Sets masses and stores native inverse masses.
 
None setTemperature (self, float temperature)
 Sets the stored target temperature.
 
None setPeriodicBoundaryCondition (self, PeriodicBoundaryCondition|int pbc)
 Sets the periodic boundary condition.
 
None setBoxDimensions (self, Sequence[float] box_dimensions)
 Sets orthorhombic box dimensions.
 
None setRandomSeed (self, int seed)
 Sets the random seed used for velocity assignment.
 
None useHolonomicConstraints (self, bool flag)
 Selects constrained degree-of-freedom accounting.
 
None setKappa (self, float kappa)
 Sets the Ewald splitting parameter.
 
None setCutoff (self, float cutoff)
 Sets the direct-space cutoff.
 
None setCtonnb (self, float ctonnb)
 Sets the nonbonded distance exposed as ctonnb.
 
None setCtofnb (self, float ctofnb)
 Sets the nonbonded distance exposed as ctofnb.
 
None setFFTGrid (self, Sequence[int] grid)
 Sets the three-dimensional PME FFT grid.
 
None setPmeSplineOrder (self, int order)
 Sets the PME interpolation spline order.
 
None setVdwType (self, VdwType|int vdw_type)
 Sets the van der Waals model identifier.
 
int getNumAtoms (self)
 Returns the context atom count.
 
int getNumDegreesOfFreedom (self)
 Returns the current degree-of-freedom count.
 
list[list[float]] getCoordinatesCharges (self)
 Returns a Python copy of coordinates and charges.
 
list[list[float]] getVelocityMass (self)
 Returns a Python copy of velocities and inverse masses.
 
PeriodicBoundaryCondition getPeriodicBoundaryCondition (self)
 Returns the periodic boundary condition.
 
tuple[float, float, float] getBoxDimensions (self)
 Returns the three stored box dimensions.
 
int getRandomSeed (self)
 Returns the stored random seed.
 
float getVolume (self)
 Returns the orthorhombic box volume.
 
float getKappa (self)
 Returns the stored Ewald splitting parameter.
 
float getCutoff (self)
 Returns the stored direct-space cutoff.
 
float getCtonnb (self)
 Returns the distance exposed as ctonnb.
 
float getCtofnb (self)
 Returns the distance exposed as ctofnb.
 
tuple[int, int, int] getFFTGrid (self)
 Returns the stored PME FFT grid.
 
int getPmeSplineOrder (self)
 Returns the stored PME interpolation spline order.
 
VdwType getVdwType (self)
 Returns the stored van der Waals model identifier.
 
ForceManager getForceManager (self)
 Returns a Python wrapper for the associated ForceManager.
 
None assignVelocitiesAtTemperature (self, float temperature)
 Assigns sampled velocities at a temperature.
 
float computeTemperature (self)
 Computes the instantaneous kinetic temperature.
 
None calculatePotentialEnergy (self, bool print_energy=False)
 Computes forces, potential energy, and virial.
 

Detailed Description

Represents mutable molecular state for apoCHARMM calculations.

Construct the wrapper from a ForceManager, or from a CharmmPsf together with CharmmParameters. The wrapper owns its C handle and retains Python references to collaborators whose native objects participate in the context.

Array setters copy Python values into temporary C buffers. Array getters return new Python lists or tuples; they do not expose native storage.

close() releases the owned context handle and is idempotent. The wrapper supports the context-manager protocol. Using a method that accesses self.handle after closure raises RuntimeError. Native nonzero statuses are raised as ApoCharmmError.

The wrapper and its native object provide no internal thread synchronization.

See also
charmm_context

Constructor & Destructor Documentation

◆ __init__()

None apocharmm.charmm_context.CharmmContext.__init__ (   self,
ForceManager | CharmmPsf  force_manager_or_psf,
CharmmParameters | None   parameters = None 
)

Constructs a Python CharmmContext wrapper.

Pass either a live ForceManager and leave parameters as None, or pass a live CharmmPsf together with a live CharmmParameters. Collaborator wrappers are retained to preserve their Python and native lifetimes.

Parameters
[in]force_manager_or_psfForceManager or CharmmPsf selecting the construction path.
[in]parametersCharmmParameters required with CharmmPsf, or None with ForceManager.
Exceptions
TypeErrorIf the argument combination does not match either supported construction path.
RuntimeErrorIf a supplied wrapper is closed, or native construction reports success but produces a NULL handle.
ApoCharmmErrorIf native validation, GPU setup, allocation, or force-manager initialization fails.

Member Function Documentation

◆ assignVelocitiesAtTemperature()

None apocharmm.charmm_context.CharmmContext.assignVelocitiesAtTemperature (   self,
float  temperature 
)

Assigns sampled velocities at a temperature.

The native context samples independent Cartesian Gaussian components using its stored seed. It does not remove center-of-mass motion or rescale the sampled result.

Parameters
[in]temperaturePython int or float accepted by ctypes.c_double, in kelvin. The value must be finite and non-negative.
Exceptions
TypeErrorIf temperature cannot initialize ctypes.c_double.
RuntimeErrorIf this context is closed.
ApoCharmmErrorIf the atom count is unset, native temperature validation fails, or the velocity transfer fails.

◆ calculatePotentialEnergy()

None apocharmm.charmm_context.CharmmContext.calculatePotentialEnergy (   self,
bool   print_energy = False 
)

Computes forces, potential energy, and virial.

The Python wrapper always passes reset=False. When print_energy is truthy, the native context writes a CHARMM-style energy table to standard output.

Parameters
[in]print_energyBoolean selecting native energy-table output.
Exceptions
RuntimeErrorIf this context is closed.
ApoCharmmErrorIf the force manager is not initialized, composite-manager printing is unsupported, or native force or CUDA work fails.

◆ computeTemperature()

float apocharmm.charmm_context.CharmmContext.computeTemperature (   self)

Computes the instantaneous kinetic temperature.

The native calculation evaluates kinetic energy on the GPU and divides by 0.5 * ndegf * k_B.

Returns
Python float in kelvin.
Exceptions
RuntimeErrorIf this context is closed.
ApoCharmmErrorIf atom, velocity, or degree-of-freedom state is incomplete, or native CUDA work fails.

◆ getBoxDimensions()

tuple[float, float, float] apocharmm.charmm_context.CharmmContext.getBoxDimensions (   self)

Returns the three stored box dimensions.

Returns
New (x, y, z) tuple of lengths in angstroms.
Exceptions
RuntimeErrorIf this context is closed.
ApoCharmmErrorIf native output validation fails.

◆ getCoordinatesCharges()

list[list[float]] apocharmm.charmm_context.CharmmContext.getCoordinatesCharges (   self)

Returns a Python copy of coordinates and charges.

Native device storage is transferred to host before copying. The result contains one [x, y, z, charge] list per atom. Coordinates use angstroms and charges use elementary-charge units.

Returns
Newly allocated list[list[float]] with shape (N, 4).
Exceptions
RuntimeErrorIf this context is closed.
ApoCharmmErrorIf atom-count retrieval, output validation, or the native device-to-host transfer fails.

◆ getCtofnb()

float apocharmm.charmm_context.CharmmContext.getCtofnb (   self)

Returns the distance exposed as ctofnb.

Returns
Python float in angstroms.
Exceptions
RuntimeErrorIf this context is closed.
ApoCharmmErrorIf no force manager is attached or the native getter fails.

◆ getCtonnb()

float apocharmm.charmm_context.CharmmContext.getCtonnb (   self)

Returns the distance exposed as ctonnb.

Returns
Python float in angstroms.
Exceptions
RuntimeErrorIf this context is closed.
ApoCharmmErrorIf no force manager is attached or the native getter fails.

◆ getCutoff()

float apocharmm.charmm_context.CharmmContext.getCutoff (   self)

Returns the stored direct-space cutoff.

Returns
Python float in angstroms.
Exceptions
RuntimeErrorIf this context is closed.
ApoCharmmErrorIf no force manager is attached or the native getter fails.

◆ getFFTGrid()

tuple[int, int, int] apocharmm.charmm_context.CharmmContext.getFFTGrid (   self)

Returns the stored PME FFT grid.

Returns
New (nfftx, nffty, nfftz) tuple of dimensionless grid sizes.
Exceptions
RuntimeErrorIf this context is closed.
ApoCharmmErrorIf no force manager is attached, the native grid does not contain exactly three values, or output validation fails.

◆ getForceManager()

ForceManager apocharmm.charmm_context.CharmmContext.getForceManager (   self)

Returns a Python wrapper for the associated ForceManager.

When construction or setForceManager() retained a wrapper, that same Python object is returned. Otherwise, the C ABI creates a newly owned force-manager handle sharing the native manager; the wrapper takes ownership of that handle and is cached by this context.

Closing the returned ForceManager releases only its C handle. The native context continues to retain its native manager.

Returns
Cached or newly created ForceManager wrapper.
Exceptions
RuntimeErrorIf the context must access its native handle after closure.
ApoCharmmErrorIf the native context has no force manager or C handle creation fails.

◆ getKappa()

float apocharmm.charmm_context.CharmmContext.getKappa (   self)

Returns the stored Ewald splitting parameter.

Returns
Python float in inverse angstroms.
Exceptions
RuntimeErrorIf this context is closed.
ApoCharmmErrorIf no force manager is attached or the native getter fails.

◆ getNumAtoms()

int apocharmm.charmm_context.CharmmContext.getNumAtoms (   self)

Returns the context atom count.

Returns
Python int containing the dimensionless atom count.
Exceptions
RuntimeErrorIf this context is closed.
ApoCharmmErrorIf the native getter fails.

◆ getNumDegreesOfFreedom()

int apocharmm.charmm_context.CharmmContext.getNumDegreesOfFreedom (   self)

Returns the current degree-of-freedom count.

Returns
Python int containing the dimensionless count.
Exceptions
RuntimeErrorIf this context is closed.
ApoCharmmErrorIf the native getter fails.

◆ getPeriodicBoundaryCondition()

PeriodicBoundaryCondition apocharmm.charmm_context.CharmmContext.getPeriodicBoundaryCondition (   self)

Returns the periodic boundary condition.

Returns
PeriodicBoundaryCondition mapped from the native value.
Exceptions
RuntimeErrorIf this context is closed.
ApoCharmmErrorIf the C ABI getter fails.
ValueErrorIf a successful C ABI call returns an integer not represented by PeriodicBoundaryCondition.

◆ getPmeSplineOrder()

int apocharmm.charmm_context.CharmmContext.getPmeSplineOrder (   self)

Returns the stored PME interpolation spline order.

Returns
Python int containing the dimensionless order.
Exceptions
RuntimeErrorIf this context is closed.
ApoCharmmErrorIf no force manager is attached or the native getter fails.

◆ getRandomSeed()

int apocharmm.charmm_context.CharmmContext.getRandomSeed (   self)

Returns the stored random seed.

Returns
Python int in the unsigned 64-bit range.
Exceptions
RuntimeErrorIf this context is closed.
ApoCharmmErrorIf the native getter fails.

◆ getVdwType()

VdwType apocharmm.charmm_context.CharmmContext.getVdwType (   self)

Returns the stored van der Waals model identifier.

Returns
VdwType mapped from the native model code.
Exceptions
RuntimeErrorIf this context is closed.
ApoCharmmErrorIf no force manager is attached or the native getter fails.
ValueErrorIf a successful native call returns an integer not represented by VdwType.

◆ getVelocityMass()

list[list[float]] apocharmm.charmm_context.CharmmContext.getVelocityMass (   self)

Returns a Python copy of velocities and inverse masses.

Despite the method name, each fourth component is inverse mass, not mass. Rows are [vx, vy, vz, inverse_mass]; velocity uses angstroms per AKMA time unit and inverse mass uses reciprocal atomic mass units.

Returns
Newly allocated list[list[float]] with shape (N, 4).
Exceptions
RuntimeErrorIf this context is closed.
ApoCharmmErrorIf atom-count retrieval, output validation, or the native device-to-host transfer fails.

◆ getVolume()

float apocharmm.charmm_context.CharmmContext.getVolume (   self)

Returns the orthorhombic box volume.

Returns
Python float in cubic angstroms.
Exceptions
RuntimeErrorIf this context is closed.
ApoCharmmErrorIf valid positive box dimensions have not been set or the native getter otherwise fails.

◆ setBoxDimensions()

None apocharmm.charmm_context.CharmmContext.setBoxDimensions (   self,
Sequence[float]  box_dimensions 
)

Sets orthorhombic box dimensions.

box_dimensions is converted to a temporary contiguous double buffer. It must contain exactly [x, y, z] lengths in angstroms.

Parameters
[in]box_dimensionsSequence of exactly three numeric values.
Exceptions
TypeErrorIf the input is not iterable or a value cannot be converted with float().
ValueErrorIf scalar conversion raises ValueError.
RuntimeErrorIf this context is closed.
ApoCharmmErrorIf the length is not three, a dimension is not positive, attached force configuration is invalid, or native initialization or neighbor-list work fails.

◆ setCharges()

None apocharmm.charmm_context.CharmmContext.setCharges (   self,
Sequence[float]  charges 
)

Sets per-atom charges while preserving coordinates.

Each scalar is converted with float(), copied to a temporary C buffer, and then copied by the native context. Charges use elementary-charge units.

Parameters
[in]chargesSequence containing exactly one value per atom.
Exceptions
TypeErrorIf charges is not iterable or a value cannot be converted with float().
ValueErrorIf scalar conversion raises ValueError.
RuntimeErrorIf this context is closed.
ApoCharmmErrorIf the atom count is unset, the sequence length is wrong, or native transfer fails.

◆ setCoordinates()

None apocharmm.charmm_context.CharmmContext.setCoordinates (   self,
CharmmCrd | Sequence[Sequence[float]]   coordinates 
)

Sets coordinates from a CharmmCrd or nested Python rows.

A CharmmCrd is borrowed for the native call and is not retained. Otherwise, coordinates must contain one [x, y, z] row per atom. Scalars are converted with float() and copied through a temporary C buffer. Coordinates use angstroms and existing charges are preserved.

Parameters
[in]coordinatesLive CharmmCrd wrapper or sequence of three-value row sequences.
Exceptions
TypeErrorIf a row is not iterable, a scalar cannot be converted, or a closed CharmmCrd is accessed.
ValueErrorIf scalar conversion fails or a row does not contain exactly three values.
RuntimeErrorIf this context or a supplied CharmmCrd is closed.
ApoCharmmErrorIf the atom count is unset, the coordinate count is wrong, or native transfer or neighbor-list work fails.

◆ setCoordinatesCharges()

None apocharmm.charmm_context.CharmmContext.setCoordinatesCharges (   self,
Sequence[Sequence[float]]   coordinates_charges 
)

Sets coordinates and charges from nested Python rows.

coordinates_charges must contain one row per atom and exactly four values per row in [x, y, z, charge] order. Coordinates use angstroms and charges use elementary-charge units. Every scalar is converted with float(), flattened into a temporary ctypes buffer, and copied by the native context.

Parameters
[in]coordinates_chargesSequence of fixed-width row sequences.
Exceptions
TypeErrorIf a row is not iterable or a scalar cannot be converted to float.
ValueErrorIf scalar conversion fails or a row does not contain exactly four values.
RuntimeErrorIf this context is closed.
ApoCharmmErrorIf the atom count is unset, the row count is wrong, or native transfer or neighbor-list work fails.

◆ setCtofnb()

None apocharmm.charmm_context.CharmmContext.setCtofnb (   self,
float  ctofnb 
)

Sets the nonbonded distance exposed as ctofnb.

Parameters
[in]ctofnbPython int or float accepted by ctypes.c_double, in angstroms. The native float-converted value must be finite and positive.
Exceptions
TypeErrorIf ctofnb cannot initialize ctypes.c_double.
RuntimeErrorIf this context is closed.
ApoCharmmErrorIf no force manager is attached or native validation fails.
Warning
The current backend forwards this value as ron. Configure it before force-manager initialization.

◆ setCtonnb()

None apocharmm.charmm_context.CharmmContext.setCtonnb (   self,
float  ctonnb 
)

Sets the nonbonded distance exposed as ctonnb.

Parameters
[in]ctonnbPython int or float accepted by ctypes.c_double, in angstroms. The native float-converted value must be finite and positive.
Exceptions
TypeErrorIf ctonnb cannot initialize ctypes.c_double.
RuntimeErrorIf this context is closed.
ApoCharmmErrorIf no force manager is attached or native validation fails.
Warning
The current backend forwards this value as roff. Configure it before force-manager initialization.

◆ setCutoff()

None apocharmm.charmm_context.CharmmContext.setCutoff (   self,
float  cutoff 
)

Sets the direct-space cutoff.

Parameters
[in]cutoffPython int or float accepted by ctypes.c_double, in angstroms. The native float-converted value must be finite and positive.
Exceptions
TypeErrorIf cutoff cannot initialize ctypes.c_double.
RuntimeErrorIf this context is closed.
ApoCharmmErrorIf no force manager is attached or native validation fails.
Warning
Configure this value before force-manager initialization.

◆ setFFTGrid()

None apocharmm.charmm_context.CharmmContext.setFFTGrid (   self,
Sequence[int]  grid 
)

Sets the three-dimensional PME FFT grid.

Each element is converted with int() and copied to a temporary C buffer. The sequence must contain exactly three positive dimensions in X, Y, Z order.

Parameters
[in]gridSequence of three integer-convertible values.
Exceptions
TypeErrorIf grid is not iterable or an element cannot be converted with int().
ValueErrorIf integer conversion fails.
RuntimeErrorIf this context is closed.
ApoCharmmErrorIf the length is not three, a dimension is not positive, or no force manager is attached.
Warning
Configure the grid before force-manager initialization.

◆ setForceManager()

None apocharmm.charmm_context.CharmmContext.setForceManager (   self,
ForceManager  force_manager 
)

Sets the ForceManager associated with the context.

The wrapper retains force_manager after a successful native state reconciliation and clears retained PSF and parameter wrappers because the new manager becomes their native source.

Parameters
[in]force_managerLive ForceManager wrapper.
Exceptions
TypeErrorIf force_manager is not a ForceManager.
RuntimeErrorIf this context or force_manager is closed.
ApoCharmmErrorIf native state reconciliation or initialization fails.

◆ setKappa()

None apocharmm.charmm_context.CharmmContext.setKappa (   self,
float  kappa 
)

Sets the Ewald splitting parameter.

Parameters
[in]kappaPython int or float accepted by ctypes.c_double, in inverse angstroms. The native float-converted value must be finite and non-negative.
Exceptions
TypeErrorIf kappa cannot initialize ctypes.c_double.
RuntimeErrorIf this context is closed.
ApoCharmmErrorIf no force manager is attached or native validation fails.
Warning
Configure this value before force-manager initialization.

◆ setMasses()

None apocharmm.charmm_context.CharmmContext.setMasses (   self,
Sequence[float]  masses 
)

Sets masses and stores native inverse masses.

Each scalar is converted with float() and interpreted as an atomic mass-unit value. The native context stores its reciprocal and preserves existing velocity components.

Parameters
[in]massesSequence containing exactly one mass per atom.
Exceptions
TypeErrorIf masses is not iterable or a value cannot be converted to float.
ValueErrorIf scalar conversion raises ValueError.
RuntimeErrorIf this context is closed.
ApoCharmmErrorIf the atom count is unset, the sequence length is wrong, or native transfer fails.
Warning
The current native implementation does not reject zero, negative, infinite, or NaN masses before division.

◆ setPeriodicBoundaryCondition()

None apocharmm.charmm_context.CharmmContext.setPeriodicBoundaryCondition (   self,
PeriodicBoundaryCondition | int   pbc 
)

Sets the periodic boundary condition.

pbc is normalized through PeriodicBoundaryCondition before its integer value is passed to the C ABI.

Parameters
[in]pbcPeriodicBoundaryCondition or matching integer value 0, 1, or 2.
Exceptions
TypeErrorIf pbc cannot be interpreted by the enumeration.
ValueErrorIf the integer is not a declared enum value.
RuntimeErrorIf this context is closed.
ApoCharmmErrorIf native propagation, initialization, imaging, or neighbor-list rebuilding fails.

◆ setPmeSplineOrder()

None apocharmm.charmm_context.CharmmContext.setPmeSplineOrder (   self,
int  order 
)

Sets the PME interpolation spline order.

Parameters
[in]orderPython integer accepted by ctypes.c_int. The native value must be positive.
Exceptions
TypeErrorIf order cannot initialize ctypes.c_int.
RuntimeErrorIf this context is closed.
ApoCharmmErrorIf order is not positive or no force manager is attached.
Warning
Configure the order before force-manager initialization.

◆ setPrm()

None apocharmm.charmm_context.CharmmContext.setPrm (   self,
CharmmParameters  parameters 
)

Sets the CHARMM parameter set.

The wrapper requires a CharmmParameters, passes its borrowed handle to the C ABI, and retains the Python object after success.

Parameters
[in]parametersLive CharmmParameters wrapper.
Exceptions
TypeErrorIf parameters is not a CharmmParameters.
RuntimeErrorIf this context or parameters is closed.
ApoCharmmErrorIf native synchronization or initialization fails.

◆ setPsf()

None apocharmm.charmm_context.CharmmContext.setPsf (   self,
CharmmPsf  psf 
)

Sets the PSF and imports its atom charges and masses.

The wrapper requires a CharmmPsf, passes its borrowed handle to the C ABI, and retains the Python object after success.

Parameters
[in]psfLive CharmmPsf wrapper.
Exceptions
TypeErrorIf psf is not a CharmmPsf.
RuntimeErrorIf this context or psf is closed.
ApoCharmmErrorIf the atom count conflicts, storage or transfer fails, or force-manager initialization fails.

◆ setRandomSeed()

None apocharmm.charmm_context.CharmmContext.setRandomSeed (   self,
int  seed 
)

Sets the random seed used for velocity assignment.

Parameters
[in]seedPython int in the inclusive range [0, 2**64 - 1].
Exceptions
TypeErrorIf seed is not comparable with integers or cannot initialize ctypes.c_uint64.
ValueErrorIf seed is outside the unsigned 64-bit range.
RuntimeErrorIf this context is closed.
ApoCharmmErrorIf the native context rejects the update.

◆ setTemperature()

None apocharmm.charmm_context.CharmmContext.setTemperature (   self,
float  temperature 
)

Sets the stored target temperature.

This method does not generate or rescale velocities.

Parameters
[in]temperaturePython int or float accepted by ctypes.c_double, in kelvin. The native value must be finite and non-negative.
Exceptions
TypeErrorIf temperature cannot initialize ctypes.c_double.
RuntimeErrorIf this context is closed.
ApoCharmmErrorIf the native value is non-finite or negative.

◆ setVdwType()

None apocharmm.charmm_context.CharmmContext.setVdwType (   self,
VdwType | int  vdw_type 
)

Sets the van der Waals model identifier.

The argument is normalized through VdwType. Native CharmmContext accepts values VdwType.VSH through VdwType.DBEXP.

Parameters
[in]vdw_typeVdwType or matching integer value.
Exceptions
TypeErrorIf vdw_type cannot be interpreted by the enum.
ValueErrorIf it is not a declared Python enum value.
RuntimeErrorIf this context is closed.
ApoCharmmErrorIf the normalized value is VdwType.NONE, no force manager is attached, or native validation fails.
Warning
Configure the model before force-manager initialization.

◆ setVelocities()

None apocharmm.charmm_context.CharmmContext.setVelocities (   self,
Sequence[Sequence[float]]  velocities 
)

Sets velocity components while preserving inverse masses.

Every row must be [vx, vy, vz] in angstroms per AKMA time unit. Scalars are converted with float() and copied through a temporary C buffer.

Parameters
[in]velocitiesSequence containing one three-value row per atom.
Exceptions
TypeErrorIf a row is not iterable or a scalar cannot be converted to float.
ValueErrorIf scalar conversion fails or a row does not contain exactly three values.
RuntimeErrorIf this context is closed.
ApoCharmmErrorIf the atom count is unset, the row count is wrong, or native transfer fails.

◆ setVelocitiesFromCHARMMVelocityFile()

None apocharmm.charmm_context.CharmmContext.setVelocitiesFromCHARMMVelocityFile (   self,
FilePath  path 
)

Loads velocities from a CHARMM velocity file.

path is encoded with os.fsencode() through encode_path() and is borrowed by the C ABI for the duration of the call. The native parser requires a matching atom count and one parseable velocity record per atom.

Parameters
[in]pathstr, bytes, or os.PathLike path accepted by os.fsencode().
Exceptions
TypeErrorIf path cannot be encoded as a filesystem path.
RuntimeErrorIf this context is closed.
ApoCharmmErrorIf the atom count is unset, the path is empty, the file cannot be opened or parsed, the atom count differs, or native transfer fails.

◆ setVelocitiesInverseMasses()

None apocharmm.charmm_context.CharmmContext.setVelocitiesInverseMasses (   self,
Sequence[Sequence[float]]   velocities_inverse_masses 
)

Sets velocities and inverse masses from nested rows.

Every row must be [vx, vy, vz, inverse_mass]. Velocity components use angstroms per AKMA time unit and inverse mass uses reciprocal atomic mass units. Scalars are converted with float() and copied through a temporary C buffer.

Parameters
[in]velocities_inverse_massesSequence of four-value rows.
Exceptions
TypeErrorIf a row is not iterable or a scalar cannot be converted to float.
ValueErrorIf scalar conversion fails or a row does not contain exactly four values.
RuntimeErrorIf this context is closed.
ApoCharmmErrorIf the atom count is unset, the row count is wrong, or native transfer fails.

◆ useHolonomicConstraints()

None apocharmm.charmm_context.CharmmContext.useHolonomicConstraints (   self,
bool  flag 
)

Selects constrained degree-of-freedom accounting.

The value is converted with ctypes.c_bool. The native context recomputes its degree-of-freedom count but does not execute a constraint solver.

Parameters
[in]flagBoolean selection.
Exceptions
RuntimeErrorIf this context is closed.
ApoCharmmErrorIf the native context has no PSF or no force manager.