git-svn-id: svn://svn.icms.temple.edu/lammps-ro/trunk@1559 f3b2605a-c512-4ea7-a41b-209d697bcdaa
This commit is contained in:
@ -1,51 +1,51 @@
|
||||
//This code was written by Philip Nicoletti
|
||||
//http://www.codeguru.com/forum/archive/index.php/t-129990.html
|
||||
//
|
||||
//Modified by Jin Ma, Oklahoma State University for LAMMPS
|
||||
//erfc() is defined in GNU libraries. This code is a simplified
|
||||
//version for implementation with Visual C++.
|
||||
//
|
||||
//Warning: these functions are not fully tested.
|
||||
//
|
||||
#include "erfc.h"
|
||||
#include "math.h"
|
||||
|
||||
double erf(double x)
|
||||
{
|
||||
//
|
||||
// Computation of the error function erf(x).
|
||||
//
|
||||
return (1-erfc(x));
|
||||
}
|
||||
|
||||
//
|
||||
//
|
||||
double erfc(double x)
|
||||
{
|
||||
//
|
||||
// Computation of the complementary error function erfc(x).
|
||||
//
|
||||
// The algorithm is based on a Chebyshev fit as denoted in
|
||||
// Numerical Recipes 2nd ed. on p. 214 (W.H.Press et al.).
|
||||
//
|
||||
// The fractional error is always less than 1.2e-7.
|
||||
//
|
||||
//
|
||||
// The parameters of the Chebyshev fit
|
||||
//
|
||||
const double a1 = -1.26551223, a2 = 1.00002368,
|
||||
a3 = 0.37409196, a4 = 0.09678418,
|
||||
a5 = -0.18628806, a6 = 0.27886807,
|
||||
a7 = -1.13520398, a8 = 1.48851587,
|
||||
a9 = -0.82215223, a10 = 0.17087277;
|
||||
//
|
||||
double v = 1; // The return value
|
||||
double z = fabs(x);
|
||||
//
|
||||
if (z == 0) return v; // erfc(0)=1
|
||||
double t = 1/(1+0.5*z);
|
||||
v = t*exp((-z*z) +a1+t*(a2+t*(a3+t*(a4+t*(a5+t*(a6+
|
||||
t*(a7+t*(a8+t*(a9+t*a10)))))))));
|
||||
if (x < 0) v = 2-v; // erfc(-x)=2-erfc(x)
|
||||
return v;
|
||||
//This code was written by Philip Nicoletti
|
||||
//http://www.codeguru.com/forum/archive/index.php/t-129990.html
|
||||
//
|
||||
//Modified by Jin Ma, Oklahoma State University for LAMMPS
|
||||
//erfc() is defined in GNU libraries. This code is a simplified
|
||||
//version for implementation with Visual C++.
|
||||
//
|
||||
//Warning: these functions are not fully tested.
|
||||
//
|
||||
#include "erfc.h"
|
||||
#include "math.h"
|
||||
|
||||
double erf(double x)
|
||||
{
|
||||
//
|
||||
// Computation of the error function erf(x).
|
||||
//
|
||||
return (1-erfc(x));
|
||||
}
|
||||
|
||||
//
|
||||
//
|
||||
double erfc(double x)
|
||||
{
|
||||
//
|
||||
// Computation of the complementary error function erfc(x).
|
||||
//
|
||||
// The algorithm is based on a Chebyshev fit as denoted in
|
||||
// Numerical Recipes 2nd ed. on p. 214 (W.H.Press et al.).
|
||||
//
|
||||
// The fractional error is always less than 1.2e-7.
|
||||
//
|
||||
//
|
||||
// The parameters of the Chebyshev fit
|
||||
//
|
||||
const double a1 = -1.26551223, a2 = 1.00002368,
|
||||
a3 = 0.37409196, a4 = 0.09678418,
|
||||
a5 = -0.18628806, a6 = 0.27886807,
|
||||
a7 = -1.13520398, a8 = 1.48851587,
|
||||
a9 = -0.82215223, a10 = 0.17087277;
|
||||
//
|
||||
double v = 1; // The return value
|
||||
double z = fabs(x);
|
||||
//
|
||||
if (z == 0) return v; // erfc(0)=1
|
||||
double t = 1/(1+0.5*z);
|
||||
v = t*exp((-z*z) +a1+t*(a2+t*(a3+t*(a4+t*(a5+t*(a6+
|
||||
t*(a7+t*(a8+t*(a9+t*a10)))))))));
|
||||
if (x < 0) v = 2-v; // erfc(-x)=2-erfc(x)
|
||||
return v;
|
||||
}
|
||||
@ -1,5 +1,5 @@
|
||||
//
|
||||
|
||||
double erf(double x);
|
||||
|
||||
//
|
||||
|
||||
double erf(double x);
|
||||
|
||||
double erfc(double x);
|
||||
@ -1,126 +1,126 @@
|
||||
This is instruction for the modification of LAMMPS for MS Windows
|
||||
LAMMPS version: Feb 2007
|
||||
|
||||
compiled without MPI and FFT in Viusal C++ 6.0
|
||||
(All packages except for XTC, MEAM appear to work.)
|
||||
|
||||
-------------------
|
||||
|
||||
1. Create an empty workspace (Win32 console), add all .h and .cpp
|
||||
files into the project.
|
||||
|
||||
2. At about 80 places in the code, variables are redefined. Most of
|
||||
these variables are loop counters, which can be easily fixed.
|
||||
|
||||
Code looks like this:
|
||||
|
||||
for (int i=0; i<5; i++) {
|
||||
something;
|
||||
}
|
||||
for (int i=0; i<5; i++) {
|
||||
something else;
|
||||
}
|
||||
|
||||
This is ok with g++ compiler. But VC thinks the i is redefined in the
|
||||
second loop. So the variable scope is different. This happens many times
|
||||
in the code. It can be fixed easily based on the compiling error.
|
||||
|
||||
3. At the beginning of fft3d.h, added:
|
||||
#ifndef FFT_NONE
|
||||
#define FFT_NONE
|
||||
#endif
|
||||
|
||||
4. In input.cpp, changed the two header files
|
||||
//#include "unistd.h"
|
||||
#include "direct.h"
|
||||
|
||||
4A. (added by Tim Lau, MIT, ttl@mit.edu)
|
||||
|
||||
In variable.cpp, change the header files
|
||||
//#include "unistd.h"
|
||||
#include "sleep.h"
|
||||
|
||||
Add in the included sleep.h and sleep.cpp files.
|
||||
|
||||
4B. (added by Tim Lau, MIT, ttl@mit.edu)
|
||||
|
||||
In shell.cpp, change the header file:
|
||||
//#include "unistd.h"
|
||||
#include "direct.h"
|
||||
|
||||
Change the line in shell.cpp:
|
||||
mkdir(arg[i], S_IRWXU | S_IRGRP | S_IXGRP);
|
||||
to:
|
||||
mkdir(arg[i]);
|
||||
since Windows obviously does not use UNIX file permissions.
|
||||
|
||||
It's also possible that the line has to be changed to:
|
||||
_mkdir(arg[i]);
|
||||
depending on the version of the Visual C++ compiler used.
|
||||
|
||||
5. Added mpi.h and mpi.cpp (in STUBS folder) to the workspace
|
||||
In mpi.cpp, commented the time.h header file
|
||||
//#include <sys/time.h>
|
||||
commented the original code in MPI_Wtime(), just make it return 0;
|
||||
|
||||
6. In system.cpp, two changes due to difference in the input argument
|
||||
list
|
||||
|
||||
Line 83: int iarg = 2;
|
||||
Line 172: inflag=1; //add this line
|
||||
|
||||
The number of input arguments (nargs) is different in g++ and VC when
|
||||
you give arguments to run a program. This might be related to MPI as
|
||||
well. The difference is one. Once the above changes are made, the
|
||||
program is taking the correct argument.
|
||||
|
||||
However, it has been observed in the latest versions of sytem.cpp that
|
||||
no modification needs be made to the file as distributed from the
|
||||
LAMMPS website to work. The user however, instead of starting LAMMPS
|
||||
by the command:
|
||||
|
||||
lammps in.file
|
||||
|
||||
as he would if he implemented the changes detailed here, would launch
|
||||
in the Unix style:
|
||||
|
||||
lammps < in.file
|
||||
|
||||
7. The new version LAMMPS calls the error function:
|
||||
double erfc(double)
|
||||
This function is in the GNU C library. However, it's not found for
|
||||
VC++.
|
||||
Three options:
|
||||
a. One can try to find erfc() from other libraries.
|
||||
b. The erfc() is called for pair_modify table option. One can set
|
||||
the table option to be 0 to avoid calling this function.
|
||||
c. Write your own functions.
|
||||
|
||||
In this code, two files erfc.h, erfc.cpp are created and added to the project.
|
||||
Files that call erfc() all add
|
||||
#include "erfc.h" at the beginning.
|
||||
Note: the functions are not fully tested, use with caution.
|
||||
|
||||
8. MSVC does not have a inttypes.h file. The simplest way
|
||||
to deal with this problem is to download inttypes.h from the
|
||||
following site:
|
||||
http://www.koders.com/c/fidDE7D6EFFD475FAB1B7F6A2BBA791401CFA88FFA3.aspx
|
||||
and add this file into the workspace.
|
||||
|
||||
9. MSVC does not have dirent.h. The problem is solved by downloading
|
||||
a version of it for Windows from the following website:
|
||||
|
||||
http://www.softagalleria.net/dirent/index.en.html
|
||||
|
||||
10. Every time an error pops up for a line like this:
|
||||
|
||||
char *words[params_per_line];
|
||||
|
||||
replace to the following type:
|
||||
|
||||
char **words = new char*[params_per_line];
|
||||
|
||||
The dynamic memory allocation in MSVC requires a line like this.
|
||||
|
||||
11. Build the project. Specify appropriate input file to run the code.
|
||||
The Windows result might be different from Unix results. Be Cautious.
|
||||
This is instruction for the modification of LAMMPS for MS Windows
|
||||
LAMMPS version: Feb 2007
|
||||
|
||||
compiled without MPI and FFT in Viusal C++ 6.0
|
||||
(All packages except for XTC, MEAM appear to work.)
|
||||
|
||||
-------------------
|
||||
|
||||
1. Create an empty workspace (Win32 console), add all .h and .cpp
|
||||
files into the project.
|
||||
|
||||
2. At about 80 places in the code, variables are redefined. Most of
|
||||
these variables are loop counters, which can be easily fixed.
|
||||
|
||||
Code looks like this:
|
||||
|
||||
for (int i=0; i<5; i++) {
|
||||
something;
|
||||
}
|
||||
for (int i=0; i<5; i++) {
|
||||
something else;
|
||||
}
|
||||
|
||||
This is ok with g++ compiler. But VC thinks the i is redefined in the
|
||||
second loop. So the variable scope is different. This happens many times
|
||||
in the code. It can be fixed easily based on the compiling error.
|
||||
|
||||
3. At the beginning of fft3d.h, added:
|
||||
#ifndef FFT_NONE
|
||||
#define FFT_NONE
|
||||
#endif
|
||||
|
||||
4. In input.cpp, changed the two header files
|
||||
//#include "unistd.h"
|
||||
#include "direct.h"
|
||||
|
||||
4A. (added by Tim Lau, MIT, ttl@mit.edu)
|
||||
|
||||
In variable.cpp, change the header files
|
||||
//#include "unistd.h"
|
||||
#include "sleep.h"
|
||||
|
||||
Add in the included sleep.h and sleep.cpp files.
|
||||
|
||||
4B. (added by Tim Lau, MIT, ttl@mit.edu)
|
||||
|
||||
In shell.cpp, change the header file:
|
||||
//#include "unistd.h"
|
||||
#include "direct.h"
|
||||
|
||||
Change the line in shell.cpp:
|
||||
mkdir(arg[i], S_IRWXU | S_IRGRP | S_IXGRP);
|
||||
to:
|
||||
mkdir(arg[i]);
|
||||
since Windows obviously does not use UNIX file permissions.
|
||||
|
||||
It's also possible that the line has to be changed to:
|
||||
_mkdir(arg[i]);
|
||||
depending on the version of the Visual C++ compiler used.
|
||||
|
||||
5. Added mpi.h and mpi.cpp (in STUBS folder) to the workspace
|
||||
In mpi.cpp, commented the time.h header file
|
||||
//#include <sys/time.h>
|
||||
commented the original code in MPI_Wtime(), just make it return 0;
|
||||
|
||||
6. In system.cpp, two changes due to difference in the input argument
|
||||
list
|
||||
|
||||
Line 83: int iarg = 2;
|
||||
Line 172: inflag=1; //add this line
|
||||
|
||||
The number of input arguments (nargs) is different in g++ and VC when
|
||||
you give arguments to run a program. This might be related to MPI as
|
||||
well. The difference is one. Once the above changes are made, the
|
||||
program is taking the correct argument.
|
||||
|
||||
However, it has been observed in the latest versions of sytem.cpp that
|
||||
no modification needs be made to the file as distributed from the
|
||||
LAMMPS website to work. The user however, instead of starting LAMMPS
|
||||
by the command:
|
||||
|
||||
lammps in.file
|
||||
|
||||
as he would if he implemented the changes detailed here, would launch
|
||||
in the Unix style:
|
||||
|
||||
lammps < in.file
|
||||
|
||||
7. The new version LAMMPS calls the error function:
|
||||
double erfc(double)
|
||||
This function is in the GNU C library. However, it's not found for
|
||||
VC++.
|
||||
Three options:
|
||||
a. One can try to find erfc() from other libraries.
|
||||
b. The erfc() is called for pair_modify table option. One can set
|
||||
the table option to be 0 to avoid calling this function.
|
||||
c. Write your own functions.
|
||||
|
||||
In this code, two files erfc.h, erfc.cpp are created and added to the project.
|
||||
Files that call erfc() all add
|
||||
#include "erfc.h" at the beginning.
|
||||
Note: the functions are not fully tested, use with caution.
|
||||
|
||||
8. MSVC does not have a inttypes.h file. The simplest way
|
||||
to deal with this problem is to download inttypes.h from the
|
||||
following site:
|
||||
http://www.koders.com/c/fidDE7D6EFFD475FAB1B7F6A2BBA791401CFA88FFA3.aspx
|
||||
and add this file into the workspace.
|
||||
|
||||
9. MSVC does not have dirent.h. The problem is solved by downloading
|
||||
a version of it for Windows from the following website:
|
||||
|
||||
http://www.softagalleria.net/dirent/index.en.html
|
||||
|
||||
10. Every time an error pops up for a line like this:
|
||||
|
||||
char *words[params_per_line];
|
||||
|
||||
replace to the following type:
|
||||
|
||||
char **words = new char*[params_per_line];
|
||||
|
||||
The dynamic memory allocation in MSVC requires a line like this.
|
||||
|
||||
11. Build the project. Specify appropriate input file to run the code.
|
||||
The Windows result might be different from Unix results. Be Cautious.
|
||||
|
||||
Reference in New Issue
Block a user