45#include "hydrodynamics/BeadModel.hpp"
47#include "hydrodynamics/CompositeShape.hpp"
48#include "hydrodynamics/Ellipsoid.hpp"
49#include "hydrodynamics/Sphere.hpp"
53#include "utils/Constants.hpp"
54#include "utils/simError.h"
97 void BeadModel::checkElement(std::size_t i) {
99 if (elements_[i].radius < 0) {
101 painCave.errMsg, MAX_SIM_ERROR_MSG_LENGTH,
102 "BeadModel::checkElement: There is a bead with a negative radius.\n"
103 "\tStarting from index 0, check bead (%lu).\n",
105 painCave.isFatal = 1;
111 if (elements_[i].radius < 1.0e-14) elements_[i].radius = 1.0e-14;
114 RealType BeadModel::volumeCorrection() {
115 RealType volume(0.0);
116 for (std::vector<HydrodynamicsElement>::iterator iter = elements_.begin();
117 iter != elements_.end(); ++iter) {
118 volume += 4.0 / 3.0 * Constants::PI * pow((*iter).radius, 3);
121 volume -= 0.5 * volumeOverlap_;
126 void BeadModel::writeElements(std::ostream& os) {
127 std::vector<HydrodynamicsElement>::iterator iter;
128 os << elements_.size() << std::endl;
129 os <<
"Generated by Hydro" << std::endl;
130 for (iter = elements_.begin(); iter != elements_.end(); ++iter) {
131 os << iter->name <<
"\t" << iter->pos[0] <<
"\t" << iter->pos[1] <<
"\t"
132 << iter->pos[2] << std::endl;
136 Mat3x3d BeadModel::interactionTensor(
const std::size_t i,
const std::size_t j,
137 const RealType viscosity) {
144 c = 1.0 / (6.0 * Constants::PI * viscosity * elements_[i].radius);
155 Vector3d Rij = elements_[i].pos - elements_[j].pos;
156 RealType rij = Rij.length();
157 RealType rij2 = rij * rij;
159 if (rij >= (elements_[i].radius + elements_[j].radius)) {
161 RealType a = ((elements_[i].radius * elements_[i].radius) +
162 (elements_[j].radius * elements_[j].radius)) /
165 op = outProduct(Rij, Rij) / rij2;
166 c = 1.0 / (8.0 * Constants::PI * viscosity * rij);
167 RealType b1 = 1.0 + a / 3.0;
168 RealType b2 = 1.0 - a;
169 Tij = (b1 * I + b2 * op) * c;
171 }
else if (rij > fabs(elements_[i].radius - elements_[j].radius) &&
172 rij < (elements_[i].radius + elements_[j].radius)) {
175 RealType sum = (elements_[i].radius + elements_[j].radius);
176 RealType diff = (elements_[i].radius - elements_[j].radius);
177 RealType diff2 = diff * diff;
179 c = 1.0 / (6.0 * Constants::PI * viscosity *
180 (elements_[i].radius * elements_[j].radius));
182 RealType rij3 = rij2 * rij;
184 op = outProduct(Rij, Rij) / rij2;
186 RealType a = diff2 + 3.0 * rij2;
187 RealType ao = (16.0 * rij3 * sum - a * a) / (32.0 * rij3);
189 RealType b = diff2 - rij2;
190 RealType bo = (3.0 * b * b) / (32.0 * rij3);
192 Tij = (ao * I + bo * op) * c;
194 RealType v1 = (-rij + sum) * (-rij + sum);
195 RealType v2 = (rij2 + 2.0 * (rij * elements_[i].radius) -
196 3.0 * (elements_[i].radius * elements_[i].radius) +
197 2.0 * (rij * elements_[j].radius) +
198 6.0 * (elements_[i].radius * elements_[j].radius) -
199 3.0 * (elements_[j].radius * elements_[j].radius));
201 volumeOverlap_ += (Constants::PI / (12.0 * rij)) * v1 * v2;
206 RealType rmin = std::min(elements_[i].radius, elements_[j].radius);
207 RealType rmax = std::max(elements_[i].radius, elements_[j].radius);
209 c = 1.0 / (6.0 * Constants::PI * viscosity * rmax);
215 volumeOverlap_ += (4.0 / 3.0) * Constants::PI * pow(rmin, 3);
static SquareMatrix< Real, Dim > identity()
This basic Periodic Table class was originally taken from the data.cpp file in OpenBabel.