mirror of https://github.com/lammps/lammps.git
Merge branch 'pod' of https://github.com/cesmix-mit/lammps into pod
This commit is contained in:
commit
78c4f46565
|
@ -12,7 +12,7 @@ Go to `lammps` directory and build with the POD package:
|
|||
|
||||
Go to `lammps/examples/pod/Ta` directory and run
|
||||
|
||||
lmp -n in.podfit
|
||||
lmp -in in.podfit
|
||||
|
||||
See the README in `lammps/examples/pod/Ta` for instructions on how to run MD with the potential.
|
||||
|
||||
|
|
|
@ -24,7 +24,7 @@ mass 1 180.88
|
|||
|
||||
|
||||
# POD potential
|
||||
pair_style pod
|
||||
pair_style mlpod
|
||||
pair_coeff * * pod.txt coefficients.txt Ta
|
||||
|
||||
# Setup output
|
||||
|
|
|
@ -26,6 +26,7 @@
|
|||
#include "neigh_list.h"
|
||||
#include "neighbor.h"
|
||||
#include "pair.h"
|
||||
#include "pod.h"
|
||||
#include "tokenizer.h"
|
||||
#include "update.h"
|
||||
|
||||
|
@ -493,13 +494,13 @@ void CFITPOD::get_data(datastruct &data, std::vector<std::string> species)
|
|||
utils::logmesg(lmp, "number of atoms in all files: {}\n", data.num_atom_sum);
|
||||
|
||||
int n = data.num_config_sum;
|
||||
data.lattice = (double *) malloc(9*n*sizeof(double));
|
||||
data.stress = (double *) malloc(9*n*sizeof(double));
|
||||
data.energy = (double *) malloc(n*sizeof(double));
|
||||
memory->create(data.lattice, 9*n, "fitpod:lattice");
|
||||
memory->create(data.stress, 9*n, "fitpod:stress");
|
||||
memory->create(data.energy, n, "fitpod:energy");
|
||||
n = data.num_atom_sum;
|
||||
data.position = (double *) malloc(3*n*sizeof(double));
|
||||
data.force = (double *) malloc(3*n*sizeof(double));
|
||||
data.atomtype = (int *) malloc(n*sizeof(int));
|
||||
memory->create(data.position, 3*n, "fitpod:position");
|
||||
memory->create(data.force, 3*n, "fitpod:force");
|
||||
memory->create(data.atomtype, n, "fitpod:atomtype");
|
||||
|
||||
int nfiles = data.data_files.size(); // number of files
|
||||
int nconfigs = 0;
|
||||
|
@ -651,13 +652,13 @@ void CFITPOD::select_data(datastruct &newdata, datastruct data)
|
|||
newdata.num_config_sum = newdata.num_atom.size();
|
||||
|
||||
int n = data.num_config_sum;
|
||||
newdata.lattice = (double *) malloc(9*n*sizeof(double));
|
||||
newdata.stress = (double *) malloc(9*n*sizeof(double));
|
||||
newdata.energy = (double *) malloc(n*sizeof(double));
|
||||
memory->create(newdata.lattice, 9*n, "fitpod:newdata_lattice");
|
||||
memory->create(newdata.stress, 9*n, "fitpod:newdata_stress");
|
||||
memory->create(newdata.energy, n, "fitpod:newdata_energy");
|
||||
n = data.num_atom_sum;
|
||||
newdata.position = (double *) malloc(3*n*sizeof(double));
|
||||
newdata.force = (double *) malloc(3*n*sizeof(double));
|
||||
newdata.atomtype = (int *) malloc(n*sizeof(int));
|
||||
memory->create(newdata.position, 3*n, "fitpod:newdata_position");
|
||||
memory->create(newdata.force, 3*n, "fitpod:newdata_force");
|
||||
memory->create(newdata.atomtype, n, "fitpod:newdata_atomtype");
|
||||
|
||||
int cn = 0, dim=3;
|
||||
for (int file = 0; file < nfiles; file++) {
|
||||
|
@ -853,10 +854,10 @@ int CFITPOD::podfullneighborlist(double *y, int *alist, int *neighlist, int *num
|
|||
void CFITPOD::allocate_memory(datastruct data)
|
||||
{
|
||||
int nd = podptr->pod.nd;
|
||||
desc.gd = (double *) malloc(nd*sizeof(double));
|
||||
desc.A = (double *) malloc(nd*nd*sizeof(double));
|
||||
desc.b = (double *) malloc(nd*sizeof(double));
|
||||
desc.c = (double *) malloc(nd*sizeof(double));
|
||||
memory->create(desc.gd, nd, "fitpod:desc_gd");
|
||||
memory->create(desc.A, nd*nd, "fitpod:desc_A");
|
||||
memory->create(desc.b, nd, "fitpod:desc_b");
|
||||
memory->create(desc.c, nd, "fitpod:desc_c");
|
||||
podptr->podArraySetValue(desc.A, 0.0, nd*nd);
|
||||
podptr->podArraySetValue(desc.b, 0.0, nd);
|
||||
podptr->podArraySetValue(desc.c, 0.0, nd);
|
||||
|
@ -899,11 +900,11 @@ void CFITPOD::allocate_memory(datastruct data)
|
|||
np = PODMAX(np, natom*natom*nl);
|
||||
}
|
||||
|
||||
nb.y = (double*) malloc (sizeof (double)*(ny));
|
||||
nb.alist = (int*) malloc (sizeof (int)*(na));
|
||||
nb.pairnum = (int*) malloc (sizeof (int)*(natom_max));
|
||||
nb.pairnum_cumsum = (int*) malloc (sizeof (int)*(natom_max+1));
|
||||
nb.pairlist = (int*) malloc (sizeof (int)*(np));
|
||||
memory->create(nb.y, ny, "fitpod:nb_y");
|
||||
memory->create(nb.alist, na, "fitpod:nb_alist");
|
||||
memory->create(nb.pairnum, natom_max, "fitpod:nb_pairnum");
|
||||
memory->create(nb.pairnum_cumsum, natom_max+1, "fitpod:nb_pairnum_cumsum");
|
||||
memory->create(nb.pairlist, np, "fitpod:nb_pairlist");
|
||||
|
||||
nb.natom_max = natom_max;
|
||||
nb.sze = nelements*nelements;
|
||||
|
@ -950,8 +951,8 @@ void CFITPOD::allocate_memory(datastruct data)
|
|||
|
||||
// gdd includes linear descriptors derivatives, quadratic descriptors derivatives and temporary memory
|
||||
|
||||
desc.gdd = (double*) malloc (sizeof (double)*(szd)); // [ldd qdd]
|
||||
desc.tmpint = (int*) malloc (sizeof (int)*(szi));
|
||||
memory->create(desc.gdd, szd, "fitpod:desc_gdd");
|
||||
memory->create(desc.tmpint, szi, "fitpod:desc_tmpint");
|
||||
desc.szd = szd;
|
||||
desc.szi = szi;
|
||||
|
||||
|
|
|
@ -26,14 +26,12 @@ CommandStyle(fitpod,CFITPOD);
|
|||
#define LMP_FITPOD_COMMAND_H
|
||||
|
||||
#include "command.h"
|
||||
#include "pod.h"
|
||||
|
||||
namespace LAMMPS_NS {
|
||||
|
||||
class CFITPOD : public Command {
|
||||
private:
|
||||
|
||||
//class NeighList *list;
|
||||
std::vector<std::string> globVector(const std::string& pattern, std::vector<std::string> & files);
|
||||
|
||||
bool is_a_number(std::string line);
|
||||
|
|
|
@ -29,13 +29,12 @@
|
|||
|
||||
#include <cmath>
|
||||
#include <cstring>
|
||||
#include <sys/time.h>
|
||||
|
||||
using namespace LAMMPS_NS;
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
CPairPOD::CPairPOD(LAMMPS *lmp) : Pair(lmp)
|
||||
PairPOD::PairPOD(LAMMPS *lmp) : Pair(lmp)
|
||||
{
|
||||
single_enable = 0;
|
||||
restartinfo = 0;
|
||||
|
@ -47,7 +46,7 @@ CPairPOD::CPairPOD(LAMMPS *lmp) : Pair(lmp)
|
|||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
CPairPOD::~CPairPOD()
|
||||
PairPOD::~PairPOD()
|
||||
{
|
||||
free_memory();
|
||||
memory->destroy(podcoeff);
|
||||
|
@ -65,7 +64,7 @@ CPairPOD::~CPairPOD()
|
|||
}
|
||||
}
|
||||
|
||||
void CPairPOD::compute(int eflag, int vflag)
|
||||
void PairPOD::compute(int eflag, int vflag)
|
||||
{
|
||||
ev_init(eflag,vflag);
|
||||
vflag_fdotr = 1;
|
||||
|
@ -153,7 +152,7 @@ void CPairPOD::compute(int eflag, int vflag)
|
|||
global settings
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
void CPairPOD::settings(int narg, char ** /* arg */)
|
||||
void PairPOD::settings(int narg, char ** /* arg */)
|
||||
{
|
||||
if (narg > 0)
|
||||
error->all(FLERR,"Illegal pair_style command");
|
||||
|
@ -163,7 +162,7 @@ void CPairPOD::settings(int narg, char ** /* arg */)
|
|||
set coeffs for one or more type pairs
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
void CPairPOD::coeff(int narg, char **arg)
|
||||
void PairPOD::coeff(int narg, char **arg)
|
||||
{
|
||||
int n = atom->ntypes;
|
||||
memory->create(setflag,n+1,n+1,"pair:setflag");
|
||||
|
@ -179,15 +178,20 @@ void CPairPOD::coeff(int narg, char **arg)
|
|||
|
||||
map_element2type(narg-4,arg+4);
|
||||
|
||||
//std::cout<<map[0]<<std::endl;
|
||||
//std::cout<<map[1]<<std::endl;
|
||||
//std::cout<<map[2]<<std::endl;
|
||||
//std::cout<<map[3]<<std::endl;
|
||||
|
||||
std::string pod_file = std::string(arg[2]); // pod input file
|
||||
std::string coeff_file = std::string(arg[3]); // coefficient input file
|
||||
|
||||
InitPairPOD(pod_file, coeff_file);
|
||||
podptr = new CPOD(lmp, pod_file, coeff_file);
|
||||
|
||||
if (coeff_file != "") {
|
||||
memory->create(podcoeff, podptr->pod.nd, "pair:podcoeff");
|
||||
memory->create(newpodcoeff, podptr->pod.nd, "pair:newpodcoeff");
|
||||
memory->create(energycoeff, podptr->pod.nd1234, "pair:energycoeff");
|
||||
memory->create(forcecoeff, podptr->pod.nd1234, "pair:forcecoeff");
|
||||
memory->create(gd, podptr->pod.nd1234, "pair:gd");
|
||||
podptr->podArrayCopy(podcoeff, podptr->pod.coeff, podptr->pod.nd);
|
||||
podptr->podArrayCopy(newpodcoeff, podptr->pod.coeff, podptr->pod.nd);
|
||||
}
|
||||
|
||||
for (int ii = 0; ii < n+1; ii++)
|
||||
for (int jj = 0; jj < n+1; jj++)
|
||||
|
@ -198,7 +202,7 @@ void CPairPOD::coeff(int narg, char **arg)
|
|||
init specific to this pair style
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
void CPairPOD::init_style()
|
||||
void PairPOD::init_style()
|
||||
{
|
||||
if (force->newton_pair == 0)
|
||||
error->all(FLERR,"Pair style POD requires newton pair on");
|
||||
|
@ -212,7 +216,7 @@ void CPairPOD::init_style()
|
|||
init for one type pair i,j and corresponding j,i
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
double CPairPOD::init_one(int i, int j)
|
||||
double PairPOD::init_one(int i, int j)
|
||||
{
|
||||
if (setflag[i][j] == 0) error->all(FLERR,"All pair coeffs are not set");
|
||||
scale[j][i] = scale[i][j];
|
||||
|
@ -223,38 +227,20 @@ double CPairPOD::init_one(int i, int j)
|
|||
memory usage
|
||||
------------------------------------------------------------------------- */
|
||||
|
||||
double CPairPOD::memory_usage()
|
||||
double PairPOD::memory_usage()
|
||||
{
|
||||
double bytes = Pair::memory_usage();
|
||||
return bytes;
|
||||
}
|
||||
|
||||
void *CPairPOD::extract(const char *str, int &dim)
|
||||
void *PairPOD::extract(const char *str, int &dim)
|
||||
{
|
||||
dim = 2;
|
||||
if (strcmp(str,"scale") == 0) return (void *) scale;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void CPairPOD::InitPairPOD(std::string pod_file, std::string coeff_file)
|
||||
{
|
||||
podptr = new CPOD(lmp, pod_file, coeff_file);
|
||||
|
||||
lammpspairlist = 1;
|
||||
|
||||
if (coeff_file != "") {
|
||||
memory->create(podcoeff, podptr->pod.nd, "pair:podcoeff");
|
||||
memory->create(newpodcoeff, podptr->pod.nd, "pair:newpodcoeff");
|
||||
memory->create(energycoeff, podptr->pod.nd1234, "pair:energycoeff");
|
||||
memory->create(forcecoeff, podptr->pod.nd1234, "pair:forcecoeff");
|
||||
memory->create(gd, podptr->pod.nd1234, "pair:gd");
|
||||
podptr->podArrayCopy(podcoeff, podptr->pod.coeff, podptr->pod.nd);
|
||||
podptr->podArrayCopy(newpodcoeff, podptr->pod.coeff, podptr->pod.nd);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void CPairPOD::free_tempmemory()
|
||||
void PairPOD::free_tempmemory()
|
||||
{
|
||||
memory->destroy(rij);
|
||||
memory->destroy(idxi);
|
||||
|
@ -267,7 +253,7 @@ void CPairPOD::free_tempmemory()
|
|||
memory->destroy(tmpmem);
|
||||
}
|
||||
|
||||
void CPairPOD::free_atommemory()
|
||||
void PairPOD::free_atommemory()
|
||||
{
|
||||
memory->destroy(forces);
|
||||
memory->destroy(stress);
|
||||
|
@ -278,13 +264,13 @@ void CPairPOD::free_atommemory()
|
|||
}
|
||||
}
|
||||
|
||||
void CPairPOD::free_memory()
|
||||
void PairPOD::free_memory()
|
||||
{
|
||||
free_tempmemory();
|
||||
free_atommemory();
|
||||
}
|
||||
|
||||
void CPairPOD::allocate_tempmemory()
|
||||
void PairPOD::allocate_tempmemory()
|
||||
{
|
||||
memory->create(rij, dim*nijmax, "pair:rij");
|
||||
memory->create(idxi, nijmax, "pair:idxi");
|
||||
|
@ -297,7 +283,7 @@ void CPairPOD::allocate_tempmemory()
|
|||
memory->create(tmpmem, szd, "pair:tmpmem");
|
||||
}
|
||||
|
||||
void CPairPOD::allocate_atommemory()
|
||||
void PairPOD::allocate_atommemory()
|
||||
{
|
||||
memory->create(forces, dim*nmaxatom, "pair:forces");
|
||||
memory->create(stress, 9, "pair:stress");
|
||||
|
@ -308,7 +294,7 @@ void CPairPOD::allocate_atommemory()
|
|||
}
|
||||
}
|
||||
|
||||
void CPairPOD::allocate_memory()
|
||||
void PairPOD::allocate_memory()
|
||||
{
|
||||
|
||||
allocate_tempmemory();
|
||||
|
@ -316,7 +302,7 @@ void CPairPOD::allocate_memory()
|
|||
|
||||
}
|
||||
|
||||
void CPairPOD::check_atommemory(int inum, int nall)
|
||||
void PairPOD::check_atommemory(int inum, int nall)
|
||||
{
|
||||
|
||||
if (nmaxatom < nall) {
|
||||
|
@ -331,7 +317,7 @@ void CPairPOD::check_atommemory(int inum, int nall)
|
|||
|
||||
}
|
||||
|
||||
void CPairPOD::estimate_tempmemory()
|
||||
void PairPOD::estimate_tempmemory()
|
||||
{
|
||||
int nrbf2 = podptr->pod.nbf2;
|
||||
int nabf3 = podptr->pod.nabf3;
|
||||
|
@ -352,7 +338,7 @@ void CPairPOD::estimate_tempmemory()
|
|||
szd = nablockmax*(podptr->pod.nd1234) + szd;
|
||||
}
|
||||
|
||||
void CPairPOD::lammpsNeighPairs(double **x, int **firstneigh, int *atomtypes, int *map, int *numneigh, int gi)
|
||||
void PairPOD::lammpsNeighPairs(double **x, int **firstneigh, int *atomtypes, int *map, int *numneigh, int gi)
|
||||
{
|
||||
|
||||
double rcutsq = podptr->pod.rcut*podptr->pod.rcut;
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
|
||||
#ifdef PAIR_CLASS
|
||||
// clang-format off
|
||||
PairStyle(pod,CPairPOD);
|
||||
PairStyle(mlpod,PairPOD);
|
||||
// clang-format on
|
||||
#else
|
||||
|
||||
|
@ -28,62 +28,11 @@ PairStyle(pod,CPairPOD);
|
|||
|
||||
namespace LAMMPS_NS {
|
||||
|
||||
class CPairPOD : public Pair {
|
||||
private:
|
||||
std::vector<std::string> globVector(const std::string& pattern, std::vector<std::string> & files);
|
||||
|
||||
bool is_a_number(std::string line);
|
||||
|
||||
int latticecoords(double *y, int *alist, double *x, double *a1, double *a2, double *a3, double rcut, int *pbc, int nx);
|
||||
|
||||
int podneighborcount(double *r, double rcutsq, int nx, int N, int dim);
|
||||
int podneighborlist(int *neighlist, int *numneigh, double *r, double rcutsq, int nx, int N, int dim);
|
||||
|
||||
void get_data(std::vector<std::string> species);
|
||||
|
||||
void read_data_files(std::string data_file, std::vector<std::string> species);
|
||||
|
||||
class PairPOD : public Pair {
|
||||
public:
|
||||
struct datastruct {
|
||||
std::string file_format;
|
||||
std::string file_extension;
|
||||
std::string data_path;
|
||||
std::vector<std::string> data_files;
|
||||
std::vector<std::string> filenames;
|
||||
|
||||
std::vector<int> num_atom;
|
||||
std::vector<int> num_atom_cumsum;
|
||||
std::vector<int> num_atom_each_file;
|
||||
std::vector<int> num_config;
|
||||
std::vector<int> num_config_cumsum;
|
||||
int num_atom_sum;
|
||||
int num_atom_min;
|
||||
int num_atom_max;
|
||||
int num_config_sum;
|
||||
|
||||
double *lattice=NULL;
|
||||
double *energy=NULL;
|
||||
double *stress=NULL;
|
||||
double *position=NULL;
|
||||
double *velocity=NULL;
|
||||
double *force=NULL;
|
||||
int *atomtype=NULL;
|
||||
|
||||
void copydatainfo(datastruct &data) {
|
||||
data.data_path = data_path;
|
||||
data.file_format = file_format;
|
||||
data.file_extension = file_extension;
|
||||
data.data_files = data_files;
|
||||
data.filenames = filenames;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
datastruct data;
|
||||
|
||||
CPairPOD(class LAMMPS *);
|
||||
~CPairPOD() override;
|
||||
void compute(int, int) override;
|
||||
PairPOD(class LAMMPS *);
|
||||
~PairPOD() override;
|
||||
void compute(int, int) override;
|
||||
|
||||
void settings(int, char **) override;
|
||||
void coeff(int, char **) override;
|
||||
|
@ -92,12 +41,9 @@ namespace LAMMPS_NS {
|
|||
double memory_usage() override;
|
||||
void *extract(const char *, int &) override;
|
||||
|
||||
void InitPairPOD(std::string pod_file, std::string coeff_file);
|
||||
|
||||
int dim = 3;
|
||||
int atommemory = 0;
|
||||
int podpairlist=0;
|
||||
int lammpspairlist=0;
|
||||
int analysis = 0;
|
||||
int runMD = 0;
|
||||
int savecalculation = 0;
|
||||
|
|
|
@ -328,17 +328,18 @@ void podsnapshots(double *rbf, double *xij, double *besselparams, double rin, do
|
|||
}
|
||||
}
|
||||
|
||||
void podeigenvaluedecomposition(double *Phi, double *Lambda, double *besselparams, double rin, double rcut,
|
||||
void CPOD::podeigenvaluedecomposition(double *Phi, double *Lambda, double *besselparams, double rin, double rcut,
|
||||
int besseldegree, int inversedegree, int nbesselpars, int N)
|
||||
{
|
||||
int ns = besseldegree*nbesselpars + inversedegree;
|
||||
|
||||
double *xij = (double *) malloc(N*sizeof(double));
|
||||
double *S = (double *) malloc(N*ns*sizeof(double));
|
||||
double *Q = (double *) malloc(N*ns*sizeof(double));
|
||||
double *A = (double *) malloc(ns*ns*sizeof(double));
|
||||
double *b = (double *) malloc(ns*sizeof(double));
|
||||
|
||||
memory->create(xij, N, "pod:xij");
|
||||
memory->create(S, N*ns, "pod:S");
|
||||
memory->create(Q, N*ns, "pod:Q");
|
||||
memory->create(A, ns*ns, "pod:A");
|
||||
memory->create(b, ns, "pod:ns");
|
||||
|
||||
for (int i=0; i<N; i++)
|
||||
xij[i] = (rin+1e-6) + (rcut-rin-1e-6)*(i*1.0/(N-1));
|
||||
|
||||
|
@ -391,8 +392,8 @@ void podeigenvaluedecomposition(double *Phi, double *Lambda, double *besselparam
|
|||
void CPOD::read_pod(std::string pod_file)
|
||||
{
|
||||
pod.nbesselpars = 3;
|
||||
pod.besselparams = (double *) malloc(3*sizeof(double));
|
||||
pod.pbc = (int *) malloc(3*sizeof(int));
|
||||
memory->create(pod.besselparams, 3, "pod:pod_besselparams");
|
||||
memory->create(pod.pbc, 3, "pod:pod_pbc");
|
||||
|
||||
pod.besselparams[0] = 0.0;
|
||||
pod.besselparams[1] = 2.0;
|
||||
|
@ -527,12 +528,12 @@ void CPOD::read_pod(std::string pod_file)
|
|||
|
||||
// allocate memory for eigenvectors and eigenvalues
|
||||
|
||||
pod.Phi2 = (double *) malloc(pod.ns2*pod.ns2*sizeof(double));
|
||||
pod.Lambda2 = (double *) malloc(pod.ns2*sizeof(double));
|
||||
pod.Phi3 = (double *) malloc(pod.ns3*pod.ns3*sizeof(double));
|
||||
pod.Lambda3 = (double *) malloc(pod.ns3*sizeof(double));
|
||||
pod.Phi4 = (double *) malloc(pod.ns4*pod.ns4*sizeof(double));
|
||||
pod.Lambda4 = (double *) malloc(pod.ns4*sizeof(double));
|
||||
memory->create(pod.Phi2, pod.ns2*pod.ns2, "pod:pod_Phi2");
|
||||
memory->create(pod.Lambda2, pod.ns2, "pod:pod_Lambda2");
|
||||
memory->create(pod.Phi3, pod.ns3*pod.ns3, "pod:pod_Phi3");
|
||||
memory->create(pod.Lambda3, pod.ns3, "pod:pod_Lambda3");
|
||||
memory->create(pod.Phi4, pod.ns4*pod.ns4, "pod:pod_Phi4");
|
||||
memory->create(pod.Lambda4, pod.ns4, "pod:pod_Lambda4");
|
||||
|
||||
if (pod.ns2>0) {
|
||||
podeigenvaluedecomposition(pod.Phi2, pod.Lambda2, pod.besselparams, pod.rin, pod.rcut,
|
||||
|
@ -650,7 +651,7 @@ void CPOD::read_pod(std::string pod_file)
|
|||
pod.nd1234 = pod.nd1 + pod.nd2 + pod.nd3 + pod.nd4;
|
||||
|
||||
int nelements = pod.nelements;
|
||||
pod.elemindex = (int*) malloc (sizeof (int)*(nelements*nelements));
|
||||
memory->create(pod.elemindex, nelements*nelements, "pod:pod_elemindex");
|
||||
|
||||
int k = 1;
|
||||
for (int i=0; i < nelements; i++)
|
||||
|
@ -743,7 +744,7 @@ void CPOD::read_coeff_file(std::string coeff_file)
|
|||
|
||||
// loop over single block of coefficients and insert values in pod.coeff
|
||||
|
||||
pod.coeff = (double *) malloc(ncoeffall*sizeof(double));
|
||||
memory->create(pod.coeff, ncoeffall, "pod:pod_coeff");
|
||||
|
||||
for (int icoeff = 0; icoeff < ncoeffall; icoeff++) {
|
||||
if (comm->me == 0) {
|
||||
|
@ -1643,18 +1644,12 @@ void CPOD::snapSetup(int twojmax, int ntypes)
|
|||
int jdim = twojmax + 1;
|
||||
int jdimpq = twojmax + 2;
|
||||
|
||||
memory->create(sna.map, ntypes+1, "sna:map");
|
||||
memory->create(sna.idxcg_block, jdim*jdim*jdim, "sna:idxcg_block");
|
||||
memory->create(sna.idxz_block, jdim*jdim*jdim, "sna:idxz_block");
|
||||
memory->create(sna.idxb_block, jdim*jdim*jdim, "sna:idxb_block");
|
||||
memory->create(sna.idxu_block, jdim, "sna:idxu_block");
|
||||
memory->create(sna.idx_max, 5, "sna:idx_max");
|
||||
//TemplateMalloc(&sna.map, ntypes+1, backend);
|
||||
// TemplateMalloc(&sna.idxcg_block, jdim*jdim*jdim, backend);
|
||||
// TemplateMalloc(&sna.idxz_block, jdim*jdim*jdim, backend);
|
||||
// TemplateMalloc(&sna.idxb_block, jdim*jdim*jdim, backend);
|
||||
// TemplateMalloc(&sna.idxu_block, jdim, backend);
|
||||
// TemplateMalloc(&sna.idx_max, 5, backend);
|
||||
memory->create(sna.map, ntypes+1, "pod:sna_map");
|
||||
memory->create(sna.idxcg_block, jdim*jdim*jdim, "pod:sna_idxcg_block");
|
||||
memory->create(sna.idxz_block, jdim*jdim*jdim, "pod:sna_idxz_block");
|
||||
memory->create(sna.idxb_block, jdim*jdim*jdim, "pod:sna_idxb_block");
|
||||
memory->create(sna.idxu_block, jdim, "pod:sna_idxu_block");
|
||||
memory->create(sna.idx_max, 5, "pod:sna_idx_max");
|
||||
|
||||
int idxb_count = 0;
|
||||
for(int j1 = 0; j1 <= twojmax; j1++)
|
||||
|
@ -1679,29 +1674,15 @@ void CPOD::snapSetup(int twojmax, int ntypes)
|
|||
idxcg_count++;
|
||||
}
|
||||
|
||||
memory->create(sna.idxz, idxz_count*10, "sna:idxz");
|
||||
memory->create(sna.idxb, idxb_count*3, "sna:idxb");
|
||||
|
||||
memory->create(sna.rcutsq, (ntypes+1)*(ntypes+1), "sna:rcutsq");
|
||||
memory->create(sna.radelem, ntypes+1, "sna:radelem");
|
||||
memory->create(sna.wjelem, ntypes+1, "sna:wjelem");
|
||||
|
||||
memory->create(sna.rootpqarray, jdimpq*jdimpq, "sna:rootpqarray");
|
||||
memory->create(sna.cglist, idxcg_count, "sna:cglist");
|
||||
memory->create(sna.bzero, jdim, "sna:bzero");
|
||||
memory->create(sna.fac, 168, "sna:fac");
|
||||
|
||||
// TemplateMalloc(&sna.idxz, idxz_count*10, backend);
|
||||
// TemplateMalloc(&sna.idxb, idxb_count*3, backend);
|
||||
//
|
||||
// TemplateMalloc(&sna.rcutsq, (ntypes+1)*(ntypes+1), backend);
|
||||
// TemplateMalloc(&sna.radelem, ntypes+1, backend);
|
||||
// TemplateMalloc(&sna.wjelem, ntypes+1, backend);
|
||||
//
|
||||
// TemplateMalloc(&sna.rootpqarray, jdimpq*jdimpq, backend);
|
||||
// TemplateMalloc(&sna.cglist, idxcg_count, backend);
|
||||
// TemplateMalloc(&sna.bzero, jdim, backend);
|
||||
// TemplateMalloc(&sna.fac, 168, backend);
|
||||
memory->create(sna.idxz, idxz_count*10, "pod:sna_idxz");
|
||||
memory->create(sna.idxb, idxb_count*3, "pod:sna_idxb");
|
||||
memory->create(sna.rcutsq, (ntypes+1)*(ntypes+1), "pod:sna_rcutsq");
|
||||
memory->create(sna.radelem, ntypes+1, "pod:sna_radelem");
|
||||
memory->create(sna.wjelem, ntypes+1, "pod:sna_wjelem");
|
||||
memory->create(sna.rootpqarray, jdimpq*jdimpq, "pod:sna_rootpqarray");
|
||||
memory->create(sna.cglist, idxcg_count, "pod:sna_cglist");
|
||||
memory->create(sna.bzero, jdim, "pod:sna_bzero");
|
||||
memory->create(sna.fac, 168, "pod:sna_fac");
|
||||
|
||||
for (int i=0; i<jdimpq*jdimpq; i++)
|
||||
sna.rootpqarray[i] = 0;
|
||||
|
@ -1739,7 +1720,8 @@ void CPOD::InitSnap()
|
|||
int bnormflag = chemflag;
|
||||
double wself=1.0;
|
||||
|
||||
// Calculate maximum cutoff for all elements
|
||||
// calculate maximum cutoff for all elements
|
||||
|
||||
double rcutmax = 0.0;
|
||||
for (int ielem = 0; ielem < ntypes; ielem++)
|
||||
rcutmax = PODMAX(2.0*elemradius[ielem]*rcutfac,rcutmax);
|
||||
|
|
|
@ -191,6 +191,11 @@ private:
|
|||
|
||||
void pod4body_force(double **force, double *rij, double *coeff4, double *tmpmem, int *atomtype,
|
||||
int *idxi, int *ai, int *aj, int *ti, int *tj, int natom, int Nij);
|
||||
|
||||
// *********************** eigenproblem functions **************************/
|
||||
|
||||
void podeigenvaluedecomposition(double *Phi, double *Lambda, double *besselparams, double rin, double rcut,
|
||||
int besseldegree, int inversedegree, int nbesselpars, int N);
|
||||
// ******************************************************************************/
|
||||
|
||||
public:
|
||||
|
@ -224,6 +229,8 @@ public:
|
|||
double *Phi2=NULL, *Phi3=NULL, *Phi4=NULL, *Lambda2=NULL, *Lambda3=NULL, *Lambda4=NULL;
|
||||
double *coeff=NULL;
|
||||
|
||||
// variables declaring number of snapshots, descriptors, and combinations
|
||||
|
||||
int nbesselpars = 3;
|
||||
int ns2, ns3, ns4; // number of snapshots for radial basis functions for linear POD potentials
|
||||
int nc2, nc3, nc4; // number of chemical combinations for linear POD potentials
|
||||
|
@ -240,12 +247,6 @@ public:
|
|||
double snapelementradius[10] = {0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5};
|
||||
double snapelementweight[10] = {1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0};
|
||||
|
||||
void allocatememory(int backend)
|
||||
{
|
||||
pbc = (int *) malloc(3*sizeof(int));
|
||||
besselparams = (double *) malloc(3*sizeof(double));
|
||||
}
|
||||
|
||||
void freememory(int backend)
|
||||
{
|
||||
CPUFREE(pbc);
|
||||
|
@ -444,6 +445,14 @@ public:
|
|||
double *tmpmem, int *pairnumsum, int *atomtype, int *idxi, int *ai, int *aj, int *ti, int *tj, int natom, int Nij);
|
||||
// ******************************************************************************/
|
||||
|
||||
// variables used in eigenvaluedecomposition
|
||||
|
||||
double *xij;
|
||||
double *S;
|
||||
double *Q;
|
||||
double *A;
|
||||
double *b;
|
||||
|
||||
};
|
||||
|
||||
} // namespace LAMMPS_NS
|
||||
|
|
Loading…
Reference in New Issue