Skip to content

Commit

Permalink
Merge pull request #7 from ZimmermanGroup:joshkamm/issue5
Browse files Browse the repository at this point in the history
Joshkamm/issue5
  • Loading branch information
joshkamm authored Aug 31, 2024
2 parents 19b5056 + 975b297 commit 7e69a51
Show file tree
Hide file tree
Showing 11 changed files with 867 additions and 51 deletions.
2 changes: 2 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# GitHub syntax highlighting
pixi.lock linguist-language=YAML linguist-generated=true
8 changes: 8 additions & 0 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
- [ ] Implement changes
- [ ] Update documentation
- [ ] Update tests
- [ ] Look through pull request changes
- [ ] Clean up code and retest
- [ ] Increment version number

Closes ISSUE
15 changes: 15 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# This workflow will compile ZStruct including dependencies
name: CI

on: [push]

jobs:
build:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- name: Set up pixi
uses: prefix-dev/setup-pixi@v0.8.1
- name: Compile and test
run: pixi run start
13 changes: 13 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# C++ build files
*.o
*.exe

# output from testing the tutorial
# a copy of the output is version controlled under tutorial/example
tutorial/scratch
tutorial/DUPLICATES
tutorial/GSMDATA*

# pixi environments
.pixi
*.egg-info
17 changes: 7 additions & 10 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,19 @@
# Executable name
CMD = zstruct.exe

# -------- description of DFLAGS ---------------


# -------- Define environmental variable C_COMPILER -----------
# Make sure it is defined
# ifeq ($(strip$(FORTRAN_COMPILER)),)
# Otherwise you can define it here also by uncommenting next line
FC = icpc -openmp -I$(MKLROOT)/include
FC = icpx -I"${CONDA_PREFIX}/include"
# FC = icpc -qopenmp -I$(MKLROOT)/include
# FC = g++ -fopenmp -I$(MKLROOT)/include

# -------- description of DFLAGS ---------------
DFLAGS = #-Define the cpp flags to be used
#DFLAGS = #-Define the cpp flags to be used
OFLAGS = # optimization

#Intel parallel openmp (only w/icpc compiler)
# Intel parallel openmp (only w/ intel compiler?)
# generated using https://www.intel.com/content/www/us/en/developer/tools/oneapi/onemkl-link-line-advisor.html
LINKERFLAGS = -L${CONDA_PREFIX}/lib -lmkl_intel_ilp64 -lmkl_tbb_thread -lmkl_core -lpthread -lm -ldl
#LINKERFLAGS = -L$(MKLROOT)/lib/em64t -lmkl_intel_lp64 -lmkl_intel_thread -lmkl_core -lpthread -lm
LINKERFLAGS = -L$(MKLROOT)/lib/intel64 -lmkl_intel_lp64 -lmkl_intel_thread -lmkl_core -lpthread
# MAC OS linkers
#LINKERFLAGS = -lm -framework Accelerate

Expand Down
14 changes: 12 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,20 @@ code for ZStruct-2

## Overview

ZStruct is a package for automated reaction discovery developed in c++.
ZStruct is a package for automated reaction discovery developed in C++.

For more information, check out the wiki page: https://github.com/ZimmermanGroup/ZStruct/wiki
For more information, check out the wiki page (somewhat out of date but hopefully still useful): https://github.com/ZimmermanGroup/ZStruct/wiki

Sample tutorial files can be found under the tutorial folder: https://github.com/ZimmermanGroup/ZStruct/tree/master/tutorial

## Installation

First, clone this github repository.

Aug 2024: Attempting a more reproducible build with [Pixi](https://pixi.sh), a tool built on the conda ecosystem to manage both dependencies and configuration / installation workflows.

The pixi.toml file in this repository specifies the dependency package names as they appear on [conda-forge](https://conda-forge.org/) and installation tasks. You can use pixi (simple installation instructions [here](https://pixi.sh)) to install the dependencies and execute the build, or reference the configuration files and do something equivalent using your preferred tools.

With pixi, I built ZStruct by navigating into the ZStruct git repository and executing `pixi run start` which installs the dependencies, executes the Makefile, and if successful runs the built executable.

Notes: The build has succeeded in a github actions environment which is a freshly cloned linux virtual machine. On our computing cluster, I find that I either need to unload one of our default linux modules or clear the LD_LIBRARY_PATH with `export LD_LIBRARY_PATH=""`. I assume this avoids a conflicting version of some dependency taking priority over the version installed for ZStruct.
12 changes: 6 additions & 6 deletions icoord.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1458,7 +1458,7 @@ void ICoord::structure_read(string xyzfile)

string line;
bool success=true;
success=getline(infile, line);
success=(bool)getline(infile, line);
if (success)
{
int length=StringTools::cleanstring(line);
Expand All @@ -1469,7 +1469,7 @@ void ICoord::structure_read(string xyzfile)
printf(" natoms: %2i natomsa: %2i \n",natoms,natomsa);
if (natoms<1) { printf(" ERROR: natoms must be > 0 \n"); exit(1); }

success=getline(infile, line);
success=(bool)getline(infile, line);
if (success) comment = line;

anumbers = new int[1+natomsa];
Expand All @@ -1478,7 +1478,7 @@ void ICoord::structure_read(string xyzfile)

//cout <<" -Reading the atomic names...";
for (int i=0;i<natoms;i++){
success=getline(infile, line);
success=(bool)getline(infile, line);
int length=StringTools::cleanstring(line);
vector<string> tok_line = StringTools::tokenize(line, " \t");
anames[i] = tok_line[0];
Expand All @@ -1502,10 +1502,10 @@ void ICoord::structure_read(string xyzfile)
fflush(stdout);


success=getline(infile, line);
success=getline(infile, line);
success=(bool)getline(infile, line);
success=(bool)getline(infile, line);
for (int j=0;j<natoms;j++){
success=getline(infile, line);
success=(bool)getline(infile, line);
int length=StringTools::cleanstring(line);
vector<string> tok_line = StringTools::tokenize(line, " \t");
coords[3*j+0]=atof(tok_line[1].c_str());
Expand Down
48 changes: 24 additions & 24 deletions nbo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -622,7 +622,7 @@ int NBO::read_mopac_mo(string filename)
int offset = 0;
while(!infile.eof())
{
success = getline(infile,line);
success = (bool)getline(infile,line);
if (line.find("NO. OF FILLED LEVELS")!=string::npos)
{
tok_line = StringTools::tokenize(line, " \t");
Expand All @@ -640,9 +640,9 @@ int NBO::read_mopac_mo(string filename)
{
// printf(" found ROOT NO, cao: %2i \n",cao);
//cout << " RR1: " << line << endl;
success = getline(infile,line);
success = (bool)getline(infile,line);
//cout << " RR2: " << line << endl;
success = getline(infile,line);
success = (bool)getline(infile,line);
//cout << " RR3: " << line << endl;
tok_line = StringTools::tokenize(line, " \t");

Expand All @@ -653,15 +653,15 @@ int NBO::read_mopac_mo(string filename)
for (int i=0;i<nnew;i++)
mo_occ[offset+i] = atof(tok_line[i].c_str());

success = getline(infile,line);
success = (bool)getline(infile,line);
//cout << " RR4: " << line << endl;
success = getline(infile,line);
success = (bool)getline(infile,line);
//cout << " RR5: " << line << endl;

//starting here, MO coefs
for (int i=0;i<natoms;i++)
{
success = getline(infile,line);
success = (bool)getline(infile,line);
//cout << " RRat: " << line << endl;
tok_line = StringTools::tokenize(line, " \t");
nnew = tok_line.size() - 3;
Expand All @@ -673,7 +673,7 @@ int NBO::read_mopac_mo(string filename)
for (int j=0;j<nnew;j++)
MO[(offset+j)*nao+cao] = atof(tok_line[3+j].c_str());
cao += 1;
success = getline(infile,line);
success = (bool)getline(infile,line);
}
else if (tok_line[1]=="B" || tok_line[1]=="C" || tok_line[1]=="N" || tok_line[1]=="O" || tok_line[1]=="F")
{
Expand All @@ -685,7 +685,7 @@ int NBO::read_mopac_mo(string filename)
for (int j=0;j<nnew;j++)
MO[(offset+j)*nao+cao] = atof(tok_line[3+j].c_str());
cao += 1;
success = getline(infile,line);
success = (bool)getline(infile,line);
}
}
}
Expand Down Expand Up @@ -717,14 +717,14 @@ int NBO::read_mopac_mo(string filename)
int nhp = 0;
while (!infile.eof())
{
success = getline(infile,line);
success = (bool)getline(infile,line);
if (line.find("NET ATOMIC CHARGES")!=string::npos)
{
success = getline(infile,line);
success = getline(infile,line);
success = (bool)getline(infile,line);
success = (bool)getline(infile,line);
for (int i=0;i<natoms;i++)
{
success = getline(infile,line);
success = (bool)getline(infile,line);
// cout << " RR1: " << line << endl;
tok_line = StringTools::tokenize(line, " \t");
q[i] = atof(tok_line[2].c_str());
Expand All @@ -739,11 +739,11 @@ int NBO::read_mopac_mo(string filename)
}
if (line.find("NUMBER OF CENTERS")!=string::npos)
{
success = getline(infile,line);
success = getline(infile,line);
success = (bool)getline(infile,line);
success = (bool)getline(infile,line);
while (!infile.eof())
{
success = getline(infile,line);
success = (bool)getline(infile,line);
tok_line = StringTools::tokenize(line, " \t");
int lsize = tok_line.size();
if (lsize>0)
Expand Down Expand Up @@ -899,7 +899,7 @@ int NBO::read_mo(string filename)
mheadersize = 0;
while(!infile.eof())
{
success = getline(infile,line);
success = (bool)getline(infile,line);
if (line.find("[MO]")!=string::npos)
break;
if (mcounting)
Expand All @@ -915,7 +915,7 @@ int NBO::read_mo(string filename)
infile.open(filename.c_str());
while(!infile.eof())
{
success = getline(infile,line);
success = (bool)getline(infile,line);
if (line.find("[Molden Format]")!=string::npos)
mcounting = 1;
if (mcounting)
Expand All @@ -931,13 +931,13 @@ int NBO::read_mo(string filename)
infile.open(filename.c_str());
while(!infile.eof())
{
success = getline(infile,line);
success = (bool)getline(infile,line);
if (line.find("[GTO]")!=string::npos)
{
// cout << " RR00: " << line << endl;
while(line.find("[MO]")==string::npos)
{
success = getline(infile,line);
success = (bool)getline(infile,line);
// cout << " RR0: " << line << endl;
tok_line = StringTools::tokenize(line, " \t");
if (tok_line.size()>1)
Expand All @@ -948,7 +948,7 @@ int NBO::read_mo(string filename)
int cont = 1;
while(cont)
{
success = getline(infile,line);
success = (bool)getline(infile,line);
tok_line = StringTools::tokenize(line, " \t");
//cout << " RR0: " << line << endl;
if (line.find("S")!=string::npos)
Expand Down Expand Up @@ -988,15 +988,15 @@ int NBO::read_mo(string filename)
}
}
for (int i=0;i<4;i++)
success = getline(infile,line);
success = (bool)getline(infile,line);

printf(" found %i ao's (with 3p 5d etc) \n",nao);

double* jMO1 = new double[MAX_BASIS]; //Note max basis limit
int dim = 0;
while (!infile.eof())
{
success = getline(infile,line);
success = (bool)getline(infile,line);
if (line.find("Sym")!=string::npos)
{
//cout << " RR1: " << line << endl;
Expand All @@ -1021,13 +1021,13 @@ int NBO::read_mo(string filename)
nmo = 1;
while (!infile.eof())
{
success = getline(infile,line);
success = (bool)getline(infile,line);
cout << " RRX: " << line << endl;
if (line.find("Occup=")!=string::npos)
{
for (int j=0;j<nao;j++)
{
success = getline(infile,line);
success = (bool)getline(infile,line);
cout << " RRY: " << line << endl;
tok_line = StringTools::tokenize(line, " \t");
MO[nmo*nao+j] = atof(tok_line[1].c_str());
Expand Down
Loading

0 comments on commit 7e69a51

Please sign in to comment.