Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F80359177
compute_dihedral.cpp
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Sat, Aug 31, 08:13
Size
2 KB
Mime Type
text/x-c
Expires
Mon, Sep 2, 08:13 (2 d)
Engine
blob
Format
Raw Data
Handle
20250098
Attached To
rLAMMPS lammps
compute_dihedral.cpp
View Options
/* ----------------------------------------------------------------------
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
http://lammps.sandia.gov, Sandia National Laboratories
Steve Plimpton, sjplimp@sandia.gov
Copyright (2003) Sandia Corporation. Under the terms of Contract
DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
certain rights in this software. This software is distributed under
the GNU General Public License.
See the README file in the top-level LAMMPS directory.
------------------------------------------------------------------------- */
#include <mpi.h>
#include <string.h>
#include "compute_dihedral.h"
#include "update.h"
#include "force.h"
#include "dihedral_hybrid.h"
#include "error.h"
using
namespace
LAMMPS_NS
;
/* ---------------------------------------------------------------------- */
ComputeDihedral
::
ComputeDihedral
(
LAMMPS
*
lmp
,
int
narg
,
char
**
arg
)
:
Compute
(
lmp
,
narg
,
arg
),
emine
(
NULL
)
{
if
(
narg
!=
3
)
error
->
all
(
FLERR
,
"Illegal compute dihedral command"
);
vector_flag
=
1
;
extvector
=
1
;
peflag
=
1
;
timeflag
=
1
;
// check if dihedral style hybrid exists
dihedral
=
(
DihedralHybrid
*
)
force
->
dihedral_match
(
"hybrid"
);
if
(
!
dihedral
)
error
->
all
(
FLERR
,
"Dihedral style for compute dihedral command is not hybrid"
);
size_vector
=
nsub
=
dihedral
->
nstyles
;
emine
=
new
double
[
nsub
];
vector
=
new
double
[
nsub
];
}
/* ---------------------------------------------------------------------- */
ComputeDihedral
::~
ComputeDihedral
()
{
delete
[]
emine
;
delete
[]
vector
;
}
/* ---------------------------------------------------------------------- */
void
ComputeDihedral
::
init
()
{
// recheck dihedral style in case it has been changed
dihedral
=
(
DihedralHybrid
*
)
force
->
dihedral_match
(
"hybrid"
);
if
(
!
dihedral
)
error
->
all
(
FLERR
,
"Dihedral style for compute dihedral command is not hybrid"
);
if
(
dihedral
->
nstyles
!=
nsub
)
error
->
all
(
FLERR
,
"Dihedral style for compute dihedral command has changed"
);
}
/* ---------------------------------------------------------------------- */
void
ComputeDihedral
::
compute_vector
()
{
invoked_vector
=
update
->
ntimestep
;
if
(
update
->
eflag_global
!=
invoked_vector
)
error
->
all
(
FLERR
,
"Energy was not tallied on needed timestep"
);
for
(
int
i
=
0
;
i
<
nsub
;
i
++
)
emine
[
i
]
=
dihedral
->
styles
[
i
]
->
energy
;
MPI_Allreduce
(
emine
,
vector
,
nsub
,
MPI_DOUBLE
,
MPI_SUM
,
world
);
}
Event Timeline
Log In to Comment