LAMMPS WWW Site - LAMMPS Documentation - LAMMPS Mailing List Archives
Re: [lammps-users] LAMMPS library: Gather specific atoms and insert small molecules
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [lammps-users] LAMMPS library: Gather specific atoms and insert small molecules

From: Stephan Grein <stephan.grein@...5733...>
Date: Thu, 31 Aug 2017 16:28:55 +0200

Dear LAMMPS users,

I'm following up on the old post on the list.
Trying to get all coordinates for a given
type, e.g. 2, I put this in my LAMMPS script:

group MYGRP type 2
variable MYCOORDS atom x
variable MYCOUNT equal count(MYGRP)

Using the functions from library.cpp by

double* pnatoms = (double*) lammps_extract_variable(lmp, "MYCOUNT", NULL);
												int natoms = (int)(*pnatoms);
										   										double* coords = (double*)
lammps_extract_variable(lmp, "MYCOORDS", "MYGRP");

However, coords contains only zeros, e.g. 0.0, 0.0, 0.0.
Apparently I'm doing something wrong, but I'm not sure what.

Maybe somebody can point me in the right direction.

Best regards,


Am 13/04/16 um 17:00 schrieb Steve Plimpton:
> Just see the variable doc page for all the syntax.
> My email was just meant to be an idea, not
> all the details of the correct syntax.  Ditto
> for the lib interface function you need to use
> to eval a variable.
> Steve
> On Tue, Apr 12, 2016 at 9:50 AM, Stephan Grein
> <stephan.grein@...5733...
> <mailto:stephan.grein@...5733...>> wrote:
>     Dear Steve,
>     thanks so much!
>     Am 12/04/16 um 17:27 schrieb Steve Plimpton:
>     > variable equal x x[id][0]
>     This sounds interesting.
>     I'm not sure how to define this
>     in my script, sorry!
>     Would I do like that:
>     myAtomNameToTrack equal x x[myAtomId][0]
>     Then using:
>     lammps_extract_variable(lmp, "myAtomNameToTrack", NULL);
>     Right? TIA.
>     Best,
>     S.

Attachment: signature.asc
Description: OpenPGP digital signature