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: Fri, 1 Sep 2017 23:38:37 +0200

Dear Axel,

thanks for the example.
I'm using the lammps stable branch.

When I run your code with my LAMMPS
input script, again, I'm getting only zeros.

I suspect maybe that my input script is wrong,
thus I'm attaching it here:

units           real
neigh_modify    delay 2 every 1

atom_style      full
bond_style      harmonic
angle_style     charmm
dihedral_style  charmm
improper_style  harmonic

pair_style      lj/charmm/coul/long 8 10
pair_modify     mix arithmetic
kspace_style    pppm 1e-4

read_data       protein.data

special_bonds   charmm
fix             1 all nve
velocity        all create 0.0 1504301625 dist uniform

thermo          1
thermo_style    multi
timestep        0.005

dump            1 all atom 10 protein.dump
dump_modify     1 image yes scale yes
group           NTGRP type 2
variable        NT atom x
variable        NTCOUNT equal count(NTGRP)

Is there anything fishy here?
Thanks in advance.

Best regards,
Stephan


Am 01/09/17 um 03:46 schrieb Axel Kohlmeyer:
> 
> 
> On Thu, Aug 31, 2017 at 10:46 AM, Stephan Grein
> <stephan.grein@...5733...
> <mailto:stephan.grein@...5733...>> wrote:
> 
>     Dear LAMMPS users,
>     dear Steve and Axel,
> 
>     I'm following up on this 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.
> 
> 
> it ​works for me. here is a complete(!) test example based on the
> "crack" example.
> 
> axel.
> 
> ​#include <stdio.h>
> #include <inttypes.h>
> #include "library.h"
> 
> int main (int argc, char **argv)
> 
> {
>     void *lmp;
>     int i,gatoms;
>     int64_t natoms;
> 
>     lammps_open_no_mpi(0,NULL,&lmp);
>     lammps_file(lmp,"in.crack");
>     lammps_command(lmp,"group MYGRP type 2");
>     lammps_command(lmp,"variable MYCOORDS atom x");
>     lammps_command(lmp,"variable MYCOUNT equal count(MYGRP)");
> 
>     natoms = *(int64_t *)lammps_extract_global(lmp,"natoms");
>     gatoms = (int) *(double *)lammps_extract_variable(lmp, "MYCOUNT", NULL);
>     printf("total atoms = %ld  atoms in group = %d\n",natoms,gatoms);
>     double *coords = (double
> *)lammps_extract_variable(lmp,"MYCOORDS","MYGRP");
>     for (i=0; i < natoms; ++i) {
>         printf("x[%03d]=%10.4f\n",i,coords[i]);
>     }
>     lammps_free((void *)coords);
>     lammps_close(lmp);
>     return 0;
> }    
> ​
>  
> 
> 
>     Maybe somebody can point me in the right direction.
> 
>     Best regards,
>     Stephan
> 
>     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...>
>     > <mailto: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.
>     >
>     >
> 
> 
> 
> 
> -- 
> Dr. Axel Kohlmeyer  akohlmey@...24... <mailto:akohlmey@...24...>
>  http://goo.gl/1wk0
> College of Science & Technology, Temple University, Philadelphia PA, USA
> International Centre for Theoretical Physics, Trieste. Italy.


Attachment: signature.asc
Description: OpenPGP digital signature