Skip to content
This repository has been archived by the owner on May 26, 2021. It is now read-only.

fixes for -Wextra -Wpedantic -Wshadow -Wconversion #47

Merged
merged 10 commits into from
Oct 26, 2019
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
40 changes: 8 additions & 32 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,40 +3,16 @@
[![Build Status](https://travis-ci.org/votca/csgapps.svg?branch=master)](https://travis-ci.org/votca/csgapps)
[![pipeline status](https://gitlab.com/votca/csgapps/badges/master/pipeline.svg)](https://gitlab.com/votca/csgapps/commits/master)

This repository contains some small analysis programs which are written based on the votca_csg framework
This repository contains some small analysis programs which are written based on the votca csg framework

# Programs

* __radii__

calculate gyration radius + hydrodynamic radius of a molecule or a set of molecules

* __sphericalorder__

calculates a spherical order parameter i.e. the distribution of e_r\*u where e_r is the unit vector from
a reference molecule to the solvent molecules and u is the principle axis of inertia of the solvent molecule

* __fluctuations__

calculate the number density fluctuations in subvolumes. Subvolumes are either cubic slabs along one of the
sim box axis or speherical subvolumes around a solute

* __orientcorr__

calculates the distance dependent orientational correlation function of a polymer melt

* __part_dist__

outputs the time-averaged number of particles, listed by particle types (was a part of csg before)

* __partial_rdf__

calculates the rdf in a spherical subvolume

* __traj_force__

add/subtracts reference forces from a given trajectory and stores in a new trajectory


* _radii_: calculate gyration radius + hydrodynamic radius of a molecule or a set of molecules
* _sphericalorder_: calculates a spherical order parameter i.e. the distribution of e\_r\*u where e\_r is the unit vector from a reference molecule to the solvent molecules and u is the principle axis of inertia of the solvent molecule
* _fluctuations_: calculate the number density fluctuations in subvolumes. Subvolumes are either cubic slabs along one of the sim box axis or speherical subvolumes around a solute
* _orientcorr_: calculates the distance dependent orientational correlation function of a polymer melt
* _part_dist_: outputs the time-averaged number of particles, listed by particle types (was a part of csg before)
* _partial\_rdf_: calculates the rdf in a spherical subvolume
* _traj\_force_: add/subtracts reference forces from a given trajectory and stores in a new trajectory

To add your own program just create a new folder and put your *.cc files in there
65 changes: 20 additions & 45 deletions fluctuations/fluctuations.cc
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,11 @@
*/

#include <boost/program_options.hpp>
#include <fstream>
#include <iostream>
#include <math.h>
#include <stdlib.h>
#include <votca/csg/cgengine.h>
#include <votca/csg/csgapplication.h>
#include <votca/tools/average.h>
#include <votca/tools/histogramnew.h>
#include <votca/tools/tokenizer.h>

// using namespace votca::tools;
using namespace std;
using namespace votca::csg;

Expand Down Expand Up @@ -77,7 +72,7 @@ class CsgFluctuations : public CsgApplication {
bool DoTrajectory() override { return true; }
bool DoMapping() override { return true; }

void BeginEvaluate(Topology *top, Topology *top_atom) override {
void BeginEvaluate(Topology *top, Topology *) override {
_filter = OptionsMap()["filter"].as<string>();
_refmol = OptionsMap()["refmol"].as<string>();
_rmin = OptionsMap()["rmin"].as<double>();
Expand All @@ -102,17 +97,11 @@ class CsgFluctuations : public CsgApplication {
cout << "Doing slabs along z-axis" << endl;
_dim = 2;
} else {
cout << "Unrecognized geometry option. (sphere|x|y|z)" << endl;
exit(0);
throw std::runtime_error("Unrecognized geometry option. (sphere|x|y|z)");
}

_N_avg = new double[_nbins];
_N_sq_avg = new double[_nbins];
N = new int[_nbins];
for (int i = 0; i < _nbins; i++) {
_N_avg[i] = 0;
_N_sq_avg[i] = 0;
}
_N_avg = Eigen::VectorXd::Zero(_nbins);
_N_sq_avg = Eigen::VectorXd::Zero(_nbins);

if (_do_spherical) {
cout << "Calculating fluctions for " << _rmin << "<r<" << _rmax;
Expand All @@ -125,17 +114,14 @@ class CsgFluctuations : public CsgApplication {

if (_refmol == "" && _do_spherical) {
Eigen::Matrix3d box = top->getBox();
Eigen::Vector3d a = box.col(0);
Eigen::Vector3d b = box.col(1);
Eigen::Vector3d c = box.col(2);
_ref = (a + b + c) / 2;
_ref = box.rowwise().sum() / 2;

cout << "Refernce is center of box " << _ref << endl;
cout << "Reference is center of box " << _ref << endl;
}

_outfile.open(_outfilename.c_str());
_outfile.open(_outfilename);
if (!_outfile) {
throw runtime_error("cannot open outfile for output");
throw runtime_error("cannot open" + _outfilename + " for output");
}
}

Expand All @@ -147,10 +133,9 @@ class CsgFluctuations : public CsgApplication {
protected:
// number of particles in dV
int _nbins;
double *_N_avg;
Eigen::VectorXd _N_avg;
// sqare
double *_N_sq_avg;
int *N;
Eigen::VectorXd _N_sq_avg;
string _filter;
string _refmol;
double _rmax;
Expand All @@ -170,11 +155,7 @@ int main(int argc, char **argv) {
return app.Exec(argc, argv);
}

void CsgFluctuations::EvalConfiguration(Topology *conf,
Topology *conf_atom = nullptr) {
Eigen::Vector3d eR;
double r = 0;
int rbin;
void CsgFluctuations::EvalConfiguration(Topology *conf, Topology *) {

if (_refmol != "") {
for (Bead *bead : conf->Beads()) {
Expand All @@ -185,21 +166,20 @@ void CsgFluctuations::EvalConfiguration(Topology *conf,
}
}

for (int i = 0; i < _nbins; i++) {
N[i] = 0;
}
votca::tools::HistogramNew hist;
hist.Initialize(_rmin, _rmax, _nbins);

/* check how many molecules are in each bin*/
for (Bead *bead : conf->Beads()) {
if (!votca::tools::wildcmp(_filter.c_str(), bead->getName().c_str())) {
continue;
}

double r = 0;
if (_do_spherical) {
eR = bead->getPos() - _ref;
Eigen::Vector3d eR = bead->getPos() - _ref;
r = eR.norm();
} else {
eR = bead->getPos();
Eigen::Vector3d eR = bead->getPos();
if (_dim == 0) {
r = eR.x();
} else if (_dim == 1) {
Expand All @@ -208,17 +188,12 @@ void CsgFluctuations::EvalConfiguration(Topology *conf,
r = eR.z();
}
}
if (r > _rmin && r < _rmax) {
rbin = (int)_nbins * (double)((r - _rmin) / (_rmax - _rmin));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks a lot like a histogram..hmm.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

True, do you want to refactor?

N[rbin]++;
}
hist.Process(r);
}

/* update averages*/
for (int i = 0; i < _nbins; i++) {
_N_avg[i] += N[i];
_N_sq_avg[i] += N[i] * N[i];
}
_N_avg += hist.data().y();
_N_sq_avg += hist.data().y().cwiseAbs2();

_nframes++;
}
Expand Down
11 changes: 5 additions & 6 deletions orientcorr/orientcorr.cc
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,6 @@ string OrientCorrApp::_nbmethod;
class MyWorker : public CsgApplication::Worker {
public:
~MyWorker() override = default;
;

// evaluate the current frame
void EvalConfiguration(Topology *top, Topology *top_ref) override;
Expand Down Expand Up @@ -135,7 +134,7 @@ NBList *OrientCorrApp::CreateNBSearch() {
}

// initialize the histograms
void OrientCorrApp::BeginEvaluate(Topology *top, Topology *top_ref) {
void OrientCorrApp::BeginEvaluate(Topology *, Topology *) {
_cor.Initialize(0, _cut_off, _nbins);
_count.Initialize(0, _cut_off, _nbins);
_cor_excl.Initialize(0, _cut_off, _nbins);
Expand All @@ -155,7 +154,7 @@ CsgApplication::Worker *OrientCorrApp::ForkWorker() {
}

// evaluates a frame
void MyWorker::EvalConfiguration(Topology *top, Topology *top_ref) {
void MyWorker::EvalConfiguration(Topology *top, Topology *) {

// first genearate a mapped topology
// the beads are sitting on the bonds and have an orientation which
Expand Down Expand Up @@ -193,8 +192,8 @@ void MyWorker::EvalConfiguration(Topology *top, Topology *top_ref) {
cout << "done\n";

// the neighbor search only finds pairs, add self-self correlation parts here
_cor.Process(0.0f, mapped.BeadCount());
_count.Process(0.0f, mapped.BeadCount());
_cor.Process(0.0f, (double)mapped.BeadCount());
_count.Process(0.0f, (double)mapped.BeadCount());

// search for all beads
BeadList b;
Expand All @@ -215,7 +214,7 @@ void MyWorker::EvalConfiguration(Topology *top, Topology *top_ref) {

// process a pair, since return value is falsed, pairs are not cached which
// saves a lot of memory for the big systems
bool MyWorker::FoundPair(Bead *b1, Bead *b2, const Eigen::Vector3d &r,
bool MyWorker::FoundPair(Bead *b1, Bead *b2, const Eigen::Vector3d &,
const double dist) {
double tmp = b1->getV().dot(b2->getV());
double P2 = 3. / 2. * tmp * tmp - 0.5;
Expand Down
Loading