Owns CHARMM PSF topology, per-atom metadata, and derived topology tables. More...
#include <CharmmPSF.h>
Public Member Functions | |
| CharmmPSF (void) | |
| Constructs an uninitialized, empty PSF object. | |
| CharmmPSF (const std::filesystem::path &filePath) | |
| Constructs and derives topology from a CHARMM PSF file. | |
| CharmmPSF (const CharmmPSF &other) | |
| Constructs an independent deep copy of another PSF object. | |
| CharmmPSF (const CharmmPSF &&other) | |
| Constructs an independent copy from a const rvalue. | |
| void | setNumAtoms (const int numAtoms) |
| Sets the atom count and resizes the seven per-atom host arrays. | |
| void | setAtomCharges (const std::vector< double > &charges) |
| Replaces all per-atom partial charges. | |
| int | getNumAtoms (void) const |
| Returns the stored atom count. | |
| int | getNumBonds (void) const |
| Returns the stored bond count. | |
| int | getNumAngles (void) const |
| Returns the stored angle count. | |
| int | getNumDihedrals (void) const |
| Returns the stored proper-dihedral count. | |
| int | getNumImpropers (void) const |
| Returns the stored improper-dihedral count. | |
| int | getNumCrossTerms (void) const |
| Returns the stored cross-term count. | |
| const std::vector< std::string > & | getSegmentIdentifiers (void) const |
| Returns the per-atom segment identifiers. | |
| const std::vector< int > & | getResidueIdentifiers (void) const |
| Returns the per-atom residue identifiers. | |
| const std::vector< std::string > & | getResidueNames (void) const |
| Returns the per-atom residue names. | |
| const std::vector< std::string > & | getAtomNames (void) const |
| Returns the per-atom atom names. | |
| const std::vector< std::string > & | getAtomTypes (void) const |
| Returns the per-atom CHARMM atom types. | |
| const std::vector< double > & | getCharges (void) const |
| Returns the per-atom partial charges. | |
| const std::vector< double > & | getMasses (void) const |
| Returns the per-atom masses. | |
| const std::vector< Bond > & | getBonds (void) const |
| Returns the parsed covalent bonds. | |
| const std::vector< Angle > & | getAngles (void) const |
| Returns the parsed valence angles. | |
| const std::vector< Dihedral > & | getDihedrals (void) const |
| Returns the parsed proper dihedrals. | |
| const std::vector< Dihedral > & | getImpropers (void) const |
| Returns the parsed improper dihedrals. | |
| const std::vector< CrossTerm > & | getCrossTerms (void) const |
| Returns the parsed CMAP cross-term records. | |
| const std::vector< std::set< int > > & | getConnected12 (void) const |
| Returns the per-atom direct-bond connectivity sets. | |
| const std::vector< std::set< int > > & | getConnected13 (void) const |
| Returns the per-atom two-bond connectivity sets. | |
| const std::vector< std::set< int > > & | getConnected14 (void) const |
| Returns the per-atom three-bond connectivity sets. | |
| const std::vector< int > & | getIblo14 (void) const |
| Returns the cumulative CHARMM exclusion offsets. | |
| const std::vector< int > & | getInb14 (void) const |
| Returns the flattened CHARMM exclusion atom numbers. | |
| const CudaContainer< int4 > & | getWaterMolecules (void) const |
| Returns recognized three-site water tuples. | |
| const CudaContainer< int2 > & | getResidues (void) const |
| Returns contiguous residue intervals. | |
| const CudaContainer< int2 > & | getGroups (void) const |
| Returns contiguous connected-component intervals. | |
| const std::filesystem::path & | getFilePath (void) const |
| Returns the path supplied to the file constructor. | |
| std::vector< std::string > & | getSegmentIdentifiers (void) |
| Returns unchecked mutable access to segment identifiers. | |
| std::vector< int > & | getResidueIdentifiers (void) |
| Returns unchecked mutable access to residue identifiers. | |
| std::vector< std::string > & | getResidueNames (void) |
| Returns unchecked mutable access to residue names. | |
| std::vector< std::string > & | getAtomNames (void) |
| Returns unchecked mutable access to atom names. | |
| std::vector< std::string > & | getAtomTypes (void) |
| Returns unchecked mutable access to atom types. | |
| std::vector< double > & | getCharges (void) |
| Returns unchecked mutable access to per-atom charges. | |
| std::vector< double > & | getMasses (void) |
| Returns unchecked mutable access to per-atom masses. | |
| std::vector< Bond > & | getBonds (void) |
| Returns unchecked mutable access to bond records. | |
| std::vector< Angle > & | getAngles (void) |
| Returns unchecked mutable access to angle records. | |
| std::vector< Dihedral > & | getDihedrals (void) |
| Returns unchecked mutable access to proper-dihedral records. | |
| std::vector< Dihedral > & | getImpropers (void) |
| Returns unchecked mutable access to improper-dihedral records. | |
| std::vector< CrossTerm > & | getCrossTerms (void) |
| Returns unchecked mutable access to cross-term records. | |
| std::vector< std::set< int > > & | getConnected12 (void) |
| Returns unchecked mutable access to direct-bond connectivity. | |
| std::vector< std::set< int > > & | getConnected13 (void) |
| Returns unchecked mutable access to two-bond connectivity. | |
| std::vector< std::set< int > > & | getConnected14 (void) |
| Returns unchecked mutable access to three-bond connectivity. | |
| std::vector< int > & | getIblo14 (void) |
| Returns unchecked mutable access to cumulative exclusion offsets. | |
| std::vector< int > & | getInb14 (void) |
| Returns unchecked mutable access to flattened exclusion atom numbers. | |
| CudaContainer< int4 > & | getWaterMolecules (void) |
| Returns unchecked mutable access to recognized water tuples. | |
| CudaContainer< int2 > & | getResidues (void) |
| Returns unchecked mutable access to residue intervals. | |
| CudaContainer< int2 > & | getGroups (void) |
| Returns unchecked mutable access to connected-component intervals. | |
| std::filesystem::path & | getFilePath (void) |
| Returns unchecked mutable access to the stored file path. | |
| double | getNetCharge (void) const |
| Computes the sum of all stored atom charges. | |
| double | getTotalMass (void) const |
| Computes the sum of all stored atom masses. | |
| InclusionExclusion | getInclusionExclusionLists (void) const |
| Builds owned 1-4 inclusion and 1-2/1-3 exclusion pair lists. | |
Owns CHARMM PSF topology, per-atom metadata, and derived topology tables.
A CharmmPSF stores segment and residue identifiers, atom names and types, charges, masses, bonded topology, topological connectivity, CHARMM-style exclusion arrays, residue intervals, connected-component intervals, and recognized water molecules. Per-atom metadata and bonded records are host-resident. Residue, connected-component, and water records are stored in CudaContainer objects with independent host and device mirrors.
The file constructor parses the PSF synchronously on the calling host thread. It then derives residue intervals, water tuples, connected components, and topological exclusions. The object stores the supplied path but does not retain a reference to the caller's string.
Parsed bonds, angles, proper dihedrals, and improper dihedrals use zero-based atom indices. The current cross-term parser retains one-based indices; see CrossTerm and CharmmPSF for the associated implementation defect.
Const accessors return borrowed references to object-owned storage. Mutable accessors are unchecked escape hatches: they do not update stored counts, dependent tables, or host/device coherence. See Native mutable access.
Copy construction deep-copies all host vectors and both mirrors of each CudaContainer. The const CharmmPSF && overload also copies and leaves its source unchanged; it is not an ownership-transferring move constructor. The compiler-generated copy-assignment operator performs memberwise assignment and can leave partially assigned state if a later allocation or CUDA operation fails. No move assignment operator is generated.
The compiler-generated destructor is non-throwing. Nested CUDA-owning containers use non-throwing destruction and discard CUDA cleanup failures during destruction.
The class provides no internal locking. Callers must externally synchronize concurrent mutation, destruction, or access that can overlap CUDA operations.
| CharmmPSF::CharmmPSF | ( | void | ) |
Constructs an uninitialized, empty PSF object.
The atom, bond, angle, proper-dihedral, improper-dihedral, and cross-term counts are initialized to -1. All host vectors and CudaContainer members are empty, and the stored file name is empty.
ApoCharmmErrorCode::NotInitialized. | CharmmPSF::CharmmPSF | ( | const std::filesystem::path & | filePath | ) |
Constructs and derives topology from a CHARMM PSF file.
The file is read completely into host memory and parsed in section order. The parser requires TITLE, ATOM, BOND, ANGLE, DIHEDRAL, IMPROPER, DONOR, ACCEPTOR, and CROSS-TERM sections. Donor and acceptor records, and sections between ACCEPTOR and CROSS-TERM, are skipped rather than retained.
Atom metadata is stored in file-record order. Charges and masses must be finite. Topology atom numbers must be in the one-based range [1, getNumAtoms()]. After parsing, the constructor derives water, connected-component, residue, and exclusion data.
| [in] | filePath | Borrowed non-empty path to a PSF file. The path is copied into the object, retained without canonicalization, and not retained by reference. |
| ApoCharmmError | With ApoCharmmErrorCode::InvalidArgument if filePath is empty. |
| ApoCharmmError | With ApoCharmmErrorCode::Runtime if the file cannot be opened or read, a required section or record is missing, a record has an invalid field count, a numeric field is malformed or non-finite, a topology atom number is out of range, or a supported section count exceeds int. |
| ApoCharmmError | With ApoCharmmErrorCode::Cuda if allocation, copying, launch checking, or cleanup for a derived CudaContainer fails. |
| std::bad_alloc | If host-side parsing, topology storage, or diagnostic construction cannot allocate memory. |
| std::length_error | If a file, container, or diagnostic exceeds an implementation-defined size limit. |
| CharmmPSF::CharmmPSF | ( | const CharmmPSF & | other | ) |
Constructs an independent deep copy of another PSF object.
All scalar values and host vectors are copied. Each CudaContainer copies its host and device mirrors independently, preserving any pre-existing host/device divergence in other.
| [in] | other | PSF object to copy. The source remains unchanged and is not retained. |
| ApoCharmmError | With ApoCharmmErrorCode::Cuda if copying a CudaContainer device allocation fails. |
| std::bad_alloc | If a host or device-copy diagnostic allocation fails. |
| std::length_error | If copied storage exceeds an implementation-defined limit. |
other. | CharmmPSF::CharmmPSF | ( | const CharmmPSF && | other | ) |
Constructs an independent copy from a const rvalue.
This compatibility overload performs the same deep-copy operations as the const-lvalue copy constructor. Because the source is const, no ownership is transferred and the source remains unchanged.
| [in] | other | PSF object to copy. The source is not moved from or retained. |
| ApoCharmmError | With ApoCharmmErrorCode::Cuda if copying a CudaContainer device allocation fails. |
| std::bad_alloc | If a host or device-copy diagnostic allocation fails. |
| std::length_error | If copied storage exceeds an implementation-defined limit. |
other. | std::vector< Angle > & CharmmPSF::getAngles | ( | void | ) |
Returns unchecked mutable access to angle records.
| const std::vector< Angle > & CharmmPSF::getAngles | ( | void | ) | const |
Returns the parsed valence angles.
| std::vector< std::string > & CharmmPSF::getAtomNames | ( | void | ) |
Returns unchecked mutable access to atom names.
| const std::vector< std::string > & CharmmPSF::getAtomNames | ( | void | ) | const |
Returns the per-atom atom names.
| std::vector< std::string > & CharmmPSF::getAtomTypes | ( | void | ) |
Returns unchecked mutable access to atom types.
| const std::vector< std::string > & CharmmPSF::getAtomTypes | ( | void | ) | const |
Returns the per-atom CHARMM atom types.
| std::vector< Bond > & CharmmPSF::getBonds | ( | void | ) |
Returns unchecked mutable access to bond records.
| const std::vector< Bond > & CharmmPSF::getBonds | ( | void | ) | const |
Returns the parsed covalent bonds.
| std::vector< double > & CharmmPSF::getCharges | ( | void | ) |
Returns unchecked mutable access to per-atom charges.
getNetCharge() to throw ApoCharmmErrorCode::Runtime. See Native mutable access. | const std::vector< double > & CharmmPSF::getCharges | ( | void | ) | const |
Returns the per-atom partial charges.
| std::vector< std::set< int > > & CharmmPSF::getConnected12 | ( | void | ) |
Returns unchecked mutable access to direct-bond connectivity.
getIblo14(), getInb14(), or bonded records. See Native mutable access. | const std::vector< std::set< int > > & CharmmPSF::getConnected12 | ( | void | ) | const |
Returns the per-atom direct-bond connectivity sets.
| std::vector< std::set< int > > & CharmmPSF::getConnected13 | ( | void | ) |
Returns unchecked mutable access to two-bond connectivity.
| const std::vector< std::set< int > > & CharmmPSF::getConnected13 | ( | void | ) | const |
Returns the per-atom two-bond connectivity sets.
| std::vector< std::set< int > > & CharmmPSF::getConnected14 | ( | void | ) |
Returns unchecked mutable access to three-bond connectivity.
| const std::vector< std::set< int > > & CharmmPSF::getConnected14 | ( | void | ) | const |
Returns the per-atom three-bond connectivity sets.
getInclusionExclusionLists() produces explicit inclusion pairs. | std::vector< CrossTerm > & CharmmPSF::getCrossTerms | ( | void | ) |
Returns unchecked mutable access to cross-term records.
| const std::vector< CrossTerm > & CharmmPSF::getCrossTerms | ( | void | ) | const |
Returns the parsed CMAP cross-term records.
| std::vector< Dihedral > & CharmmPSF::getDihedrals | ( | void | ) |
Returns unchecked mutable access to proper-dihedral records.
| const std::vector< Dihedral > & CharmmPSF::getDihedrals | ( | void | ) | const |
Returns the parsed proper dihedrals.
| std::filesystem::path & CharmmPSF::getFilePath | ( | void | ) |
Returns unchecked mutable access to the stored file path.
| const std::filesystem::path & CharmmPSF::getFilePath | ( | void | ) | const |
Returns the path supplied to the file constructor.
| CudaContainer< int2 > & CharmmPSF::getGroups | ( | void | ) |
Returns unchecked mutable access to connected-component intervals.
CudaContainer<int2>. No ownership is transferred. | const CudaContainer< int2 > & CharmmPSF::getGroups | ( | void | ) | const |
Returns contiguous connected-component intervals.
CudaContainer<int2>. Each element stores a zero-based inclusive [x, y] interval. No ownership is transferred. | std::vector< int > & CharmmPSF::getIblo14 | ( | void | ) |
Returns unchecked mutable access to cumulative exclusion offsets.
getInb14() or the atom count. See Native mutable access. | const std::vector< int > & CharmmPSF::getIblo14 | ( | void | ) | const |
Returns the cumulative CHARMM exclusion offsets.
getIblo14()[i] is the cumulative number of entries in getInb14() through atom i. | std::vector< Dihedral > & CharmmPSF::getImpropers | ( | void | ) |
Returns unchecked mutable access to improper-dihedral records.
| const std::vector< Dihedral > & CharmmPSF::getImpropers | ( | void | ) | const |
Returns the parsed improper dihedrals.
| std::vector< int > & CharmmPSF::getInb14 | ( | void | ) |
Returns unchecked mutable access to flattened exclusion atom numbers.
getIblo14(), the atom count, or the one-based CHARMM atom-number convention. See Native mutable access. | const std::vector< int > & CharmmPSF::getInb14 | ( | void | ) | const |
Returns the flattened CHARMM exclusion atom numbers.
| InclusionExclusion CharmmPSF::getInclusionExclusionLists | ( | void | ) | const |
Builds owned 1-4 inclusion and 1-2/1-3 exclusion pair lists.
Every pair is emitted once with its lower zero-based atom index first. Inclusion pairs are 1-4 connections not also present in the source atom's 1-2 or 1-3 sets. Exclusion pairs are the ordered union of the source atom's 1-2 and 1-3 sets. Inclusion pairs precede exclusion pairs in the returned flattened vector.
sizes[0] is the inclusion-pair count, sizes[1] is the exclusion-pair count, and in14_ex14 contains the corresponding zero-based pairs. | ApoCharmmError | With ApoCharmmErrorCode::NotInitialized if the atom count is negative. |
| ApoCharmmError | With ApoCharmmErrorCode::Runtime if any outer connectivity vector length differs from the atom count. |
| std::bad_alloc | If temporary or returned host vectors cannot allocate storage. |
| std::length_error | If temporary or returned storage exceeds an implementation-defined vector size limit. |
| std::vector< double > & CharmmPSF::getMasses | ( | void | ) |
Returns unchecked mutable access to per-atom masses.
getTotalMass() to throw ApoCharmmErrorCode::Runtime. See Native mutable access. | const std::vector< double > & CharmmPSF::getMasses | ( | void | ) | const |
Returns the per-atom masses.
| double CharmmPSF::getNetCharge | ( | void | ) | const |
Computes the sum of all stored atom charges.
0.0. | ApoCharmmError | With ApoCharmmErrorCode::NotInitialized if the atom count is negative. |
| ApoCharmmError | With ApoCharmmErrorCode::Runtime if the charge vector length differs from the atom count. |
| std::bad_alloc | If constructing an error diagnostic fails. |
| std::length_error | If an error diagnostic exceeds an implementation-defined limit. |
| int CharmmPSF::getNumAngles | ( | void | ) | const |
Returns the stored angle count.
-1 before a PSF has initialized the angle section. getAngles() does not update this value. | int CharmmPSF::getNumAtoms | ( | void | ) | const |
Returns the stored atom count.
-1 for a default-constructed object whose atom count has not been initialized. | int CharmmPSF::getNumBonds | ( | void | ) | const |
Returns the stored bond count.
-1 before a PSF has initialized the bond section. getBonds() does not update this value. | int CharmmPSF::getNumCrossTerms | ( | void | ) | const |
Returns the stored cross-term count.
-1 before a PSF has initialized the cross-term section. getCrossTerms() does not update this value. | int CharmmPSF::getNumDihedrals | ( | void | ) | const |
Returns the stored proper-dihedral count.
-1 before a PSF has initialized the proper-dihedral section. getDihedrals() does not update this value. | int CharmmPSF::getNumImpropers | ( | void | ) | const |
Returns the stored improper-dihedral count.
-1 before a PSF has initialized the improper section. getImpropers() does not update this value. | std::vector< int > & CharmmPSF::getResidueIdentifiers | ( | void | ) |
Returns unchecked mutable access to residue identifiers.
getResidues() and resizing does not update the atom count. See Native mutable access. | const std::vector< int > & CharmmPSF::getResidueIdentifiers | ( | void | ) | const |
Returns the per-atom residue identifiers.
| std::vector< std::string > & CharmmPSF::getResidueNames | ( | void | ) |
Returns unchecked mutable access to residue names.
| const std::vector< std::string > & CharmmPSF::getResidueNames | ( | void | ) | const |
Returns the per-atom residue names.
| CudaContainer< int2 > & CharmmPSF::getResidues | ( | void | ) |
Returns unchecked mutable access to residue intervals.
CudaContainer<int2>. No ownership is transferred. | const CudaContainer< int2 > & CharmmPSF::getResidues | ( | void | ) | const |
Returns contiguous residue intervals.
CudaContainer<int2>. Each element stores a zero-based inclusive [x, y] atom interval. No ownership is transferred. | std::vector< std::string > & CharmmPSF::getSegmentIdentifiers | ( | void | ) |
Returns unchecked mutable access to segment identifiers.
| const std::vector< std::string > & CharmmPSF::getSegmentIdentifiers | ( | void | ) | const |
Returns the per-atom segment identifiers.
getNumAtoms() entries, but unchecked mutable access can violate that relationship. | double CharmmPSF::getTotalMass | ( | void | ) | const |
Computes the sum of all stored atom masses.
0.0. | ApoCharmmError | With ApoCharmmErrorCode::NotInitialized if the atom count is negative. |
| ApoCharmmError | With ApoCharmmErrorCode::Runtime if the mass vector length differs from the atom count. |
| std::bad_alloc | If constructing an error diagnostic fails. |
| std::length_error | If an error diagnostic exceeds an implementation-defined limit. |
| CudaContainer< int4 > & CharmmPSF::getWaterMolecules | ( | void | ) |
Returns unchecked mutable access to recognized water tuples.
CudaContainer<int4>. No ownership is transferred. transferToDevice() before device consumers can observe it; device mutation requires transferToHost() before host consumers can observe it. See Native mutable access. | const CudaContainer< int4 > & CharmmPSF::getWaterMolecules | ( | void | ) | const |
Returns recognized three-site water tuples.
CudaContainer<int4>. Each host/device element stores zero-based (oxygen, hydrogen1, hydrogen2, 0) components in x, y, z, w order. No ownership is transferred. OT, HT, HT. | void CharmmPSF::setAtomCharges | ( | const std::vector< double > & | charges | ) |
Replaces all per-atom partial charges.
The input is copied into host-owned storage. No topology, aggregate cache, CudaContainer, or device allocation is changed.
| [in] | charges | Host vector containing exactly getNumAtoms() finite or non-finite double values in elementary-charge units. This setter does not validate finiteness or physical range. |
| ApoCharmmError | With ApoCharmmErrorCode::NotInitialized if the atom count is negative. |
| ApoCharmmError | With ApoCharmmErrorCode::InvalidArgument if charges.size() differs from the initialized atom count. |
| std::bad_alloc | If copying the vector cannot allocate storage. |
| std::length_error | If the input exceeds an implementation-defined vector size limit. |
getCharges() contains an independent copy of charges. | void CharmmPSF::setNumAtoms | ( | const int | numAtoms | ) |
Sets the atom count and resizes the seven per-atom host arrays.
The segment identifiers, residue identifiers, residue names, atom names, atom types, charges, and masses are resized to numAtoms. Newly added strings are empty, newly added residue identifiers are zero, and newly added charges and masses are 0.0.
This method does not change any bonded-topology count or record. It also does not rebuild residue intervals, water tuples, connected components, topological connectivity, or CHARMM exclusion arrays.
| [in] | numAtoms | New dimensionless atom count. The value must be nonnegative. |
| ApoCharmmError | With ApoCharmmErrorCode::InvalidArgument if numAtoms is negative. |
| std::bad_alloc | If resizing a per-atom host vector cannot allocate storage. |
| std::length_error | If numAtoms exceeds a host vector's maximum size. |
getNumAtoms() == numAtoms and every per-atom host vector has length numAtoms.