Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F85843133
fix_com.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
Wed, Oct 2, 11:56
Size
2 KB
Mime Type
text/x-c
Expires
Fri, Oct 4, 11:56 (1 d, 23 h)
Engine
blob
Format
Raw Data
Handle
21258519
Attached To
rLAMMPS lammps
fix_com.cpp
View Options
/* ----------------------------------------------------------------------
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
www.cs.sandia.gov/~sjplimp/lammps.html
Steve Plimpton, sjplimp@sandia.gov, Sandia National Laboratories
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 "stdlib.h"
#include "fix_com.h"
#include "atom.h"
#include "update.h"
#include "domain.h"
#include "group.h"
#include "error.h"
/* ---------------------------------------------------------------------- */
FixCOM
::
FixCOM
(
int
narg
,
char
**
arg
)
:
Fix
(
narg
,
arg
)
{
if
(
narg
!=
5
)
error
->
all
(
"Illegal fix com command"
);
nevery
=
atoi
(
arg
[
3
]);
if
(
nevery
<=
0
)
error
->
all
(
"Illegal fix com command"
);
first
=
1
;
MPI_Comm_rank
(
world
,
&
me
);
if
(
me
==
0
)
{
fp
=
fopen
(
arg
[
4
],
"w"
);
if
(
fp
==
NULL
)
{
char
str
[
128
];
sprintf
(
str
,
"Cannot open fix com file %s"
,
arg
[
4
]);
error
->
one
(
str
);
}
}
if
(
me
==
0
)
{
fprintf
(
fp
,
"Center-of-mass for group %s
\n
"
,
group
->
names
[
igroup
]);
fprintf
(
fp
,
"TimeStep x y z
\n
"
);
}
}
/* ---------------------------------------------------------------------- */
FixCOM
::~
FixCOM
()
{
if
(
me
==
0
)
fclose
(
fp
);
}
/* ---------------------------------------------------------------------- */
int
FixCOM
::
setmask
()
{
int
mask
=
0
;
mask
|=
END_OF_STEP
;
return
mask
;
}
/* ---------------------------------------------------------------------- */
void
FixCOM
::
init
()
{
masstotal
=
group
->
mass
(
igroup
);
}
/* ---------------------------------------------------------------------- */
void
FixCOM
::
setup
()
{
if
(
first
)
end_of_step
();
first
=
0
;
}
/* ---------------------------------------------------------------------- */
void
FixCOM
::
end_of_step
()
{
double
xcm
[
3
];
group
->
xcm
(
igroup
,
masstotal
,
xcm
);
if
(
me
==
0
)
fprintf
(
fp
,
"%d %g %g %g
\n
"
,
update
->
ntimestep
,
xcm
[
0
],
xcm
[
1
],
xcm
[
2
]);
}
Event Timeline
Log In to Comment