Skip to content
Snippets Groups Projects
Commit c44b1c52 authored by Gareth Tribello's avatar Gareth Tribello
Browse files

Added manyrestraints module

At the moment this can only be used to place a wall around a cluster
so that the atoms stay within a bubble centred on the centre of mass
parent 41440ee1
No related branches found
No related tags found
No related merge requests found
include ../scripts/test.make
#! FIELDS time sr.bias
0.000000 0.0087
0.050000 0.0099
0.100000 0.0096
0.150000 0.0090
0.200000 0.0081
type=driver
# this is to test a different name
arg="--plumed plumed.dat --trajectory-stride 10 --timestep 0.005 --ixyz trajectory.xyz --dump-forces forces --dump-forces-fmt=%8.4f"
extra_files="../trajectories/trajectory.xyz"
#! FIELDS time parameter sr.bias srnum.bias
0.000000 0 -0.0006 -0.0006
0.000000 1 0.0017 0.0017
0.000000 2 -0.0038 -0.0038
0.000000 3 -0.0006 -0.0006
0.000000 4 0.0017 0.0017
0.000000 5 -0.0038 -0.0038
0.000000 6 -0.0006 -0.0006
0.000000 7 0.0017 0.0017
0.000000 8 -0.0038 -0.0038
0.000000 9 -0.0006 -0.0006
0.000000 10 0.0017 0.0017
0.000000 11 -0.0038 -0.0038
0.000000 12 -0.0006 -0.0006
0.000000 13 0.0017 0.0017
0.000000 14 -0.0038 -0.0038
0.000000 15 -0.0006 -0.0006
0.000000 16 0.0017 0.0017
0.000000 17 -0.0038 -0.0038
0.000000 18 -0.0006 -0.0006
0.000000 19 0.0017 0.0017
0.000000 20 -0.0038 -0.0038
0.000000 21 -0.0006 -0.0006
0.000000 22 0.0017 0.0017
0.000000 23 -0.0038 -0.0038
0.000000 24 -0.0006 -0.0006
0.000000 25 0.0017 0.0017
0.000000 26 -0.0038 -0.0038
0.000000 27 0.0106 0.0106
0.000000 28 -0.0318 -0.0318
0.000000 29 0.0716 0.0716
0.000000 30 -0.0006 -0.0006
0.000000 31 0.0017 0.0017
0.000000 32 -0.0038 -0.0038
0.000000 33 -0.0006 -0.0006
0.000000 34 0.0017 0.0017
0.000000 35 -0.0038 -0.0038
0.000000 36 -0.0006 -0.0006
0.000000 37 0.0017 0.0017
0.000000 38 -0.0038 -0.0038
0.000000 39 -0.0006 -0.0006
0.000000 40 0.0017 0.0017
0.000000 41 -0.0038 -0.0038
0.000000 42 -0.0006 -0.0006
0.000000 43 0.0017 0.0017
0.000000 44 -0.0038 -0.0038
0.000000 45 -0.0006 -0.0006
0.000000 46 0.0017 0.0017
0.000000 47 -0.0038 -0.0038
0.000000 48 -0.0006 -0.0006
0.000000 49 0.0017 0.0017
0.000000 50 -0.0038 -0.0038
0.000000 51 -0.0006 -0.0006
0.000000 52 0.0017 0.0017
0.000000 53 -0.0038 -0.0038
0.000000 54 -0.0006 -0.0006
0.000000 55 0.0017 0.0017
0.000000 56 -0.0038 -0.0038
0.000000 57 -0.0006 -0.0006
0.000000 58 0.0017 0.0017
0.000000 59 -0.0038 -0.0038
0.000000 60 -0.0040 -0.0040
0.000000 61 0.0121 0.0121
0.000000 62 -0.0273 -0.0273
0.000000 63 0.0121 0.0121
0.000000 64 -0.0365 -0.0365
0.000000 65 0.0821 0.0821
0.000000 66 -0.0273 -0.0273
0.000000 67 0.0821 0.0821
0.000000 68 -0.1850 -0.1850
0.050000 0 -0.0005 -0.0005
0.050000 1 0.0018 0.0018
0.050000 2 -0.0040 -0.0040
0.050000 3 -0.0005 -0.0005
0.050000 4 0.0018 0.0018
0.050000 5 -0.0040 -0.0040
0.050000 6 -0.0005 -0.0005
0.050000 7 0.0018 0.0018
0.050000 8 -0.0040 -0.0040
0.050000 9 -0.0005 -0.0005
0.050000 10 0.0018 0.0018
0.050000 11 -0.0040 -0.0040
0.050000 12 -0.0005 -0.0005
0.050000 13 0.0018 0.0018
0.050000 14 -0.0040 -0.0040
0.050000 15 -0.0005 -0.0005
0.050000 16 0.0018 0.0018
0.050000 17 -0.0040 -0.0040
0.050000 18 -0.0005 -0.0005
0.050000 19 0.0018 0.0018
0.050000 20 -0.0040 -0.0040
0.050000 21 -0.0005 -0.0005
0.050000 22 0.0018 0.0018
0.050000 23 -0.0040 -0.0040
0.050000 24 -0.0005 -0.0005
0.050000 25 0.0018 0.0018
0.050000 26 -0.0040 -0.0040
0.050000 27 0.0097 0.0097
0.050000 28 -0.0342 -0.0342
0.050000 29 0.0765 0.0765
0.050000 30 -0.0005 -0.0005
0.050000 31 0.0018 0.0018
0.050000 32 -0.0040 -0.0040
0.050000 33 -0.0005 -0.0005
0.050000 34 0.0018 0.0018
0.050000 35 -0.0040 -0.0040
0.050000 36 -0.0005 -0.0005
0.050000 37 0.0018 0.0018
0.050000 38 -0.0040 -0.0040
0.050000 39 -0.0005 -0.0005
0.050000 40 0.0018 0.0018
0.050000 41 -0.0040 -0.0040
0.050000 42 -0.0005 -0.0005
0.050000 43 0.0018 0.0018
0.050000 44 -0.0040 -0.0040
0.050000 45 -0.0005 -0.0005
0.050000 46 0.0018 0.0018
0.050000 47 -0.0040 -0.0040
0.050000 48 -0.0005 -0.0005
0.050000 49 0.0018 0.0018
0.050000 50 -0.0040 -0.0040
0.050000 51 -0.0005 -0.0005
0.050000 52 0.0018 0.0018
0.050000 53 -0.0040 -0.0040
0.050000 54 -0.0005 -0.0005
0.050000 55 0.0018 0.0018
0.050000 56 -0.0040 -0.0040
0.050000 57 -0.0005 -0.0005
0.050000 58 0.0018 0.0018
0.050000 59 -0.0040 -0.0040
0.050000 60 -0.0032 -0.0032
0.050000 61 0.0112 0.0112
0.050000 62 -0.0252 -0.0252
0.050000 63 0.0112 0.0112
0.050000 64 -0.0397 -0.0397
0.050000 65 0.0888 0.0888
0.050000 66 -0.0252 -0.0252
0.050000 67 0.0888 0.0888
0.050000 68 -0.1988 -0.1988
0.100000 0 -0.0004 -0.0004
0.100000 1 0.0018 0.0018
0.100000 2 -0.0040 -0.0040
0.100000 3 -0.0004 -0.0004
0.100000 4 0.0018 0.0018
0.100000 5 -0.0040 -0.0040
0.100000 6 -0.0004 -0.0004
0.100000 7 0.0018 0.0018
0.100000 8 -0.0040 -0.0040
0.100000 9 -0.0004 -0.0004
0.100000 10 0.0018 0.0018
0.100000 11 -0.0040 -0.0040
0.100000 12 -0.0004 -0.0004
0.100000 13 0.0018 0.0018
0.100000 14 -0.0040 -0.0040
0.100000 15 -0.0004 -0.0004
0.100000 16 0.0018 0.0018
0.100000 17 -0.0040 -0.0040
0.100000 18 -0.0004 -0.0004
0.100000 19 0.0018 0.0018
0.100000 20 -0.0040 -0.0040
0.100000 21 -0.0004 -0.0004
0.100000 22 0.0018 0.0018
0.100000 23 -0.0040 -0.0040
0.100000 24 -0.0004 -0.0004
0.100000 25 0.0018 0.0018
0.100000 26 -0.0040 -0.0040
0.100000 27 0.0077 0.0077
0.100000 28 -0.0343 -0.0343
0.100000 29 0.0757 0.0757
0.100000 30 -0.0004 -0.0004
0.100000 31 0.0018 0.0018
0.100000 32 -0.0040 -0.0040
0.100000 33 -0.0004 -0.0004
0.100000 34 0.0018 0.0018
0.100000 35 -0.0040 -0.0040
0.100000 36 -0.0004 -0.0004
0.100000 37 0.0018 0.0018
0.100000 38 -0.0040 -0.0040
0.100000 39 -0.0004 -0.0004
0.100000 40 0.0018 0.0018
0.100000 41 -0.0040 -0.0040
0.100000 42 -0.0004 -0.0004
0.100000 43 0.0018 0.0018
0.100000 44 -0.0040 -0.0040
0.100000 45 -0.0004 -0.0004
0.100000 46 0.0018 0.0018
0.100000 47 -0.0040 -0.0040
0.100000 48 -0.0004 -0.0004
0.100000 49 0.0018 0.0018
0.100000 50 -0.0040 -0.0040
0.100000 51 -0.0004 -0.0004
0.100000 52 0.0018 0.0018
0.100000 53 -0.0040 -0.0040
0.100000 54 -0.0004 -0.0004
0.100000 55 0.0018 0.0018
0.100000 56 -0.0040 -0.0040
0.100000 57 -0.0004 -0.0004
0.100000 58 0.0018 0.0018
0.100000 59 -0.0040 -0.0040
0.100000 60 -0.0020 -0.0020
0.100000 61 0.0090 0.0090
0.100000 62 -0.0199 -0.0199
0.100000 63 0.0090 0.0090
0.100000 64 -0.0404 -0.0404
0.100000 65 0.0890 0.0890
0.100000 66 -0.0199 -0.0199
0.100000 67 0.0890 0.0890
0.100000 68 -0.1964 -0.1964
0.150000 0 -0.0003 -0.0003
0.150000 1 0.0018 0.0018
0.150000 2 -0.0039 -0.0039
0.150000 3 -0.0003 -0.0003
0.150000 4 0.0018 0.0018
0.150000 5 -0.0039 -0.0039
0.150000 6 -0.0003 -0.0003
0.150000 7 0.0018 0.0018
0.150000 8 -0.0039 -0.0039
0.150000 9 -0.0003 -0.0003
0.150000 10 0.0018 0.0018
0.150000 11 -0.0039 -0.0039
0.150000 12 -0.0003 -0.0003
0.150000 13 0.0018 0.0018
0.150000 14 -0.0039 -0.0039
0.150000 15 -0.0003 -0.0003
0.150000 16 0.0018 0.0018
0.150000 17 -0.0039 -0.0039
0.150000 18 -0.0003 -0.0003
0.150000 19 0.0018 0.0018
0.150000 20 -0.0039 -0.0039
0.150000 21 -0.0003 -0.0003
0.150000 22 0.0018 0.0018
0.150000 23 -0.0039 -0.0039
0.150000 24 -0.0003 -0.0003
0.150000 25 0.0018 0.0018
0.150000 26 -0.0039 -0.0039
0.150000 27 0.0053 0.0053
0.150000 28 -0.0340 -0.0340
0.150000 29 0.0730 0.0730
0.150000 30 -0.0003 -0.0003
0.150000 31 0.0018 0.0018
0.150000 32 -0.0039 -0.0039
0.150000 33 -0.0004 -0.0004
0.150000 34 0.0017 0.0017
0.150000 35 -0.0030 -0.0030
0.150000 36 -0.0003 -0.0003
0.150000 37 0.0018 0.0018
0.150000 38 -0.0039 -0.0039
0.150000 39 -0.0003 -0.0003
0.150000 40 0.0018 0.0018
0.150000 41 -0.0039 -0.0039
0.150000 42 -0.0003 -0.0003
0.150000 43 0.0018 0.0018
0.150000 44 -0.0039 -0.0039
0.150000 45 -0.0003 -0.0003
0.150000 46 0.0018 0.0018
0.150000 47 -0.0039 -0.0039
0.150000 48 -0.0003 -0.0003
0.150000 49 0.0018 0.0018
0.150000 50 -0.0039 -0.0039
0.150000 51 -0.0003 -0.0003
0.150000 52 0.0018 0.0018
0.150000 53 -0.0039 -0.0039
0.150000 54 -0.0003 -0.0003
0.150000 55 0.0018 0.0018
0.150000 56 -0.0039 -0.0039
0.150000 57 -0.0003 -0.0003
0.150000 58 0.0018 0.0018
0.150000 59 -0.0039 -0.0039
0.150000 60 -0.0010 -0.0010
0.150000 61 0.0064 0.0064
0.150000 62 -0.0135 -0.0135
0.150000 63 0.0064 0.0064
0.150000 64 -0.0409 -0.0409
0.150000 65 0.0880 0.0880
0.150000 66 -0.0135 -0.0135
0.150000 67 0.0880 0.0880
0.150000 68 -0.1907 -0.1907
0.200000 0 -0.0002 -0.0002
0.200000 1 0.0017 0.0017
0.200000 2 -0.0037 -0.0037
0.200000 3 -0.0002 -0.0002
0.200000 4 0.0017 0.0017
0.200000 5 -0.0037 -0.0037
0.200000 6 -0.0002 -0.0002
0.200000 7 0.0017 0.0017
0.200000 8 -0.0037 -0.0037
0.200000 9 -0.0002 -0.0002
0.200000 10 0.0017 0.0017
0.200000 11 -0.0037 -0.0037
0.200000 12 -0.0002 -0.0002
0.200000 13 0.0017 0.0017
0.200000 14 -0.0037 -0.0037
0.200000 15 -0.0002 -0.0002
0.200000 16 0.0017 0.0017
0.200000 17 -0.0037 -0.0037
0.200000 18 -0.0002 -0.0002
0.200000 19 0.0017 0.0017
0.200000 20 -0.0037 -0.0037
0.200000 21 -0.0002 -0.0002
0.200000 22 0.0017 0.0017
0.200000 23 -0.0037 -0.0037
0.200000 24 -0.0002 -0.0002
0.200000 25 0.0017 0.0017
0.200000 26 -0.0037 -0.0037
0.200000 27 0.0032 0.0032
0.200000 28 -0.0327 -0.0327
0.200000 29 0.0688 0.0688
0.200000 30 -0.0002 -0.0002
0.200000 31 0.0017 0.0017
0.200000 32 -0.0037 -0.0037
0.200000 33 -0.0004 -0.0004
0.200000 34 0.0015 0.0015
0.200000 35 -0.0015 -0.0015
0.200000 36 -0.0002 -0.0002
0.200000 37 0.0017 0.0017
0.200000 38 -0.0037 -0.0037
0.200000 39 -0.0002 -0.0002
0.200000 40 0.0017 0.0017
0.200000 41 -0.0037 -0.0037
0.200000 42 -0.0002 -0.0002
0.200000 43 0.0017 0.0017
0.200000 44 -0.0037 -0.0037
0.200000 45 -0.0002 -0.0002
0.200000 46 0.0017 0.0017
0.200000 47 -0.0037 -0.0037
0.200000 48 -0.0002 -0.0002
0.200000 49 0.0017 0.0017
0.200000 50 -0.0037 -0.0037
0.200000 51 -0.0002 -0.0002
0.200000 52 0.0017 0.0017
0.200000 53 -0.0037 -0.0037
0.200000 54 -0.0002 -0.0002
0.200000 55 0.0017 0.0017
0.200000 56 -0.0037 -0.0037
0.200000 57 -0.0002 -0.0002
0.200000 58 0.0017 0.0017
0.200000 59 -0.0037 -0.0037
0.200000 60 -0.0004 -0.0004
0.200000 61 0.0038 0.0038
0.200000 62 -0.0075 -0.0075
0.200000 63 0.0038 0.0038
0.200000 64 -0.0398 -0.0398
0.200000 65 0.0844 0.0844
0.200000 66 -0.0075 -0.0075
0.200000 67 0.0844 0.0844
0.200000 68 -0.1826 -0.1826
SPHERICAL_RESTRAINT ATOMS=1-20 RADIUS=2.5 KAPPA=0.2 LABEL=sr
SPHERICAL_RESTRAINT ATOMS=1-20 RADIUS=2.5 KAPPA=0.2 NUMERICAL_DERIVATIVES LABEL=srnum
PRINT ARG=sr.bias FILE=colvar FMT=%8.4f
DUMPDERIVATIVES ARG=sr.bias,srnum.bias FILE=deriv FMT=%8.4f
USE=core tools vesselbase
# generic makefile
include ../maketools/make.module
/* +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Copyright (c) 2012 The plumed team
(see the PEOPLE file at the root of the distribution for a list of names)
See http://www.plumed-code.org for more information.
This file is part of plumed, version 2.0.
plumed is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
plumed is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with plumed. If not, see <http://www.gnu.org/licenses/>.
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ */
#include "ManyRestraintsBase.h"
#include "vesselbase/Vessel.h"
namespace PLMD {
namespace manyrestraints {
void ManyRestraintsBase::registerKeywords( Keywords& keys ){
Action::registerKeywords( keys );
ActionWithValue::registerKeywords( keys );
ActionAtomistic::registerKeywords( keys );
ActionWithVessel::registerKeywords( keys );
ActionPilot::registerKeywords( keys );
keys.add("hidden","STRIDE","the frequency with which the forces due to the bias should be calculated. This can be used to correctly set up multistep algorithms");
keys.remove("TOL");
}
ManyRestraintsBase::ManyRestraintsBase(const ActionOptions& ao):
Action(ao),
ActionAtomistic(ao),
ActionWithValue(ao),
ActionPilot(ao),
ActionWithVessel(ao)
{
}
void ManyRestraintsBase::createRestraints( const unsigned& nrestraints ){
std::string fake_input;
for(unsigned i=0;i<nrestraints;++i) taskList.addIndexToList(i);
taskList.activateAll();
addVessel( "SUM", fake_input, 0, "bias" );
readVesselKeywords();
forcesToApply.resize( getNumberOfDerivatives() );
}
void ManyRestraintsBase::apply(){
plumed_dbg_assert( getNumberOfComponents()==1 );
getPntrToComponent(0)->addForce(1.0);
getForcesFromVessels( forcesToApply );
setForcesOnAtoms( forcesToApply );
}
}
}
/* +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Copyright (c) 2012 The plumed team
(see the PEOPLE file at the root of the distribution for a list of names)
See http://www.plumed-code.org for more information.
This file is part of plumed, version 2.0.
plumed is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
plumed is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with plumed. If not, see <http://www.gnu.org/licenses/>.
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ */
#ifndef __PLUMED_manyrestraints_ManyRestraintsBase_h
#define __PLUMED_manyrestraints_ManyRestraintsBase_h
#include "core/ActionAtomistic.h"
#include "core/ActionWithValue.h"
#include "core/ActionPilot.h"
#include "vesselbase/ActionWithVessel.h"
namespace PLMD {
namespace manyrestraints {
class ManyRestraintsBase :
public ActionAtomistic,
public ActionWithValue,
public ActionPilot,
public vesselbase::ActionWithVessel
{
private:
std::vector<double> forcesToApply;
protected:
void createRestraints( const unsigned& nrestraints );
/// Add some derivatives to a particular atom
void addAtomsDerivatives(const int&,const Vector&);
/// Add some derivatives to the virial
void addBoxDerivatives(const Tensor&);
public:
static void registerKeywords( Keywords& keys );
ManyRestraintsBase(const ActionOptions&);
unsigned getNumberOfDerivatives();
/// Deactivate task now does nothing
void deactivate_task(){}
void apply();
};
inline
unsigned ManyRestraintsBase::getNumberOfDerivatives(){
return 3*getNumberOfAtoms() + 9;
}
inline
void ManyRestraintsBase::addAtomsDerivatives(const int& iatom, const Vector& der){
plumed_dbg_assert( iatom<getNumberOfAtoms() );
addElementDerivative( 3*iatom+0, der[0] );
addElementDerivative( 3*iatom+1, der[1] );
addElementDerivative( 3*iatom+2, der[2] );
}
inline
void ManyRestraintsBase::addBoxDerivatives(const Tensor& vir){
int natoms=getNumberOfAtoms();
addElementDerivative( 3*natoms+0, vir(0,0) );
addElementDerivative( 3*natoms+1, vir(0,1) );
addElementDerivative( 3*natoms+2, vir(0,2) );
addElementDerivative( 3*natoms+3, vir(1,0) );
addElementDerivative( 3*natoms+4, vir(1,1) );
addElementDerivative( 3*natoms+5, vir(1,2) );
addElementDerivative( 3*natoms+6, vir(2,0) );
addElementDerivative( 3*natoms+7, vir(2,1) );
addElementDerivative( 3*natoms+8, vir(2,2) );
}
}
}
#endif
/* +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Copyright (c) 2012 The plumed team
(see the PEOPLE file at the root of the distribution for a list of names)
See http://www.plumed-code.org for more information.
This file is part of plumed, version 2.0.
plumed is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
plumed is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with plumed. If not, see <http://www.gnu.org/licenses/>.
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ */
#include "ManyRestraintsBase.h"
#include "core/ActionRegister.h"
namespace PLMD {
namespace manyrestraints {
class Sphere : public ManyRestraintsBase {
private:
double at;
double kappa;
double exp;
double eps;
double offset;
bool nopbc;
Vector com;
std::vector<double> com_deriv;
public:
static void registerKeywords( Keywords& keys );
Sphere( const ActionOptions& );
bool isPeriodic(){ return false; }
unsigned getNumberOfFunctionsInAction();
void performTask( const unsigned& j );
void calculate();
};
PLUMED_REGISTER_ACTION(Sphere,"SPHERICAL_RESTRAINT")
void Sphere::registerKeywords( Keywords& keys ){
ManyRestraintsBase::registerKeywords( keys );
keys.add("atoms","ATOMS","the atoms that are being confined to the sphere");
keys.add("compulsory","RADIUS","the radius of the sphere");
keys.add("compulsory","KAPPA","the force constant for the wall. The k_i in the expression for a wall.");
keys.add("compulsory","OFFSET","0.0","the offset for the start of the wall. The o_i in the expression for a wall.");
keys.add("compulsory","EXP","2.0","the powers for the walls. The e_i in the expression for a wall.");
keys.add("compulsory","EPS","1.0","the values for s_i in the expression for a wall");
keys.addFlag("NOPBC",false,"turn off periodic boundary conditions");
}
Sphere::Sphere(const ActionOptions& ao):
Action(ao),
ManyRestraintsBase(ao)
{
std::vector<AtomNumber> atoms;
parseAtomList("ATOMS",atoms);
com_deriv.resize( atoms.size() );
parse("RADIUS",at);
parse("OFFSET",offset);
parse("EPS",eps);
parse("EXP",exp);
parse("KAPPA",kappa);
parseFlag("NOPBC",nopbc);
checkRead();
requestAtoms( atoms );
createRestraints( atoms.size() );
}
unsigned Sphere::getNumberOfFunctionsInAction(){
return getNumberOfAtoms();
}
void Sphere::calculate(){
// Calculate position of the center of mass
double mass=0; com.zero();
for(unsigned i=0;i<getNumberOfAtoms();i++) mass+=getMass(i);
for(unsigned i=0;i<getNumberOfAtoms();i++){
com+=(getMass(i)/mass)*getPosition(i);
com_deriv[i]=(getMass(i)/mass);
}
// Now run the full set of tasks
runAllTasks();
}
void Sphere::performTask( const unsigned& j ){
Vector distance;
if(!nopbc){
distance=pbcDistance(com,getPosition(current));
} else {
distance=delta(com,getPosition(current));
}
double value=distance.modulo();
double uscale = (value - at + offset)/eps;
if( uscale > 0. ){
double invvalue= 1.0 / value ;
double power = pow( uscale, exp );
double f = invvalue * ( kappa / eps ) * exp * power / uscale;
setElementValue( 0, kappa*power ); setElementValue( 1, 1.0 );
// Add derivatives for com
for(unsigned i=0;i<getNumberOfAtoms();++i) addAtomsDerivatives( i, -com_deriv[i]*f*distance );
// Add derivatives for other atom
addAtomsDerivatives( current, f*distance );
// Add derivatives for virial
addBoxDerivatives( -f*Tensor(distance,distance) );
// We need to accumulate derivatives
return;
}
// We need do nothing more if this is not true
setElementValue( 1, 0.0 );
return;
}
}
}
../core
\ No newline at end of file
default-off
../tools
\ No newline at end of file
../vesselbase
\ No newline at end of file
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