vdw_new.cpp File Reference
#include <iostream>
#include <Eigen/Core>

Macros

#define SCALAR   float
 
#define SIZE   10000
 
#define REPEAT   10000
 

Typedefs

typedef Matrix< SCALAR, Eigen::Dynamic, 1 > Vec
 

Functions

SCALAR E_VDW (const Vec &interactions1, const Vec &interactions2)
 
int main ()
 

Macro Definition Documentation

◆ REPEAT

#define REPEAT   10000

◆ SCALAR

#define SCALAR   float

◆ SIZE

#define SIZE   10000

Typedef Documentation

◆ Vec

Function Documentation

◆ E_VDW()

SCALAR E_VDW ( const Vec interactions1,
const Vec interactions2 
)
22  {
23  return (interactions2.cwise() / interactions1).cwise().cube().cwise().square().cwise().square().sum();
24 }

Referenced by main().

◆ main()

int main ( )
26  {
27  //
28  // 1 2 3 4 ... (interactions)
29  // ka . . . . ...
30  // rab . . . . ...
31  // energy . . . . ...
32  // ... ... ... ... ... ...
33  // (variables
34  // for
35  // interaction)
36  //
37  Vec interactions1(SIZE), interactions2(SIZE); // SIZE is the number of vdw interactions in our system
38  // SetupCalculations()
39  SCALAR rab = 1.0;
40  interactions1.setConstant(2.4);
41  interactions2.setConstant(rab);
42 
43  // Energy()
44  SCALAR energy = 0.0;
45  for (unsigned int i = 0; i < REPEAT; ++i) {
46  energy += E_VDW(interactions1, interactions2);
47  energy *= 1 + 1e-20 * i; // prevent compiler from optimizing the loop
48  }
49  cout << "energy = " << energy << endl;
50 }
int i
Definition: BiCGSTAB_step_by_step.cpp:9
Array< double, 1, 3 > e(1./3., 0.5, 2.)
#define REPEAT
Definition: vdw_new.cpp:15
SCALAR E_VDW(const Vec &interactions1, const Vec &interactions2)
Definition: vdw_new.cpp:22
#define SIZE
Definition: vdw_new.cpp:11
#define SCALAR
Definition: vdw_new.cpp:7

References e(), E_VDW(), i, REPEAT, SCALAR, Eigen::PlainObjectBase< Derived >::setConstant(), and SIZE.