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

More...

Inherits _ApoObject.

Public Member Functions

None __init__ (self, FilePath path)
 Constructs an owning wrapper from one PSF file.
 
int getNumAtoms (self)
 Returns the atom count.
 
int getNumBonds (self)
 Returns the bond count.
 
int getNumAngles (self)
 Returns the angle count.
 
int getNumDihedrals (self)
 Returns the proper-dihedral count.
 
int getNumImpropers (self)
 Returns the improper-dihedral count.
 
int getNumCrossTerms (self)
 Returns the CMAP cross-term count.
 
list[str] getSegmentIdentifiers (self)
 Returns copied per-atom segment identifiers.
 
list[int] getResidueIdentifiers (self)
 Returns copied per-atom residue identifiers.
 
list[str] getResidueNames (self)
 Returns copied per-atom residue names.
 
list[str] getAtomNames (self)
 Returns copied per-atom atom names.
 
list[str] getAtomTypes (self)
 Returns copied per-atom CHARMM atom types.
 
list[float] getCharges (self)
 Returns copied per-atom partial charges.
 
list[float] getMasses (self)
 Returns copied per-atom masses.
 
float getNetCharge (self)
 Computes the net partial charge.
 
float getTotalMass (self)
 Computes the total mass.
 
str getFileName (self)
 Returns the stored PSF path.
 

Detailed Description

Owns a parsed native CHARMM PSF.

Construct the wrapper from a str, bytes, os.PathLike[str], or os.PathLike[bytes] path. The path is converted with os.fsencode, copied through the C ABI, and not retained as a Python object. Parsing and native derivation complete before construction returns.

Every metadata getter returns a new Python scalar, string, or list. No returned Python value aliases native PSF storage. The current Python API exposes counts, per-atom metadata, aggregate charge and mass, and the stored path; native bond, angle, dihedral, connectivity, residue-interval, water, and group arrays are not exposed.

The wrapper owns one C handle. close() and context-manager exit release that handle and are idempotent. Accessing a method after closure raises RuntimeError. Native ForceManager and CharmmContext objects created from this PSF retain shared native ownership; their Python wrappers also retain the source wrapper where required by the current high-level API.

The wrapper provides no internal synchronization. Do not overlap close() with another method call from a different thread.

See also
charmm_psf

Constructor & Destructor Documentation

◆ __init__()

None apocharmm.charmm_psf.CharmmPsf.__init__ (   self,
FilePath  path 
)

Constructs an owning wrapper from one PSF file.

The path is converted with os.fsencode and copied before native parsing. File-name extensions are not validated. The native constructor parses atom metadata and topology, then derives residue intervals, recognized water tuples, connected-component intervals, and exclusion data.

Parameters
[in]pathPath supplied as str, bytes, os.PathLike[str], or os.PathLike[bytes]. Its encoded representation must be non-empty.
Exceptions
TypeErrorIf path cannot be converted by os.fsencode.
ApoCharmmErrorIf the encoded path is empty, the file cannot be read, the PSF is malformed, a count or topology atom number is unsupported, or a native CUDA operation fails.
RuntimeErrorIf APOCHARMM_LIBRARY_PATH is unset or empty, or if native construction reports success but produces a NULL handle.
OSErrorIf the configured apoCHARMM C ABI shared library cannot be loaded.
Postcondition
On success, this wrapper owns a live native PSF handle.
Warning
An encoded path containing an embedded null byte is truncated at that byte by the C-string boundary instead of being rejected.

Member Function Documentation

◆ getAtomNames()

list[str] apocharmm.charmm_psf.CharmmPsf.getAtomNames (   self)

Returns copied per-atom atom names.

Each native field occupies eight bytes, is decoded as UTF-8, and has leading and trailing whitespace removed with str.strip().

Returns
New list[str] of length getNumAtoms() in atom-record order. The list and strings do not alias native storage.
Exceptions
RuntimeErrorIf this wrapper is closed.
ApoCharmmErrorIf a native count or buffer operation fails.
UnicodeDecodeErrorIf a returned fixed-width field is not valid UTF-8.
Warning
Native names longer than eight bytes are silently truncated by the current C ABI.

◆ getAtomTypes()

list[str] apocharmm.charmm_psf.CharmmPsf.getAtomTypes (   self)

Returns copied per-atom CHARMM atom types.

Each native field occupies eight bytes, is decoded as UTF-8, and has leading and trailing whitespace removed with str.strip().

Returns
New list[str] of length getNumAtoms() in atom-record order. The list and strings do not alias native storage.
Exceptions
RuntimeErrorIf this wrapper is closed.
ApoCharmmErrorIf a native count or buffer operation fails.
UnicodeDecodeErrorIf a returned fixed-width field is not valid UTF-8.
Warning
Native types longer than eight bytes are silently truncated by the current C ABI.

◆ getCharges()

list[float] apocharmm.charmm_psf.CharmmPsf.getCharges (   self)

Returns copied per-atom partial charges.

Returns
New list[float] of length getNumAtoms() in atom-record order. Values use elementary-charge units and do not alias native storage.
Exceptions
RuntimeErrorIf this wrapper is closed.
ApoCharmmErrorIf a native count or buffer operation fails.

◆ getFileName()

str apocharmm.charmm_psf.CharmmPsf.getFileName (   self)

Returns the stored PSF path.

The method requests a fixed 1024-byte C buffer, decodes the complete buffer as UTF-8, and removes trailing ASCII spaces. The returned Python string is a copy and does not alias native storage.

Returns
Stored path as a Python str.
Exceptions
RuntimeErrorIf this wrapper is closed.
ApoCharmmErrorIf the native path requires more than 1024 bytes or the native handle is invalid.
UnicodeDecodeErrorIf the stored path bytes are not valid UTF-8.
Warning
Trailing spaces that were part of the supplied path are removed by the current wrapper.

◆ getMasses()

list[float] apocharmm.charmm_psf.CharmmPsf.getMasses (   self)

Returns copied per-atom masses.

Returns
New list[float] of length getNumAtoms() in atom-record order. Values use atomic mass units and do not alias native storage.
Exceptions
RuntimeErrorIf this wrapper is closed.
ApoCharmmErrorIf a native count or buffer operation fails.

◆ getNetCharge()

float apocharmm.charmm_psf.CharmmPsf.getNetCharge (   self)

Computes the net partial charge.

Returns
Python float containing the sum in elementary-charge units.
Exceptions
RuntimeErrorIf this wrapper is closed.
ApoCharmmErrorIf the native atom count is uninitialized, the native charge-vector length is inconsistent, or the handle is invalid.

◆ getNumAngles()

int apocharmm.charmm_psf.CharmmPsf.getNumAngles (   self)

Returns the angle count.

Returns
Nonnegative dimensionless Python int.
Exceptions
RuntimeErrorIf this wrapper is closed.
ApoCharmmErrorIf the native handle is invalid or reports a negative angle count.

◆ getNumAtoms()

int apocharmm.charmm_psf.CharmmPsf.getNumAtoms (   self)

Returns the atom count.

Returns
Nonnegative dimensionless Python int.
Exceptions
RuntimeErrorIf this wrapper is closed.
ApoCharmmErrorIf the native handle is invalid or reports a negative atom count.

◆ getNumBonds()

int apocharmm.charmm_psf.CharmmPsf.getNumBonds (   self)

Returns the bond count.

Returns
Nonnegative dimensionless Python int.
Exceptions
RuntimeErrorIf this wrapper is closed.
ApoCharmmErrorIf the native handle is invalid or reports a negative bond count.

◆ getNumCrossTerms()

int apocharmm.charmm_psf.CharmmPsf.getNumCrossTerms (   self)

Returns the CMAP cross-term count.

Returns
Nonnegative dimensionless Python int.
Exceptions
RuntimeErrorIf this wrapper is closed.
ApoCharmmErrorIf the native handle is invalid or reports a negative cross-term count.

◆ getNumDihedrals()

int apocharmm.charmm_psf.CharmmPsf.getNumDihedrals (   self)

Returns the proper-dihedral count.

Returns
Nonnegative dimensionless Python int.
Exceptions
RuntimeErrorIf this wrapper is closed.
ApoCharmmErrorIf the native handle is invalid or reports a negative proper-dihedral count.

◆ getNumImpropers()

int apocharmm.charmm_psf.CharmmPsf.getNumImpropers (   self)

Returns the improper-dihedral count.

Returns
Nonnegative dimensionless Python int.
Exceptions
RuntimeErrorIf this wrapper is closed.
ApoCharmmErrorIf the native handle is invalid or reports a negative improper-dihedral count.

◆ getResidueIdentifiers()

list[int] apocharmm.charmm_psf.CharmmPsf.getResidueIdentifiers (   self)

Returns copied per-atom residue identifiers.

Returns
New list[int] of length getNumAtoms() in atom-record order. Values are dimensionless and do not alias native storage.
Exceptions
RuntimeErrorIf this wrapper is closed.
ApoCharmmErrorIf a native count or buffer operation fails.

◆ getResidueNames()

list[str] apocharmm.charmm_psf.CharmmPsf.getResidueNames (   self)

Returns copied per-atom residue names.

Each native field occupies eight bytes, is decoded as UTF-8, and has leading and trailing whitespace removed with str.strip().

Returns
New list[str] of length getNumAtoms() in atom-record order. The list and strings do not alias native storage.
Exceptions
RuntimeErrorIf this wrapper is closed.
ApoCharmmErrorIf a native count or buffer operation fails.
UnicodeDecodeErrorIf a returned fixed-width field is not valid UTF-8.
Warning
Native names longer than eight bytes are silently truncated by the current C ABI.

◆ getSegmentIdentifiers()

list[str] apocharmm.charmm_psf.CharmmPsf.getSegmentIdentifiers (   self)

Returns copied per-atom segment identifiers.

Each native field occupies eight bytes, is decoded as UTF-8, and has leading and trailing whitespace removed with str.strip().

Returns
New list[str] of length getNumAtoms() in atom-record order. The list and strings do not alias native storage.
Exceptions
RuntimeErrorIf this wrapper is closed.
ApoCharmmErrorIf a native count or buffer operation fails.
UnicodeDecodeErrorIf a returned fixed-width field is not valid UTF-8.
Warning
Native identifiers longer than eight bytes are silently truncated by the current C ABI.

◆ getTotalMass()

float apocharmm.charmm_psf.CharmmPsf.getTotalMass (   self)

Computes the total mass.

Returns
Python float containing the sum in atomic mass units.
Exceptions
RuntimeErrorIf this wrapper is closed.
ApoCharmmErrorIf the native atom count is uninitialized, the native mass-vector length is inconsistent, or the handle is invalid.