Merge branch 'improve_reax' of ssh://github.com/stanmoore1/lammps into reax_dup

This commit is contained in:
Stan Moore
2017-11-30 09:48:15 -07:00
7 changed files with 206 additions and 114 deletions

View File

@ -1529,6 +1529,8 @@ void PairReaxCKokkos<DeviceType>::operator()(PairReaxBuildListsFull, const int &
}
}
if (rsq > cut_bosq) continue;
// bond_list
const F_FLOAT rij = sqrt(rsq);
const F_FLOAT p_bo1 = paramstwbp(itype,jtype).p_bo1;
@ -1718,6 +1720,8 @@ void PairReaxCKokkos<DeviceType>::operator()(PairReaxBuildListsHalf<NEIGHFLAG>,
}
}
if (rsq > cut_bosq) continue;
// bond_list
const F_FLOAT rij = sqrt(rsq);
const F_FLOAT p_bo1 = paramstwbp(itype,jtype).p_bo1;
@ -1939,6 +1943,8 @@ void PairReaxCKokkos<DeviceType>::operator()(PairReaxBuildListsHalf_LessAtomics<
}
}
if (rsq > cut_bosq) continue;
// bond_list
const F_FLOAT rij = sqrt(rsq);
const F_FLOAT p_bo1 = paramstwbp(itype,jtype).p_bo1;

View File

@ -43,7 +43,8 @@
using namespace LAMMPS_NS;
using namespace MathConst;
enum{INT,FLOAT,BIGINT}; // same as in thermo.cpp
enum{THERMO_INT,THERMO_FLOAT,THERMO_BIGINT}; // same as in thermo.cpp
enum{DUMP_INT,DUMP_DOUBLE,DUMP_STRING,DUMP_BIGINT}; // same as in DumpCFG
const char NC_FRAME_STR[] = "frame";
const char NC_SPATIAL_STR[] = "spatial";
@ -121,10 +122,6 @@ DumpNetCDF::DumpNetCDF(LAMMPS *lmp, int narg, char **arg) :
ndims = 3;
strcpy(mangled, "velocities");
}
// extensions to the AMBER specification
else if (!strcmp(mangled, "type")) {
strcpy(mangled, "atom_types");
}
else if (!strcmp(mangled, "xs") || !strcmp(mangled, "ys") ||
!strcmp(mangled, "zs")) {
idim = mangled[0] - 'x';
@ -325,18 +322,6 @@ void DumpNetCDF::openfile()
// variables specified in the input file
for (int i = 0; i < n_perat; i++) {
nc_type xtype;
// Type mangling
if (vtype[perat[i].field[0]] == INT) {
xtype = NC_INT;
} else {
if (double_precision)
xtype = NC_DOUBLE;
else
xtype = NC_FLOAT;
}
NCERRX( nc_inq_varid(ncid, perat[i].name, &perat[i].var),
perat[i].name );
}
@ -421,10 +406,11 @@ void DumpNetCDF::openfile()
nc_type xtype;
// Type mangling
if (vtype[perat[i].field[0]] == INT) {
if (vtype[perat[i].field[0]] == DUMP_INT) {
xtype = NC_INT;
}
else {
} else if (vtype[perat[i].field[0]] == DUMP_BIGINT) {
xtype = NC_INT64;
} else {
if (double_precision)
xtype = NC_DOUBLE;
else
@ -488,17 +474,22 @@ void DumpNetCDF::openfile()
if (thermo) {
Thermo *th = output->thermo;
for (int i = 0; i < th->nfield; i++) {
if (th->vtype[i] == FLOAT) {
if (th->vtype[i] == THERMO_FLOAT) {
NCERRX( nc_def_var(ncid, th->keyword[i], NC_DOUBLE, 1, dims,
&thermovar[i]), th->keyword[i] );
}
else if (th->vtype[i] == INT) {
else if (th->vtype[i] == THERMO_INT) {
NCERRX( nc_def_var(ncid, th->keyword[i], NC_INT, 1, dims,
&thermovar[i]), th->keyword[i] );
}
else if (th->vtype[i] == BIGINT) {
else if (th->vtype[i] == THERMO_BIGINT) {
#if defined(LAMMPS_SMALLBIG) || defined(LAMMPS_BIGBIG)
NCERRX( nc_def_var(ncid, th->keyword[i], NC_INT64, 1, dims,
&thermovar[i]), th->keyword[i] );
#else
NCERRX( nc_def_var(ncid, th->keyword[i], NC_LONG, 1, dims,
&thermovar[i]), th->keyword[i] );
#endif
}
}
}
@ -606,6 +597,7 @@ void DumpNetCDF::openfile()
count[1] = 5;
NCERR( nc_put_vara_text(ncid, cell_angular_var, index, count, "gamma") );
append_flag = 1;
framei = 1;
}
}
@ -651,6 +643,52 @@ int nc_put_var1_bigint<long long>(int ncid, int varid, const size_t index[],
return nc_put_var1_longlong(ncid, varid, index, tp);
}
template <typename T>
int nc_put_vara_bigint(int ncid, int varid, const size_t start[],
const size_t count[], const T* tp)
{
return nc_put_vara_int(ncid, varid, start, count, tp);
}
template <>
int nc_put_vara_bigint<long>(int ncid, int varid, const size_t start[],
const size_t count[], const long* tp)
{
return nc_put_vara_long(ncid, varid, start, count, tp);
}
template <>
int nc_put_vara_bigint<long long>(int ncid, int varid, const size_t start[],
const size_t count[], const long long* tp)
{
return nc_put_vara_longlong(ncid, varid, start, count, tp);
}
template <typename T>
int nc_put_vars_bigint(int ncid, int varid, const size_t start[],
const size_t count[], const ptrdiff_t stride[],
const T* tp)
{
return nc_put_vars_int(ncid, varid, start, count, stride, tp);
}
template <>
int nc_put_vars_bigint<long>(int ncid, int varid, const size_t start[],
const size_t count[], const ptrdiff_t stride[],
const long* tp)
{
return nc_put_vars_long(ncid, varid, start, count, stride, tp);
}
template <>
int nc_put_vars_bigint<long long>(int ncid, int varid, const size_t start[],
const size_t count[],
const ptrdiff_t stride[],
const long long* tp)
{
return nc_put_vars_longlong(ncid, varid, start, count, stride, tp);
}
void DumpNetCDF::write()
{
// open file
@ -672,16 +710,16 @@ void DumpNetCDF::write()
for (int i = 0; i < th->nfield; i++) {
th->call_vfunc(i);
if (filewriter) {
if (th->vtype[i] == FLOAT) {
if (th->vtype[i] == THERMO_FLOAT) {
NCERRX( nc_put_var1_double(ncid, thermovar[i], start,
&th->dvalue),
th->keyword[i] );
}
else if (th->vtype[i] == INT) {
else if (th->vtype[i] == THERMO_INT) {
NCERRX( nc_put_var1_int(ncid, thermovar[i], start, &th->ivalue),
th->keyword[i] );
}
else if (th->vtype[i] == BIGINT) {
else if (th->vtype[i] == THERMO_BIGINT) {
NCERRX( nc_put_var1_bigint(ncid, thermovar[i], start, &th->bivalue),
th->keyword[i] );
}
@ -782,16 +820,16 @@ void DumpNetCDF::write_data(int n, double *mybuf)
if (!int_buffer) {
n_buffer = n;
int_buffer = (int *)
memory->smalloc(n*sizeof(int),"dump::int_buffer");
int_buffer = (bigint *)
memory->smalloc(n*sizeof(bigint),"dump::int_buffer");
double_buffer = (double *)
memory->smalloc(n*sizeof(double),"dump::double_buffer");
}
if (n > n_buffer) {
n_buffer = n;
int_buffer = (int *)
memory->srealloc(int_buffer, n*sizeof(int),"dump::int_buffer");
int_buffer = (bigint *)
memory->srealloc(int_buffer, n*sizeof(bigint),"dump::int_buffer");
double_buffer = (double *)
memory->srealloc(double_buffer, n*sizeof(double),"dump::double_buffer");
}
@ -811,7 +849,7 @@ void DumpNetCDF::write_data(int n, double *mybuf)
for (int i = 0; i < n_perat; i++) {
int iaux = perat[i].field[0];
if (vtype[iaux] == INT) {
if (vtype[iaux] == DUMP_INT || vtype[iaux] == DUMP_BIGINT) {
// integers
if (perat[i].dims > 1) {
@ -819,41 +857,55 @@ void DumpNetCDF::write_data(int n, double *mybuf)
iaux = perat[i].field[idim];
if (iaux >= 0) {
for (int j = 0; j < n; j++, iaux+=size_one) {
int_buffer[j] = mybuf[iaux];
if (vtype[iaux] == DUMP_INT) {
for (int j = 0; j < n; j++, iaux+=size_one) {
int_buffer[j] = static_cast<int>(mybuf[iaux]);
}
}
else { // DUMP_BIGINT
for (int j = 0; j < n; j++, iaux+=size_one) {
int_buffer[j] = static_cast<bigint>(mybuf[iaux]);
}
}
start[2] = idim;
if (perat[i].constant) {
if (perat[i].ndumped < ntotalgr) {
NCERR( nc_put_vars_int(ncid, perat[i].var,
start+1, count+1, stride+1,
int_buffer) );
NCERR( nc_put_vars_bigint(ncid, perat[i].var,
start+1, count+1, stride+1,
int_buffer) );
perat[i].ndumped += n;
}
}
else
NCERR( nc_put_vars_int(ncid, perat[i].var, start, count, stride,
int_buffer) );
NCERR( nc_put_vars_bigint(ncid, perat[i].var, start, count, stride,
int_buffer) );
}
}
}
else {
for (int j = 0; j < n; j++, iaux+=size_one) {
int_buffer[j] = mybuf[iaux];
if (vtype[iaux] == DUMP_INT) {
for (int j = 0; j < n; j++, iaux+=size_one) {
int_buffer[j] = static_cast<int>(mybuf[iaux]);
}
}
else { // DUMP_BIGINT
for (int j = 0; j < n; j++, iaux+=size_one) {
int_buffer[j] = static_cast<bigint>(mybuf[iaux]);
}
}
if (perat[i].constant) {
if (perat[i].ndumped < ntotalgr) {
NCERR( nc_put_vara_int(ncid, perat[i].var, start+1, count+1,
int_buffer) );
NCERR( nc_put_vara_bigint(ncid, perat[i].var, start+1, count+1,
int_buffer) );
perat[i].ndumped += n;
}
}
else
NCERR( nc_put_vara_int(ncid, perat[i].var, start, count,
int_buffer) );
NCERR( nc_put_vara_bigint(ncid, perat[i].var, start, count,
int_buffer) );
}
}
else {

View File

@ -66,7 +66,7 @@ class DumpNetCDF : public DumpCustom {
bool thermo; // write thermo output to netcdf file
bigint n_buffer; // size of buffer
int *int_buffer; // buffer for passing data to netcdf
bigint *int_buffer; // buffer for passing data to netcdf
double *double_buffer; // buffer for passing data to netcdf
int ncid;

View File

@ -43,7 +43,8 @@
using namespace LAMMPS_NS;
using namespace MathConst;
enum{INT,FLOAT,BIGINT}; // same as in thermo.cpp
enum{THERMO_INT,THERMO_FLOAT,THERMO_BIGINT}; // same as in thermo.cpp
enum{DUMP_INT,DUMP_DOUBLE,DUMP_STRING,DUMP_BIGINT}; // same as in DumpCFG
const char NC_FRAME_STR[] = "frame";
const char NC_SPATIAL_STR[] = "spatial";
@ -321,19 +322,6 @@ void DumpNetCDFMPIIO::openfile()
// variables specified in the input file
for (int i = 0; i < n_perat; i++) {
nc_type xtype;
// Type mangling
if (vtype[perat[i].field[0]] == INT) {
xtype = NC_INT;
}
else {
if (double_precision)
xtype = NC_DOUBLE;
else
xtype = NC_FLOAT;
}
NCERRX( ncmpi_inq_varid(ncid, perat[i].name, &perat[i].var),
perat[i].name );
}
@ -417,10 +405,11 @@ void DumpNetCDFMPIIO::openfile()
nc_type xtype;
// Type mangling
if (vtype[perat[i].field[0]] == INT) {
if (vtype[perat[i].field[0]] == DUMP_INT) {
xtype = NC_INT;
}
else {
} else if (vtype[perat[i].field[0]] == DUMP_BIGINT) {
xtype = NC_INT64;
} else {
if (double_precision)
xtype = NC_DOUBLE;
else
@ -456,17 +445,22 @@ void DumpNetCDFMPIIO::openfile()
if (thermo) {
Thermo *th = output->thermo;
for (int i = 0; i < th->nfield; i++) {
if (th->vtype[i] == FLOAT) {
if (th->vtype[i] == THERMO_FLOAT) {
NCERRX( ncmpi_def_var(ncid, th->keyword[i], NC_DOUBLE, 1, dims,
&thermovar[i]), th->keyword[i] );
}
else if (th->vtype[i] == INT) {
else if (th->vtype[i] == THERMO_INT) {
NCERRX( ncmpi_def_var(ncid, th->keyword[i], NC_INT, 1, dims,
&thermovar[i]), th->keyword[i] );
}
else if (th->vtype[i] == BIGINT) {
else if (th->vtype[i] == THERMO_BIGINT) {
#if defined(LAMMPS_SMALLBIG) || defined(LAMMPS_BIGBIG)
NCERRX( ncmpi_def_var(ncid, th->keyword[i], NC_INT64, 1, dims,
&thermovar[i]), th->keyword[i] );
#else
NCERRX( ncmpi_def_var(ncid, th->keyword[i], NC_LONG, 1, dims,
&thermovar[i]), th->keyword[i] );
#endif
}
}
}
@ -583,6 +577,7 @@ void DumpNetCDFMPIIO::openfile()
NCERR( ncmpi_end_indep_data(ncid) );
append_flag = 1;
framei = 1;
}
}
@ -609,25 +604,77 @@ void DumpNetCDFMPIIO::closefile()
template <typename T>
int ncmpi_put_var1_bigint(int ncid, int varid, const MPI_Offset index[],
const T* tp)
const T* tp)
{
return ncmpi_put_var1_int(ncid, varid, index, tp);
}
template <>
int ncmpi_put_var1_bigint<long>(int ncid, int varid, const MPI_Offset index[],
const long* tp)
const long* tp)
{
return ncmpi_put_var1_long(ncid, varid, index, tp);
}
template <>
int ncmpi_put_var1_bigint<long long>(int ncid, int varid, const MPI_Offset index[],
const long long* tp)
int ncmpi_put_var1_bigint<long long>(int ncid, int varid,
const MPI_Offset index[],
const long long* tp)
{
return ncmpi_put_var1_longlong(ncid, varid, index, tp);
}
template <typename T>
int ncmpi_put_vara_bigint_all(int ncid, int varid, const MPI_Offset start[],
const MPI_Offset count[], const T* tp)
{
return ncmpi_put_vara_int_all(ncid, varid, start, count, tp);
}
template <>
int ncmpi_put_vara_bigint_all<long>(int ncid, int varid,
const MPI_Offset start[],
const MPI_Offset count[], const long* tp)
{
return ncmpi_put_vara_long_all(ncid, varid, start, count, tp);
}
template <>
int ncmpi_put_vara_bigint_all<long long>(int ncid, int varid,
const MPI_Offset start[],
const MPI_Offset count[],
const long long* tp)
{
return ncmpi_put_vara_longlong_all(ncid, varid, start, count, tp);
}
template <typename T>
int ncmpi_put_vars_bigint_all(int ncid, int varid, const MPI_Offset start[],
const MPI_Offset count[],
const MPI_Offset stride[], const T* tp)
{
return ncmpi_put_vars_int_all(ncid, varid, start, count, stride, tp);
}
template <>
int ncmpi_put_vars_bigint_all<long>(int ncid, int varid,
const MPI_Offset start[],
const MPI_Offset count[],
const MPI_Offset stride[], const long* tp)
{
return ncmpi_put_vars_long_all(ncid, varid, start, count, stride, tp);
}
template <>
int ncmpi_put_vars_bigint_all<long long>(int ncid, int varid,
const MPI_Offset start[],
const MPI_Offset count[],
const MPI_Offset stride[],
const long long* tp)
{
return ncmpi_put_vars_longlong_all(ncid, varid, start, count, stride, tp);
}
void DumpNetCDFMPIIO::write()
{
// open file
@ -651,16 +698,16 @@ void DumpNetCDFMPIIO::write()
for (int i = 0; i < th->nfield; i++) {
th->call_vfunc(i);
if (filewriter) {
if (th->vtype[i] == FLOAT) {
if (th->vtype[i] == THERMO_FLOAT) {
NCERRX( ncmpi_put_var1_double(ncid, thermovar[i], start,
&th->dvalue),
th->keyword[i] );
}
else if (th->vtype[i] == INT) {
else if (th->vtype[i] == THERMO_INT) {
NCERRX( ncmpi_put_var1_int(ncid, thermovar[i], start, &th->ivalue),
th->keyword[i] );
}
else if (th->vtype[i] == BIGINT) {
else if (th->vtype[i] == THERMO_BIGINT) {
NCERRX( ncmpi_put_var1_bigint(ncid, thermovar[i], start, &th->bivalue),
th->keyword[i] );
}
@ -789,16 +836,16 @@ void DumpNetCDFMPIIO::write_data(int n, double *mybuf)
if (!int_buffer) {
n_buffer = std::max(1, n);
int_buffer = (int *)
memory->smalloc(n_buffer*sizeof(int),"dump::int_buffer");
int_buffer = (bigint *)
memory->smalloc(n_buffer*sizeof(bigint),"dump::int_buffer");
double_buffer = (double *)
memory->smalloc(n_buffer*sizeof(double),"dump::double_buffer");
}
if (n > n_buffer) {
n_buffer = std::max(1, n);
int_buffer = (int *)
memory->srealloc(int_buffer, n_buffer*sizeof(int),"dump::int_buffer");
int_buffer = (bigint *)
memory->srealloc(int_buffer, n_buffer*sizeof(bigint),"dump::int_buffer");
double_buffer = (double *)
memory->srealloc(double_buffer, n_buffer*sizeof(double),
"dump::double_buffer");
@ -831,7 +878,7 @@ void DumpNetCDFMPIIO::write_data(int n, double *mybuf)
error->one(FLERR,errmsg);
}
if (vtype[iaux] == INT) {
if (vtype[iaux] == DUMP_INT || vtype[iaux] == DUMP_BIGINT) {
// integers
if (perat[i].dims > 1) {
@ -846,13 +893,21 @@ void DumpNetCDFMPIIO::write_data(int n, double *mybuf)
error->one(FLERR,errmsg);
}
for (int j = 0; j < n; j++, iaux+=size_one) {
int_buffer[j] = mybuf[iaux];
if (vtype[iaux] == DUMP_INT) {
for (int j = 0; j < n; j++, iaux+=size_one) {
int_buffer[j] = static_cast<int>(mybuf[iaux]);
}
}
else { // DUMP_BIGINT
for (int j = 0; j < n; j++, iaux+=size_one) {
int_buffer[j] = static_cast<bigint>(mybuf[iaux]);
}
}
start[2] = idim;
NCERRX( ncmpi_put_vars_int_all(ncid, perat[i].var, start, count,
stride, int_buffer), perat[i].name );
NCERRX( ncmpi_put_vars_bigint_all(ncid, perat[i].var, start, count,
stride, int_buffer),
perat[i].name );
}
}
}
@ -861,8 +916,8 @@ void DumpNetCDFMPIIO::write_data(int n, double *mybuf)
int_buffer[j] = mybuf[iaux];
}
NCERRX( ncmpi_put_vara_int_all(ncid, perat[i].var, start, count,
int_buffer), perat[i].name );
NCERRX( ncmpi_put_vara_bigint_all(ncid, perat[i].var, start, count,
int_buffer), perat[i].name );
}
}
else {

View File

@ -65,7 +65,7 @@ class DumpNetCDFMPIIO : public DumpCustom {
bool thermo; // write thermo output to netcdf file
bigint n_buffer; // size of buffer
int *int_buffer; // buffer for passing data to netcdf
bigint *int_buffer; // buffer for passing data to netcdf
double *double_buffer; // buffer for passing data to netcdf
int ncid;

View File

@ -601,44 +601,17 @@ void Compute_ForcesOMP( reax_system *system, control_params *control,
MPI_Comm comm = mpi_data->world;
// Init Forces
#if defined(LOG_PERFORMANCE)
double t_start = 0;
if( system->my_rank == MASTER_NODE )
t_start = Get_Time( );
#endif
Init_Forces_noQEq_OMP( system, control, data, workspace,
lists, out_control, comm );
#if defined(LOG_PERFORMANCE)
//MPI_Barrier( comm );
if( system->my_rank == MASTER_NODE )
Update_Timing_Info( &t_start, &(data->timing.init_forces) );
#endif
lists, out_control, comm );
// Bonded Interactions
Compute_Bonded_ForcesOMP( system, control, data, workspace,
lists, out_control, mpi_data->world );
#if defined(LOG_PERFORMANCE)
if( system->my_rank == MASTER_NODE )
Update_Timing_Info( &t_start, &(data->timing.bonded) );
#endif
// Nonbonded Interactions
Compute_NonBonded_ForcesOMP( system, control, data, workspace,
lists, out_control, mpi_data->world );
#if defined(LOG_PERFORMANCE)
if( system->my_rank == MASTER_NODE )
Update_Timing_Info( &t_start, &(data->timing.nonb) );
#endif
// Total Force
Compute_Total_ForceOMP( system, control, data, workspace, lists, mpi_data );
#if defined(LOG_PERFORMANCE)
if( system->my_rank == MASTER_NODE )
Update_Timing_Info( &t_start, &(data->timing.bonded) );
#endif
}

View File

@ -697,7 +697,7 @@ int PairReaxC::write_reax_lists()
int itr_i, itr_j, i, j;
int num_nbrs;
int *ilist, *jlist, *numneigh, **firstneigh;
double d_sqr;
double d_sqr, cutoff_sqr;
rvec dvec;
double *dist, **x;
reax_list *far_nbrs;
@ -712,6 +712,7 @@ int PairReaxC::write_reax_lists()
far_list = far_nbrs->select.far_nbr_list;
num_nbrs = 0;
int inum = list->inum;
dist = (double*) calloc( system->N, sizeof(double) );
int numall = list->inum + list->gnum;
@ -721,12 +722,17 @@ int PairReaxC::write_reax_lists()
jlist = firstneigh[i];
Set_Start_Index( i, num_nbrs, far_nbrs );
if (i < inum)
cutoff_sqr = control->nonb_cut*control->nonb_cut;
else
cutoff_sqr = control->bond_cut*control->bond_cut;
for( itr_j = 0; itr_j < numneigh[i]; ++itr_j ){
j = jlist[itr_j];
j &= NEIGHMASK;
get_distance( x[j], x[i], &d_sqr, &dvec );
if( d_sqr <= (control->nonb_cut*control->nonb_cut) ){
if( d_sqr <= (cutoff_sqr) ){
dist[j] = sqrt( d_sqr );
set_far_nbr( &far_list[num_nbrs], j, dist[j], dvec );
++num_nbrs;