ESPResSo 3.2.0-11-g9950804-git
Extensible Simulation Package for Soft Matter Research
Functions
tab.h File Reference

Routines to calculate the energy and/or force for a particle pair or bonds via interpolating from lookup tables. More...

#include "utils.h"
#include "interaction_data.h"
#include "particle_data.h"
#include "mol_cut.h"
#include "dihedral.h"
#include "forcecap.h"
Include dependency graph for tab.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

int tabulated_set_params (int part_type_a, int part_type_b, char *filename)
 Non-Bonded tabulated potentials: Reads tabulated parameters and force and energy tables from a file.
int tabulated_bonded_set_params (int bond_type, int tab_type, char *filename)
 Bonded tabulated potentials: Reads tabulated parameters and force and energy tables from a file.
MDINLINE void add_tabulated_pair_force (Particle *p1, Particle *p2, IA_parameters *ia_params, double d[3], double dist, double force[3])
 Add a non-bonded pair force by linear interpolation from a table.
MDINLINE double tabulated_pair_energy (Particle *p1, Particle *p2, IA_parameters *ia_params, double d[3], double dist)
 Add a non-bonded pair energy by linear interpolation from a table.
void check_tab_forcecap (double force_cap)
 check the tabulated forcecap to see that it is sensible
MDINLINE double bonded_tab_force_lookup (double val, Bonded_ia_parameters *iaparams)
 Force factor lookup in a force table for bonded interactions (see Bonded_ia_parameters).
MDINLINE double bonded_tab_energy_lookup (double val, Bonded_ia_parameters *iaparams)
 Energy lookup in a energy table for bonded interactions (see Bonded_ia_parameters).
MDINLINE int calc_tab_bond_force (Particle *p1, Particle *p2, Bonded_ia_parameters *iaparams, double dx[3], double force[3])
 Calculate a tabulated bond length force with number type_num (see Bonded_ia_parameters) between particles p1 and p2 and add it to the particle forces.
MDINLINE int tab_bond_energy (Particle *p1, Particle *p2, Bonded_ia_parameters *iaparams, double dx[3], double *_energy)
 Calculate and return a tabulated bond length energy with number type_num (see Bonded_ia_parameters) between particles p1 and p2.
MDINLINE int calc_tab_angle_force (Particle *p_mid, Particle *p_left, Particle *p_right, Bonded_ia_parameters *iaparams, double force1[3], double force2[3])
 Calculate a tabulated bond angle force with number type_num (see Bonded_ia_parameters) between particles p_left, p_mid and p_right and add it to the particle forces.
MDINLINE void calc_angle_3body_tabulated_forces (Particle *p_mid, Particle *p_left, Particle *p_right, Bonded_ia_parameters *iaparams, double force1[3], double force2[3], double force3[3])
MDINLINE int tab_angle_energy (Particle *p_mid, Particle *p_left, Particle *p_right, Bonded_ia_parameters *iaparams, double *_energy)
 Calculate and return tabulated bond angle energy with number type_num (see Bonded_ia_parameters) between particles p_left, p_mid and p_right.
MDINLINE int calc_tab_dihedral_force (Particle *p2, Particle *p1, Particle *p3, Particle *p4, Bonded_ia_parameters *iaparams, double force2[3], double force1[3], double force3[3])
 Calculate a tabulated dihedral force with number type_num (see Bonded_ia_parameters) between particles p1.
MDINLINE int tab_dihedral_energy (Particle *p2, Particle *p1, Particle *p3, Particle *p4, Bonded_ia_parameters *iaparams, double *_energy)
 Calculate and return a tabulated dihedral energy with number type_num (see Bonded_ia_parameters) between particles p1.

Detailed Description

Routines to calculate the energy and/or force for a particle pair or bonds via interpolating from lookup tables.

forces.c Needs feature TABULATED compiled in (see config.h).

Definition in file tab.h.


Function Documentation

MDINLINE void add_tabulated_pair_force ( Particle p1,
Particle p2,
IA_parameters ia_params,
double  d[3],
double  dist,
double  force[3] 
)

Add a non-bonded pair force by linear interpolation from a table.

Needs feature TABULATED compiled in (see config.h).

Definition at line 85 of file tab.h.

References CUTOFF_CHECK, DoubleList::e, force_cap, IA_parameters::TAB_minval, IA_parameters::TAB_startindex, IA_parameters::TAB_stepsize, and tabulated_forces.

Referenced by calc_non_bonded_pair_force_parts().

MDINLINE double bonded_tab_energy_lookup ( double  val,
Bonded_ia_parameters iaparams 
)

Energy lookup in a energy table for bonded interactions (see Bonded_ia_parameters).

The force is calculated by linear interpolation between the closest tabulated values. There is no check for the upper bound! Needs feature TABULATED compiled in (see config.h).

Definition at line 193 of file tab.h.

References Bonded_ia_parameters::p, and Bonded_ia_parameters::tab.

Referenced by tab_angle_energy(), tab_bond_energy(), and tab_dihedral_energy().

MDINLINE double bonded_tab_force_lookup ( double  val,
Bonded_ia_parameters iaparams 
)

Force factor lookup in a force table for bonded interactions (see Bonded_ia_parameters).

The force is calculated by linear interpolation between the closest tabulated values. There is no check for the upper bound! Needs feature TABULATED compiled in (see config.h).

Definition at line 173 of file tab.h.

References Bonded_ia_parameters::p, and Bonded_ia_parameters::tab.

Referenced by calc_angle_3body_tabulated_forces(), calc_tab_angle_force(), calc_tab_bond_force(), and calc_tab_dihedral_force().

MDINLINE void calc_angle_3body_tabulated_forces ( Particle p_mid,
Particle p_left,
Particle p_right,
Bonded_ia_parameters iaparams,
double  force1[3],
double  force2[3],
double  force3[3] 
)
MDINLINE int calc_tab_angle_force ( Particle p_mid,
Particle p_left,
Particle p_right,
Bonded_ia_parameters iaparams,
double  force1[3],
double  force2[3] 
)

Calculate a tabulated bond angle force with number type_num (see Bonded_ia_parameters) between particles p_left, p_mid and p_right and add it to the particle forces.

The force on p_left and p_right acts perpendicular to the connecting vector between the particle and p_mid and in the plane defined by the three particles. The force on the middle particle balances the other two forces. The forces are scaled with the invers length of the connecting vectors. It is assumed that the potential is tabulated for all angles between 0 and Pi. Needs feature TABULATED compiled in (see config.h).

Definition at line 275 of file tab.h.

References bonded_tab_force_lookup(), get_mi_vector(), ParticlePosition::p, Particle::r, scalar(), sqrlen(), and TINY_SIN_VALUE.

Referenced by add_bonded_force().

MDINLINE int calc_tab_bond_force ( Particle p1,
Particle p2,
Bonded_ia_parameters iaparams,
double  dx[3],
double  force[3] 
)

Calculate a tabulated bond length force with number type_num (see Bonded_ia_parameters) between particles p1 and p2 and add it to the particle forces.

The force acts in the direction of the connecting vector between the particles. For distances smaller than the tabulated range it uses a linear extrapolation based on the first two tabulated force values. Needs feature TABULATED compiled in (see config.h).

Definition at line 215 of file tab.h.

References bonded_tab_force_lookup(), check_id, ParticleForce::f, Particle::f, i, ParticleProperties::identity, ONEPART_TRACE, Particle::p, Bonded_ia_parameters::p, sqrlen(), Bonded_ia_parameters::tab, and this_node.

Referenced by add_bonded_force(), and calc_bonded_force().

MDINLINE int calc_tab_dihedral_force ( Particle p2,
Particle p1,
Particle p3,
Particle p4,
Bonded_ia_parameters iaparams,
double  force2[3],
double  force1[3],
double  force3[3] 
)

Calculate a tabulated dihedral force with number type_num (see Bonded_ia_parameters) between particles p1.

p2, p3 and p4 and add it to the particle forces. This function is not tested yet. Needs feature TABULATED compiled in (see config.h).

Definition at line 400 of file tab.h.

References bonded_tab_force_lookup(), calc_dihedral_angle(), i, and vector_product().

Referenced by add_bonded_force().

void check_tab_forcecap ( double  force_cap)

check the tabulated forcecap to see that it is sensible

Warning:
This routine will probably give strange results if forcecap is applied before the table is loaded. Needs feature TABULATED compiled in (see config.h).

Definition at line 199 of file tab.c.

References DoubleList::e, errexit(), force_cap, get_ia_param(), i, DoubleList::max, n_particle_types, IA_parameters::TAB_maxval, IA_parameters::TAB_npoints, IA_parameters::TAB_startindex, and tabulated_forces.

MDINLINE int tab_angle_energy ( Particle p_mid,
Particle p_left,
Particle p_right,
Bonded_ia_parameters iaparams,
double *  _energy 
)

Calculate and return tabulated bond angle energy with number type_num (see Bonded_ia_parameters) between particles p_left, p_mid and p_right.

It is assumed that the potential is tabulated for all angles between 0 and Pi. Needs feature TABULATED compiled in (see config.h).

Definition at line 376 of file tab.h.

References bonded_tab_energy_lookup(), get_mi_vector(), ParticlePosition::p, Particle::r, scalar(), and sqrlen().

Referenced by add_bonded_energy().

MDINLINE int tab_bond_energy ( Particle p1,
Particle p2,
Bonded_ia_parameters iaparams,
double  dx[3],
double *  _energy 
)

Calculate and return a tabulated bond length energy with number type_num (see Bonded_ia_parameters) between particles p1 and p2.

For distances smaller than the tabulated range it uses a quadratic extrapolation based on the first two tabulated force values and the first tabulated energy value. Needs feature TABULATED compiled in (see config.h).

Definition at line 240 of file tab.h.

References bonded_tab_energy_lookup(), Bonded_ia_parameters::p, SQR(), sqrlen(), and Bonded_ia_parameters::tab.

Referenced by add_bonded_energy().

MDINLINE int tab_dihedral_energy ( Particle p2,
Particle p1,
Particle p3,
Particle p4,
Bonded_ia_parameters iaparams,
double *  _energy 
)

Calculate and return a tabulated dihedral energy with number type_num (see Bonded_ia_parameters) between particles p1.

p2, p3 and p4. This function is not tested yet. Needs feature TABULATED compiled in (see config.h).

Definition at line 448 of file tab.h.

References bonded_tab_energy_lookup(), and calc_dihedral_angle().

Referenced by add_bonded_energy().

int tabulated_bonded_set_params ( int  bond_type,
int  tab_type,
char *  filename 
)

Bonded tabulated potentials: Reads tabulated parameters and force and energy tables from a file.

ia_params and force/energy tables are then communicated to each node.

Parameters:
bond_typebond type for which the interaction is defined
tab_typetable type, TAB_BOND_LENGTH, TAB_BOND_ANGLE, TAB_BOND_DIHEDRAL
filenamefrom which file to fetch the data
Returns:
  • 0 on success
  • 1 if wrong bond type
  • 2 currently unused
  • 3 cannot open the file
  • 4 file too short
  • 5 file broken, cannot parse numbers
  • 6 parameter out of bounds

Definition at line 112 of file tab.c.

References bonded_ia_params, BONDED_IA_TABULATED, ES_OK, i, make_bond_type_exist(), malloc, mpi_bcast_ia_params(), Bonded_ia_parameters::num, Bonded_ia_parameters::p, PI, ROUND_ERROR_PREC, Bonded_ia_parameters::tab, TAB_BOND_ANGLE, TAB_BOND_DIHEDRAL, TAB_BOND_LENGTH, and Bonded_ia_parameters::type.

Referenced by tclcommand_inter_parse_tabulated_bonded().

MDINLINE double tabulated_pair_energy ( Particle p1,
Particle p2,
IA_parameters ia_params,
double  d[3],
double  dist 
)

Add a non-bonded pair energy by linear interpolation from a table.

Needs feature TABULATED compiled in (see config.h).

Definition at line 127 of file tab.h.

References CUTOFF_CHECK, DoubleList::e, SQR(), IA_parameters::TAB_minval, IA_parameters::TAB_startindex, IA_parameters::TAB_stepsize, tabulated_energies, and tabulated_forces.

Referenced by calc_non_bonded_pair_energy().

int tabulated_set_params ( int  part_type_a,
int  part_type_b,
char *  filename 
)

Non-Bonded tabulated potentials: Reads tabulated parameters and force and energy tables from a file.

ia_params and force/energy tables are then communicated to each node

Parameters:
part_type_aparticle type for which the interaction is defined
part_type_bparticle type for which the interaction is defined
filenamefrom which file to fetch the data
Returns:
  • 0 on success
  • 1 on particle type mismatches
  • 2 file name too long
  • 3 cannot open the file
  • 4 file too short
  • 5 file broken, cannot parse numbers
  • 6 number of points of existing potential changed

Definition at line 30 of file tab.c.

References DoubleList::e, force_cap, get_ia_param_safe(), i, DoubleList::max, MAXLENGTH_TABFILE_NAME, mpi_bcast_ia_params(), mpi_cap_forces(), realloc_doublelist(), IA_parameters::TAB_filename, IA_parameters::TAB_maxval, IA_parameters::TAB_minval, IA_parameters::TAB_npoints, IA_parameters::TAB_startindex, IA_parameters::TAB_stepsize, tabulated_energies, and tabulated_forces.

Referenced by tclcommand_inter_parse_tab().