Gromacs  2025.0-dev-20241009-5c23d5f
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Classes | Functions | Variables
lincs.cpp File Reference
#include "gmxpre.h"
#include "lincs.h"
#include "config.h"
#include <cassert>
#include <cinttypes>
#include <climits>
#include <cmath>
#include <cstdint>
#include <cstdlib>
#include <algorithm>
#include <array>
#include <filesystem>
#include <functional>
#include <memory>
#include <optional>
#include <string>
#include <type_traits>
#include <utility>
#include <vector>
#include "gromacs/domdec/domdec.h"
#include "gromacs/domdec/domdec_struct.h"
#include "gromacs/gmxlib/nrnb.h"
#include "gromacs/math/arrayrefwithpadding.h"
#include "gromacs/math/functions.h"
#include "gromacs/math/paddedvector.h"
#include "gromacs/math/units.h"
#include "gromacs/math/vec.h"
#include "gromacs/mdlib/constr.h"
#include "gromacs/mdlib/gmx_omp_nthreads.h"
#include "gromacs/mdrunutility/multisim.h"
#include "gromacs/mdtypes/commrec.h"
#include "gromacs/mdtypes/inputrec.h"
#include "gromacs/mdtypes/md_enums.h"
#include "gromacs/mdtypes/observablesreducer.h"
#include "gromacs/pbcutil/pbc.h"
#include "gromacs/pbcutil/pbc_simd.h"
#include "gromacs/simd/simd.h"
#include "gromacs/simd/simd_math.h"
#include "gromacs/simd/vector_operations.h"
#include "gromacs/timing/wallcycle.h"
#include "gromacs/topology/idef.h"
#include "gromacs/topology/ifunc.h"
#include "gromacs/topology/mtop_util.h"
#include "gromacs/topology/topology.h"
#include "gromacs/utility/alignedallocator.h"
#include "gromacs/utility/arrayref.h"
#include "gromacs/utility/basedefinitions.h"
#include "gromacs/utility/bitmask.h"
#include "gromacs/utility/cstringutil.h"
#include "gromacs/utility/exceptions.h"
#include "gromacs/utility/fatalerror.h"
#include "gromacs/utility/gmxomp.h"
#include "gromacs/utility/listoflists.h"
#include "gromacs/utility/pleasecite.h"
#include "gromacs/utility/stringutil.h"
+ Include dependency graph for lincs.cpp:

Description

Defines LINCS code.

Author
Berk Hess hess@.nosp@m.kth..nosp@m.se
Mark Abraham mark..nosp@m.j.ab.nosp@m.raham.nosp@m.@gma.nosp@m.il.co.nosp@m.m

Classes

struct  anonymous_namespace{lincs.cpp}::AtomPair
 Indices of the two atoms involved in a single constraint. More...
 
struct  anonymous_namespace{lincs.cpp}::Task
 Unit of work within LINCS. More...
 
class  gmx::Lincs
 Data for LINCS algorithm. More...
 
struct  gmx::LincsDeviations
 Status information about how well LINCS satisfied the constraints in this domain. More...
 

Functions

real gmx::lincs_rmsd (const Lincs *lincsd)
 Return the RMSD of the constraint.
 
static void gmx::lincs_matrix_expand (const Lincs &lincsd, const Task &li_task, gmx::ArrayRef< const real > blcc, gmx::ArrayRef< real > rhs1, gmx::ArrayRef< real > rhs2, gmx::ArrayRef< real > sol)
 Do a set of nrec LINCS matrix multiplications. More...
 
static void gmx::lincs_update_atoms_noind (int ncons, gmx::ArrayRef< const AtomPair > atoms, real preFactor, gmx::ArrayRef< const real > fac, gmx::ArrayRef< const gmx::RVec > r, gmx::ArrayRef< const real > invmass, rvec *x)
 Update atomic coordinates when an index is not required.
 
static void gmx::lincs_update_atoms_ind (gmx::ArrayRef< const int > ind, gmx::ArrayRef< const AtomPair > atoms, real preFactor, gmx::ArrayRef< const real > fac, gmx::ArrayRef< const gmx::RVec > r, gmx::ArrayRef< const real > invmass, rvec *x)
 Update atomic coordinates when an index is required.
 
static void gmx::lincs_update_atoms (Lincs *li, int th, real preFactor, gmx::ArrayRef< const real > fac, gmx::ArrayRef< const gmx::RVec > r, gmx::ArrayRef< const real > invmass, rvec *x)
 Update coordinates for atoms.
 
static void gmx::do_lincsp (ArrayRefWithPadding< const RVec > xPadded, ArrayRefWithPadding< RVec > fPadded, ArrayRef< RVec > fp, t_pbc *pbc, Lincs *lincsd, int th, ArrayRef< const real > invmass, ConstraintVariable econq, bool bCalcDHDL, bool bCalcVir, tensor rmdf)
 LINCS projection, works on derivatives of the coordinates.
 
static gmx_unused void gmx::calc_dist_iter (int b0, int b1, gmx::ArrayRef< const AtomPair > atoms, const rvec *gmx_restrict xp, const real *gmx_restrict bllen, const real *gmx_restrict blc, const t_pbc *pbc, real wfac, real *gmx_restrict rhs, real *gmx_restrict sol, bool *bWarn)
 Determine the distances and right-hand side for the next iteration.
 
static void gmx::do_lincs (ArrayRefWithPadding< const RVec > xPadded, ArrayRefWithPadding< RVec > xpPadded, const matrix box, t_pbc *pbc, Lincs *lincsd, int th, ArrayRef< const real > invmass, const t_commrec *cr, bool bCalcDHDL, real wangle, bool *bWarn, real invdt, ArrayRef< RVec > vRef, bool bCalcVir, tensor vir_r_m_dr, gmx_wallcycle *wcycle)
 Implements LINCS constraining.
 
static void gmx::set_lincs_matrix_task (Lincs *li, Task *li_task, ArrayRef< const real > invmass, int *ncc_triangle, int *nCrossTaskTriangles)
 Sets the elements in the LINCS matrix for task task.
 
static void gmx::set_lincs_matrix (Lincs *li, ArrayRef< const real > invmass, real lambda)
 Sets the elements in the LINCS matrix.
 
int gmx::count_triangle_constraints (const InteractionLists &ilist, const ListOfLists< int > &at2con)
 Counts the number of constraint triangles, i.e. triplets of atoms connected by three constraints. More...
 
static bool gmx::more_than_two_sequential_constraints (const InteractionLists &ilist, const ListOfLists< int > &at2con)
 Finds sequences of sequential constraints.
 
Lincs * gmx::init_lincs (FILE *fplog, const gmx_mtop_t &mtop, int nflexcon_global, ArrayRef< const ListOfLists< int >> atomsToConstraintsPerMolType, bool bPLINCS, int nIter, int nProjOrder, ObservablesReducerBuilder *observablesReducerBuilder)
 Initializes and returns the lincs data struct.
 
void gmx::done_lincs (Lincs *li)
 Destructs the lincs object when it is not nullptr.
 
static void gmx::lincs_thread_setup (Lincs *li, int natoms)
 Sets up the work division over the threads.
 
static void gmx::assign_constraint (Lincs *li, int constraint_index, int a1, int a2, real lenA, real lenB, const ListOfLists< int > &at2con)
 Assign a constraint.
 
static void gmx::check_assign_connected (Lincs *li, gmx::ArrayRef< const int > iatom, const InteractionDefinitions &idef, bool bDynamics, int a1, int a2, const ListOfLists< int > &at2con)
 Check if constraint with topology index constraint_index is connected to other constraints, and if so add those connected constraints to our task.
 
static void gmx::check_assign_triangle (Lincs *li, gmx::ArrayRef< const int > iatom, const InteractionDefinitions &idef, bool bDynamics, int constraint_index, int a1, int a2, const ListOfLists< int > &at2con)
 Check if constraint with topology index constraint_index is involved in a constraint triangle, and if so add the other two constraints in the triangle to our task.
 
static void gmx::set_matrix_indices (Lincs *li, const Task &li_task, const ListOfLists< int > &at2con, bool bSortMatrix)
 Sets matrix indices.
 
void gmx::set_lincs (const InteractionDefinitions &idef, int numAtoms, ArrayRef< const real > invmass, real lambda, bool bDynamics, const t_commrec *cr, Lincs *li)
 Initialize lincs stuff.
 
static void gmx::lincs_warning (gmx_domdec_t *dd, ArrayRef< const RVec > x, ArrayRef< const RVec > xprime, t_pbc *pbc, int ncons, gmx::ArrayRef< const AtomPair > atoms, gmx::ArrayRef< const real > bllen, real wangle, int maxwarn, int *warncount)
 Issues a warning when LINCS constraints cannot be satisfied.
 
static LincsDeviations gmx::makeLincsDeviations (const Lincs &lincsd, ArrayRef< const RVec > x, const t_pbc *pbc)
 Determine how well the constraints have been satisfied.
 
bool gmx::constrain_lincs (bool computeRmsd, const t_inputrec &ir, int64_t step, Lincs *lincsd, ArrayRef< const real > invmass, const t_commrec *cr, const gmx_multisim_t *ms, ArrayRefWithPadding< const RVec > x, ArrayRefWithPadding< RVec > xprime, ArrayRef< RVec > min_proj, const matrix box, t_pbc *pbc, bool hasMassPerturbed, real lambda, real *dvdlambda, real invdt, ArrayRef< RVec > v, bool bCalcVir, tensor vir_r_m_dr, ConstraintVariable econq, t_nrnb *nrnb, int maxwarn, int *warncount, gmx_wallcycle *wcycle)
 Applies LINCS constraints. More...
 

Variables

static const int gmx::simd_width = 1
 Define simd_width for memory allocation used for SIMD code.