<commit_before>#ifndef TRANSFORMABLE_BASE_H
#define TRANSFORMABLE_BASE_H

#include "BasicTypes.h" //For uint.
#include "Molecules.h" //For start
#include "BoxDimensions.h" //For pbc wrapping
#include "XYZArray.h" //Parent class
#include "MoveSettings.h"
#include "Coordinates.h"
#include "EnergyTypes.h"
#include "COM.h"
#include "MoveConst.h"
#include "System.h"
#include "StaticVals.h"
#include "CalculateEnergy.h"
#include "EwaldCached.h"
#include "Ewald.h"
#include "NoEwald.h"
#include "MolPick.h"
#include "Forcefield.h"
#include <omp.h>

class MoveBase
{
 public:

   MoveBase(System & sys, StaticVals const& statV) :
   boxDimRef(sys.boxDimRef), moveSetRef(sys.moveSettings), 
     sysPotRef(sys.potential),
     calcEnRef(sys.calcEnergy), comCurrRef(sys.com), 
     coordCurrRef(sys.coordinates), prng(sys.prng), molRef(statV.mol), 
     BETA(statV.forcefield.beta), ewald(statV.forcefield.ewald),
     cellList(sys.cellList), molRemoved(false)
   {
      calcEwald = sys.GetEwald();
   }

    //Based on the random draw, determine the move kind, box, and 
    //(if necessary) molecule kind.
    virtual uint Prep(const double subDraw, const double movPerc) = 0;

    //Note, in general this function is responsible for generating the new
    //configuration to test.
    virtual uint Transform() = 0;

    //In general, this function is responsible for calculating the
    //energy of the system for the new trial configuration.
    virtual void CalcEn() = 0;

    //This function carries out actions based on the internal acceptance state.
    virtual void Accept(const uint rejectState, const uint step) = 0;

 protected:
    uint subPick;
    //If a single molecule move, this is set by the target.
    MoveSettings & moveSetRef;
    SystemPotential & sysPotRef;
    Coordinates & coordCurrRef;
    COM & comCurrRef;
    CalculateEnergy & calcEnRef;
    EwaldCached * calcEwald;
    
    PRNG & prng;
    BoxDimensions & boxDimRef;
    Molecules const& molRef;
    const double BETA;
    const bool ewald;
    CellList& cellList;
    bool molRemoved;
};

//Data needed for transforming a molecule's position via inter or intrabox 
//moves.
class MolTransformBase
{
 protected:
   uint GetBoxAndMol(PRNG & prng, Molecules const& molRef,
		     const double subDraw, const double movPerc);
   void ReplaceWith(MolTransformBase const& other);

   //Box, molecule, and molecule kind
   uint b, m, mk;
   uint pStart, pLen;
   //Position
   XYZArray newMolPos; 
};

inline uint MolTransformBase::GetBoxAndMol
(PRNG & prng, Molecules const& molRef,
 const double subDraw, const double movPerc)
{
#if ENSEMBLE == GCMC
   b = mv::BOX0;
   uint state = prng.PickMol(m, mk, b, subDraw, movPerc);
#else
   uint state = prng.PickMolAndBox(m, mk, b, subDraw, movPerc);
#endif
   pStart = pLen = 0;
   molRef.GetRangeStartLength(pStart, pLen, m);
   newMolPos.Uninit();
   newMolPos.Init(pLen);
   return state;
}

inline void MolTransformBase::ReplaceWith(MolTransformBase const& other)
{
   m = other.m;
   mk = other.mk;
   b = other.b;
   pStart = other.pStart;
   pLen = other.pLen;
   newMolPos = other.newMolPos;
}

class Rotate;

class Translate : public MoveBase, public MolTransformBase
{
 public:

   Translate(System &sys, StaticVals const& statV) : MoveBase(sys, statV) {}<commit_msg>Update MoveBase.h<commit_after>#ifndef TRANSFORMABLE_BASE_H
#define TRANSFORMABLE_BASE_H

#include "BasicTypes.h" //For uint.
#include "Molecules.h" //For start
#include "BoxDimensions.h" //For pbc wrapping
#include "XYZArray.h" //Parent class
#include "MoveSettings.h"
#include "Coordinates.h"
#include "EnergyTypes.h"
#include "COM.h"
#include "MoveConst.h"
#include "System.h"
#include "StaticVals.h"
#include "CalculateEnergy.h"
#include "EwaldCached.h"
#include "Ewald.h"
#include "NoEwald.h"
#include "MolPick.h"
#include "Forcefield.h"
#include <omp.h>

class MoveBase
{
 public:

   MoveBase(System & sys, StaticVals const& statV) :
   boxDimRef(sys.boxDimRef), moveSetRef(sys.moveSettings), 
     sysPotRef(sys.potential),
     calcEnRef(sys.calcEnergy), comCurrRef(sys.com), 
     coordCurrRef(sys.coordinates), prng(sys.prng), molRef(statV.mol), 
     BETA(statV.forcefield.beta), ewald(statV.forcefield.ewald),
     cellList(sys.cellList), molRemoved(false)
   {
      calcEwald = sys.GetEwald();
   }

    //Based on the random draw, determine the move kind, box, and 
    //(if necessary) molecule kind.
    virtual uint Prep(const double subDraw, const double movPerc) = 0;

    //Note, in general this function is responsible for generating the new
    //configuration to test.
    virtual uint Transform() = 0;

    //In general, this function is responsible for calculating the
    //energy of the system for the new trial configuration.
    virtual void CalcEn() = 0;

    //This function carries out actions based on the internal acceptance state.
    virtual void Accept(const uint rejectState, const uint step) = 0;

 protected:
    uint subPick;
    //If a single molecule move, this is set by the target.
    MoveSettings & moveSetRef;
    SystemPotential & sysPotRef;
    Coordinates & coordCurrRef;
    COM & comCurrRef;
    CalculateEnergy & calcEnRef;
    EwaldCached * calcEwald;
    
    PRNG & prng;
    BoxDimensions & boxDimRef;
    Molecules const& molRef;
    const double BETA;
    const bool ewald;
    CellList& cellList;
    bool molRemoved;
};

//Data needed for transforming a molecule's position via inter or intrabox 
//moves.
class MolTransformBase
{
 protected:
   uint GetBoxAndMol(PRNG & prng, Molecules const& molRef,
		     const double subDraw, const double movPerc);
   void ReplaceWith(MolTransformBase const& other);

   //Box, molecule, and molecule kind
   uint b, m, mk;
   uint pStart, pLen;
   //Position
   XYZArray newMolPos; 
};

inline uint MolTransformBase::GetBoxAndMol
(PRNG & prng, Molecules const& molRef,
 const double subDraw, const double movPerc)
{
#if ENSEMBLE == GCMC
   b = mv::BOX0;
   uint state = prng.PickMol(m, mk, b, subDraw, movPerc);
#else
   uint state = prng.PickMolAndBox(m, mk, b, subDraw, movPerc);
#endif
   pStart = pLen = 0;
   if(state == mv::fail_state::NO_FAIL)
   {
      molRef.GetRangeStartLength(pStart, pLen, m);
      newMolPos.Uninit();
      newMolPos.Init(pLen);
   }
   return state;
}

inline void MolTransformBase::ReplaceWith(MolTransformBase const& other)
{
   m = other.m;
   mk = other.mk;
   b = other.b;
   pStart = other.pStart;
   pLen = other.pLen;
   newMolPos = other.newMolPos;
}

class Rotate;

class Translate : public MoveBase, public MolTransformBase
{
 public:

   Translate(System &sys, StaticVals const& statV) : MoveBase(sys, statV) {}
{'fraction_non_alphanumeric': 0.10800660958389666, 'fraction_numerical': 0.0018026137899954935, 'mean_word_length': 3.6887323943661974, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5954087', 'n_tokens_mistral': 2360, 'n_tokens_neox': 2239, 'n_words': 647}