1. Program
- 我在constructor和header file加了member variables (原本app_diffusion是有的 )
//app_alloy.cpp
//1. Delete all things about Shweobel Hop
// statistics
ndeposit = ndep_failed = 0;
nhop = 0;
//app_alloy.cpp
int ndeposit, ndep_failed, nhop;
double **Q;
double **hbarrier
int particleid //a global variable
- 大部分的array还需要一个alloc method,注意在deconstructor里也加上新的allocated memory
//cpp line 704 allocate_data()
// creat() alloc memory for 2D arrays, they NEED to be initialized!
memory->create(firstevent,nlocal,"app:firstevent");
memory->create(hbarrier,maxneigh+1,maxneigh+1,"app:hbarrier");
for (int i = 0; i <= maxneigh; i++)
for (int j = 0; j <= maxneigh; j++)
hbarrier[i][j] = 0.0;
memory->create(Q, 128, 128, "app:Q");
for (int i = 0; i < 128; i++)
for (int j = 0; j < 128; j++)
Q[i][j] = 0.0;
hopsite = new int[maxneigh*maxneigh + maxneigh];
//cpp line 27 Alloy constructor for other initializations
//pointers are all instantiated as nullptr, in C style NULL
ninteger = 2; ndouble = 0;
delpropensity = 3; delevent = 1;
allow_kmc = 1;
create_arrays();
maxevent = 0;
events = NULL; firstevent = NULL;
Q = NULL;
particleid = 0;
hbarrier = NULL;
//ecoord = NULL;
hopsite = NULL;
//cpp line 73 AppAlloy::~AppAlloy() deconstructor
memory->sfree(events);
memory->destroy(firstevent);
//delete Q, Q[128][128]
memory->destroy(Q);
memory->destroy(hbarrier);
//delete [] ecoord;
delete [] hopsite;
3.在 input_app() 可以添加和修改command, 比如说deposition里加了一个particleid, 注意这个是global variable, 需要在header file 里面declare. 有点类似于C0 virtual machine,可以定制command。
if (strcmp(command,"deposition") == 0) {
if (narg < 1) error->all(FLERR,"Illegal deposition command");
if (strcmp(arg[0],