modernize a couple examples/COUPLE apps

This commit is contained in:
Steve Plimpton
2023-04-12 15:59:12 -06:00
parent ff5b4e971d
commit b3c00f3edf
28 changed files with 57 additions and 744 deletions

View File

@ -33,7 +33,6 @@ These are the sub-directories included in this directory:
simple simple example of driver code calling LAMMPS as a lib simple simple example of driver code calling LAMMPS as a lib
multiple example of driver code calling multiple instances of LAMMPS multiple example of driver code calling multiple instances of LAMMPS
plugin example for loading LAMMPS at runtime from a shared library plugin example for loading LAMMPS at runtime from a shared library
lammps_quest MD with quantum forces, coupling to Quest DFT code
lammps_spparks grain-growth Monte Carlo with strain via MD, lammps_spparks grain-growth Monte Carlo with strain via MD,
coupling to SPPARKS kinetic MC code coupling to SPPARKS kinetic MC code
library collection of useful inter-code communication routines library collection of useful inter-code communication routines

View File

@ -1,47 +0,0 @@
# Makefile for MD with quantum forces via LAMMPS <-> Quest coupling
SHELL = /bin/sh
# System-specific settings
LAMMPS = /home/sjplimp/lammps
CC = g++
CCFLAGS = -g -O -DMPICH_IGNORE_CXX_SEEK -I../library
DEPFLAGS = -M
LINK = g++
LINKFLAGS = -g -O -L../library -L${LAMMPS}/src
USRLIB = -lcouple -llammps_g++
SYSLIB = -lfftw -lmpich -lpthread
ARCHIVE = ar
ARFLAGS = -rc
SIZE = size
# Files
EXE = lmpqst
SRC = $(wildcard *.cpp)
INC = $(wildcard *.h)
OBJ = $(SRC:.cpp=.o)
# Targets
$(EXE): $(OBJ)
$(LINK) $(LINKFLAGS) $(OBJ) $(USRLIB) $(SYSLIB) -o $(EXE)
$(SIZE) $(EXE)
clean:
rm $(EXE) *.o
# Compilation rules
%.o:%.cpp
$(CC) $(CCFLAGS) -c $<
%.d:%.cpp
$(CC) $(CCFLAGS) $(DEPFLAGS) $< > $@
# Individual dependencies
DEPENDS = $(OBJ:.o=.d)
include $(DEPENDS)

View File

@ -1,70 +0,0 @@
IMPORTANT NOTE: This example has not been updated since 2014,
so it is not likely to work anymore out of the box. There have
been changes to LAMMPS and its library interface that would need
to be applied. Please see the manual for the documentation of
the library interface.
This directory has an application that runs classical MD via LAMMPS,
but uses quantum forces calculated by the Quest DFT (density
functional) code in place of the usual classical MD forces calculated
by a pair style in LAMMPS.
lmpqst.cpp main program
it links LAMMPS as a library
it invokes Quest as an executable
in.lammps LAMMPS input script, without the run command
si_111.in Quest input script for an 8-atom Si unit cell
lmppath.h contains path to LAMMPS home directory
qstexe.h contains full pathname to Quest executable
After editing the Makefile, lmppath.h, and qstexe.h to make them
suitable for your box, type:
make -f Makefile.g++
and you should get the lmpqst executable.
NOTE: To run this coupled application, you must of course, have Quest
built on your system. It's WWW site is http://dft.sandia.gov/Quest.
It is not an open-source code, buy you can contact its authors to
obtain a copy.
You can run lmpqst in serial or parallel as:
% lmpqst Niter in.lammps in.quest
% mpirun -np 4 lmpqst Niter in.lammps in.quest
where
Niter = # of MD iterations
in.lammps = LAMMPS input script
in.quest = Quest input script
The log files are for this run:
% lmpqst 10 in.lammps si_111.in
This application is an example of a coupling where the driver code
(lmpqst) runs one code (LAMMPS) as an outer code and facilitates it
calling the other code (Quest) as an inner code. Specifically, the
driver (lmpqst) invokes one code (LAMMPS) to perform its timestep
loop, and grabs information from the other code (Quest) during its
timestep. This is done in LAMMPS using the fix external command,
which makes a "callback" to the driver application (lmpqst), which in
turn invokes Quest with new atom coordinates, lets Quest compute
forces, and returns those forces to the LAMMPS fix external.
The driver code launches LAMMPS in parallel. But Quest is only run on
a single processor. It would be possible to change this by using a
parallel build of Quest.
Since Quest does not currently have a library interface, the driver
code interfaces with Quest via input and output files.
Note that essentially 100% of the run time for this coupled
application is spent in Quest, as the quantum calculation of forces
dominates the calculation.
You can look at the log files in the directory to see sample LAMMPS
output for this simulation. Dump files produced by LAMMPS are stored
as dump.md.

View File

@ -1,20 +0,0 @@
# LAMMPS input for coupling MD/Quantum
units metal
dimension 3
atom_style atomic
atom_modify sort 0 0.0
lattice diamond 5.43
region box block 0 1 0 1 0 1
create_box 1 box
create_atoms 1 box
mass 1 28.08
velocity all create 300.0 87293 loop geom
fix 1 all nve
fix 2 all external pf/callback 1 1
dump 1 all custom 1 dump.md id type x y z fx fy fz
thermo 1

View File

@ -1 +0,0 @@
#define LMPPATH /home/sjplimp/lammps

View File

@ -1,270 +0,0 @@
// lmpqst = umbrella driver to couple LAMMPS + Quest
// for MD using quantum forces
// Syntax: lmpqst Niter in.lammps in.quest
// Niter = # of MD iterations
// in.lammps = LAMMPS input script
// in.quest = Quest input script
#include <mpi.h>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include "stdint.h"
#include "many2one.h"
#include "one2many.h"
#include "files.h"
#include "memory.h"
#include "error.h"
#define QUOTE_(x) #x
#define QUOTE(x) QUOTE_(x)
#include "lmppath.h"
#include QUOTE(LMPPATH/src/lammps.h)
#include QUOTE(LMPPATH/src/library.h)
#include QUOTE(LMPPATH/src/input.h)
#include QUOTE(LMPPATH/src/modify.h)
#include QUOTE(LMPPATH/src/fix.h)
#include QUOTE(LMPPATH/src/fix_external.h)
#include "qstexe.h"
using namespace LAMMPS_NS;
#define ANGSTROM_per_BOHR 0.529
#define EV_per_RYDBERG 13.6056923
void quest_callback(void *, bigint, int, int *, double **, double **);
struct Info {
int me;
Memory *memory;
LAMMPS *lmp;
char *quest_input;
};
/* ---------------------------------------------------------------------- */
int main(int narg, char **arg)
{
int n;
char str[128];
// setup MPI
MPI_Init(&narg,&arg);
MPI_Comm comm = MPI_COMM_WORLD;
int me,nprocs;
MPI_Comm_rank(comm,&me);
MPI_Comm_size(comm,&nprocs);
Memory *memory = new Memory(comm);
Error *error = new Error(comm);
// command-line args
if (narg != 4) error->all("Syntax: lmpqst Niter in.lammps in.quest");
int niter = atoi(arg[1]);
n = strlen(arg[2]) + 1;
char *lammps_input = new char[n];
strcpy(lammps_input,arg[2]);
n = strlen(arg[3]) + 1;
char *quest_input = new char[n];
strcpy(quest_input,arg[3]);
// instantiate LAMMPS
LAMMPS *lmp = new LAMMPS(0,NULL,MPI_COMM_WORLD);
// create simulation in LAMMPS from in.lammps
lmp->input->file(lammps_input);
// make info available to callback function
Info info;
info.me = me;
info.memory = memory;
info.lmp = lmp;
info.quest_input = quest_input;
// set callback to Quest inside fix external
// this could also be done thru Python, using a ctypes callback
int ifix = lmp->modify->find_fix("2");
FixExternal *fix = (FixExternal *) lmp->modify->fix[ifix];
fix->set_callback(quest_callback,&info);
// run LAMMPS for Niter
// each time it needs forces, it will invoke quest_callback
sprintf(str,"run %d",niter);
lmp->input->one(str);
// clean up
delete lmp;
delete memory;
delete error;
delete [] lammps_input;
delete [] quest_input;
MPI_Finalize();
}
/* ----------------------------------------------------------------------
callback to Quest with atom IDs and coords from each proc
invoke Quest to compute forces, load them into f for LAMMPS to use
f can be NULL if proc owns no atoms
------------------------------------------------------------------------- */
void quest_callback(void *ptr, bigint ntimestep,
int nlocal, int *id, double **x, double **f)
{
int i,j;
char str[128];
Info *info = (Info *) ptr;
// boxlines = LAMMPS box size converted into Quest lattice vectors
char **boxlines = NULL;
if (info->me == 0) {
boxlines = new char*[3];
for (i = 0; i < 3; i++) boxlines[i] = new char[128];
}
double boxxlo = *((double *) lammps_extract_global(info->lmp,"boxxlo"));
double boxxhi = *((double *) lammps_extract_global(info->lmp,"boxxhi"));
double boxylo = *((double *) lammps_extract_global(info->lmp,"boxylo"));
double boxyhi = *((double *) lammps_extract_global(info->lmp,"boxyhi"));
double boxzlo = *((double *) lammps_extract_global(info->lmp,"boxzlo"));
double boxzhi = *((double *) lammps_extract_global(info->lmp,"boxzhi"));
double boxxy = *((double *) lammps_extract_global(info->lmp,"xy"));
double boxxz = *((double *) lammps_extract_global(info->lmp,"xz"));
double boxyz = *((double *) lammps_extract_global(info->lmp,"yz"));
double xprd = (boxxhi-boxxlo)/ANGSTROM_per_BOHR;
double yprd = (boxyhi-boxylo)/ANGSTROM_per_BOHR;
double zprd = (boxzhi-boxzlo)/ANGSTROM_per_BOHR;
double xy = boxxy/ANGSTROM_per_BOHR;
double xz = boxxz/ANGSTROM_per_BOHR;
double yz = boxyz/ANGSTROM_per_BOHR;
if (info->me == 0) {
sprintf(boxlines[0],"%g %g %g\n",xprd,0.0,0.0);
sprintf(boxlines[1],"%g %g %g\n",xy,yprd,0.0);
sprintf(boxlines[2],"%g %g %g\n",xz,yz,zprd);
}
// xlines = x for atoms on each proc converted to text lines
// xlines is suitable for insertion into Quest input file
// convert LAMMPS Angstroms to Quest bohr
int natoms;
MPI_Allreduce(&nlocal,&natoms,1,MPI_INT,MPI_SUM,MPI_COMM_WORLD);
Many2One *lmp2qst = new Many2One(MPI_COMM_WORLD);
lmp2qst->setup(nlocal,id,natoms);
char **xlines = NULL;
double **xquest = NULL;
if (info->me == 0) {
xquest = info->memory->create_2d_double_array(natoms,3,"lmpqst:xquest");
xlines = new char*[natoms];
for (i = 0; i < natoms; i++) xlines[i] = new char[128];
}
if (info->me == 0) lmp2qst->gather(&x[0][0],3,&xquest[0][0]);
else lmp2qst->gather(&x[0][0],3,NULL);
if (info->me == 0) {
for (i = 0; i < natoms; i++) {
xquest[i][0] /= ANGSTROM_per_BOHR;
xquest[i][1] /= ANGSTROM_per_BOHR;
xquest[i][2] /= ANGSTROM_per_BOHR;
}
for (i = 0; i < natoms; i++) {
sprintf(xlines[i],"%d %d %g %g %g\n",i+1,1,
xquest[i][0],xquest[i][1],xquest[i][2]);
}
}
// one-processor tasks:
// whack all lcao.* files
// cp quest_input to lcao.in
// replace atom coords section of lcao.in with new atom coords
// run Quest on one proc, save screen output to file
// flines = atom forces extracted from Quest screen file
// fquest = atom forces
// convert Quest Ryd/bohr to LAMMPS eV/Angstrom
char **flines = NULL;
double **fquest = NULL;
if (info->me == 0) {
fquest = info->memory->create_2d_double_array(natoms,3,"lmpqst:fquest");
flines = new char*[natoms];
for (i = 0; i < natoms; i++) flines[i] = new char[128];
}
if (info->me == 0) {
system("rm lcao.*");
sprintf(str,"cp %s lcao.in",info->quest_input);
system(str);
sprintf(str,"cp %s lcao.x",QUOTE(QUEST));
system(str);
replace("lcao.in","primitive lattice vectors",3,boxlines);
replace("lcao.in","atom, type, position vector",natoms,xlines);
system("lcao.x > lcao.screen");
extract("lcao.screen","atom x force "
"y force z force",natoms,flines);
int itmp;
for (i = 0; i < natoms; i++)
sscanf(flines[i],"%d %lg %lg %lg",&itmp,
&fquest[i][0],&fquest[i][1],&fquest[i][2]);
for (i = 0; i < natoms; i++) {
fquest[i][0] *= EV_per_RYDBERG / ANGSTROM_per_BOHR;
fquest[i][1] *= EV_per_RYDBERG / ANGSTROM_per_BOHR;
fquest[i][2] *= EV_per_RYDBERG / ANGSTROM_per_BOHR;
}
}
// convert fquest on one proc into f for atoms on each proc
One2Many *qst2lmp = new One2Many(MPI_COMM_WORLD);
qst2lmp->setup(natoms,nlocal,id);
double *fvec = NULL;
if (f) fvec = &f[0][0];
if (info->me == 0) qst2lmp->scatter(&fquest[0][0],3,fvec);
else qst2lmp->scatter(NULL,3,fvec);
// clean up
// some data only exists on proc 0
delete lmp2qst;
delete qst2lmp;
info->memory->destroy_2d_double_array(xquest);
info->memory->destroy_2d_double_array(fquest);
if (boxlines) {
for (i = 0; i < 3; i++) delete [] boxlines[i];
delete [] boxlines;
}
if (xlines) {
for (i = 0; i < natoms; i++) delete [] xlines[i];
delete [] xlines;
}
if (flines) {
for (i = 0; i < natoms; i++) delete [] flines[i];
delete [] flines;
}
}

View File

@ -1,58 +0,0 @@
LAMMPS (20 Sep 2010)
# LAMMPS input for coupling MD/Quantum
units metal
dimension 3
atom_style atomic
atom_modify sort 0 0.0
lattice diamond 5.43
Lattice spacing in x,y,z = 5.43 5.43 5.43
region box block 0 1 0 1 0 1
create_box 1 box
Created orthogonal box = (0 0 0) to (5.43 5.43 5.43)
1 by 1 by 1 processor grid
create_atoms 1 box
Created 8 atoms
mass 1 28.08
velocity all create 300.0 87293 loop geom
fix 1 all nve
fix 2 all external
dump 1 all custom 1 dump.md id type x y z fx fy fz
thermo 1
run 10
Memory usage per processor = 1.25982 Mbytes
Step Temp E_pair E_mol TotEng Press
0 300 0 0 0.2714463 1810.9378
1 298.22165 0 0 0.26983722 1800.2029
2 293.2839 0 0 0.26536943 1770.3964
3 286.18537 0 0 0.25894654 1727.5464
4 277.61576 0 0 0.25119258 1675.8163
5 267.3325 0 0 0.24188807 1613.7418
6 254.94702 0 0 0.23068142 1538.9774
7 240.91176 0 0 0.21798202 1454.2541
8 226.27996 0 0 0.20474287 1365.9298
9 212.1059 0 0 0.19191788 1280.3687
10 199.27609 0 0 0.18030919 1202.922
Loop time of 80.663 on 1 procs for 10 steps with 8 atoms
Pair time (%) = 0 (0)
Neigh time (%) = 0 (0)
Comm time (%) = 4.91142e-05 (6.08882e-05)
Outpt time (%) = 0.00111485 (0.0013821)
Other time (%) = 80.6618 (99.9986)
Nlocal: 8 ave 8 max 8 min
Histogram: 1 0 0 0 0 0 0 0 0 0
Nghost: 10 ave 10 max 10 min
Histogram: 1 0 0 0 0 0 0 0 0 0
Neighs: 0 ave 0 max 0 min
Histogram: 1 0 0 0 0 0 0 0 0 0
Total # of neighbors = 0
Ave neighs/atom = 0
Neighbor list builds = 0
Dangerous builds = 0

View File

@ -1,58 +0,0 @@
LAMMPS (20 Sep 2010)
# LAMMPS input for coupling MD/Quantum
units metal
dimension 3
atom_style atomic
atom_modify sort 0 0.0
lattice diamond 5.43
Lattice spacing in x,y,z = 5.43 5.43 5.43
region box block 0 1 0 1 0 1
create_box 1 box
Created orthogonal box = (0 0 0) to (5.43 5.43 5.43)
1 by 2 by 2 processor grid
create_atoms 1 box
Created 8 atoms
mass 1 28.08
velocity all create 300.0 87293 loop geom
fix 1 all nve
fix 2 all external
dump 1 all custom 1 dump.md id type x y z fx fy fz
thermo 1
run 10
Memory usage per processor = 1.25928 Mbytes
Step Temp E_pair E_mol TotEng Press
0 300 0 0 0.2714463 1810.9378
1 298.22166 0 0 0.26983722 1800.2029
2 293.28391 0 0 0.26536944 1770.3964
3 286.18538 0 0 0.25894655 1727.5464
4 277.61578 0 0 0.25119259 1675.8164
5 267.33252 0 0 0.24188809 1613.7419
6 254.94703 0 0 0.23068143 1538.9774
7 240.91175 0 0 0.21798202 1454.254
8 226.27997 0 0 0.20474287 1365.9299
9 212.10594 0 0 0.19191791 1280.3689
10 199.27613 0 0 0.18030923 1202.9223
Loop time of 79.8256 on 4 procs for 10 steps with 8 atoms
Pair time (%) = 0 (0)
Neigh time (%) = 0 (0)
Comm time (%) = 0.000365376 (0.000457718)
Outpt time (%) = 0.00169969 (0.00212925)
Other time (%) = 79.8236 (99.9974)
Nlocal: 2 ave 2 max 2 min
Histogram: 4 0 0 0 0 0 0 0 0 0
Nghost: 5 ave 5 max 5 min
Histogram: 4 0 0 0 0 0 0 0 0 0
Neighs: 0 ave 0 max 0 min
Histogram: 4 0 0 0 0 0 0 0 0 0
Total # of neighbors = 0
Ave neighs/atom = 0
Neighbor list builds = 0
Dangerous builds = 0

View File

@ -1 +0,0 @@
#define QUEST /home/sjplimp/csrf/quest/src/lcao.x

View File

@ -1,161 +0,0 @@
do setup
do iters
do force
no relax
setup data
title
Si 1x1x1 unit cell
functional
PBE
dimensions of system (0=cluster ... 3=bulk)
3
primitive lattice vectors
10.261212 0.000000 0.000000
0.000000 10.261212 0.000000
0.000000 0.000000 10.261212
grid dimensions
10 10 10
atom types
1
type number, label:
1 Si_pbe
notes5
Originally constructed by Peter A. Schultz, 12Apr01
potential generated by new Hamann program PUNSLDX
Cite use with: D.R. Hamann, unpublished.
Potential: "standard" setting out to l=2
Basis: amended Jun05 for better (2d/1d not 1d/1d) d-function
effective nuclear charge (s2p2 to 10.0)
4.00000000d+00
pseudopotentials: Lmax, and effective gaussian range
2 0.86000000d+00
functional type used in generating potential:
PBE
radial mesh: number of points for local and non-local pot integrals
80 67
mesh points for nuclear potential; ham2dh
0.02500000 0.02696978 0.02909477 0.03138719 0.03386023 0.03652812
0.03940622 0.04251109 0.04586060 0.04947402 0.05337215 0.05757741
0.06211402 0.06700807 0.07228773 0.07798338 0.08412779 0.09075634
0.09790716 0.10562140 0.11394345 0.12292121 0.13260635 0.14305458
0.15432605 0.16648562 0.17960325 0.19375443 0.20902061 0.22548964
0.24325628 0.26242278 0.28309943 0.30540522 0.32946852 0.35542780
0.38343245 0.41364362 0.44623518 0.48139466 0.51932441 0.56024270
0.60438500 0.65200533 0.70337773 0.75879783 0.81858456 0.88308197
0.95266121 1.02772271 1.10869840 1.19605428 1.29029305 1.39195702
1.50163124 1.61994684 1.74758469 1.88527930 2.03382306 2.19407079
2.36694466 2.55343950 2.75462852 2.97166951 3.20581145 3.45840177
3.73089402 4.02485632 4.34198031 4.68409093 5.05315693 5.45130215
5.88081777 6.34417553 6.84404189 7.38329340 7.96503329 8.59260927
9.26963282 10.00000000
radwts: weights for radial points
0.00189603 0.00204542 0.00220659 0.00238045 0.00256800 0.00277034
0.00298862 0.00322410 0.00347813 0.00375218 0.00404781 0.00436675
0.00471081 0.00508198 0.00548240 0.00591436 0.00638036 0.00688308
0.00742541 0.00801047 0.00864162 0.00932251 0.01005704 0.01084945
0.01170429 0.01262649 0.01362135 0.01469459 0.01585240 0.01710143
0.01844888 0.01990249 0.02147064 0.02316234 0.02498733 0.02695611
0.02908002 0.03137128 0.03384307 0.03650961 0.03938625 0.04248955
0.04583736 0.04944895 0.05334510 0.05754823 0.06208254 0.06697411
0.07225109 0.07794385 0.08408515 0.09071034 0.09785753 0.10556786
0.11388570 0.12285891 0.13253914 0.14298208 0.15424783 0.16640123
0.17951222 0.19365623 0.20891467 0.22537535 0.24313298 0.26228977
0.28295594 0.30525043 0.32930153 0.35524766 0.38323811 0.41343397
0.44600900 0.48115067 0.51906119 0.55995874 0.60407867 0.65167486
0.70302122 0.75841323
non-local potential: l,potential*integration weight
0 0.62022930 0.62128855 0.62243016 0.62366033 0.62498568 0.62641328
0.62795061 0.62960563 0.63138673 0.63330275 0.63536294 0.63757692
0.63995464 0.64250630 0.64524218 0.64817253 0.65130735 0.65465605
0.65822713 0.66202767 0.66606269 0.67033437 0.67484108 0.67957602
0.68452576 0.68966817 0.69497006 0.70038419 0.70584566 0.71126756
0.71653578 0.72150290 0.72598113 0.72973436 0.73246932 0.73382636
0.73337030 0.73058243 0.72485505 0.71549107 0.70171167 0.68267654
0.65752236 0.62542611 0.58570073 0.53792896 0.48213811 0.41900888
0.35009536 0.27800640 0.20646172 0.14009458 0.08384960 0.04186877
0.01596164 0.00423035 0.00115036 0.00066636 0.00047879 0.00029939
0.00016329 0.00007995 0.00003517 0.00001362 0.00000445 0.00000111
0.00000016 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000
0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000
0.00000000 0.00000000
non-local potential: l,potential*integration weight
1 0.59551624 0.59463303 0.59368033 0.59265268 0.59154422 0.59034862
0.58905906 0.58766819 0.58616811 0.58455033 0.58280567 0.58092430
0.57889565 0.57670833 0.57435015 0.57180802 0.56906791 0.56611482
0.56293268 0.55950435 0.55581158 0.55183493 0.54755377 0.54294628
0.53798942 0.53265896 0.52692951 0.52077458 0.51416671 0.50707751
0.49947790 0.49133817 0.48262822 0.47331766 0.46337588 0.45277197
0.44147437 0.42945016 0.41666374 0.40307468 0.38863443 0.37328165
0.35693601 0.33949042 0.32080256 0.30068740 0.27891443 0.25521609
0.22931791 0.20100526 0.17024474 0.13737521 0.10336405 0.07007167
0.04035673 0.01767907 0.00470635 0.00076638 0.00047880 0.00029939
0.00016329 0.00007995 0.00003517 0.00001362 0.00000445 0.00000111
0.00000016 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000
0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000
0.00000000 0.00000000
non-local potential: l,potential*integration weight
2 0.56305372 0.55961728 0.55591134 0.55191498 0.54760572 0.54295941
0.53795013 0.53255008 0.52672947 0.52045641 0.51369682 0.50641433
0.49857022 0.49012333 0.48103004 0.47124429 0.46071759 0.44939919
0.43723624 0.42417413 0.41015690 0.39512792 0.37903070 0.36181001
0.34341340 0.32379300 0.30290805 0.28072780 0.25723539 0.23243242
0.20634465 0.17902876 0.15058041 0.12114359 0.09092117 0.06018665
0.02929636 -0.00129833 -0.03104046 -0.05926034 -0.08517498 -0.10789810
-0.12646610 -0.13988656 -0.14721657 -0.14767751 -0.14080976 -0.12666296
-0.10600305 -0.08049270 -0.05276798 -0.02629475 -0.00486427 0.00837657
0.01228139 0.00892332 0.00342796 0.00074936 0.00047880 0.00029939
0.00016329 0.00007995 0.00003517 0.00001362 0.00000445 0.00000111
0.00000016 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000
0.00000000 0.00000000 0.00000000 0.00000000 0.00000000 0.00000000
0.00000000 0.00000000
number of radial functions **** Si PBE Ham-II basis 20Feb01-PAS ****
5
angular momentum, number of alphas
0 4
alphas - s - 4s/2/4s407 (bulk Si dzp Eopt+reopt c1)
0.10460000d+00 0.27226300d+00 1.30050800d+00 2.60103000d+00
wave function coefficients
0.20995300d+00 0.55978200d+00 -0.99128200d+00 0.33487100d+00
angular momentum, number of alphas
1 3
alphas - p - 3p/2/3p492 (bulk Si dzp Eopt + reopt c1)
0.09424100d+00 0.31767900d+00 1.56114500d+00
wave function coefficients
0.06761600d+00 0.31821200d+00 -0.06638300d+00
angular momentum, number of alphas
0 1
alphas - s - second zeta s polarization
0.10460000d+00
wave function coefficients
1.00000000d+00
angular momentum, number of alphas
1 1
alphas - p - second zeta p polarization
0.09424100d+00
wave function coefficients
1.00000000d+00
angular momentum, number of alphas
2 2
alphas - d - angular polarization (dzp Eopt)
0.32000000d+00 1.40000000d+00
wave function coefficients
0.31557000d+00 1.00000000d+00
shell occupancies for this silicon, Si: s(2.00)p(2.00)
2.00000000 2.00000000 0.00000000 0.00000000 0.00000000 0.00000000
end atom file
number of atoms in unit cell
8
atom, type, position vector
1 1 0.0000000000 0.0000000000 0.0000000000
2 1 5.1306060590 5.1306060590 0.0000000000
3 1 5.1306060590 0.0000000000 5.1306060590
4 1 0.0000000000 5.1306060590 5.1306060590
5 1 2.5653030295 2.5653030295 2.5653030295
6 1 7.6959090885 7.6959090885 2.5653030295
7 1 7.6959090885 2.5653030295 7.6959090885
8 1 2.5653030295 7.6959090885 7.6959090885
kgrid
0 0 0
end setup phase data
run phase input data
end of run phase data

View File

@ -4,13 +4,13 @@ SHELL = /bin/sh
# System-specific settings # System-specific settings
LAMMPS = /home/sjplimp/lammps LAMMPS = /home/sjplimp/lammps/git/src
SPPARKS = /home/sjplimp/spparks SPPARKS = /home/sjplimp/spparks/git/src
CC = g++ CC = mpicxx
CCFLAGS = -g -O -DMPICH_IGNORE_CXX_SEEK -I../library CCFLAGS = -g -O -DMPICH_IGNORE_CXX_SEEK -I../library
DEPFLAGS = -M DEPFLAGS = -M
LINK = g++ LINK = mpicxx
LINKFLAGS = -g -O -L../library -L${LAMMPS}/src -L${SPPARKS}/src LINKFLAGS = -g -O -L../library -L${LAMMPS}/src -L${SPPARKS}/src
USRLIB = -lcouple -llmp_g++ -lspk_g++ USRLIB = -lcouple -llmp_g++ -lspk_g++
SYSLIB = -lfftw -lmpich -lpthread SYSLIB = -lfftw -lmpich -lpthread

View File

@ -1 +1 @@
#define LMPPATH /home/sjplimp/lammps #define LMPPATH /home/sjplimp/lammps/git

View File

@ -20,10 +20,10 @@
#define QUOTE_(x) #x #define QUOTE_(x) #x
#define QUOTE(x) QUOTE_(x) #define QUOTE(x) QUOTE_(x)
#include "spkpath.h" //#include "spkpath.h"
#include QUOTE(SPKPATH/src/spparks.h) //#include QUOTE(SPKPATH/src/spparks.h)
#include QUOTE(SPKPATH/src/library.h) //#include QUOTE(SPKPATH/src/library.h)
#include QUOTE(SPKPATH/src/input.h) //#include QUOTE(SPKPATH/src/input.h)
#include "lmppath.h" #include "lmppath.h"
#include QUOTE(LMPPATH/src/lammps.h) #include QUOTE(LMPPATH/src/lammps.h)
@ -32,7 +32,7 @@
#include QUOTE(LMPPATH/src/modify.h) #include QUOTE(LMPPATH/src/modify.h)
#include QUOTE(LMPPATH/src/compute.h) #include QUOTE(LMPPATH/src/compute.h)
using namespace SPPARKS_NS; //using namespace SPPARKS_NS;
using namespace LAMMPS_NS; using namespace LAMMPS_NS;
/* ---------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- */
@ -83,28 +83,28 @@ int main(int narg, char **arg)
double **xyz; double **xyz;
double *strain; double *strain;
dimension = *((int *) spparks_extract(spk,"dimension")); dimension = *((int *) spparks_extract(spk,(char *) "dimension"));
nglobal = *((int *) spparks_extract(spk,"nglobal")); nglobal = *((int *) spparks_extract(spk,(char *) "nglobal"));
nlocal_spparks = *((int *) spparks_extract(spk,"nlocal")); nlocal_spparks = *((int *) spparks_extract(spk,(char *) "nlocal"));
boxxlo = *((double *) spparks_extract(spk,"boxxlo")); boxxlo = *((double *) spparks_extract(spk,(char *) "boxxlo"));
boxxhi = *((double *) spparks_extract(spk,"boxxhi")); boxxhi = *((double *) spparks_extract(spk,(char *) "boxxhi"));
boxylo = *((double *) spparks_extract(spk,"boxylo")); boxylo = *((double *) spparks_extract(spk,(char *) "boxylo"));
boxyhi = *((double *) spparks_extract(spk,"boxyhi")); boxyhi = *((double *) spparks_extract(spk,(char *) "boxyhi"));
if (dimension == 3) { if (dimension == 3) {
boxzlo = *((double *) spparks_extract(spk,"boxzlo")); boxzlo = *((double *) spparks_extract(spk,(char *) "boxzlo"));
boxzhi = *((double *) spparks_extract(spk,"boxzhi")); boxzhi = *((double *) spparks_extract(spk,(char *) "boxzhi"));
} else { } else {
boxzlo = -0.5; boxzlo = -0.5;
boxzhi = 0.5; boxzhi = 0.5;
} }
id_spparks = (int *) spparks_extract(spk,"id"); id_spparks = (int *) spparks_extract(spk,(char *) "id");
spins = (int *) spparks_extract(spk,"site"); spins = (int *) spparks_extract(spk,(char *) "site");
xyz = (double **) spparks_extract(spk,"xyz"); xyz = (double **) spparks_extract(spk,(char *) "xyz");
nspins = *((int *) spparks_extract(spk,"nspins")); nspins = *((int *) spparks_extract(spk,(char *) "nspins"));
strain = (double *) spparks_extract(spk,"strain"); strain = (double *) spparks_extract(spk,(char *) "strain");
// write a LAMMPS input script using SPPARKS params // write a LAMMPS input script using SPPARKS params
@ -114,7 +114,7 @@ int main(int narg, char **arg)
fprintf(fp,"units lj\n"); fprintf(fp,"units lj\n");
sprintf(str,"dimension %d\n",dimension); sprintf(str,"dimension %d\n",dimension);
fprintf(fp,str); fprintf(fp,"%s",str);
fprintf(fp,"atom_style atomic\n\n"); fprintf(fp,"atom_style atomic\n\n");
fprintf(fp,"read_data data.lammps\n"); fprintf(fp,"read_data data.lammps\n");
@ -124,7 +124,7 @@ int main(int narg, char **arg)
fprintf(fp,"pair_coeff * * 1.0 1.2\n"); fprintf(fp,"pair_coeff * * 1.0 1.2\n");
for (i = 0; i < nspins; i++) { for (i = 0; i < nspins; i++) {
sprintf(str,"pair_coeff %d %d 1.0 1.0\n",i+1,i+1); sprintf(str,"pair_coeff %d %d 1.0 1.0\n",i+1,i+1);
fprintf(fp,str); fprintf(fp,"%s",str);
} }
fprintf(fp,"\n"); fprintf(fp,"\n");
@ -138,12 +138,12 @@ int main(int narg, char **arg)
// write a LAMMPS data file using SPPARKS data // write a LAMMPS data file using SPPARKS data
LAMMPSDataWrite *lwd = new LAMMPSDataWrite(MPI_COMM_WORLD); LAMMPSDataWrite *lwd = new LAMMPSDataWrite(MPI_COMM_WORLD);
lwd->file("data.lammps"); lwd->file((char *) "data.lammps");
lwd->header("%d atoms",nglobal); lwd->header((char *) "%d atoms",nglobal);
lwd->header("%d atom types",nspins); lwd->header((char *) "%d atom types",nspins);
lwd->header("%g %g xlo xhi",boxxlo,boxxhi); lwd->header((char *) "%g %g xlo xhi",boxxlo,boxxhi);
lwd->header("%g %g ylo yhi",boxylo,boxyhi); lwd->header((char *) "%g %g ylo yhi",boxylo,boxyhi);
lwd->header("%g %g zlo zhi",boxzlo,boxzhi); lwd->header((char *) "%g %g zlo zhi",boxzlo,boxzhi);
lwd->atoms(nlocal_spparks); lwd->atoms(nlocal_spparks);
lwd->atoms(id_spparks); lwd->atoms(id_spparks);
lwd->atoms(spins); lwd->atoms(spins);

View File

@ -1 +1 @@
#define SPKPATH /home/sjplimp/spparks #define SPKPATH /home/sjplimp/spparks/git

View File

@ -6,7 +6,7 @@ SPPARKS applications in 2 sister directories.
The library dir has a Makefile (which you may need to edit for your The library dir has a Makefile (which you may need to edit for your
box). If you type box). If you type
g++ -f Makefile.g++ g++ -f Makefile.mpi
you should create libcouple.a, which the other coupled applications you should create libcouple.a, which the other coupled applications
link to. link to.

View File

@ -1,11 +1,11 @@
#include <mpi.h> #include <mpi.h>
#include <cstdio> #include <cstdio>
#include <cstdlib> #include <cstdlib>
#include "error.h" #include "errorlib.h"
/* ---------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- */
Error::Error(MPI_Comm caller) ErrorLib::ErrorLib(MPI_Comm caller)
{ {
comm = caller; comm = caller;
MPI_Comm_rank(comm,&me); MPI_Comm_rank(comm,&me);
@ -15,7 +15,7 @@ Error::Error(MPI_Comm caller)
called by all procs called by all procs
------------------------------------------------------------------------- */ ------------------------------------------------------------------------- */
void Error::all(const char *str) void ErrorLib::all(const char *str)
{ {
if (me == 0) printf("ERROR: %s\n",str); if (me == 0) printf("ERROR: %s\n",str);
MPI_Finalize(); MPI_Finalize();
@ -26,7 +26,7 @@ void Error::all(const char *str)
called by one proc called by one proc
------------------------------------------------------------------------- */ ------------------------------------------------------------------------- */
void Error::one(const char *str) void ErrorLib::one(const char *str)
{ {
printf("ERROR on proc %d: %s\n",me,str); printf("ERROR on proc %d: %s\n",me,str);
MPI_Abort(comm,1); MPI_Abort(comm,1);
@ -36,7 +36,7 @@ void Error::one(const char *str)
called by one proc called by one proc
------------------------------------------------------------------------- */ ------------------------------------------------------------------------- */
void Error::warning(const char *str) void ErrorLib::warning(const char *str)
{ {
printf("WARNING: %s\n",str); printf("WARNING: %s\n",str);
} }

View File

@ -1,11 +1,11 @@
#ifndef ERROR_H #ifndef ERRORLIB_H
#define ERROR_H #define ERRORLIB_H
#include <mpi.h> #include <mpi.h>
class Error { class ErrorLib {
public: public:
Error(MPI_Comm); ErrorLib(MPI_Comm);
void all(const char *); void all(const char *);
void one(const char *); void one(const char *);

View File

@ -29,7 +29,7 @@ void replace(char *file, char *header, int n, char **lines)
/* ---------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- */
char **extract(char *file, char *header, int n, char **lines) void extract(char *file, char *header, int n, char **lines)
{ {
FILE *fp = fopen(file,"r"); FILE *fp = fopen(file,"r");

View File

@ -1,5 +1,5 @@
#ifndef FILES_H #ifndef FILES_H
#define FILES_H #define FILES_H
void replace(char *, char *, int, char **); void replace(char *, char *, int, char **);
char **extract(char *, char *, int, char **); void extract(char *, char *, int, char **);
#endif #endif

View File

@ -3,7 +3,7 @@
#include <cstring> #include <cstring>
#include "irregular.h" #include "irregular.h"
#include "memory.h" #include "memory.h"
#include "error.h" #include "errorlib.h"
#define MAX(A,B) ((A) > (B)) ? (A) : (B) #define MAX(A,B) ((A) > (B)) ? (A) : (B)
@ -19,7 +19,7 @@ Irregular::Irregular(MPI_Comm caller)
MPI_Comm_size(comm,&nprocs); MPI_Comm_size(comm,&nprocs);
memory = new Memory(comm); memory = new Memory(comm);
error = new Error(comm); error = new ErrorLib(comm);
init(); init();

View File

@ -47,7 +47,7 @@ class Irregular {
MPI_Comm comm; // MPI communicator for all communication MPI_Comm comm; // MPI communicator for all communication
class Memory *memory; class Memory *memory;
class Error *error; class ErrorLib *error;
void exchange_same(char *, char *); void exchange_same(char *, char *);
void exchange_varying(char *, char *); void exchange_varying(char *, char *);

View File

@ -4,7 +4,7 @@
#include "many2many.h" #include "many2many.h"
#include "irregular.h" #include "irregular.h"
#include "memory.h" #include "memory.h"
#include "error.h" #include "errorlib.h"
#include <map> #include <map>
@ -19,7 +19,7 @@ Many2Many::Many2Many(MPI_Comm caller)
MPI_Comm_size(comm,&nprocs); MPI_Comm_size(comm,&nprocs);
memory = new Memory(comm); memory = new Memory(comm);
error = new Error(comm); error = new ErrorLib(comm);
src_own = dest_own = NULL; src_own = dest_own = NULL;
src_off = dest_off = NULL; src_off = dest_off = NULL;

View File

@ -16,7 +16,7 @@ class Many2Many {
int me,nprocs; int me,nprocs;
MPI_Comm comm; MPI_Comm comm;
class Memory *memory; class Memory *memory;
class Error *error; class ErrorLib *error;
int nown; // # of IDs common to src and dest int nown; // # of IDs common to src and dest
int nsrc_off,ndest_off; // # of off-processor IDs int nsrc_off,ndest_off; // # of off-processor IDs

View File

@ -2,13 +2,13 @@
#include <cstdlib> #include <cstdlib>
#include <cstdio> #include <cstdio>
#include "memory.h" #include "memory.h"
#include "error.h" #include "errorlib.h"
/* ---------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- */
Memory::Memory(MPI_Comm comm) Memory::Memory(MPI_Comm comm)
{ {
error = new Error(comm); error = new ErrorLib(comm);
} }
/* ---------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- */

View File

@ -17,7 +17,7 @@ class Memory {
void destroy_2d_double_array(double **); void destroy_2d_double_array(double **);
private: private:
class Error *error; class ErrorLib *error;
}; };
#endif #endif

View File

@ -3,7 +3,7 @@
#include <cstdio> #include <cstdio>
#include "send2one.h" #include "send2one.h"
#include "memory.h" #include "memory.h"
#include "error.h" #include "errorlib.h"
/* ---------------------------------------------------------------------- */ /* ---------------------------------------------------------------------- */
@ -14,7 +14,7 @@ Send2One::Send2One(MPI_Comm caller_comm)
MPI_Comm_size(comm,&nprocs); MPI_Comm_size(comm,&nprocs);
memory = new Memory(comm); memory = new Memory(comm);
error = new Error(comm); error = new ErrorLib(comm);
buf = NULL; buf = NULL;
maxbuf = 0; maxbuf = 0;

View File

@ -14,7 +14,7 @@ class Send2One {
int me,nprocs; int me,nprocs;
MPI_Comm comm; MPI_Comm comm;
class Memory *memory; class Memory *memory;
class Error *error; class ErrorLib *error;
int maxbuf; int maxbuf;
char *buf; char *buf;