Hi all!
I was wondering if there is any consistent way of extracting the (lj-cut-coul-cut) interatomic potential coefficients (sigma and epsilon) from a LAMMPS object.
I am using LAMMPS as a library for a C++ code. In the beginning, I used the following command to read the interatomic potential coefficients for any atom-type pair in the system:
lmp->input->file( "in.lmp" );
Then, I was able to acquire the interatomic coefficients as follows:
int types_num = *( int *)lammps_extract_global( lmp , const_cast<char*>( "ntypes" ) );
double **sigma_temp = ( double **)lmp->force->pair->extract( const_cast<char*>( "sigma" ) , 2 );
Afterward, I attempted to access the data using a double for loop:
for( int i = 1; i < types_num + 1; ++i ){
for( int j =1; j < types_num + 1; ++j ){
printf( "Sigma%d%d=%f and sigma%d%d=%f \n" , i , j , sigma_temp[i][j] , j , i , sigma_temp[j][i] );
}
}
Here, I observed the following:
- For some pairs sigma_temp[i][j] has a non-zero value but sigma_temp[j][i] is zero
- For some other pairs sigma_temp[j][i] has a non-zero value but sigma_temp[i][j] is zero
I believe that overcoming issues 1 and 2 is not very challenging. One can simply create a new array and see if a pair has zero sigma_temp, and if so initialize it with the value of the inverse pair:(i.e., sigma[i][j] = sigma_temp[j][i] when sigma[i][j] = 0.0 and vice versa.). However, I was just generally wondering if retrieving the interatomic coefficients as above is thread-safe.
Also, I am aware that I can retrieve the interatomic potential coefficients as I read the file by writing a custom function (i.e., reading the input file line by line on proc 0, extracting the coefficients from there, and then broadcasting the information to all other procs). However, I was just wondering if there is any other thread-safe way of extracting epsilon or sigma directly from an object of the LAMMPS class (by using a lammps_extract_global function, for example).
Thank you in advance for your kind help ![]()
Cheers,
Stavros