git-svn-id: svn://svn.icms.temple.edu/lammps-ro/trunk@13671 f3b2605a-c512-4ea7-a41b-209d697bcdaa

This commit is contained in:
sjplimp 2015-07-22 14:38:27 +00:00
parent 6e40300d26
commit 8ee843d1bd
7 changed files with 41 additions and 60 deletions

View File

@ -22,6 +22,7 @@
#include "compute_saed.h"
#include "compute_saed_consts.h"
#include "atom.h"
#include "comm.h"
#include "update.h"
#include "domain.h"
#include "group.h"
@ -31,16 +32,8 @@
#include "stdio.h"
#include "string.h"
#include <iostream>
#ifdef _OPENMP
#include "omp.h"
#include "comm.h"
#endif
using namespace LAMMPS_NS;
using namespace MathConst;
using namespace std;
static const char cite_compute_saed_c[] =
"compute_saed command:\n\n"
@ -60,12 +53,12 @@ ComputeSAED::ComputeSAED(LAMMPS *lmp, int narg, char **arg) :
{
if (lmp->citeme) lmp->citeme->add(cite_compute_saed_c);
MPI_Comm_rank(world,&me);
int ntypes = atom->ntypes;
int natoms = group->count(igroup);
int dimension = domain->dimension;
int *periodicity = domain->periodicity;
int triclinic = domain->triclinic;
me = comm->me;
// Checking errors specific to the compute
if (dimension == 2)
@ -409,12 +402,10 @@ void ComputeSAED::compute_vector()
if (Smax > 2) offset = 10;
// Setting up OMP
int nthreads = 1;
#ifdef _OPENMP
nthreads = comm->nthreads;
#if defined(_OPENMP)
if (me == 0 && echo) {
if (screen)
fprintf(screen," using %d OMP threads",nthreads);
fprintf(screen," using %d OMP threads\n",comm->nthreads);
}
#endif
@ -426,20 +417,23 @@ void ComputeSAED::compute_vector()
int m = 0;
double frac = 0.1;
#pragma omp parallel num_threads(nthreads)
#if defined(_OPENMP)
#pragma omp parallel default(none) shared(offset,ASFSAED,typelocal,xlocal,Fvec,m,frac)
#endif
{
double *f = new double[ntypes]; // atomic structure factor by type
int typei = 0;
double Fatom1 = 0.0; // structure factor per atom
double Fatom2 = 0.0; // structure factor per atom (imaginary)
double S = 0.0; // sin(theta)/lambda
double K[3];
double dinv2 = 0.0;
double dinv = 0.0;
double SinTheta_lambda = 0.0;
double inners = 0.0;
#if defined(_OPENMP)
#pragma omp for
#endif
for (int n = 0; n < nRows; n++) {
int i = store_tmp[3*n+0];
int j = store_tmp[3*n+1];
@ -479,7 +473,10 @@ void ComputeSAED::compute_vector()
// reporting progress of calculation
if ( echo ) {
#if defined(_OPENMP)
#pragma omp critical
// TODO use VMD timer style incrementer
#endif
{
if ( m == round(frac * nRows) ) {
if (me == 0 && screen) fprintf(screen," %0.0f%% -",frac*100);

View File

@ -20,7 +20,6 @@ ComputeStyle(saed,ComputeSAED)
#ifndef LMP_COMPUTE_SAED_H
#define LMP_COMPUTE_SAED_H
#include "stdio.h"
#include "compute.h"
namespace LAMMPS_NS {

View File

@ -30,7 +30,7 @@ Acta Crystallogr.A 52 25776
#define SAEDmaxType 98
// list of element types associated with atomic scattering factor constants
const char *SAEDtypeList[SAEDmaxType] = {
static const char *SAEDtypeList[SAEDmaxType] = {
"H", "He", "Li", "Be", "B",
"C", "N", "O", "F", "Ne",
"Na", "Mg", "Al", "Si", "P",
@ -53,7 +53,7 @@ const char *SAEDtypeList[SAEDmaxType] = {
"Cm", "Bk", "Cf"};
// list of atomic scattering factor constants for electron diffraction
const double ASFSAED[SAEDmaxType][20] = {
static const double ASFSAED[SAEDmaxType][20] = {
/* Each set of four rows in this file represents a single row in the matrix
First two rows are constants for 0 < sin(theta)/lambda < 2
Z-number A1 A2 A3 A4 A5

View File

@ -23,6 +23,7 @@
#include "compute_xrd.h"
#include "compute_xrd_consts.h"
#include "atom.h"
#include "comm.h"
#include "update.h"
#include "domain.h"
#include "group.h"
@ -32,16 +33,8 @@
#include "stdio.h"
#include "string.h"
#include <iostream>
#ifdef _OPENMP
#include "omp.h"
#include "comm.h"
#endif
using namespace LAMMPS_NS;
using namespace MathConst;
using namespace std;
static const char cite_compute_xrd_c[] =
"compute_xrd command:\n\n"
@ -61,12 +54,12 @@ ComputeXRD::ComputeXRD(LAMMPS *lmp, int narg, char **arg) :
{
if (lmp->citeme) lmp->citeme->add(cite_compute_xrd_c);
MPI_Comm_rank(world,&me);
int ntypes = atom->ntypes;
int natoms = group->count(igroup);
int dimension = domain->dimension;
int *periodicity = domain->periodicity;
int triclinic = domain->triclinic;
me = comm->me;
// Checking errors
if (dimension == 2)
@ -104,7 +97,7 @@ ComputeXRD::ComputeXRD(LAMMPS *lmp, int narg, char **arg) :
// Set defaults for optional args
Min2Theta = 1;
Max2Theta = 179;
radflag ==1;
radflag = 1;
c[0] = 1; c[1] = 1; c[2] = 1;
LP = 1;
manual = false;
@ -224,7 +217,7 @@ ComputeXRD::ComputeXRD(LAMMPS *lmp, int narg, char **arg) :
dinv2 = (K[0] * K[0] + K[1] * K[1] + K[2] * K[2]);
if (4 >= dinv2 * lambda * lambda ) {
ang = asin(lambda * sqrt(dinv2) * 0.5);
if (ang <= Max2Theta & ang >= Min2Theta) {
if ((ang <= Max2Theta) && (ang >= Min2Theta)) {
nRows++;
}
}
@ -284,7 +277,7 @@ void ComputeXRD::init()
dinv2 = (K[0] * K[0] + K[1] * K[1] + K[2] * K[2]);
if (4 >= dinv2 * lambda * lambda ) {
ang = asin(lambda * sqrt(dinv2) * 0.5);
if (ang <= Max2Theta & ang >= Min2Theta) {
if ((ang <= Max2Theta) && (ang >= Min2Theta)) {
store_tmp[3*n] = k;
store_tmp[3*n+1] = j;
store_tmp[3*n+2] = i;
@ -342,27 +335,29 @@ void ComputeXRD::compute_array()
}
// Setting up OMP
int nthreads = 1;
#ifdef _OPENMP
nthreads = comm->nthreads;
#if defined(_OPENMP)
if (me == 0 && echo) {
if (screen)
fprintf(screen," using %d OMP threads",nthreads);
fprintf(screen," using %d OMP threads\n",comm->nthreads);
}
#endif
if (me == 0 && echo) {
if (screen)
fprintf(screen,"\n");
if (LP == 1)
fprintf(screen,"Applying Lorentz-Polarization Factor During XRD Calculation 2\n");
}
int m = 0;
double frac = 0.1;
#pragma omp parallel num_threads(nthreads)
#if defined(_OPENMP)
#pragma omp parallel default(none) shared(typelocal,xlocal,Fvec,m,frac,ASFXRD)
#endif
{
double *f = new double[ntypes]; // atomic structure factor by type
int typei = 0;
int n,typei = 0;
double Fatom1 = 0.0; // structure factor per atom (real)
double Fatom2 = 0.0; // structure factor per atom (imaginary)
@ -380,18 +375,10 @@ void ComputeXRD::compute_array()
if (LP == 1) {
if (me == 0 && echo && screen) {
#ifdef _OPENMP
if (omp_get_thread_num() == 0)
fprintf(screen,"Applying Lorentz-Polarization Factor During XRD Calculation 2\n");
#endif
#ifndef _OPENMP
fprintf(screen,"Applying Lorentz-Polarization Factor During XRD Calculation 2\n");
#endif
}
#if defined(_OPENMP)
#pragma omp for
for (int n = 0; n < size_array_rows; n++) {
#endif
for (n = 0; n < size_array_rows; n++) {
int k = store_tmp[3*n];
int j = store_tmp[3*n+1];
int i = store_tmp[3*n+2];
@ -434,7 +421,9 @@ void ComputeXRD::compute_array()
// reporting progress of calculation
if ( echo ) {
#if defined(_OPENMP)
#pragma omp critical
#endif
{
if ( m == round(frac * size_array_rows) ) {
if (me == 0 && screen) fprintf(screen," %0.0f%% -",frac*100);
@ -446,8 +435,10 @@ void ComputeXRD::compute_array()
} // End of pragma omp for region
} else {
#if defined(_OPENMP)
#pragma omp for
for (int n = 0; n < size_array_rows; n++) {
#endif
for (n = 0; n < size_array_rows; n++) {
int k = store_tmp[3*n];
int j = store_tmp[3*n+1];
int i = store_tmp[3*n+2];
@ -484,7 +475,9 @@ void ComputeXRD::compute_array()
// reporting progress of calculation
if ( echo ) {
#if defined(_OPENMP)
#pragma omp critical
#endif
{
if ( m == round(frac * size_array_rows) ) {
if (me == 0 && screen) fprintf(screen," %0.0f%% -",frac*100 );

View File

@ -20,7 +20,6 @@ ComputeStyle(xrd,ComputeXRD)
#ifndef LMP_COMPUTE_XRD_H
#define LMP_COMPUTE_XRD_H
#include "stdio.h"
#include "compute.h"
namespace LAMMPS_NS {

View File

@ -30,7 +30,7 @@ Acta Crystallogr. A 45 78693
#define XRDmaxType 210
const char *XRDtypeList[XRDmaxType] = {
static const char *XRDtypeList[XRDmaxType] = {
"H", "He1-", "He", "Li", "Li1+",
"Be", "Be2+", "B", "C", "Cval",
"N", "O", "O1-", "F", "F1-",
@ -75,7 +75,7 @@ const char *XRDtypeList[XRDmaxType] = {
"Pu6+", "Am", "Cm", "Bk", "Cf"};
// a list of atomic scattering factor constants for x-ray diffraction
const double ASFXRD[XRDmaxType][9] = {
static const double ASFXRD[XRDmaxType][9] = {
/* Each set of two rows in this file contains the constants
for 0 < sin(theta)/lambda < 2
A1, B1, A2, B2, A3,

View File

@ -32,10 +32,6 @@
#include "math.h"
#include "domain.h"
#include <stdio.h>
#include <iostream>
using namespace std;
using namespace LAMMPS_NS;
using namespace FixConst;
@ -72,9 +68,8 @@ FixSAEDVTK::FixSAEDVTK(LAMMPS *lmp, int narg, char **arg) :
options(narg,arg);
which = NULL;
which = 0;
ids = NULL;
int maxvalues = nvalues;
nvalues = 0;
@ -126,8 +121,6 @@ FixSAEDVTK::FixSAEDVTK(LAMMPS *lmp, int narg, char **arg) :
if (compute->extvector != 0)
error->all(FLERR,"Illegal fix saed/vtk command");
int length = modify->compute[icompute]->size_vector;
nrows = compute->size_vector;
nvalues++;
iarg++;