NAMD
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
PmePencilZ Class Reference

#include <PmeSolver.h>

Inheritance diagram for PmePencilZ:

Public Member Functions

PmePencilZ_SDAG_CODE PmePencilZ ()
 
 PmePencilZ (CkMigrateMessage *m)
 
virtual ~PmePencilZ ()
 
void skip ()
 

Protected Member Functions

void initBlockSizes ()
 
void submitReductions (unsigned int iGrid)
 

Protected Attributes

PmeGrid pmeGrid
 
bool doEnergy
 
bool doVirial
 
int simulationStep
 
std::array< FFTCompute *, NUM_GRID_MAXfftComputes
 
std::array< PmeTranspose *, NUM_GRID_MAXpmeTransposes
 
std::array< PmeKSpaceCompute *, NUM_GRID_MAXpmeKSpaceComputes
 
std::array< int, NUM_GRID_MAXenergyReady
 
std::vector< int > blockSizes
 
Lattice lattice
 
int numStrayAtoms
 
int imsg
 

Detailed Description

Definition at line 253 of file PmeSolver.h.

Constructor & Destructor Documentation

◆ PmePencilZ() [1/2]

PmePencilZ::PmePencilZ ( )

Definition at line 567 of file PmeSolver.C.

References doEnergy, doVirial, fftComputes, NUM_GRID_MAX, numStrayAtoms, ReductionMgr::Object(), pmeKSpaceComputes, pmeTransposes, REDUCTIONS_BASIC, and ReductionMgr::willSubmit().

567  {
568  __sdag_init();
569  setMigratable(false);
570  for (unsigned int iGrid = 0; iGrid < NUM_GRID_MAX; ++iGrid) {
571  pmeTransposes[iGrid] = NULL;
572  fftComputes[iGrid] = NULL;
573  pmeKSpaceComputes[iGrid] = NULL;
574  }
576  doEnergy = false;
577  doVirial = false;
578  numStrayAtoms = 0;
579 }
std::array< PmeKSpaceCompute *, NUM_GRID_MAX > pmeKSpaceComputes
Definition: PmeSolver.h:266
bool doEnergy
Definition: PmeSolver.h:262
SubmitReduction * willSubmit(int setID, int size=-1)
Definition: ReductionMgr.C:368
static ReductionMgr * Object(void)
Definition: ReductionMgr.h:290
const unsigned int NUM_GRID_MAX
Definition: PmeSolverUtil.h:9
bool doVirial
Definition: PmeSolver.h:262
int numStrayAtoms
Definition: PmeSolver.h:270
std::array< PmeTranspose *, NUM_GRID_MAX > pmeTransposes
Definition: PmeSolver.h:265
std::array< FFTCompute *, NUM_GRID_MAX > fftComputes
Definition: PmeSolver.h:264

◆ PmePencilZ() [2/2]

PmePencilZ::PmePencilZ ( CkMigrateMessage *  m)

Definition at line 581 of file PmeSolver.C.

References NAMD_bug().

581  {
582  NAMD_bug("PmePencilZ cannot be migrated");
583  //__sdag_init();
584  // setMigratable(false);
585  // fftCompute = NULL;
586  // pmeTranspose = NULL;
587 }
void NAMD_bug(const char *err_msg)
Definition: common.C:195

◆ ~PmePencilZ()

PmePencilZ::~PmePencilZ ( )
virtual

Definition at line 589 of file PmeSolver.C.

References fftComputes, NUM_GRID_MAX, pmeKSpaceComputes, and pmeTransposes.

589  {
590 // if (fftCompute != NULL) delete fftCompute;
591 // if (pmeTranspose != NULL) delete pmeTranspose;
592 // if (pmeKSpaceCompute != NULL) delete pmeKSpaceCompute;
593 // if (fftCompute2 != NULL) delete fftCompute2;
594 // if (pmeTranspose2 != NULL) delete pmeTranspose2;
595 // if (pmeKSpaceCompute2 != NULL) delete pmeKSpaceCompute2;
596  for (unsigned int iGrid = 0; iGrid < NUM_GRID_MAX; ++iGrid) {
597  if (pmeTransposes[iGrid] != NULL) delete pmeTransposes[iGrid];
598  if (fftComputes[iGrid] != NULL) delete fftComputes[iGrid];
599  if (pmeKSpaceComputes[iGrid] != NULL) delete pmeKSpaceComputes[iGrid];
600  }
601  delete reduction;
602 }
std::array< PmeKSpaceCompute *, NUM_GRID_MAX > pmeKSpaceComputes
Definition: PmeSolver.h:266
const unsigned int NUM_GRID_MAX
Definition: PmeSolverUtil.h:9
std::array< PmeTranspose *, NUM_GRID_MAX > pmeTransposes
Definition: PmeSolver.h:265
std::array< FFTCompute *, NUM_GRID_MAX > fftComputes
Definition: PmeSolver.h:264

Member Function Documentation

◆ initBlockSizes()

void PmePencilZ::initBlockSizes ( )
protected

Definition at line 632 of file PmeSolver.C.

References blockSizes, getBlockDim(), Perm_Z_cX_Y, pmeGrid, and PmeGrid::zBlocks.

632  {
633  blockSizes.resize(pmeGrid.zBlocks);
634  for (int z=0;z < pmeGrid.zBlocks;z++) {
635  int i0, i1, j0, j1, k0, k1;
636  getBlockDim(pmeGrid, Perm_Z_cX_Y, z, thisIndex.x, thisIndex.y,
637  i0, i1, j0, j1, k0, k1);
638  int size = (i1-i0+1)*(j1-j0+1)*(k1-k0+1);
639  blockSizes[z] = size;
640  }
641 }
int zBlocks
Definition: PmeBase.h:25
std::vector< int > blockSizes
Definition: PmeSolver.h:268
PmeGrid pmeGrid
Definition: PmeSolver.h:261
static void getBlockDim(const PmeGrid &pmeGrid, const int permutation, const int iblock, const int jblock, const int kblock, int &i0, int &i1, int &j0, int &j1, int &k0, int &k1)
Definition: PmeSolverUtil.h:89

◆ skip()

void PmePencilZ::skip ( void  )

Definition at line 811 of file PmeSolver.C.

References SubmitReduction::submit().

811  {
812  reduction->submit();
813 }
virtual void submit(void)=0

◆ submitReductions()

void PmePencilZ::submitReductions ( unsigned int  iGrid)
protected

Definition at line 655 of file PmeSolver.C.

References energyReady, SubmitReduction::item(), NAMD_bug(), NUM_GRID_MAX, numStrayAtoms, Node::Object(), pmeKSpaceComputes, REDUCTION_ELECT_ENERGY_SLOW, REDUCTION_ELECT_ENERGY_SLOW_F, REDUCTION_ELECT_ENERGY_SLOW_TI_1, REDUCTION_ELECT_ENERGY_SLOW_TI_2, REDUCTION_STRAY_CHARGE_ERRORS, Node::simParameters, simParams, simulationStep, and SubmitReduction::submit().

655  {
656  if (pmeKSpaceComputes[iGrid] == NULL)
657  NAMD_bug("PmePencilZ::submitReductions, pmeKSpaceCompute not initialized");
658 // fprintf(stderr, "PmePencilZ::submitReductions\n");
660  double virial[9];
661  double energy = pmeKSpaceComputes[iGrid]->getEnergy();
662  pmeKSpaceComputes[iGrid]->getVirial(virial);
663  if (simParams->alchOn) {
664  double energy_F = energy;
665  double scale1 = 1.0;
666  double scale2 = 1.0;
667  if (simParams->alchFepOn) {
668  switch (iGrid) {
669  case 0: {
670  const BigReal alchLambda = simParams->getCurrentLambda(simulationStep);
671  const BigReal alchLambda2 = simParams->getCurrentLambda2(simulationStep);
672  const BigReal elecLambdaUp = simParams->getElecLambda(alchLambda);
673  const BigReal elecLambda2Up = simParams->getElecLambda(alchLambda2);
674  scale1 = elecLambdaUp;
675  scale2 = elecLambda2Up;
676  break;
677  }
678  case 1: {
679  const BigReal alchLambda = simParams->getCurrentLambda(simulationStep);
680  const BigReal alchLambda2 = simParams->getCurrentLambda2(simulationStep);
681  const BigReal elecLambdaDown = simParams->getElecLambda(1 - alchLambda);
682  const BigReal elecLambda2Down = simParams->getElecLambda(1 - alchLambda2);
683  scale1 = elecLambdaDown;
684  scale2 = elecLambda2Down;
685  break;
686  }
687  case 2: {
688  const BigReal alchLambda = simParams->getCurrentLambda(simulationStep);
689  const BigReal alchLambda2 = simParams->getCurrentLambda2(simulationStep);
690  const BigReal elecLambdaUp = simParams->getElecLambda(alchLambda);
691  const BigReal elecLambda2Up = simParams->getElecLambda(alchLambda2);
692  scale1 = 1.0 - elecLambdaUp;
693  scale2 = 1.0 - elecLambda2Up;
694  break;
695  }
696  case 3: {
697  const BigReal alchLambda = simParams->getCurrentLambda(simulationStep);
698  const BigReal alchLambda2 = simParams->getCurrentLambda2(simulationStep);
699  const BigReal elecLambdaDown = simParams->getElecLambda(1 - alchLambda);
700  const BigReal elecLambda2Down = simParams->getElecLambda(1 - alchLambda2);
701  scale1 = 1.0 - elecLambdaDown;
702  scale2 = 1.0 - elecLambda2Down;
703  break;
704  }
705  case 4: {
706  const BigReal alchLambda = simParams->getCurrentLambda(simulationStep);
707  const BigReal alchLambda2 = simParams->getCurrentLambda2(simulationStep);
708  const BigReal elecLambdaUp = simParams->getElecLambda(alchLambda);
709  const BigReal elecLambda2Up = simParams->getElecLambda(alchLambda2);
710  const BigReal elecLambdaDown = simParams->getElecLambda(1 - alchLambda);
711  const BigReal elecLambda2Down = simParams->getElecLambda(1 - alchLambda2);
712  scale1 = -1.0 * (elecLambdaUp + elecLambdaDown - 1.0);
713  scale2 = -1.0 * (elecLambda2Up + elecLambda2Down - 1.0);
714  break;
715  }
716  }
717  energy *= scale1;
718  energy_F *= scale2;
719  for (size_t i = 0; i < 9; ++i) {
720  virial[i] *= scale1;
721  }
722  reduction->item(REDUCTION_ELECT_ENERGY_SLOW_F) += energy_F;
723  }
724  if (simParams->alchThermIntOn) {
725  double energy_TI_1 = 0.0;
726  double energy_TI_2 = 0.0;
727  double scale1 = 1.0;
728  switch (iGrid) {
729  case 0: {
730  const BigReal alchLambda = simParams->getCurrentLambda(simulationStep);
731  const BigReal elecLambdaUp = simParams->getElecLambda(alchLambda);
732  scale1 = elecLambdaUp;
733  energy_TI_1 = energy;
734  break;
735  }
736  case 1: {
737  const BigReal alchLambda = simParams->getCurrentLambda(simulationStep);
738  const BigReal elecLambdaDown = simParams->getElecLambda(1 - alchLambda);
739  scale1 = elecLambdaDown;
740  energy_TI_2 = energy;
741  break;
742  }
743  case 2: {
744  const BigReal alchLambda = simParams->getCurrentLambda(simulationStep);
745  const BigReal elecLambdaUp = simParams->getElecLambda(alchLambda);
746  scale1 = 1.0 - elecLambdaUp;
747  energy_TI_1 = -1.0 * energy;
748  break;
749  }
750  case 3: {
751  const BigReal alchLambda = simParams->getCurrentLambda(simulationStep);
752  const BigReal elecLambdaDown = simParams->getElecLambda(1 - alchLambda);
753  scale1 = 1.0 - elecLambdaDown;
754  energy_TI_2 = -1.0 * energy;
755  break;
756  }
757  case 4: {
758  const BigReal alchLambda = simParams->getCurrentLambda(simulationStep);
759  const BigReal elecLambdaUp = simParams->getElecLambda(alchLambda);
760  const BigReal elecLambdaDown = simParams->getElecLambda(1 - alchLambda);
761  scale1 = -1.0 * (elecLambdaUp + elecLambdaDown - 1.0);
762  energy_TI_1 = -1.0 * energy;
763  energy_TI_2 = -1.0 * energy;
764  break;
765  }
766  }
767 // fprintf(stdout, "Grid %u : energy_TI_1 = %lf ; energy_TI_2 = %lf\n", iGrid, energy_TI_1, energy_TI_2);
768  reduction->item(REDUCTION_ELECT_ENERGY_SLOW_TI_1) += energy_TI_1;
769  reduction->item(REDUCTION_ELECT_ENERGY_SLOW_TI_2) += energy_TI_2;
770  }
771  }
772  reduction->item(REDUCTION_ELECT_ENERGY_SLOW) += energy;
773  reduction->item(REDUCTION_VIRIAL_SLOW_XX) += virial[0];
774  reduction->item(REDUCTION_VIRIAL_SLOW_XY) += virial[1];
775  reduction->item(REDUCTION_VIRIAL_SLOW_XZ) += virial[2];
776  reduction->item(REDUCTION_VIRIAL_SLOW_YX) += virial[3];
777  reduction->item(REDUCTION_VIRIAL_SLOW_YY) += virial[4];
778  reduction->item(REDUCTION_VIRIAL_SLOW_YZ) += virial[5];
779  reduction->item(REDUCTION_VIRIAL_SLOW_ZX) += virial[6];
780  reduction->item(REDUCTION_VIRIAL_SLOW_ZY) += virial[7];
781  reduction->item(REDUCTION_VIRIAL_SLOW_ZZ) += virial[8];
783  numStrayAtoms = 0;
784  energyReady[iGrid] = 1;
785  bool ready_to_submit = true;
786  for (size_t i = 0; i < NUM_GRID_MAX; ++i) {
787  if (energyReady[i] == -1) continue;
788  if (energyReady[i] == 0) ready_to_submit = false;
789  }
790  if (ready_to_submit) {
791  reduction->submit();
792  for (size_t i = 0; i < NUM_GRID_MAX; ++i) {
793  if (energyReady[i] == -1) continue;
794  if (energyReady[i] == 1) energyReady[i] = 0;
795  }
796  }
797 }
static Node * Object()
Definition: Node.h:86
std::array< PmeKSpaceCompute *, NUM_GRID_MAX > pmeKSpaceComputes
Definition: PmeSolver.h:266
virtual void submit(void)=0
SimParameters * simParameters
Definition: Node.h:181
BigReal & item(int i)
Definition: ReductionMgr.h:336
int simulationStep
Definition: PmeSolver.h:263
const unsigned int NUM_GRID_MAX
Definition: PmeSolverUtil.h:9
void NAMD_bug(const char *err_msg)
Definition: common.C:195
std::array< int, NUM_GRID_MAX > energyReady
Definition: PmeSolver.h:267
int numStrayAtoms
Definition: PmeSolver.h:270
#define simParams
Definition: Output.C:131
double BigReal
Definition: common.h:123

Member Data Documentation

◆ blockSizes

std::vector<int> PmePencilZ::blockSizes
protected

Definition at line 268 of file PmeSolver.h.

Referenced by initBlockSizes().

◆ doEnergy

bool PmePencilZ::doEnergy
protected

Definition at line 262 of file PmeSolver.h.

Referenced by PmePencilZ().

◆ doVirial

bool PmePencilZ::doVirial
protected

Definition at line 262 of file PmeSolver.h.

Referenced by PmePencilZ().

◆ energyReady

std::array<int, NUM_GRID_MAX> PmePencilZ::energyReady
protected

Definition at line 267 of file PmeSolver.h.

Referenced by submitReductions().

◆ fftComputes

std::array<FFTCompute*, NUM_GRID_MAX> PmePencilZ::fftComputes
protected

Definition at line 264 of file PmeSolver.h.

Referenced by PmePencilZ(), and ~PmePencilZ().

◆ imsg

int PmePencilZ::imsg
protected

Definition at line 273 of file PmeSolver.h.

◆ lattice

Lattice PmePencilZ::lattice
protected

Definition at line 269 of file PmeSolver.h.

◆ numStrayAtoms

int PmePencilZ::numStrayAtoms
protected

Definition at line 270 of file PmeSolver.h.

Referenced by PmePencilZ(), and submitReductions().

◆ pmeGrid

PmeGrid PmePencilZ::pmeGrid
protected

Definition at line 261 of file PmeSolver.h.

Referenced by initBlockSizes().

◆ pmeKSpaceComputes

std::array<PmeKSpaceCompute*, NUM_GRID_MAX> PmePencilZ::pmeKSpaceComputes
protected

Definition at line 266 of file PmeSolver.h.

Referenced by PmePencilZ(), submitReductions(), and ~PmePencilZ().

◆ pmeTransposes

std::array<PmeTranspose*, NUM_GRID_MAX> PmePencilZ::pmeTransposes
protected

Definition at line 265 of file PmeSolver.h.

Referenced by PmePencilZ(), and ~PmePencilZ().

◆ simulationStep

int PmePencilZ::simulationStep
protected

Definition at line 263 of file PmeSolver.h.

Referenced by submitReductions().


The documentation for this class was generated from the following files: