Skip to content

Commit

Permalink
Added some debugging info - charges are set but disappear
Browse files Browse the repository at this point in the history
Signed-off-by: Geoff Hutchison <[email protected]>
  • Loading branch information
ghutchis committed Oct 15, 2024
1 parent 3caa5b0 commit 6703321
Showing 1 changed file with 15 additions and 5 deletions.
20 changes: 15 additions & 5 deletions avogadro/io/xyzformat.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -104,17 +104,18 @@ bool XyzFormat::read(std::istream& inStream, Core::Molecule& mol)
vector<string> tokens(split(properties, ':'));
unsigned int column = 0;
for (size_t i = 0; i < tokens.size(); i += 3) {
// increment column based on the count of the property
if (i + 2 < tokens.size()) {
column += lexicalCast<unsigned int>(tokens[i + 2]);
}

// we can safely assume species and pos are present
if (tokens[i] == "charge") {
chargeColumn = column;
std::cout << " found charges " << chargeColumn << std::endl;
} else if (tokens[i] == "force" || tokens[i] == "forces") {
forceColumn = column;
} // TODO other properties (velocity, spin, selection, etc.)

// increment column based on the count of the property
if (i + 2 < tokens.size()) {
column += lexicalCast<unsigned int>(tokens[i + 2]);
}
}
}

Expand Down Expand Up @@ -175,6 +176,9 @@ bool XyzFormat::read(std::istream& inStream, Core::Molecule& mol)
chargesMatrix(i, 0) = charges[i];
}
mol.setPartialCharges("From File", chargesMatrix);

std::cout << "Charges set " << charges.size() << " " << mol.atomCount()
<< std::endl;
}

// Do we have an animation?
Expand Down Expand Up @@ -245,6 +249,12 @@ bool XyzFormat::read(std::istream& inStream, Core::Molecule& mol)
mol.perceiveBondOrders();
}

// check partial charge types
auto types = mol.partialChargeTypes();
for (const auto& type : types) {
std::cout << "Partial charge type: " << type << std::endl;
}

return true;
}

Expand Down

0 comments on commit 6703321

Please sign in to comment.