Merge pull request #2750 from akohlmey/update-bop
Updated pair style bop
This commit is contained in:
@ -19,11 +19,9 @@
|
|||||||
0.00000000E+00 0.00000000E+00
|
0.00000000E+00 0.00000000E+00
|
||||||
0.50000000E+00 0.00000000E+00 0.10000000E+07
|
0.50000000E+00 0.00000000E+00 0.10000000E+07
|
||||||
0.39687010E+00 0.88101950E+00 -0.27788970E+00
|
0.39687010E+00 0.88101950E+00 -0.27788970E+00
|
||||||
-0.10071280E+00 0.10000000E+01 0.10071280E+00
|
|
||||||
0.20952380E+00 0.60000000E+00 0.19047620E+00
|
|
||||||
0.39284960E-02 0.99992720E+00 -0.38556650E-02
|
|
||||||
-0.10071280E+00 0.10000000E+01 0.10071280E+00
|
-0.10071280E+00 0.10000000E+01 0.10071280E+00
|
||||||
0.20073220E+00 0.60000000E+00 0.19926780E+00
|
0.20073220E+00 0.60000000E+00 0.19926780E+00
|
||||||
|
0.20952380E+00 0.60000000E+00 0.19047620E+00
|
||||||
0.39284960E-02 0.99992720E+00 -0.38556650E-02
|
0.39284960E-02 0.99992720E+00 -0.38556650E-02
|
||||||
0.11718170E+00 0.83481160E+00 0.48006700E-01
|
0.11718170E+00 0.83481160E+00 0.48006700E-01
|
||||||
0.37236414E+06 0.37236414E+06 0.37236414E+06 0.37236414E+06 0.37236414E+06
|
0.37236414E+06 0.37236414E+06 0.37236414E+06 0.37236414E+06 0.37236414E+06
|
||||||
@ -4831,3 +4829,5 @@
|
|||||||
0.00000000E+00
|
0.00000000E+00
|
||||||
0.00000000E+00
|
0.00000000E+00
|
||||||
0.00000000E+00
|
0.00000000E+00
|
||||||
|
0.00000000E+00
|
||||||
|
0.00000000E+00
|
||||||
|
|||||||
9664
potentials/CdTeZn.bop.table
Normal file
9664
potentials/CdTeZn.bop.table
Normal file
File diff suppressed because it is too large
Load Diff
@ -19,11 +19,9 @@
|
|||||||
0.00000000E+00 0.00000000E+00
|
0.00000000E+00 0.00000000E+00
|
||||||
0.50000000E+00 0.00000000E+00 0.10E-04
|
0.50000000E+00 0.00000000E+00 0.10E-04
|
||||||
9.21518535E-02 7.20160363E-01 1.87687783E-01
|
9.21518535E-02 7.20160363E-01 1.87687783E-01
|
||||||
5.37304525E-02 7.20160376E-01 2.26109172E-01
|
|
||||||
2.34227480E-01 7.65772520E-01 0.00000000E+00
|
|
||||||
-3.18730636E-02 7.49789590E-01 2.82083474E-01
|
|
||||||
5.37304525E-02 7.20160376E-01 2.26109172E-01
|
5.37304525E-02 7.20160376E-01 2.26109172E-01
|
||||||
2.56221496E-01 6.68582598E-01 7.51959058E-02
|
2.56221496E-01 6.68582598E-01 7.51959058E-02
|
||||||
|
2.34227480E-01 7.65772520E-01 0.00000000E+00
|
||||||
-3.18730636E-02 7.49789590E-01 2.82083474E-01
|
-3.18730636E-02 7.49789590E-01 2.82083474E-01
|
||||||
-2.11787351E-02 7.66726837E-01 2.54451898E-01
|
-2.11787351E-02 7.66726837E-01 2.54451898E-01
|
||||||
0.67538417E+03 0.67538417E+03 0.67538417E+03 0.67538417E+03 0.67538417E+03
|
0.67538417E+03 0.67538417E+03 0.67538417E+03 0.67538417E+03 0.67538417E+03
|
||||||
@ -4831,3 +4829,5 @@
|
|||||||
0.00000000E+00
|
0.00000000E+00
|
||||||
0.00000000E+00
|
0.00000000E+00
|
||||||
0.00000000E+00
|
0.00000000E+00
|
||||||
|
0.00000000E+00
|
||||||
|
0.00000000E+00
|
||||||
|
|||||||
8
src/.gitignore
vendored
8
src/.gitignore
vendored
@ -923,8 +923,6 @@
|
|||||||
/pair_dipole_cut.h
|
/pair_dipole_cut.h
|
||||||
/pair_dipole_sf.cpp
|
/pair_dipole_sf.cpp
|
||||||
/pair_dipole_sf.h
|
/pair_dipole_sf.h
|
||||||
/pair_dpd_mt.cpp
|
|
||||||
/pair_dpd_mt.h
|
|
||||||
/pair_dsmc.cpp
|
/pair_dsmc.cpp
|
||||||
/pair_dsmc.h
|
/pair_dsmc.h
|
||||||
/pair_e3b.cpp
|
/pair_e3b.cpp
|
||||||
@ -1400,8 +1398,10 @@
|
|||||||
/pair_thole.h
|
/pair_thole.h
|
||||||
/pair_buck_mdf.cpp
|
/pair_buck_mdf.cpp
|
||||||
/pair_buck_mdf.h
|
/pair_buck_mdf.h
|
||||||
/pair_dpd_conservative.cpp
|
/pair_dpd_ext.cpp
|
||||||
/pair_dpd_conservative.h
|
/pair_dpd_ext.h
|
||||||
|
/pair_dpd_ext_tstat.cpp
|
||||||
|
/pair_dpd_ext_tstat.h
|
||||||
/pair_dpd_fdt.cpp
|
/pair_dpd_fdt.cpp
|
||||||
/pair_dpd_fdt.h
|
/pair_dpd_fdt.h
|
||||||
/pair_dpd_fdt_energy.cpp
|
/pair_dpd_fdt_energy.cpp
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@ -17,9 +17,9 @@
|
|||||||
------------------------------------------------------------------------- */
|
------------------------------------------------------------------------- */
|
||||||
|
|
||||||
#ifdef PAIR_CLASS
|
#ifdef PAIR_CLASS
|
||||||
|
// clang-format off
|
||||||
PairStyle(bop,PairBOP)
|
PairStyle(bop,PairBOP);
|
||||||
|
// clang-format on
|
||||||
#else
|
#else
|
||||||
|
|
||||||
#ifndef LMP_PAIR_BOP_H
|
#ifndef LMP_PAIR_BOP_H
|
||||||
@ -28,8 +28,10 @@ PairStyle(bop,PairBOP)
|
|||||||
#include "pair.h"
|
#include "pair.h"
|
||||||
|
|
||||||
namespace LAMMPS_NS {
|
namespace LAMMPS_NS {
|
||||||
|
class TabularFunction;
|
||||||
|
|
||||||
class PairBOP : public Pair {
|
class PairBOP : public Pair {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
PairBOP(class LAMMPS *);
|
PairBOP(class LAMMPS *);
|
||||||
virtual ~PairBOP();
|
virtual ~PairBOP();
|
||||||
@ -41,117 +43,50 @@ class PairBOP : public Pair {
|
|||||||
double memory_usage();
|
double memory_usage();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
int maxneigh; // maximum size of neighbor list on this processor
|
|
||||||
int maxneigh3; // maximum size of neighbor list on this processor
|
|
||||||
int update_list; // check for changing maximum size of neighbor list
|
|
||||||
int maxbopn; // maximum size of bop neighbor list for allocation
|
|
||||||
int maxnall; // maximum size of bop neighbor list for allocation
|
|
||||||
int nr; // increments for the BOP pair potential
|
|
||||||
int ntheta; // increments for the angle function
|
|
||||||
int npower; // power of the angular function
|
|
||||||
int nBOt; // second BO increments
|
|
||||||
int bop_types; // number of elements in potential
|
|
||||||
int npairs; // number of element pairs
|
|
||||||
int bop_step;
|
|
||||||
int allocate_neigh;
|
|
||||||
int nb_pi,nb_sg;
|
|
||||||
int ago1;
|
|
||||||
|
|
||||||
int *BOP_index; // index for neighbor list position
|
struct PairParameters {
|
||||||
int *BOP_total; // index for neighbor list position
|
double cutB, cutBsq, cutL, cutLsq;
|
||||||
int *BOP_index3; // index for neighbor list position
|
TabularFunction *betaS;
|
||||||
int *BOP_total3; // index for neighbor list position
|
TabularFunction *betaP;
|
||||||
int *neigh_index; // index for neighbor list position
|
TabularFunction *rep;
|
||||||
int *neigh_index3; // index for neighbor list position
|
TabularFunction *cphi;
|
||||||
int neigh_total; // total number of neighbors stored
|
TabularFunction *bo;
|
||||||
int neigh_total3; // total number of neighbors stored
|
PairParameters();
|
||||||
int *cos_index; // index for neighbor cosine if not using on the fly
|
~PairParameters();
|
||||||
int *neigh_flag; // index for neighbor cosine if not using on the fly
|
};
|
||||||
int *neigh_flag3; // index for neighbor cosine if not using on the fly
|
|
||||||
int cos_total; // number of cosines stored if not using on the fly
|
|
||||||
int neigh_ct; // limit for large arrays
|
|
||||||
|
|
||||||
// Parameters variables
|
struct PairList1 {
|
||||||
|
double r, dis[3];
|
||||||
|
double betaS, dBetaS, betaP, dBetaP, rep, dRep;
|
||||||
|
PairList1(){};
|
||||||
|
};
|
||||||
|
|
||||||
int ncutoff,nfunc;
|
struct PairList2 {
|
||||||
int a_flag;
|
double r, dis[3];
|
||||||
double *pi_a,*pro_delta,*pi_delta;
|
double rep, dRep;
|
||||||
double *pi_p,*pi_c,*sigma_r0,*pi_r0,*phi_r0;
|
PairList2(){};
|
||||||
double *sigma_rc,*pi_rc,*phi_rc,*r1,*sigma_beta0;
|
};
|
||||||
double *pi_beta0,*phi0,*sigma_n,*pi_n,*phi_m;
|
|
||||||
double *sigma_nc,*pi_nc,*phi_nc;
|
|
||||||
double *pro,*sigma_delta,*sigma_c,*sigma_a;
|
|
||||||
double *sigma_f,*sigma_k,*small3;
|
|
||||||
double small1,small2,small3g,small4,small5,small6,small7;
|
|
||||||
double which,alpha,alpha1,beta1,gamma1,alpha2,beta2,alpha3;
|
|
||||||
double beta3,rsmall,rbig,rcore;
|
|
||||||
char **words;
|
|
||||||
|
|
||||||
double cutmax; // max cutoff for all elements
|
struct TripleList {
|
||||||
int otfly; // Defines whether to do on the fly
|
double G, dG, cosAng, dCosAngi[3], dCosAngj[3], dCosAngk[3];
|
||||||
// calculations of angles and distances
|
TripleList(){};
|
||||||
// on the fly will slow down calculations
|
};
|
||||||
// but requires less memory on = 1, off=0
|
|
||||||
|
|
||||||
// Neigh variables
|
struct B_SG {
|
||||||
|
double dAA[3];
|
||||||
|
double dBB[3];
|
||||||
|
double dCC[3];
|
||||||
|
double dDD[3];
|
||||||
|
double dEE1[3];
|
||||||
|
double dFF[3];
|
||||||
|
double dAAC[3];
|
||||||
|
double dSigB1[3];
|
||||||
|
double dSigB[3];
|
||||||
|
int temp;
|
||||||
|
int i;
|
||||||
|
int j;
|
||||||
|
};
|
||||||
|
|
||||||
double *rcut,*rcut3,*dr,*rdr,*dr3,*rdr3;
|
|
||||||
double *rcutsq,*rcutsq3;
|
|
||||||
double **disij,*rij;
|
|
||||||
double rcutall,rctroot;
|
|
||||||
|
|
||||||
// Triple variables
|
|
||||||
|
|
||||||
double *cosAng,***dcosAng,***dcAng;
|
|
||||||
|
|
||||||
// Double variables
|
|
||||||
|
|
||||||
double *betaS,*dBetaS,*betaP;
|
|
||||||
double *dBetaP,*repul,*dRepul;
|
|
||||||
|
|
||||||
// Sigma variables
|
|
||||||
|
|
||||||
int *itypeSigBk,nSigBk;
|
|
||||||
double sigB,sigB_0;
|
|
||||||
double sigB1;
|
|
||||||
|
|
||||||
// Pi variables
|
|
||||||
|
|
||||||
int *itypePiBk,nPiBk;
|
|
||||||
double piB,piB_0;
|
|
||||||
|
|
||||||
// Grids1 variables
|
|
||||||
|
|
||||||
double **pBetaS,**pBetaS1,**pBetaS2,**pBetaS3;
|
|
||||||
double **pBetaS4,**pBetaS5,**pBetaS6;
|
|
||||||
|
|
||||||
// Grids2 variables
|
|
||||||
|
|
||||||
double **pBetaP,**pBetaP1,**pBetaP2,**pBetaP3;
|
|
||||||
double **pBetaP4,**pBetaP5,**pBetaP6;
|
|
||||||
|
|
||||||
// Grids3 variables
|
|
||||||
|
|
||||||
double **pRepul,**pRepul1,**pRepul2,**pRepul3;
|
|
||||||
double **pRepul4,**pRepul5,**pRepul6;
|
|
||||||
|
|
||||||
double **pLong,**pLong1,**pLong2,**pLong3;
|
|
||||||
double **pLong4,**pLong5,**pLong6;
|
|
||||||
|
|
||||||
double ****gfunc,****gpara;
|
|
||||||
double ****gfunc1,****gfunc2,****gfunc3;
|
|
||||||
double ****gfunc4,****gfunc5,****gfunc6;
|
|
||||||
double dtheta,rdtheta;
|
|
||||||
|
|
||||||
// Grids4 variables
|
|
||||||
|
|
||||||
double **FsigBO,**FsigBO1,**FsigBO2,**FsigBO3;
|
|
||||||
double **FsigBO4,**FsigBO5,**FsigBO6;
|
|
||||||
double dBO,rdBO;
|
|
||||||
|
|
||||||
// End of BOP variables
|
|
||||||
|
|
||||||
double **rcmin,**rcmax,**rcmaxp;
|
|
||||||
struct B_PI {
|
struct B_PI {
|
||||||
double dAA[3];
|
double dAA[3];
|
||||||
double dBB[3];
|
double dBB[3];
|
||||||
@ -160,64 +95,73 @@ class PairBOP : public Pair {
|
|||||||
int i;
|
int i;
|
||||||
int j;
|
int j;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
PairParameters *pairParameters;
|
||||||
|
TabularFunction *tripletParameters;
|
||||||
|
|
||||||
|
// Parameters variables
|
||||||
|
|
||||||
|
double small1, small2, small3g, small4, small5, small6, small7, *pi_p;
|
||||||
|
double *sigma_c, *sigma_a, *pi_c, *pi_a, *sigma_delta, *pi_delta;
|
||||||
|
double *sigma_f, *sigma_k, *small3;
|
||||||
|
double *pro_delta, *pro;
|
||||||
|
|
||||||
|
int bop_types; // number of elments in potential file
|
||||||
|
int npairs; // number of element pairs
|
||||||
|
int ntriples; // number of all triples
|
||||||
|
char **bop_elements; // names of elements in potential file
|
||||||
|
double bytes;
|
||||||
|
|
||||||
|
int otfly; // = 1 faster, more memory, = 0 slower, less memory
|
||||||
|
|
||||||
|
PairList1 *pairlist1;
|
||||||
|
PairList2 *pairlist2;
|
||||||
|
TripleList *triplelist;
|
||||||
|
|
||||||
|
B_SG *bt_sg;
|
||||||
B_PI *bt_pi;
|
B_PI *bt_pi;
|
||||||
|
|
||||||
struct B_SG{
|
int *BOP_index; // index for neighbor list position
|
||||||
double dAA[3];
|
int *BOP_total; // index for neighbor list position
|
||||||
double dBB[3];
|
int *BOP_index2; // index for neighbor list position
|
||||||
double dCC[3];
|
int *BOP_total2; // index for neighbor list position
|
||||||
double dDD[3];
|
int *neigh_index; // index for neighbor list position
|
||||||
double dEE[3];
|
int *neigh_index2; // index for neighbor list position
|
||||||
double dEE1[3];
|
int atomlimit; // current size of atom based list
|
||||||
double dFF[3];
|
int neighlimit; // current size of neighbor based list
|
||||||
double dAAC[3];
|
int neighlimit2; // current size of neighbor based list
|
||||||
double dBBC[3];
|
int neineilimit; // current size of triple based list
|
||||||
double dCCC[3];
|
int sglimit; // current size of bt_sg
|
||||||
double dDDC[3];
|
int pilimit; // current size of bt_pi
|
||||||
double dEEC[3];
|
int *cos_index; // index for neighbor cosine if not using on the fly
|
||||||
double dFFC[3];
|
double cutmax;
|
||||||
double dGGC[3];
|
|
||||||
double dUT[3];
|
#if defined(LMP_BOP_WRITE_TABLES)
|
||||||
double dSigB1[3];
|
void write_tables(int);
|
||||||
double dSigB[3];
|
#endif
|
||||||
int temp;
|
|
||||||
int i;
|
|
||||||
int j;
|
|
||||||
};
|
|
||||||
B_SG *bt_sg;
|
|
||||||
|
|
||||||
void setPbetaS();
|
|
||||||
void setPbetaP();
|
|
||||||
void setPrepul();
|
|
||||||
void setSign();
|
|
||||||
void gneigh();
|
void gneigh();
|
||||||
double sigmaBo(int, int);
|
void angle(double, double *, double, double *, double &, double *, double *);
|
||||||
|
double SigmaBo(int, int);
|
||||||
double PiBo(int, int);
|
double PiBo(int, int);
|
||||||
void memory_theta_create();
|
|
||||||
void memory_theta_destroy();
|
|
||||||
void memory_theta_grow();
|
|
||||||
|
|
||||||
void read_table(char *);
|
void read_table(char *);
|
||||||
void allocate();
|
void allocate();
|
||||||
void allocate_tables();
|
void memory_sg(int);
|
||||||
void create_pi(int);
|
void memory_pi(int);
|
||||||
void create_sigma(int);
|
void initial_sg(int);
|
||||||
void destroy_pi();
|
void initial_pi(int);
|
||||||
void destroy_sigma();
|
|
||||||
void grow_pi(int,int);
|
|
||||||
void grow_sigma(int,int);
|
|
||||||
};
|
};
|
||||||
}
|
|
||||||
|
} // namespace LAMMPS_NS
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* ERROR/WARNING messages:
|
/* ERROR/WARNING messages:
|
||||||
|
|
||||||
E: Illegal ... command
|
E: Illegal pair_style command
|
||||||
|
|
||||||
Self-explanatory. Check the input script syntax and compare to the
|
Self-explanatory.
|
||||||
documentation for the command. You can use -echo screen as a
|
|
||||||
command-line option when running LAMMPS to see the offending line.
|
|
||||||
|
|
||||||
E: Incorrect args for pair coefficients
|
E: Incorrect args for pair coefficients
|
||||||
|
|
||||||
@ -229,34 +173,20 @@ This is a requirement to use the BOP potential.
|
|||||||
|
|
||||||
E: Pair style BOP requires newton pair on
|
E: Pair style BOP requires newton pair on
|
||||||
|
|
||||||
See the newton command. This is a restriction to use the BOP
|
This is a restriction to use the BOP potential.
|
||||||
potential.
|
|
||||||
|
|
||||||
E: Pair style bop requires comm ghost cutoff at least 3x larger than %g
|
E: Pair style bop requires a comm ghost cutoff of at least %lf
|
||||||
|
|
||||||
Use the communicate ghost command to set this. See the pair bop
|
Use the comm_modify cutoff to set this. See the pair bop doc page for
|
||||||
doc page for more details.
|
more details.
|
||||||
|
|
||||||
E: All pair coeffs are not set
|
E: All pair coeffs are not set
|
||||||
|
|
||||||
All pair coefficients must be set in the data file or by the
|
Self-explanatory.
|
||||||
pair_coeff command before running a simulation.
|
|
||||||
|
|
||||||
E: Too many atom pairs for pair bop
|
|
||||||
|
|
||||||
The number of atomic pairs exceeds the expected number. Check your
|
|
||||||
atomic structure to ensure that it is realistic.
|
|
||||||
|
|
||||||
E: Too many atom triplets for pair bop
|
|
||||||
|
|
||||||
The number of three atom groups for angle determinations exceeds the
|
|
||||||
expected number. Check your atomic structure to ensure that it is
|
|
||||||
realistic.
|
|
||||||
|
|
||||||
E: Cannot open BOP potential file %s
|
E: Cannot open BOP potential file %s
|
||||||
|
|
||||||
The specified BOP potential file cannot be opened. Check that the
|
Self-explanatory.
|
||||||
path and name are correct.
|
|
||||||
|
|
||||||
E: Incorrect table format check for element types
|
E: Incorrect table format check for element types
|
||||||
|
|
||||||
@ -264,6 +194,12 @@ Self-explanatory.
|
|||||||
|
|
||||||
E: Unsupported BOP potential file format
|
E: Unsupported BOP potential file format
|
||||||
|
|
||||||
|
Self-explanatory.
|
||||||
|
|
||||||
|
E: Pair style bop requires system dimension of at least %g
|
||||||
|
|
||||||
|
Self-explanatory.
|
||||||
|
|
||||||
UNDOCUMENTED
|
UNDOCUMENTED
|
||||||
|
|
||||||
*/
|
*/
|
||||||
|
|||||||
279
src/tabular_function.cpp
Normal file
279
src/tabular_function.cpp
Normal file
@ -0,0 +1,279 @@
|
|||||||
|
/* ----------------------------------------------------------------------
|
||||||
|
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
|
||||||
|
http://lammps.sandia.gov, Sandia National Laboratories
|
||||||
|
Steve Plimpton, sjplimp@sandia.gov
|
||||||
|
|
||||||
|
Copyright (2003) Sandia Corporation. Under the terms of Contract
|
||||||
|
DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
|
||||||
|
certain rights in this software. This software is distributed under
|
||||||
|
the GNU General Public License.
|
||||||
|
|
||||||
|
See the README file in the top-level LAMMPS directory.
|
||||||
|
------------------------------------------------------------------------- */
|
||||||
|
|
||||||
|
#include "tabular_function.h"
|
||||||
|
|
||||||
|
#include <cmath>
|
||||||
|
#include <cstring>
|
||||||
|
|
||||||
|
using namespace LAMMPS_NS;
|
||||||
|
|
||||||
|
TabularFunction::TabularFunction()
|
||||||
|
: size(0), xmin(0.0), xmax(0.0), xmaxsq(0.0), rdx(0.0), vmax(0.0),
|
||||||
|
xs(nullptr), ys(nullptr), ys1(nullptr), ys2(nullptr), ys3(nullptr),
|
||||||
|
ys4(nullptr), ys5(nullptr), ys6(nullptr) {}
|
||||||
|
|
||||||
|
TabularFunction::TabularFunction(int n, double x1, double x2)
|
||||||
|
: TabularFunction()
|
||||||
|
{
|
||||||
|
set_xrange(x1, x2);
|
||||||
|
reset_size(n);
|
||||||
|
}
|
||||||
|
|
||||||
|
TabularFunction::~TabularFunction()
|
||||||
|
{
|
||||||
|
delete [] xs;
|
||||||
|
delete [] ys;
|
||||||
|
delete [] ys1;
|
||||||
|
delete [] ys2;
|
||||||
|
delete [] ys3;
|
||||||
|
delete [] ys4;
|
||||||
|
delete [] ys5;
|
||||||
|
delete [] ys6;
|
||||||
|
}
|
||||||
|
|
||||||
|
void TabularFunction::set_values(int n, double x1, double x2, double *values)
|
||||||
|
{
|
||||||
|
reset_size(n);
|
||||||
|
set_xrange(x1, x2);
|
||||||
|
memcpy(ys, values, n*sizeof(double));
|
||||||
|
initialize();
|
||||||
|
}
|
||||||
|
|
||||||
|
void TabularFunction::set_values(int n, double x1, double x2, double *values, double epsilon)
|
||||||
|
{
|
||||||
|
int ilo=0,ihi=n-1;
|
||||||
|
double vlo, vhi;
|
||||||
|
|
||||||
|
// get lo/hi boundaries where value < epsilon to shrink stored table
|
||||||
|
for (int i = ilo; ((fabs(values[i]) <= epsilon) && (i < n)); ++i)
|
||||||
|
ilo = i;
|
||||||
|
for (int i = ihi; ((fabs(values[i]) <= epsilon) && (i >= 0)); --i)
|
||||||
|
ihi = i;
|
||||||
|
if (ihi < ilo) ihi = ilo;
|
||||||
|
|
||||||
|
vlo = values[ilo];
|
||||||
|
vhi = values[ilo];
|
||||||
|
for (int i = ilo; i <= ihi; ++i) {
|
||||||
|
if (vlo > values[i]) vlo = values[i];
|
||||||
|
if (vhi < values[i]) vhi = values[i];
|
||||||
|
}
|
||||||
|
|
||||||
|
// do not shrink small tables
|
||||||
|
if (ihi - ilo < 50) {
|
||||||
|
ilo = 0;
|
||||||
|
ihi = n-1;
|
||||||
|
}
|
||||||
|
|
||||||
|
xmin = x1 + (x2-x1)/(n -1)*ilo;
|
||||||
|
xmax = xmin + (x2-x1)/(n -1)*(ihi-ilo);
|
||||||
|
xmaxsq = xmax*xmax;
|
||||||
|
n = ihi - ilo + 1;
|
||||||
|
reset_size(n);
|
||||||
|
for (int i = ilo; i <= ihi; i++) {
|
||||||
|
ys[i-ilo] = values[i];
|
||||||
|
}
|
||||||
|
initialize();
|
||||||
|
}
|
||||||
|
|
||||||
|
void TabularFunction::set_xrange(double x1, double x2)
|
||||||
|
{
|
||||||
|
xmin = x1;
|
||||||
|
xmax = x2;
|
||||||
|
xmaxsq = x2*x2;
|
||||||
|
}
|
||||||
|
|
||||||
|
void TabularFunction::reset_size(int n)
|
||||||
|
{
|
||||||
|
if (n != size) {
|
||||||
|
size = n;
|
||||||
|
delete [] xs;
|
||||||
|
delete [] ys;
|
||||||
|
delete [] ys1;
|
||||||
|
delete [] ys2;
|
||||||
|
delete [] ys3;
|
||||||
|
delete [] ys4;
|
||||||
|
delete [] ys5;
|
||||||
|
delete [] ys6;
|
||||||
|
xs = new double[n];
|
||||||
|
ys = new double[n];
|
||||||
|
ys1 = new double[n];
|
||||||
|
ys2 = new double[n];
|
||||||
|
ys3 = new double[n];
|
||||||
|
ys4 = new double[n];
|
||||||
|
ys5 = new double[n];
|
||||||
|
ys6 = new double[n];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void TabularFunction::initialize()
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
rdx = (xmax - xmin) / (size - 1.0);
|
||||||
|
for (i = 0; i < size; i++) xs[i] = xmin + i * rdx;
|
||||||
|
rdx = 1.0 / rdx;
|
||||||
|
ys1[0] = ys[1] - ys[0];
|
||||||
|
ys1[1] = 0.5 * (ys[2] - ys[0]);
|
||||||
|
ys1[size - 2] = 0.5 * (ys[size - 1] - ys[size - 3]);
|
||||||
|
ys1[size - 1] = ys[size - 1] - ys[size - 2];
|
||||||
|
for (i = 2; i < size - 2; i++)
|
||||||
|
ys1[i] = ((ys[i - 2] - ys[i + 2]) + 8.0 * (ys[i + 1] - ys[i - 1])) / 12.0;
|
||||||
|
for (i = 0; i < size - 1; i++) {
|
||||||
|
ys2[i] = 3.0 * (ys[i + 1] - ys[i]) - 2.0 * ys1[i] - ys1[i + 1];
|
||||||
|
ys3[i] = ys1[i] + ys1[i + 1] - 2.0 * (ys[i + 1] - ys[i]);
|
||||||
|
}
|
||||||
|
ys2[size - 1] = 0.0;
|
||||||
|
ys3[size - 1] = 0.0;
|
||||||
|
for (i = 0; i < size; i++) {
|
||||||
|
ys4[i] = ys1[i] * rdx;
|
||||||
|
ys5[i] = 2.0 * ys2[i] * rdx;
|
||||||
|
ys6[i] = 3.0 * ys3[i] * rdx;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#if 0
|
||||||
|
void set_values(int n, double x1, double x2, double * values, double epsilon)
|
||||||
|
{
|
||||||
|
int shrink = 1;
|
||||||
|
int ilo,ihi;
|
||||||
|
double vlo,vhi;
|
||||||
|
ilo = 0;
|
||||||
|
ihi = n-1;
|
||||||
|
for (int i = 0; i < n; i++) {
|
||||||
|
if (fabs(values[i]) <= epsilon) {
|
||||||
|
ilo = i;
|
||||||
|
} else {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (int i = n-1; i >= 0; i--) {
|
||||||
|
if (fabs(values[i]) <= epsilon) {
|
||||||
|
ihi = i;
|
||||||
|
} else {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (ihi < ilo) ihi = ilo;
|
||||||
|
vlo = values[ilo];
|
||||||
|
vhi = values[ilo];
|
||||||
|
for (int i = ilo; i <= ihi; i++) {
|
||||||
|
if (vlo > values[i]) vlo = values[i];
|
||||||
|
if (vhi < values[i]) vhi = values[i];
|
||||||
|
}
|
||||||
|
|
||||||
|
// shrink (remove near zero points) reduces cutoff radius, and therefore computational cost
|
||||||
|
// do not shrink when x2 < 1.1 (angular function) or x2 > 20.0 (non-radial function)
|
||||||
|
if (x2 < 1.1 || x2 > 20.0) {
|
||||||
|
shrink = 0;
|
||||||
|
}
|
||||||
|
// do not shrink when when list is abnormally small
|
||||||
|
if (ihi - ilo < 50) {
|
||||||
|
shrink = 0;
|
||||||
|
}
|
||||||
|
// shrink if it is a constant
|
||||||
|
if (vhi - vlo <= epsilon) {
|
||||||
|
// shrink = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (shrink == 0) {
|
||||||
|
ilo = 0;
|
||||||
|
ihi = n-1;
|
||||||
|
}
|
||||||
|
xmin = x1 + (x2-x1)/(n -1)*ilo;
|
||||||
|
xmax = xmin + (x2-x1)/(n -1)*(ihi-ilo);
|
||||||
|
xmaxsq = xmax*xmax;
|
||||||
|
n = ihi - ilo + 1;
|
||||||
|
resize(n);
|
||||||
|
for (int i = ilo; i <= ihi; i++) {
|
||||||
|
ys[i-ilo] = values[i];
|
||||||
|
}
|
||||||
|
initialize();
|
||||||
|
}
|
||||||
|
void value(double x, double &y, int ny, double &y1, int ny1)
|
||||||
|
{
|
||||||
|
double ps = (x - xmin) * rdx;
|
||||||
|
int ks = ps + 0.5;
|
||||||
|
if (ks > size-1) ks = size-1;
|
||||||
|
if (ks < 0 ) ks = 0;
|
||||||
|
ps = ps - ks;
|
||||||
|
if (ny) y = ((ys3[ks]*ps + ys2[ks])*ps + ys1[ks])*ps + ys[ks];
|
||||||
|
if (ny1) y1 = (ys6[ks]*ps + ys5[ks])*ps + ys4[ks];
|
||||||
|
}
|
||||||
|
void print_value()
|
||||||
|
{
|
||||||
|
printf("%d %f %f %f \n",size,xmin,xmax,rdx);
|
||||||
|
printf(" \n");
|
||||||
|
for (int i = 0; i < size; i++) {
|
||||||
|
printf("%f %f \n",xs[i],ys[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected:
|
||||||
|
|
||||||
|
void resize(int n) {
|
||||||
|
if (n != size) {
|
||||||
|
size = n;
|
||||||
|
delete [] xs;
|
||||||
|
xs = new double[n];
|
||||||
|
delete [] ys;
|
||||||
|
ys = new double[n];
|
||||||
|
delete [] ys1;
|
||||||
|
ys1 = new double[n];
|
||||||
|
delete [] ys2;
|
||||||
|
ys2 = new double[n];
|
||||||
|
delete [] ys3;
|
||||||
|
ys3 = new double[n];
|
||||||
|
delete [] ys4;
|
||||||
|
ys4 = new double[n];
|
||||||
|
delete [] ys5;
|
||||||
|
ys5 = new double[n];
|
||||||
|
delete [] ys6;
|
||||||
|
ys6 = new double[n];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
void initialize() {
|
||||||
|
int n = size;
|
||||||
|
rdx = (xmax-xmin)/(n-1.0);
|
||||||
|
vmax = 0.0;
|
||||||
|
for (int i = 0; i < n; i++) {
|
||||||
|
if (fabs(ys[i]) > vmax) vmax = fabs(ys[i]);
|
||||||
|
}
|
||||||
|
for (int i = 0; i < n; i++) {
|
||||||
|
xs[i] = xmin+i*rdx;
|
||||||
|
}
|
||||||
|
rdx = 1.0 / rdx;
|
||||||
|
ys1[0] = ys[1] - ys[0];
|
||||||
|
ys1[1] = 0.5 * (ys[2] - ys[0]);
|
||||||
|
ys1[n-2] = 0.5 * (ys[n-1] - ys[n-3]);
|
||||||
|
ys1[n-1] = ys[n-1] - ys[n-2];
|
||||||
|
for (int i = 2; i < n-2; i++) {
|
||||||
|
ys1[i]=((ys[i-2]-ys[i+2])+ 8.0*(ys[i+1]-ys[i-1]))/12.0;
|
||||||
|
}
|
||||||
|
for (int i = 0; i < n-1; i++) {
|
||||||
|
ys2[i]=3.0*(ys[i+1]-ys[i])-2.0*ys1[i]-ys1[i+1];
|
||||||
|
ys3[i]=ys1[i]+ys1[i+1]-2.0*(ys[i+1]-ys[i]);
|
||||||
|
}
|
||||||
|
ys2[n-1]=0.0;
|
||||||
|
ys3[n-1]=0.0;
|
||||||
|
for (int i = 0; i < n; i++) {
|
||||||
|
ys4[i]=ys1[i]*rdx;
|
||||||
|
ys5[i]=2.0*ys2[i]*rdx;
|
||||||
|
ys6[i]=3.0*ys3[i]*rdx;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
int size;
|
||||||
|
double xmin,xmax,xmaxsq,rdx,vmax;
|
||||||
|
double *ys, *ys1, *ys2, *ys3, *ys4, *ys5, *ys6;
|
||||||
|
double *xs;
|
||||||
|
};
|
||||||
|
#endif
|
||||||
68
src/tabular_function.h
Normal file
68
src/tabular_function.h
Normal file
@ -0,0 +1,68 @@
|
|||||||
|
/* -*- c++ -*- ----------------------------------------------------------
|
||||||
|
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
|
||||||
|
https://lammps.sandia.gov/, Sandia National Laboratories
|
||||||
|
Steve Plimpton, sjplimp@sandia.gov
|
||||||
|
|
||||||
|
Copyright (2003) Sandia Corporation. Under the terms of Contract
|
||||||
|
DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
|
||||||
|
certain rights in this software. This software is distributed under
|
||||||
|
the GNU General Public License.
|
||||||
|
|
||||||
|
See the README file in the top-level LAMMPS directory.
|
||||||
|
------------------------------------------------------------------------- */
|
||||||
|
|
||||||
|
#ifndef LMP_TABULAR_FUNCTION_H
|
||||||
|
#define LMP_TABULAR_FUNCTION_H
|
||||||
|
|
||||||
|
namespace LAMMPS_NS {
|
||||||
|
class TabularFunction {
|
||||||
|
public:
|
||||||
|
TabularFunction();
|
||||||
|
TabularFunction(int, double, double);
|
||||||
|
virtual ~TabularFunction();
|
||||||
|
|
||||||
|
void set_values(int, double, double, double *);
|
||||||
|
void set_values(int, double, double, double *, double);
|
||||||
|
|
||||||
|
private:
|
||||||
|
int size;
|
||||||
|
double xmin, xmax, xmaxsq, rdx, vmax;
|
||||||
|
double *xs, *ys, *ys1, *ys2, *ys3, *ys4, *ys5, *ys6;
|
||||||
|
|
||||||
|
void set_xrange(double x1, double x2);
|
||||||
|
void reset_size(int);
|
||||||
|
void initialize();
|
||||||
|
|
||||||
|
public:
|
||||||
|
void value(double x, double &y, int ny, double &y1, int ny1)
|
||||||
|
{
|
||||||
|
double ps = (x - xmin) * rdx + 1.0;
|
||||||
|
int ks = ps;
|
||||||
|
if (ks > size - 1) ks = size - 1;
|
||||||
|
ps = ps - ks;
|
||||||
|
if (ps > 1.0) ps = 1.0;
|
||||||
|
if (ny)
|
||||||
|
y = ((ys3[ks - 1] * ps + ys2[ks - 1]) * ps + ys1[ks - 1]) * ps +
|
||||||
|
ys[ks - 1];
|
||||||
|
if (ny1) y1 = (ys6[ks - 1] * ps + ys5[ks - 1]) * ps + ys4[ks - 1];
|
||||||
|
}
|
||||||
|
void value2(double x, double &y, int ny, double &y1, int ny1)
|
||||||
|
{
|
||||||
|
double ps = (x - xmin) * rdx;
|
||||||
|
int ks = ps + 0.5;
|
||||||
|
if (ks > size-1) ks = size-1;
|
||||||
|
if (ks < 0 ) ks = 0;
|
||||||
|
ps = ps - ks;
|
||||||
|
if (ny) y = ((ys3[ks]*ps + ys2[ks])*ps + ys1[ks])*ps + ys[ks];
|
||||||
|
if (ny1) y1 = (ys6[ks]*ps + ys5[ks])*ps + ys4[ks];
|
||||||
|
}
|
||||||
|
|
||||||
|
double get_xmin() const { return xmin; }
|
||||||
|
double get_xmax() const { return xmax; }
|
||||||
|
double get_xmaxsq() const { return xmaxsq; }
|
||||||
|
double get_rdx() const { return rdx; }
|
||||||
|
double get_vmax() { return vmax; }
|
||||||
|
};
|
||||||
|
} // namespace LAMMPS_NS
|
||||||
|
|
||||||
|
#endif
|
||||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user