38 std::vector<double> result;
41 if (!intt.is_open()) {
42 throw std::runtime_error(
"File:" + filename +
" could not be opened");
50 if (!split.size() || split[0] ==
"#" || split[0].substr(0, 1) ==
"#") {
53 if (split.size() != 2) {
54 throw std::runtime_error(
"Row should only contain id and occupation");
57 Index id_readin = std::stoi(split[0]);
58 if (id_readin !=
id) {
59 throw std::runtime_error(
"Ids should be sorted and start at zero.");
62 result.push_back(std::stod(split[1]));
68 std::string filename)
const {
69 std::vector<Rate_Engine::PairRates> result;
72 if (!intt.is_open()) {
73 throw std::runtime_error(
"File:" + filename +
" could not be opened");
81 if (!split.size() || split[0] ==
"#" || split[0].substr(0, 1) ==
"#") {
84 if (split.size() != 5) {
85 throw std::runtime_error(
86 "Row should only contain pairid,segid1,segid2 ,rate12,rate21");
89 Index id_readin = std::stoi(split[0]);
90 if (id_readin !=
id) {
91 throw std::runtime_error(
"Ids should be sorted and start at zero.");
95 pair.
rate12 = std::stod(split[3]);
96 pair.rate21 = std::stod(split[4]);
97 result.push_back(pair);
103 std::cout << std::endl
104 <<
"... ... Computing velocity average for all sites\n";
105 std::cout <<
"Reading in site occupations from " <<
occfile_ << std::endl;
107 if (top.
Segments().size() != occ.size()) {
108 throw std::runtime_error(
109 "Number of occupations is" + std::to_string(occ.size()) +
110 " Topology has size:" + std::to_string(top.
Segments().size()));
112 std::cout <<
"Reading in rates from " <<
ratefile_ << std::endl;
115 throw std::runtime_error(
116 "Number of pairs in file is" + std::to_string(rates.size()) +
117 " Topology has size:" + std::to_string(top.
NBList().
size()));
119 std::vector<Eigen::Vector3d> velocities =
120 std::vector<Eigen::Vector3d>(occ.size(), Eigen::Vector3d::Zero());
122 Index id1 = pair->Seg1()->getId();
123 Index id2 = pair->Seg1()->getId();
124 Index pairid = pair->getId();
125 double p1 = occ[id1];
126 double p2 = occ[id2];
127 double w12 = rates[pairid].rate12;
128 double w21 = rates[pairid].rate21;
129 const Eigen::Vector3d& dR12 =
132 Eigen::Vector3d v_12_21 = 0.5 * (p1 * w12 - p2 * w21) * dR12;
133 velocities[id1] += v_12_21;
134 velocities[id2] += v_12_21;
139 if (!ofs.is_open()) {
140 throw std::runtime_error(
"Bad file handle: " +
outputfile_);
142 ofs <<
"# 1 | 2 | 3 4 5 | 6 7 8 |" << std::endl;
143 ofs <<
"# ----|---------|--------------|-------------------|" << std::endl;
144 ofs <<
"# ID | NAME | X Y Z [nm] | VX VY VZ [nm/s] |" << std::endl;
148 ofs << (boost::format(
"%1$4d %2$-10s %3$+1.7e %4$+1.7e "
149 "%5$+1.7e %6$+1.7e %7$+1.7e %8$+1.7e") %
150 seg.getId() % seg.getType() % r.x() % r.y() % r.z() % v.x() %
154 std::cout <<
"Writing velocities to " <<
outputfile_ << std::endl;