double _ln_gammacElec(int i, unifac_solution *s) { double result; result = log(_phiElec(i, s)/s->xi[i]) + 1 - _phiElec(i, s)/s->xi[i] + Z/2*_q(s->m[i]) * (1 - _phi(i, s)/_theta(i, s) + log(_phi(i, s)/_theta(i, s))); return result; }
void FluidSDF::_sweep(int i0, int i1, int j0, int j1) { const int di = i0 < i1 ? 1 : -1; const int dj = j0 < j1 ? 1 : -1; for (int i = i0; i != i1; i+= di) { for (int j = j0; j != j1; j+= dj) { if (!isFluid(i,j)) { _solveEikonal(_phi(i - di,j), _phi(i,j - dj), _phi(i,j)); } } } }
/** * Calculate that natural log of the combinatorial component of the activity coefficient for the ith molecule in the solution. * \f[ * \ln\gamma_i^c = \ln\frac{\phi_i}{x_i} * + \frac{z}{2}q_i\ln\frac{\theta_i}{\phi_i} + L_i * - \frac{\phi_i}{x_i}\sum_{j=1}^n x_j L_j * \f] * @param i Molecule ID in the solution. * @param s Solution * @returns ln(gamma_i^c) */ double _ln_gammac(int i, unifac_solution *s) { int j; double result, sum = 0; for(j=0; j<s->nsolutes; j++) sum += s->xi[i] * _L(s->m[i]); result = log(_phi(i, s)/s->xi[i]) + Z/2*_q(s->m[i])*log(_theta(i, s)/_phi(i, s)) + _L(s->m[i]) - _phi(i, s)/s->xi[i] * sum; return result; }
void FluidSDF::reconstructSurface(Particles::Ptr particles, float R, float r) { LOG_OUTPUT("Reconstructing fluid surface."); assert(R && r); _sum.reset(); _pAvg.reset(); int nx = _phi.nx(); int ny = _phi.ny(); for (int p = 0; p < particles->numParticles(); ++p) { const int ci = particles->pos(p).x / _phi.dx(); const int cj = particles->pos(p).y / _phi.dx(); assert(ci < _phi.nx() && cj < _phi.ny()); for (int i = std::max(0,ci-2); i < std::min(nx,ci+2); ++i) { for (int j = std::max(0,cj-2); j < std::min(ny,cj+2); ++j) { const Vec2f xd = particles->pos(p) - _phi.pos(i,j); const float k = _kernel(xd.length() / R); _sum(i,j) += k; _pAvg(i,j) += k * particles->pos(p); } } } for (int i = 0; i < _phi.nx(); ++i) { for (int j = 0; j < _phi.ny(); ++j) { if (_sum(i,j) > 0) { _pAvg(i,j) *= (1.0f / _sum(i,j)); const Vec2f xd = _phi.pos(i,j) - _pAvg(i,j); _phi(i,j) = xd.length() - r; } else { _phi(i,j) = _phi.dx() * 1e15; } } } }
void IsotropicSphereModel::doGenerate(Catalog& catalog) { if (catalog.getType() != _catType) { std::stringstream ss; ss << "Generate failed. Model '" << ModelMapper::instance()->getKey(getType()) << "'. Provided catalog type doesn't match requested one."; Exception exc(type::EXCEPTION_WARNING + type::EXCEPTION_MOD_NO_PREFIX, ss.str(), PRETTY_FUNCTION); throw exc; } for (std::size_t i = 0; i < getNumberOfEntries(); ++i) { CatalogEntryGrbcat* entry = createEntry(); entry->getCoordFlag() = 0.0; entry->getCoodinates().getX0() = _time(getGenerator()); entry->getCoodinates().getX1() = 1.0; entry->getCoodinates().getX2() = _phi(getGenerator()); entry->getCoodinates().getX3() = _theta(getGenerator()); catalog.getEntries().push_back(entry); } }
void WaterPorous2D::Mass() { real_t c=OFELI_THIRD*_area*_cw*_density; for (size_t i=1; i<=3; i++) eA1(i,i) = c*_phi(i); }