Skip to content
Snippets Groups Projects
Commit fe8244c1 authored by Ulf R. Pedersen's avatar Ulf R. Pedersen
Browse files

Rename fix

parent 3381a433
No related branches found
No related tags found
No related merge requests found
...@@ -5,16 +5,17 @@ ...@@ -5,16 +5,17 @@
The usage is as follows: The usage is as follows:
fix [name] [groupID] rhoKUmbrella [nx] [ny] [nz] [kappa = spring constant] [rhoK0] fix [name] [groupID] rhoK [nx] [ny] [nz] [kappa = spring constant] [rhoK0]
where k_i = (2 pi / L_i) * n_i where k_i = (2 pi / L_i) * n_i
Written by Ulf Pedersen and Patrick Varilly, 4 Feb 2010 Written by Ulf Pedersen and Patrick Varilly, 4 Feb 2010
Tweaked for LAMMPS 15 Jan 2010 version by Ulf Pedersen, 19 Aug 2010 Tweaked for LAMMPS 15 Jan 2010 version by Ulf Pedersen, 19 Aug 2010
Tweaked again March 4th 2012 by Ulf Pedersen. Tweaked again March 4th 2012 by Ulf R. Pedersen,
September 2016 by Ulf R. Pedersen
*/ */
#include "fix_rhoKUmbrella.h" #include "fix_rhok.h"
#include "error.h" #include "error.h"
#include "update.h" #include "update.h"
#include "respa.h" #include "respa.h"
...@@ -32,7 +33,7 @@ using namespace FixConst; ...@@ -32,7 +33,7 @@ using namespace FixConst;
// Constructor: all the parameters to this fix specified in // Constructor: all the parameters to this fix specified in
// the LAMMPS input get passed in // the LAMMPS input get passed in
FixRhoKUmbrella::FixRhoKUmbrella( LAMMPS* inLMP, int inArgc, char** inArgv ) FixRhok::FixRhok( LAMMPS* inLMP, int inArgc, char** inArgv )
: Fix( inLMP, inArgc, inArgv ) : Fix( inLMP, inArgc, inArgv )
{ {
// Check arguments // Check arguments
...@@ -64,7 +65,7 @@ FixRhoKUmbrella::FixRhoKUmbrella( LAMMPS* inLMP, int inArgc, char** inArgv ) ...@@ -64,7 +65,7 @@ FixRhoKUmbrella::FixRhoKUmbrella( LAMMPS* inLMP, int inArgc, char** inArgv )
mRhoK0 = atof( inArgv[7] ); mRhoK0 = atof( inArgv[7] );
} }
FixRhoKUmbrella::~FixRhoKUmbrella() FixRhok::~FixRhok()
{ {
} }
...@@ -73,7 +74,7 @@ FixRhoKUmbrella::~FixRhoKUmbrella() ...@@ -73,7 +74,7 @@ FixRhoKUmbrella::~FixRhoKUmbrella()
// Tells LAMMPS where this fix should act // Tells LAMMPS where this fix should act
int int
FixRhoKUmbrella::setmask() FixRhok::setmask()
{ {
int mask = 0; int mask = 0;
...@@ -88,7 +89,7 @@ FixRhoKUmbrella::setmask() ...@@ -88,7 +89,7 @@ FixRhoKUmbrella::setmask()
return mask; return mask;
} }
/*int FixRhoKUmbrella::setmask() /*int FixRhok::setmask()
{ {
int mask = 0; int mask = 0;
mask |= POST_FORCE; mask |= POST_FORCE;
...@@ -100,7 +101,7 @@ FixRhoKUmbrella::setmask() ...@@ -100,7 +101,7 @@ FixRhoKUmbrella::setmask()
// Initializes the fix at the beginning of a run // Initializes the fix at the beginning of a run
void void
FixRhoKUmbrella::init() FixRhok::init()
{ {
// RESPA boilerplate // RESPA boilerplate
if( strcmp( update->integrate_style, "respa" ) == 0 ) if( strcmp( update->integrate_style, "respa" ) == 0 )
...@@ -122,7 +123,7 @@ FixRhoKUmbrella::init() ...@@ -122,7 +123,7 @@ FixRhoKUmbrella::init()
// Initial application of the fix to a system (when doing MD) // Initial application of the fix to a system (when doing MD)
void void
FixRhoKUmbrella::setup( int inVFlag ) FixRhok::setup( int inVFlag )
{ {
if( strcmp( update->integrate_style, "verlet" ) == 0 ) if( strcmp( update->integrate_style, "verlet" ) == 0 )
post_force( inVFlag ); post_force( inVFlag );
...@@ -136,14 +137,14 @@ FixRhoKUmbrella::setup( int inVFlag ) ...@@ -136,14 +137,14 @@ FixRhoKUmbrella::setup( int inVFlag )
// Initial application of the fix to a system (when doing minimization) // Initial application of the fix to a system (when doing minimization)
void void
FixRhoKUmbrella::min_setup( int inVFlag ) FixRhok::min_setup( int inVFlag )
{ {
post_force( inVFlag ); post_force( inVFlag );
} }
// Modify the forces calculated in the main force loop of ordinary MD // Modify the forces calculated in the main force loop of ordinary MD
void void
FixRhoKUmbrella::post_force( int inVFlag ) FixRhok::post_force( int inVFlag )
{ {
double **x = atom->x; double **x = atom->x;
double **f = atom->f; double **f = atom->f;
...@@ -168,11 +169,9 @@ FixRhoKUmbrella::post_force( int inVFlag ) ...@@ -168,11 +169,9 @@ FixRhoKUmbrella::post_force( int inVFlag )
MPI_Allreduce( mRhoKLocal, mRhoKGlobal, MPI_Allreduce( mRhoKLocal, mRhoKGlobal,
2, MPI_DOUBLE, MPI_SUM, world ); 2, MPI_DOUBLE, MPI_SUM, world );
// WARNING!!!!! < \sum_{i,j} e^{-ik.(r_i - r_j)} > ~ N, so // Info: < \sum_{i,j} e^{-ik.(r_i - r_j)} > ~ N, so
// we define rho_k as (1 / sqrt(N)) \sum_i e^{-i k.r_i}, so that // we define rho_k as (1 / sqrt(N)) \sum_i e^{-i k.r_i}, so that
// <rho_k^2> is intensive. // <rho_k^2> is intensive.
//
// Don't forget this two years from now when you change the system size!!!
mRhoKGlobal[0] /= mSqrtNThis; mRhoKGlobal[0] /= mSqrtNThis;
mRhoKGlobal[1] /= mSqrtNThis; mRhoKGlobal[1] /= mSqrtNThis;
...@@ -207,7 +206,7 @@ FixRhoKUmbrella::post_force( int inVFlag ) ...@@ -207,7 +206,7 @@ FixRhoKUmbrella::post_force( int inVFlag )
// Forces in RESPA loop // Forces in RESPA loop
void void
FixRhoKUmbrella::post_force_respa( int inVFlag, int inILevel, int inILoop ) FixRhok::post_force_respa( int inVFlag, int inILevel, int inILoop )
{ {
if( inILevel == mNLevelsRESPA - 1 ) if( inILevel == mNLevelsRESPA - 1 )
post_force( inVFlag ); post_force( inVFlag );
...@@ -215,14 +214,14 @@ FixRhoKUmbrella::post_force_respa( int inVFlag, int inILevel, int inILoop ) ...@@ -215,14 +214,14 @@ FixRhoKUmbrella::post_force_respa( int inVFlag, int inILevel, int inILoop )
// Forces in minimization loop // Forces in minimization loop
void void
FixRhoKUmbrella::min_post_force( int inVFlag ) FixRhok::min_post_force( int inVFlag )
{ {
post_force( inVFlag ); post_force( inVFlag );
} }
// Compute the change in the potential energy induced by this fix // Compute the change in the potential energy induced by this fix
double double
FixRhoKUmbrella::compute_scalar() FixRhok::compute_scalar()
{ {
double rhoK = sqrt( mRhoKGlobal[0]*mRhoKGlobal[0] double rhoK = sqrt( mRhoKGlobal[0]*mRhoKGlobal[0]
+ mRhoKGlobal[1]*mRhoKGlobal[1] ); + mRhoKGlobal[1]*mRhoKGlobal[1] );
...@@ -232,7 +231,7 @@ FixRhoKUmbrella::compute_scalar() ...@@ -232,7 +231,7 @@ FixRhoKUmbrella::compute_scalar()
// Compute the ith component of the vector // Compute the ith component of the vector
double double
FixRhoKUmbrella::compute_vector( int inI ) FixRhok::compute_vector( int inI )
{ {
if( inI == 0 ) if( inI == 0 )
return mRhoKGlobal[0]; // Real part return mRhoKGlobal[0]; // Real part
......
/* /*
fix_rhoK_umbrella.h fix_rhok.h
A fix to do umbrella sampling on rho(k). A fix to do umbrella sampling on rho(k).
...@@ -15,24 +15,24 @@ ...@@ -15,24 +15,24 @@
#ifdef FIX_CLASS #ifdef FIX_CLASS
FixStyle(rhoKUmbrella,FixRhoKUmbrella) FixStyle(rhok,FixRhok)
#else #else
#ifndef __FIX_RHOKUMBRELLA__ #ifndef __FIX_RHOK__
#define __FIX_RHOKUMBRELLA__ #define __FIX_RHOK__
#include "fix.h" #include "fix.h"
namespace LAMMPS_NS { namespace LAMMPS_NS {
class FixRhoKUmbrella : public Fix class FixRhok : public Fix
{ {
public: public:
// Constructor: all the parameters to this fix specified in // Constructor: all the parameters to this fix specified in
// the LAMMPS input get passed in // the LAMMPS input get passed in
FixRhoKUmbrella( LAMMPS* inLMP, int inArgc, char** inArgv ); FixRhok( LAMMPS* inLMP, int inArgc, char** inArgv );
virtual ~FixRhoKUmbrella(); virtual ~FixRhok();
// Methods that this fix implements // Methods that this fix implements
// -------------------------------- // --------------------------------
...@@ -76,6 +76,6 @@ private: ...@@ -76,6 +76,6 @@ private:
} // namespace LAMMPS_NS } // namespace LAMMPS_NS
#endif // __FIX_RHOKUMBRELLA__ #endif // __FIX_RHOK__
#endif // FIX_CLASS #endif // FIX_CLASS
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment