Tinker9 70bd052 (Thu Nov 9 12:11:35 2023 -0800)
Loading...
Searching...
No Matches
Macros | Typedefs
Precision

Definitions of data types used in the MD simulations. More...

Macros

#define TINKER_DETERMINISTIC_FORCE   1
 
#define TINKER_REAL_SIZE   4
 
#define TINKER_MIXED_SIZE   8
 
#define TINKER_DOUBLE_PRECISION   0
 
#define TINKER_MIXED_PRECISION   1
 
#define TINKER_SINGLE_PRECISION   0
 

Typedefs

typedef unsigned long long tinker::fixed
 
typedef float tinker::real
 
typedef double tinker::mixed
 
typedef mixed tinker::time_prec
 Floating-point type for time. More...
 
typedef mixed tinker::T_prec
 Floating-point type for temperature. More...
 
typedef mixed tinker::vel_prec
 Floating-point type for velocities. More...
 
typedef mixed tinker::pos_prec
 Floating-point type for coordinates. More...
 
typedef real tinker::e_prec
 Floating-point type for the pairwise energy components. More...
 
typedef real tinker::v_prec
 Floating-point type for the pairwise virial components. More...
 
typedef real tinker::g_prec
 Floating-point type for the pairwise gradient components. More...
 
typedef mixed tinker::energy_prec
 Floating-point type for total energies. More...
 
typedef mixed tinker::virial_prec
 
typedef fixed tinker::grad_prec
 

Detailed Description

Definitions of data types used in the MD simulations.

Macro Definition Documentation

◆ TINKER_DETERMINISTIC_FORCE

#define TINKER_DETERMINISTIC_FORCE   1

Logical macro for the underlying type of energy gradients.

  • If true, always uses fixed-point arithmetic to accumulate energy gradients, regardless of the underlying type of each individual component.
  • If false, use type real, which can either be float or double based on the precision macro.
See also
TINKER_DOUBLE_PRECISION
TINKER_MIXED_PRECISION
TINKER_SINGLE_PRECISION

In general, evaluating energy, forces, etc. twice, we don't expect to get two identical answers, but we may not care as much because the difference is usually negligible. [See Why is cos(x) != cos(y)?] Whereas in MD, two simulations with the same initial configurations can easily diverge due to the accumulated difference. If, for whatever reason, you are willing to elongate the process of the inevitable divergence at the cost of slightly slower simulation speed, a more "deterministic" force (using fixed-point arithmetic) can help.

To accumulate floating-point values via fixed-point arithmetic, we first scale the values by a large integer then sum only the integer part.

// fixed sum = 0;
// FLT is float or double
FLT val2 = val * 0x100000000ull;
sum += (fixed)((long long)val2);

To get the floating-point sum, we have to cast the integer sum back to floating-point number, then divide it by the same large integer.

FLT val2 = (FLT)((long long)sum);
FLT answer = val2 / 0x100000000ull;

◆ TINKER_DOUBLE_PRECISION

#define TINKER_DOUBLE_PRECISION   0

Macro for the precision mode. Types real and mixed have different definitions in different modes.

Macros real mixed
DOUBLE double double
MIXED float double
SINGLE float float

Only one of the precision macros can be set to 1 and the others will be set to 0.

◆ TINKER_MIXED_PRECISION

#define TINKER_MIXED_PRECISION   1

Macro for the precision mode. Types real and mixed have different definitions in different modes.

Macros real mixed
DOUBLE double double
MIXED float double
SINGLE float float

Only one of the precision macros can be set to 1 and the others will be set to 0.

◆ TINKER_MIXED_SIZE

#define TINKER_MIXED_SIZE   8

Number of bytes of the type mixed.

◆ TINKER_REAL_SIZE

#define TINKER_REAL_SIZE   4

Number of bytes of the type real.

◆ TINKER_SINGLE_PRECISION

#define TINKER_SINGLE_PRECISION   0

Macro for the precision mode. Types real and mixed have different definitions in different modes.

Macros real mixed
DOUBLE double double
MIXED float double
SINGLE float float

Only one of the precision macros can be set to 1 and the others will be set to 0.

Typedef Documentation

◆ e_prec

Floating-point type for the pairwise energy components.

◆ energy_prec

Floating-point type for total energies.

◆ fixed

64-bit unsigned integer type for fixed-point arithmetic.

◆ g_prec

Floating-point type for the pairwise gradient components.

◆ grad_prec

Floating-point or fixed-point type for the total gradients.

See also
TINKER_DETERMINISTIC_FORCE

◆ mixed

Floating-point type with higher precision (not lower than real).

See also
TINKER_MIXED_PRECISION

◆ pos_prec

Floating-point type for coordinates.

◆ real

Floating-point type with lower precision (not higher than mixed).

See also
TINKER_MIXED_PRECISION

◆ T_prec

Floating-point type for temperature.

◆ time_prec

Floating-point type for time.

◆ v_prec

Floating-point type for the pairwise virial components.

◆ vel_prec

Floating-point type for velocities.

◆ virial_prec

Floating-point type for total virials.