export bond topology related per-atom data via library interface

This commit is contained in:
Axel Kohlmeyer
2025-05-05 06:25:22 -04:00
parent 7ec7745640
commit 0d7e07b9be
2 changed files with 80 additions and 10 deletions

View File

@ -2874,6 +2874,8 @@ void Atom::remove_custom(int index, int flag, int cols)
}
}
// TODO: complete list of exported properties.
/** Provide access to internal data of the Atom class by keyword
*
\verbatim embed:rst
@ -3035,7 +3037,6 @@ void *Atom::extract(const char *name)
if (strcmp(name,"x") == 0) return (void *) x;
if (strcmp(name,"v") == 0) return (void *) v;
if (strcmp(name,"f") == 0) return (void *) f;
if (strcmp(name,"molecule") == 0) return (void *) molecule;
if (strcmp(name,"q") == 0) return (void *) q;
if (strcmp(name,"mu") == 0) return (void *) mu;
if (strcmp(name,"omega") == 0) return (void *) omega;
@ -3051,6 +3052,33 @@ void *Atom::extract(const char *name)
if (strcmp(name,"temperature") == 0) return (void *) temperature;
if (strcmp(name,"heatflow") == 0) return (void *) heatflow;
// MOLECULE PACKAGE
if (strcmp(name,"molecule") == 0) return (void *) molecule;
if (strcmp(name,"molindex") == 0) return (void *) molindex;
if (strcmp(name,"nspecial") == 0) return (void *) nspecial;
if (strcmp(name,"special") == 0) return (void *) special;
if (strcmp(name,"num_bond") == 0) return (void *) num_bond;
if (strcmp(name,"bond_type") == 0) return (void *) bond_type;
if (strcmp(name,"bond_atom") == 0) return (void *) bond_atom;
if (strcmp(name,"num_angle") == 0) return (void *) num_angle;
if (strcmp(name,"angle_type") == 0) return (void *) angle_type;
if (strcmp(name,"angle_atom1") == 0) return (void *) angle_atom1;
if (strcmp(name,"angle_atom2") == 0) return (void *) angle_atom2;
if (strcmp(name,"angle_atom3") == 0) return (void *) angle_atom3;
if (strcmp(name,"num_dihedral") == 0) return (void *) num_dihedral;
if (strcmp(name,"dihedral_type") == 0) return (void *) dihedral_type;
if (strcmp(name,"dihedral_atom1") == 0) return (void *) dihedral_atom1;
if (strcmp(name,"dihedral_atom2") == 0) return (void *) dihedral_atom2;
if (strcmp(name,"dihedral_atom3") == 0) return (void *) dihedral_atom3;
if (strcmp(name,"dihedral_atom4") == 0) return (void *) dihedral_atom4;
if (strcmp(name,"num_improper") == 0) return (void *) num_improper;
if (strcmp(name,"improper_type") == 0) return (void *) improper_type;
if (strcmp(name,"improper_atom1") == 0) return (void *) improper_atom1;
if (strcmp(name,"improper_atom2") == 0) return (void *) improper_atom2;
if (strcmp(name,"improper_atom3") == 0) return (void *) improper_atom3;
if (strcmp(name,"improper_atom4") == 0) return (void *) improper_atom4;
// PERI PACKAGE
if (strcmp(name,"vfrac") == 0) return (void *) vfrac;
@ -3172,7 +3200,6 @@ int Atom::extract_datatype(const char *name)
if (strcmp(name,"x") == 0) return LAMMPS_DOUBLE_2D;
if (strcmp(name,"v") == 0) return LAMMPS_DOUBLE_2D;
if (strcmp(name,"f") == 0) return LAMMPS_DOUBLE_2D;
if (strcmp(name,"molecule") == 0) return LAMMPS_TAGINT;
if (strcmp(name,"q") == 0) return LAMMPS_DOUBLE;
if (strcmp(name,"mu") == 0) return LAMMPS_DOUBLE_2D;
if (strcmp(name,"omega") == 0) return LAMMPS_DOUBLE_2D;
@ -3188,6 +3215,34 @@ int Atom::extract_datatype(const char *name)
if (strcmp(name,"temperature") == 0) return LAMMPS_DOUBLE;
if (strcmp(name,"heatflow") == 0) return LAMMPS_DOUBLE;
// MOLECULE package
if (strcmp(name,"molecule") == 0) return LAMMPS_TAGINT;
if (strcmp(name,"molindex") == 0) return LAMMPS_INT;
if (strcmp(name,"molatom") == 0) return LAMMPS_INT;
if (strcmp(name,"nspecial") == 0) return LAMMPS_INT_2D;
if (strcmp(name,"special") == 0) return LAMMPS_TAGINT_2D;
if (strcmp(name,"num_bond") == 0) return LAMMPS_INT;
if (strcmp(name,"bond_type") == 0) return LAMMPS_INT_2D;
if (strcmp(name,"bond_atom") == 0) return LAMMPS_TAGINT_2D;
if (strcmp(name,"num_angle") == 0) return LAMMPS_INT;
if (strcmp(name,"angle_type") == 0) return LAMMPS_INT_2D;
if (strcmp(name,"angle_atom1") == 0) return LAMMPS_TAGINT_2D;
if (strcmp(name,"angle_atom2") == 0) return LAMMPS_TAGINT_2D;
if (strcmp(name,"angle_atom3") == 0) return LAMMPS_TAGINT_2D;
if (strcmp(name,"num_dihedral") == 0) return LAMMPS_INT;
if (strcmp(name,"dihedral_type") == 0) return LAMMPS_INT_2D;
if (strcmp(name,"dihedral_atom1") == 0) return LAMMPS_TAGINT_2D;
if (strcmp(name,"dihedral_atom2") == 0) return LAMMPS_TAGINT_2D;
if (strcmp(name,"dihedral_atom3") == 0) return LAMMPS_TAGINT_2D;
if (strcmp(name,"dihedral_atom4") == 0) return LAMMPS_TAGINT_2D;
if (strcmp(name,"num_improper") == 0) return LAMMPS_INT;
if (strcmp(name,"improper_type") == 0) return LAMMPS_INT_2D;
if (strcmp(name,"improper_atom1") == 0) return LAMMPS_TAGINT_2D;
if (strcmp(name,"improper_atom2") == 0) return LAMMPS_TAGINT_2D;
if (strcmp(name,"improper_atom3") == 0) return LAMMPS_TAGINT_2D;
if (strcmp(name,"improper_atom4") == 0) return LAMMPS_TAGINT_2D;
// PERI package (and in part MACHDYN)
if (strcmp(name,"vfrac") == 0) return LAMMPS_DOUBLE;

View File

@ -1387,6 +1387,16 @@ internally by the :doc:`Fortran interface <Fortran>` and are not likely to be us
- number of dihedral types
* - nimpropertypes
- number of improper types
* - bond_per_atom
- size of per-atom bond data arrays
* - angle_per_atom
- size of per-atom angle data arrays
* - dihedral_per_atom
- size of per-atom dihedral data arrays
* - improper_per_atom
- size of per-atom improper data arrays
* - maxspecial
- size of per-atom special data array
* - nellipsoids
- number of atoms that have ellipsoid data
* - nlines
@ -1505,6 +1515,11 @@ int lammps_extract_setting(void *handle, const char *keyword)
if (strcmp(keyword,"nangletypes") == 0) return lmp->atom->nangletypes;
if (strcmp(keyword,"ndihedraltypes") == 0) return lmp->atom->ndihedraltypes;
if (strcmp(keyword,"nimpropertypes") == 0) return lmp->atom->nimpropertypes;
if (strcmp(keyword,"bond_per_atom") == 0) return lmp->atom->bond_per_atom;
if (strcmp(keyword,"angle_per_atom") == 0) return lmp->atom->angle_per_atom;
if (strcmp(keyword,"dihedral_per_atom") == 0) return lmp->atom->dihedral_per_atom;
if (strcmp(keyword,"improper_per_atom") == 0) return lmp->atom->improper_per_atom;
if (strcmp(keyword,"maxspecial") == 0) return lmp->atom->maxspecial;
if (strcmp(keyword,"nellipsoids") == 0) return lmp->atom->nellipsoids;
if (strcmp(keyword,"nlines") == 0) return lmp->atom->nlines;
if (strcmp(keyword,"ntris") == 0) return lmp->atom->ntris;
@ -1841,10 +1856,10 @@ report the "native" data type. The following tables are provided:
- Type
- Length
- Description
* - ntypes
- int
* - natoms
- bigint
- 1
- number of atom types
- total number of atoms in the simulation.
* - nbonds
- bigint
- 1
@ -1861,10 +1876,6 @@ report the "native" data type. The following tables are provided:
- bigint
- 1
- total number of impropers in the simulation.
* - natoms
- bigint
- 1
- total number of atoms in the simulation.
* - nlocal
- int
- 1
@ -1877,6 +1888,10 @@ report the "native" data type. The following tables are provided:
- int
- 1
- maximum of nlocal+nghost across all MPI ranks (for per-atom data array size).
* - ntypes
- int
- 1
- number of atom types
* - special_lj
- double
- 4
@ -2166,7 +2181,6 @@ void *lammps_extract_global(void *handle, const char *name)
return (void *) &lmp->comm->procgrid;
if (strcmp(name,"natoms") == 0) return (void *) &lmp->atom->natoms;
if (strcmp(name,"ntypes") == 0) return (void *) &lmp->atom->ntypes;
if (strcmp(name,"nbonds") == 0) return (void *) &lmp->atom->nbonds;
if (strcmp(name,"nangles") == 0) return (void *) &lmp->atom->nangles;
if (strcmp(name,"ndihedrals") == 0) return (void *) &lmp->atom->ndihedrals;
@ -2174,6 +2188,7 @@ void *lammps_extract_global(void *handle, const char *name)
if (strcmp(name,"nlocal") == 0) return (void *) &lmp->atom->nlocal;
if (strcmp(name,"nghost") == 0) return (void *) &lmp->atom->nghost;
if (strcmp(name,"nmax") == 0) return (void *) &lmp->atom->nmax;
if (strcmp(name,"ntypes") == 0) return (void *) &lmp->atom->ntypes;
if (strcmp(name,"special_lj") == 0) return (void *) lmp->force->special_lj;
if (strcmp(name,"special_coul") == 0) return (void *) lmp->force->special_coul;