Use lammps memory class in pair_pod
This commit is contained in:
@ -12,7 +12,7 @@ Go to `lammps` directory and build with the POD package:
|
||||
|
||||
Go to `lammps/examples/pod/Ta` directory and run
|
||||
|
||||
lmp < in.podfit
|
||||
lmp -n in.podfit
|
||||
|
||||
See the README in `lammps/examples/pod/Ta` for instructions on how to run MD with the potential.
|
||||
|
||||
|
||||
@ -5,10 +5,10 @@ of the training data taken from [the FitSNAP repo](https://github.com/FitSNAP/Fi
|
||||
|
||||
Fit POD with
|
||||
|
||||
lmp < in.podfit
|
||||
lmp -in in.podfit
|
||||
|
||||
This creates `coefficients.txt` for the linear model, which we can use to run MD with
|
||||
|
||||
lmp < in.pod
|
||||
lmp -in in.pod
|
||||
|
||||
|
||||
|
||||
@ -10,8 +10,6 @@
|
||||
#include "neighbor.h"
|
||||
#include "tokenizer.h"
|
||||
|
||||
#include <glob.h>
|
||||
|
||||
#include <cmath>
|
||||
#include <cstring>
|
||||
#include <sys/time.h>
|
||||
@ -27,6 +25,7 @@ CPairPOD::CPairPOD(LAMMPS *lmp) : Pair(lmp)
|
||||
one_coeff = 1;
|
||||
manybody_flag = 1;
|
||||
centroidstressflag = CENTROID_NOTAVAIL;
|
||||
podptr = nullptr;
|
||||
}
|
||||
|
||||
/* ---------------------------------------------------------------------- */
|
||||
@ -34,11 +33,11 @@ CPairPOD::CPairPOD(LAMMPS *lmp) : Pair(lmp)
|
||||
CPairPOD::~CPairPOD()
|
||||
{
|
||||
free_memory();
|
||||
TemplateFree(gd, backend);
|
||||
TemplateFree(energycoeff, backend);
|
||||
TemplateFree(forcecoeff, backend);
|
||||
TemplateFree(podcoeff, backend);
|
||||
TemplateFree(newpodcoeff, backend);
|
||||
memory->destroy(podcoeff);
|
||||
memory->destroy(newpodcoeff);
|
||||
memory->destroy(gd);
|
||||
memory->destroy(energycoeff);
|
||||
memory->destroy(forcecoeff);
|
||||
|
||||
delete podptr;
|
||||
|
||||
@ -227,11 +226,11 @@ void CPairPOD::InitPairPOD(std::string pod_file, std::string coeff_file)
|
||||
lammpspairlist = 1;
|
||||
|
||||
if (coeff_file != "") {
|
||||
TemplateMalloc(&podcoeff, podptr->pod.nd, backend);
|
||||
TemplateMalloc(&newpodcoeff, podptr->pod.nd, backend);
|
||||
TemplateMalloc(&energycoeff, podptr->pod.nd1234, backend);
|
||||
TemplateMalloc(&forcecoeff, podptr->pod.nd1234, backend);
|
||||
TemplateMalloc(&gd, podptr->pod.nd1234, backend);
|
||||
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);
|
||||
}
|
||||
@ -240,25 +239,25 @@ void CPairPOD::InitPairPOD(std::string pod_file, std::string coeff_file)
|
||||
|
||||
void CPairPOD::free_tempmemory()
|
||||
{
|
||||
TemplateFree(rij, backend);
|
||||
TemplateFree(idxi, backend);
|
||||
TemplateFree(ai, backend);
|
||||
TemplateFree(aj, backend);
|
||||
TemplateFree(ti, backend);
|
||||
TemplateFree(tj, backend);
|
||||
TemplateFree(numneighsum, backend);
|
||||
TemplateFree(typeai, backend);
|
||||
TemplateFree(tmpmem, backend);
|
||||
memory->destroy(rij);
|
||||
memory->destroy(idxi);
|
||||
memory->destroy(ai);
|
||||
memory->destroy(aj);
|
||||
memory->destroy(ti);
|
||||
memory->destroy(tj);
|
||||
memory->destroy(numneighsum);
|
||||
memory->destroy(typeai);
|
||||
memory->destroy(tmpmem);
|
||||
}
|
||||
|
||||
void CPairPOD::free_atommemory()
|
||||
{
|
||||
TemplateFree(forces, backend);
|
||||
TemplateFree(stress, backend);
|
||||
memory->destroy(forces);
|
||||
memory->destroy(stress);
|
||||
if (atommemory) {
|
||||
TemplateFree(atomtype, backend);
|
||||
TemplateFree(pos, backend);
|
||||
TemplateFree(vel, backend);
|
||||
memory->destroy(atomtype);
|
||||
memory->destroy(pos);
|
||||
memory->destroy(vel);
|
||||
}
|
||||
}
|
||||
|
||||
@ -270,25 +269,25 @@ void CPairPOD::free_memory()
|
||||
|
||||
void CPairPOD::allocate_tempmemory()
|
||||
{
|
||||
TemplateMalloc(&rij, dim*nijmax, backend);
|
||||
TemplateMalloc(&idxi, nijmax, backend);
|
||||
TemplateMalloc(&ai, nijmax, backend);
|
||||
TemplateMalloc(&aj, nijmax, backend);
|
||||
TemplateMalloc(&ti, nijmax, backend);
|
||||
TemplateMalloc(&tj, nijmax, backend);
|
||||
TemplateMalloc(&numneighsum, nablockmax+1, backend);
|
||||
TemplateMalloc(&typeai, nablockmax, backend);
|
||||
TemplateMalloc(&tmpmem, szd, backend);
|
||||
memory->create(rij, dim*nijmax, "pair:rij");
|
||||
memory->create(idxi, nijmax, "pair:idxi");
|
||||
memory->create(ai, nijmax, "pair:ai");
|
||||
memory->create(aj, nijmax, "pair:aj");
|
||||
memory->create(ti, nijmax, "pair:ti");
|
||||
memory->create(tj, nijmax, "pair:tj");
|
||||
memory->create(numneighsum, nablockmax+1, "pair:numneighsum");
|
||||
memory->create(typeai, nablockmax, "pair:typeai");
|
||||
memory->create(tmpmem, szd, "pair:tmpmem");
|
||||
}
|
||||
|
||||
void CPairPOD::allocate_atommemory()
|
||||
{
|
||||
TemplateMalloc(&forces, dim*nmaxatom, backend);
|
||||
TemplateMalloc(&stress, 9, backend);
|
||||
memory->create(forces, dim*nmaxatom, "pair:forces");
|
||||
memory->create(stress, 9, "pair:stress");
|
||||
if (atommemory) {
|
||||
TemplateMalloc(&atomtype, nmaxatom, backend);
|
||||
TemplateMalloc(&pos, dim*nmaxatom, backend);
|
||||
TemplateMalloc(&vel, dim*nmaxatom, backend);
|
||||
memory->create(atomtype, nmaxatom, "pair:atomtype");
|
||||
memory->create(pos, dim*nmaxatom, "pair:pos");
|
||||
memory->create(vel, dim*nmaxatom, "pair:vel");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -61,20 +61,10 @@ namespace LAMMPS_NS {
|
||||
data.filenames = filenames;
|
||||
}
|
||||
|
||||
void freememory(int backend)
|
||||
{
|
||||
TemplateFree(lattice, backend);
|
||||
TemplateFree(energy, backend);
|
||||
TemplateFree(stress, backend);
|
||||
TemplateFree(position, backend);
|
||||
TemplateFree(velocity, backend);
|
||||
TemplateFree(force, backend);
|
||||
TemplateFree(atomtype, backend);
|
||||
}
|
||||
};
|
||||
|
||||
datastruct data;
|
||||
class CPOD *podptr;
|
||||
//class CPOD *podptr;
|
||||
|
||||
CPairPOD(class LAMMPS *);
|
||||
~CPairPOD() override;
|
||||
@ -89,7 +79,6 @@ namespace LAMMPS_NS {
|
||||
|
||||
void InitPairPOD(std::string pod_file, std::string coeff_file);
|
||||
|
||||
int backend=1;
|
||||
int dim = 3;
|
||||
int atommemory = 0;
|
||||
int podpairlist=0;
|
||||
@ -156,6 +145,9 @@ namespace LAMMPS_NS {
|
||||
int nijmax=0; // maximum number of atom pairs
|
||||
int szd=0; // size of tmpmem
|
||||
|
||||
class CPOD *podptr;
|
||||
// class SNA *snaptr; // why does this work, but commenting #include pod.h causes the above line to fail?
|
||||
|
||||
// temporary arrays for computation blocks
|
||||
|
||||
double *tmpmem=NULL; // temporary memory
|
||||
|
||||
@ -4,8 +4,11 @@
|
||||
Contributing authors: Ngoc-Cuong Nguyen (cuongng@mit.edu, exapde@gmail.com)
|
||||
***************************************************************************/
|
||||
|
||||
#ifndef __POD_H__
|
||||
#define __POD_H__
|
||||
#ifndef LMP_POD_H__
|
||||
#define LMP_POD_H__
|
||||
|
||||
//#ifndef LMP_SNA_H
|
||||
//#define LMP_SNA_H
|
||||
|
||||
#include "podcommon.h"
|
||||
#include "pointers.h"
|
||||
|
||||
Reference in New Issue
Block a user