Parameter extraction from pair style

Dear all,

I am using the pair style morse in my simulations and would like to extract the values of d0, r0 and alpha for each pair of atom types for use in a custom fix. May I know how this can be done?

I am able to extract a scalar quantity such as the global cutoff for a particular pair style using the following lines of code:

  Pair *pair = force->pair_match("dpd/bc2",1);
  if (pair == NULL) error->all(FLERR,"No pair dpd/bc2 for fix test/bc2");
  int jtmp;
  double *gcutoff = (double *) pair->extract("cut_global",jtmp);
  double cutg = *gcutoff;

Here, dpd/bc2 and test/bc2 are a custom pair style and fix. I am wondering how to do likewise for arrays such as those mentioned above.

Best,
Karthik

***DISCLAIMER*** The sender of this email is an alumnus of National University of Singapore (NUS). Kindly note that NUS is not responsible for the contents of this email, and views and opinions expressed are solely the sender's.

You can extract those the same way. You may need to add lines to the extract() method in pair style Morse. Please see lj/cut for an example.

Axel

Dear Sir,

Thank you for the prompt response. The extract method of pair_morse already specifies the quantities that I want to extract as shown below:

void *PairMorse::extract(const char *str, int &dim)

{

dim = 2;

if (strcmp(str,"d0") == 0) return (void *) d0;

if (strcmp(str,"r0") == 0) return (void *) r0;

if (strcmp(str,"alpha") == 0) return (void *) alpha;

return NULL;

}

I tried to extract d0 using the code below in a custom fix:

Pair *pair = force->pair_match("morse",1);
  int jtmp;
  double *dk = (double *) pair->extract("d0",jtmp);

double de = *dk;

Although the above code compiles fine, I am wondering how to access the individual elements of d0? When I tried to include the line ‘printf ("de11= %6.2f \n", de[1][1]);’ after the above code, I obtained a compilation error.

Best,
Karthik

You must cast the void pointer to the exact same type as in the pair style. Those are 2d arrays!
Axel

Dear Sir,

Thanks for your help. Upon modifying the code to ‘double **dk = (double **) pair->extract("d0",ktmp);’, it works fine.

Best,
Karthik