LAMMPS WWW Site - LAMMPS Documentation - LAMMPS Mailing List Archives
Re: [lammps-users] the returned integer from extract() method of pair_styles
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [lammps-users] the returned integer from extract() method of pair_styles

From: Axel Kohlmeyer <akohlmey@...24...>
Date: Thu, 9 Nov 2017 22:57:50 -0500

dim indicates the dimensionality of the pointer returned by Pair::extract().
since the function returns a void pointer, one needs to know what kind of pointer to cast to.

dim == 0  => pointer to a single double precision floating point number
dim == 1  => pointer to a 1d double array
dim == 2  => pointer to a 2d double array

On Thu, Nov 9, 2017 at 10:09 PM, JENEL PETRISOR VATAMANU <u0615401@...222...> wrote:

I have a question regarding the returned integer in the extract method of pairs , specifically the variable "dim"  in
void *PairLJCharmmCoulLong::extract(const char *str, int &dim).

For this pair the returned value of dim is 2 for the lj parameters and 0 for the cut offs (as shown below).
---pasted from pair_lj_charmm_coul_long.cpp of lammps' source code:
 void *PairLJCharmmCoulLong::extract(const char *str, int &dim)
   dim = 2;
   if (strcmp(str,"lj14_1") == 0) return (void *) lj14_1;
   if (strcmp(str,"lj14_2") == 0) return (void *) lj14_2;
   if (strcmp(str,"lj14_3") == 0) return (void *) lj14_3;
   if (strcmp(str,"lj14_4") == 0) return (void *) lj14_4;

   dim = 0;
   if (strcmp(str,"implicit") == 0) return (void *) &implicit;
   if (strcmp(str,"cut_coul") == 0) return (void *) &cut_coul;

   return NULL;

I examined some functions (such as ppm.cpp) that called the extract( some_char*,dim ) method.
---pasted from pppm.cpp of lammps' source code:
   int itmp = 0;
   double *p_cutoff = (double *) force->pair->extract("cut_coul",itmp);
   if (p_cutoff == NULL)
     error->all(FLERR,"KSpace style is incompatible with Pair style");
  cutoff = *p_cutoff;

In above pasted code the variable &dim from the extract of the pair is stored in itmp however it seems to me that the pppm does not use the itmp any further. 

I haven' yet figured out the &dim variable returned from the extract() of the pairs, and my question is:
For a 'new/custom' defined/codded pair-wise additive pair_style  (call it:"PairACustomBuiltPairCutCoulLong") should the returned int at &dim from the extract method of this pairstyle:
 void *PairACustomBuiltPairCutCoulLong::extract(const char *str, int &dim){...}

be dim=2  for the van der Waals parameters and dim=0 for cut offs? Or what other values should have?

​for your case only the case for "cut_coul" must be present in extract() (so that kspace can infer its parameters).


 Thank you.

Check out the vibrant tech community on one of the world's most
engaging tech sites,!
lammps-users mailing list

Dr. Axel Kohlmeyer  akohlmey@...12...24...
College of Science & Technology, Temple University, Philadelphia PA, USA
International Centre for Theoretical Physics, Trieste. Italy.