Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Minor fix for PSF with NUMLP #1100

Merged
merged 3 commits into from
Aug 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 39 additions & 10 deletions src/Parm_CharmmPsf.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,32 @@ int Parm_CharmmPsf::processReadArgs(ArgList& argIn) {
}

// Parm_CharmmPsf::FindTag()
/** Scan for the given PSF tag of format <#> <TAG>
* \return the <#> value of the tag, or -1 if no tag found.
*/
int Parm_CharmmPsf::FindTag(char* tag, const char* target, BufferedLine& infile) {
int nval = 0;
int tgtsize = strlen( target );
while (strncmp(tag,target,tgtsize)!=0) {
const char* buffer = infile.Line();
if ( buffer == 0 ) return 0;
sscanf(buffer,"%i %10s",&nval,tag);
int nval = -1;
// Check the current line
const char* buffer = infile.CurrentLine();
//mprintf("DEBUG: Current Line: %s\n", buffer);
const char* ptr = strstr(buffer, target);
while (ptr == 0) {
// Check subsequent lines
buffer = infile.Line();
if (buffer == 0) return -1;
//mprintf("DEBUG: Subsequent line: %s\n", buffer);
ptr = strstr(buffer, target);
}
if (ptr != 0) {
//mprintf("DEBUG: Line found: %s\n", buffer);
int nscan = sscanf(buffer,"%i %10s", &nval, tag);
// Sanity check
if (nscan != 2) {
mprinterr("Error: Could not get value for PSF tag %s\n", target);
return -1;
//int tgtsize = strlen( target );
//if (strncmp(tag, target, tgtsize) != 0)
}
}
return nval;
}
Expand Down Expand Up @@ -521,10 +540,20 @@ int Parm_CharmmPsf::ReadParm(FileName const& fname, Topology &parmOut) {
// Advance to <# lone pairs> <# lone pair hosts> NUMLP NUMLPH
int numlp = -1;
int numlph = -1;
while (strncmp(tag, "!NUMLP", 6) !=0) {
const char* buffer = infile.Line();
if ( buffer == 0 ) break;
sscanf(buffer,"%i %i %10s", &numlp, &numlph, tag);
buffer = infile.CurrentLine();
const char* ptr = strstr(buffer, "!NUMLP");
while (ptr == 0) {
buffer = infile.Line();
if (buffer == 0) break;
ptr = strstr(buffer, "!NUMLP");
}
if (ptr != 0) {
int nscan = sscanf(buffer, "%i %i %10s", &numlp, &numlph, tag);
// Sanity check
if (nscan != 3) {
mprinterr("Error: Could not scan values for !NUMLP NUMLPH\n");
return 1;
}
}
if (numlp > -1) {
if (debug_ > 0) mprintf("DEBUG: PSF contains %i lone pairs, %i lone pair hosts.\n", numlp, numlph);
Expand Down
11 changes: 8 additions & 3 deletions src/Topology.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -826,7 +826,8 @@ int Topology::RemoveBond(int atom1, int atom2)
* For bonds to H always insert the H second.
*/
void Topology::AddBond(int atom1, int atom2, int pidxIn) {
//mprintf("DEBUG: Enter AddBond(%i, %i, %i)\n", atom1+1, atom2+1, pidxIn);
//mprintf("DEBUG: Enter AddBond(%i, %i, %s, %s, %i)\n", atom1+1, atom2+1,
// AtomMaskName(atom1).c_str(), AtomMaskName(atom2).c_str(), pidxIn);
// Check if atoms are out of range.
if (WarnOutOfRange(atoms_.size(), atom1, "bond")) return;
if (WarnOutOfRange(atoms_.size(), atom2, "bond")) return;
Expand All @@ -851,9 +852,13 @@ void Topology::AddBond(int atom1, int atom2, int pidxIn) {
if ( (it->A1() == atom1 && it->A2() == atom2) ||
(it->A1() == atom2 && it->A2() == atom1) )
{
mprintf("DEBUG: Existing bond found. Existing Idx %i\n", it->Idx());
if (debug_ > 0)
mprintf("DEBUG: Existing bond found. Existing Idx %i Rk=%f Req=%f\n",
it->Idx(), bondparm_[it->Idx()].Rk(), bondparm_[it->Idx()].Req());
if (it->Idx() < 0) {
mprintf("DEBUG: Adding bond parameter index %i for existing bond.\n", pidxIn);
if (debug_ > 0)
mprintf("DEBUG: Adding bond parameter index %i Rk=%f Req=%f for existing bond.\n",
pidxIn, bondparm_[pidxIn].Rk(), bondparm_[pidxIn].Req());
it->SetIdx( pidxIn );
}
break;
Expand Down
2 changes: 1 addition & 1 deletion src/Version.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
* Whenever a number that precedes <revision> is incremented, all subsequent
* numbers should be reset to 0.
*/
#define CPPTRAJ_INTERNAL_VERSION "V6.29.0"
#define CPPTRAJ_INTERNAL_VERSION "V6.29.1"
/// PYTRAJ relies on this
#define CPPTRAJ_VERSION_STRING CPPTRAJ_INTERNAL_VERSION
#endif
Loading