-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #52 from nirgoldman/test_branch
Test branch
- Loading branch information
Showing
9 changed files
with
480 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
CXX = g++ -O3 -std=c++11 | ||
CCOMP = gcc -O3 | ||
DEBUG = 1 | ||
|
||
C_LOC = $(realpath .) | ||
|
||
CHIMESFF_LOC=$(C_LOC)/../../../chimesFF/src | ||
CHIMESFF_SRC=$(CHIMESFF_LOC)/chimesFF.cpp | ||
CHIMESFF_HDR=$(CHIMESFF_LOC)/chimesFF.h | ||
|
||
chimesFF.o : $(CHIMESFF_SRC) | ||
$(CXX) -c $(CHIMESFF_SRC) -I $(CHIMESFF_LOC) | ||
|
||
SERIAL_LOC=$(C_LOC)/../../src | ||
SERIAL_SRC=$(SERIAL_LOC)/serial_chimes_interface.cpp | ||
SERIAL_HDR=$(SERIAL_LOC)/serial_chimes_interface.h | ||
|
||
serial_chimes_interface.o : $(SERIAL_SRC) | ||
$(CXX) -c $(SERIAL_SRC) -I $(SERIAL_LOC) -I $(CHIMESFF_LOC) | ||
|
||
WRAPPER_LOC=$(C_LOC)/../../api | ||
WRAPPER_SRC=$(WRAPPER_LOC)/chimescalc_serial_C.cpp | ||
WRAPPER_HDR=$(WRAPPER_LOC)/chimescalc_serial_C.h | ||
|
||
chimescalc_serial_C.o : $(WRAPPER_SRC) | ||
$(CXX) -c $(WRAPPER_SRC) -I $(WRAPPER_LOC) -I $(SERIAL_LOC) -I $(CHIMESFF_LOC) | ||
|
||
TEST_LOC=$(C_LOC) | ||
TEST_SRC=$(TEST_LOC)/main.c | ||
|
||
main.o: $(TEST_SRC) | ||
$(CCOMP) -c $(TEST_SRC) -DDEBUG=${DEBUG} -I $(WRAPPER_LOC) -I $(SERIAL_LOC) -I $(CHIMESFF_LOC) | ||
|
||
TEST_LNK = chimesFF.o serial_chimes_interface.o chimescalc_serial_C.o main.o | ||
|
||
test-C: $(TEST_LNK) | ||
$(CXX) $(TEST_LNK) -o chimescalc-test_serial-C_instance | ||
|
||
clean: | ||
rm -f *.o | ||
|
||
clean-all: | ||
make clean | ||
rm -f chimescalc-test_serial-C_instance | ||
|
||
all: | ||
make chimesFF.o | ||
make serial_chimes_interface.o | ||
make chimescalc_serial_C.o | ||
make main.o | ||
make test-C | ||
make clean |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,110 @@ | ||
/* | ||
ChIMES Calculator | ||
Copyright (C) 2020 Rebecca K. Lindsey, Nir Goldman, and Laurence E. Fried | ||
Contributing Author: Nir Goldman (2020) | ||
*/ | ||
|
||
#include <stdlib.h> | ||
#include <math.h> | ||
#include <stdio.h> | ||
#include <string.h> | ||
#include <unistd.h> | ||
#include "chimescalc_serial_C.h" | ||
|
||
int main (int argc, char **argv) | ||
{ | ||
int small = 0; // 0 = false, 1 = true | ||
|
||
if ((argc != 4)&&(argc !=3)) | ||
{ | ||
printf("To run: ./test.x <parameter file> <xyz config. file>\n"); | ||
printf("or\n"); | ||
printf("./test.x <parameter file> <xyz config. file> <allow_replicates(0/1)>\n"); | ||
printf("Exiting code.\n"); | ||
exit(0); | ||
} | ||
if(argc==4) | ||
small = atoi(argv[3]); | ||
|
||
const double GPa = 6.9479; // convert kcal/mol.A^3 to GPa | ||
FILE *fconf; | ||
int natom, i, j, k, l; | ||
char junk; | ||
double lx, ly, lz; | ||
double ca[3], cb[3], cc[3]; | ||
fconf = fopen (argv[2],"r"); | ||
fscanf(fconf,"%d\n",&natom); | ||
fscanf(fconf,"%lf %lf %lf %lf %lf %lf %lf %lf %lf\n",&ca[0],&ca[1],&ca[2],&cb[0],&cb[1],&cb[2],&cc[0],&cc[1],&cc[2]); | ||
double vol = lx*ly*lz; | ||
double *stress = (double *) calloc(9,sizeof(double)); | ||
double energy = 0.0; | ||
double xij, yij, zij, rij, dr[3]; | ||
double xc[natom], yc[natom], zc[natom]; | ||
double fx[natom], fy[natom], fz[natom]; | ||
char atom_types[natom][50], *atom[natom]; | ||
char *atype2b[2], *atype3b[3], *atype4b[4]; | ||
|
||
for (i = 0; i < natom; i++) | ||
{ | ||
fx[i] = 0.0; | ||
fy[i] = 0.0; | ||
fz[i] = 0.0; | ||
} | ||
for (i = 0; i < natom; i++) | ||
{ | ||
fscanf(fconf,"%s %lf %lf %lf\n",atom_types[i],&xc[i],&yc[i],&zc[i]); | ||
atom[i] = atom_types[i]; | ||
} | ||
fclose(fconf); | ||
//set_chimes_serial(small); | ||
void *chimes_ptr = chimes_open_instance(); | ||
set_chimes_serial_instance(chimes_ptr, small); | ||
|
||
printf("Read args:\n"); | ||
for (i=1; i<argc; i++) | ||
printf("%i %s\n",i, argv[i]); | ||
|
||
int rank = 0; | ||
//init_chimes_serial(argv[1],&rank); | ||
init_chimes_serial_instance(chimes_ptr, argv[1], rank); | ||
|
||
//calculate_chimes(natom, xc, yc, zc, atom, ca, cb, cc, &energy, fx, fy, fz, stress); | ||
calculate_chimes_instance(chimes_ptr, natom, xc, yc, zc, atom, ca, cb, cc, &energy, fx, fy, fz, stress); | ||
for (i = 0; i < 9; i++) { | ||
stress[i] *= GPa; | ||
} | ||
|
||
printf("\n%s\n", "Success!"); | ||
printf("%s\t%f\n","Energy (kcal/mol):", energy); | ||
printf("%s\n", "Stress tensors (GPa)"); | ||
printf("%s %f\n","\ts_xx: ",stress[0]); | ||
printf("%s %f\n","\ts_yy: ",stress[4]); | ||
printf("%s %f\n","\ts_zz: ",stress[8]); | ||
printf("%s %f\n","\ts_xy: ",stress[1]); | ||
printf("%s %f\n","\ts_xz: ",stress[2]); | ||
printf("%s %f\n","\ts_yz: ",stress[5]); | ||
printf("%s\n", "Forces (kcal/mol/A)"); | ||
for (i = 0; i <natom; i++) | ||
printf("\t%f\t%f\t%f\n", fx[i], fy[i], fz[i]); | ||
printf("\n"); | ||
|
||
#if DEBUG==1 | ||
|
||
FILE *fout; | ||
fout = fopen("debug.dat","w"); | ||
fprintf(fout,"%0.6f\n", energy); | ||
fprintf(fout,"%0.6f\n", stress[0]); | ||
fprintf(fout,"%0.6f\n", stress[4]); | ||
fprintf(fout,"%0.6f\n", stress[8]); | ||
fprintf(fout,"%0.6f\n", stress[1]); | ||
fprintf(fout,"%0.6f\n", stress[2]); | ||
fprintf(fout,"%0.6f\n", stress[5]); | ||
|
||
for (i = 0; i <natom; i++) | ||
fprintf(fout,"%0.6f\n%0.6e\n%0.6e\n", fx[i], fy[i],fz[i]); | ||
fclose(fout); | ||
chimes_close_instance(chimes_ptr); | ||
|
||
#endif | ||
|
||
} |
Oops, something went wrong.