update of COUPLE/simple examples

This commit is contained in:
Steven J Plimpton
2018-01-16 10:48:38 -07:00
parent e798cdf31f
commit 21ff4407ab
7 changed files with 48 additions and 36 deletions

View File

@ -109,11 +109,11 @@ int main(int narg, char **arg)
int natoms = static_cast<int> (lmp->atom->natoms);
x = new double[3*natoms];
v = new double[3*natoms];
lammps_gather_atoms(lmp,"x",1,3,x);
lammps_gather_atoms(lmp,"v",1,3,v);
lammps_gather_atoms(lmp,(char *) "x",1,3,x);
lammps_gather_atoms(lmp,(char *) "v",1,3,v);
double epsilon = 0.1;
x[0] += epsilon;
lammps_scatter_atoms(lmp,"x",1,3,x);
lammps_scatter_atoms(lmp,(char *) "x",1,3,x);
// these 2 lines are the same
@ -124,21 +124,22 @@ int main(int narg, char **arg)
// extract force on single atom two different ways
if (lammps == 1) {
double **f = (double **) lammps_extract_atom(lmp,"f");
double **f = (double **) lammps_extract_atom(lmp,(char *) "f");
printf("Force on 1 atom via extract_atom: %g\n",f[0][0]);
double *fx = (double *) lammps_extract_variable(lmp,"fx","all");
double *fx = (double *)
lammps_extract_variable(lmp,(char *) "fx",(char *) "all");
printf("Force on 1 atom via extract_variable: %g\n",fx[0]);
}
// use commands_string() and commands_list() to invoke more commands
char *strtwo = "run 10\nrun 20";
char *strtwo = (char *) "run 10\nrun 20";
if (lammps == 1) lammps_commands_string(lmp,strtwo);
char *cmds[2];
cmds[0] = "run 10";
cmds[1] = "run 20";
cmds[0] = (char *) "run 10";
cmds[1] = (char *) "run 20";
if (lammps == 1) lammps_commands_list(lmp,2,cmds);
// delete all atoms