Skip to content

Commit

Permalink
Merge pull request #309 from cniethammer/improve_log_output_site_para…
Browse files Browse the repository at this point in the history
…meters

Add log output for site parameters when reading xml input configuration
  • Loading branch information
cniethammer authored May 24, 2024
2 parents 269b91e + 550a158 commit baff96a
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 8 deletions.
4 changes: 2 additions & 2 deletions src/molecules/Component.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,11 @@ void Component::readXML(XMLfileUnits& xmlconfig) {
Log::global_log->info() << "Reading in component" << std::endl;
unsigned int cid = 0;
xmlconfig.getNodeValue( "@id", cid );
Log::global_log->info() << "Component ID:" << cid << std::endl;
Log::global_log->info() << "Component ID: " << cid << std::endl;
setID(cid - 1);
std::string name;
xmlconfig.getNodeValue( "@name", name );
Log::global_log->info() << "Component name:" << name << std::endl;
Log::global_log->info() << "Component name: " << name << std::endl;
setName(name);

XMLfile::Query query = xmlconfig.query( "site" );
Expand Down
23 changes: 17 additions & 6 deletions src/molecules/Site.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,16 +51,17 @@ class Site {
\endcode
*/
virtual void readXML(XMLfileUnits& xmlconfig) {
if (!xmlconfig.getNodeValue("@name", _name)) {
Log::global_log->warning() << "Cannot find site name. Defaulting to type." << std::endl;
xmlconfig.getNodeValue("@type", _name);
}
Log::global_log->info() << "Site name: " << _name << std::endl;
xmlconfig.getNodeValueReduced("coords/x", _r[0]);
xmlconfig.getNodeValueReduced("coords/y", _r[1]);
xmlconfig.getNodeValueReduced("coords/z", _r[2]);
Log::global_log->info() << "Site coordinates: (x, y, z) = (" << _r[0] << ", " << _r[1] << ", " << _r[2] << ")" << std::endl;
xmlconfig.getNodeValueReduced("mass", _m);

if (!xmlconfig.getNodeValue("@name", _name)) {
Log::global_log->error() << "Cannot find site name. Defaulting to type." << std::endl;
xmlconfig.getNodeValue("@type", _name);
}

Log::global_log->info() << "Site mass: " << _m << std::endl;
}

virtual ~Site() {}
Expand Down Expand Up @@ -124,9 +125,11 @@ class LJcenter : public Site {
*/
void readXML(XMLfileUnits& xmlconfig) {
Site::readXML(xmlconfig);
Log::global_log->info() << "Site type: Lennard-Jones 12-6" << std::endl;
xmlconfig.getNodeValueReduced("epsilon", _epsilon);
xmlconfig.getNodeValueReduced("sigma", _sigma);
xmlconfig.getNodeValue("shifted", _shiftRequested);
Log::global_log->info() << "Site parameters: epsilon = " << _epsilon << ", sigma: " << _sigma << ", shifted: " << _shiftRequested << std::endl;
}

/// write to stream
Expand Down Expand Up @@ -191,7 +194,9 @@ class Charge : public Site {
*/
void readXML(XMLfileUnits& xmlconfig) {
Site::readXML(xmlconfig);
Log::global_log->info() << "Site type: Charge" << std::endl;
xmlconfig.getNodeValueReduced("charge", _q);
Log::global_log->info() << "Site parameters: charge = " << _q << std::endl;
}

/// write to stream
Expand Down Expand Up @@ -312,6 +317,7 @@ class Dipole : public OrientedSite {
*/
void readXML(XMLfileUnits& xmlconfig) {
Site::readXML(xmlconfig);
Log::global_log->info() << "Site type: Dipole" << std::endl;
bool bAngleInput = true;
double theta, phi;
bAngleInput = bAngleInput && xmlconfig.getNodeValueReduced("dipolemoment/theta", theta);
Expand All @@ -324,7 +330,9 @@ class Dipole : public OrientedSite {
xmlconfig.getNodeValueReduced("dipolemoment/z", _e[2]);
normalize_e();
}
Log::global_log->info() << "Site parameters: dipole moment (ex, ey, ez) = (" << _e[0] << ", " << _e[1] << ", " << _e[2] << ")" << std::endl;
xmlconfig.getNodeValueReduced("dipolemoment/abs", _abs);
Log::global_log->info() << "Site parameters: dipole moment abs = " << _abs << std::endl;
}

double absMy() const { return abs(); } /**< get the absolute value of the dipole moment. */
Expand Down Expand Up @@ -374,6 +382,7 @@ class Quadrupole : public OrientedSite {
*/
void readXML(XMLfileUnits& xmlconfig) {
Site::readXML(xmlconfig);
Log::global_log->info() << "Site type: Quadrupole" << std::endl;
bool bAngleInput = true;
double theta, phi;
bAngleInput = bAngleInput && xmlconfig.getNodeValueReduced("quadrupolemoment/theta", theta);
Expand All @@ -386,7 +395,9 @@ class Quadrupole : public OrientedSite {
xmlconfig.getNodeValueReduced("quadrupolemoment/z", _e[2]);
normalize_e();
}
Log::global_log->info() << "Site parameters: quadrupole moment (ex, ey, ez) = (" << _e[0] << ", " << _e[1] << ", " << _e[2] << ")" << std::endl;
xmlconfig.getNodeValueReduced("quadrupolemoment/abs", _abs);
Log::global_log->info() << "Site parameters: quadrupole moment (abs) = " << _abs << std::endl;
}

double absQ() const { return abs(); } /**< get the absolute value of the quadrupole moment. */
Expand Down

0 comments on commit baff96a

Please sign in to comment.