REAL computeSolvation(int size1, int size2, int * type1_m_aTypes, int * type2_m_aTypes, int type1, int type2, REAL * dists, int diff) { #pragma HLS INLINE recursive //assert(diff >= 0); REAL sum = 0.0; for (int i = 0; i < size1; i++) for (int j = 0; j < size2; j++) { int ex = isExcluded(diff, type1, i, type2, j); if (ex != EXCLUDED) { REAL lambda1 = getLambda(type1, i, type1_m_aTypes[i]); REAL lambda2 = getLambda(type2, j, type2_m_aTypes[j]); REAL dists_param = dists[i*MAX_ROTAMER_SIZE + j]; sum += computeSolventEffect(type1_m_aTypes[i], type2_m_aTypes[j], dists_param, lambda1, lambda2, ex == PAIR1_4); } } return sum; }
bool tedop::SweepLine::coincideOK( plysegment* line, plysegment* cross, float lps, float rps) { // first we going to check that the points laying on the line are not // outside the segment // i.e. if neither of the entry points are lying on the segment line // then there is nothing to check further here, get out // In fact the result returned here doesn't really matter, because this case should // be in place only after the first pair of isLeft() checks in intersect() // if false is returned, the second pair of isLeft() should reject this case as // non-crossing. float lambdaL = (0 == lps) ? getLambda(line->lP, line->rP, cross->lP) : 0; float lambdaR = (0 == rps) ? getLambda(line->lP, line->rP, cross->rP) : 0; // filter-out all cases when both lines have no common points if (((0 != lps) || (lambdaL < 0)) && ((0 != rps) || (lambdaR < 0))) return true; // filter-out the cases when both lines have exactly one common point // and it is an edge point of both segmets bool Ljoint = (0==lps) && (0 == lambdaL); bool Rjoint = (0==rps) && (0 == lambdaR); if ((!Ljoint && Rjoint) || (!Rjoint && Ljoint)) return true; // now start checking the coincidence case //get the _plist index of the points in segment cross int indxLP = (*(cross->lP) == _plist[cross->edge]) ? cross->edge : cross->edge + 1; int indxRP = (*(cross->rP) == _plist[cross->edge]) ? cross->edge : cross->edge + 1; // make sure they are not the same assert(indxLP != indxRP); // we'll pickup the neighbour of the point(s) laying on the line and will // recalculate the lps/rps for them. do { // the code below just increments/decrements the indexes in the point sequence // they look so weird, to keep the indexes within [0:_numv-1] boundaries bool indxpos = indxLP > indxRP; if (0 == lps) if (indxpos) ++indxLP % _numv; else (0==indxLP) ? indxLP = _numv-1 : indxLP--; if (0 == rps) if (!indxpos) ++indxRP % _numv; else (0==indxRP) ? indxRP = _numv-1 : indxRP--; // calculate lps/rps with the new points lps = isLeft(line->lP, line->rP, &_plist[indxLP]); rps = isLeft(line->lP, line->rP, &_plist[indxRP]); } while (0 == (lps * rps)); return (lps*rps > 0) ? true : false; }
// ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- void LaplacianSmoothing::readFilterParameters(AbstractFilterParametersReader* reader, int index) { reader->openFilterGroup(this, index); setIterationSteps( reader->readValue("IterationSteps", getIterationSteps()) ); setLambda( reader->readValue("Lambda", getLambda()) ); setTripleLineLambda( reader->readValue("TripleLineLambda", getTripleLineLambda()) ); setQuadPointLambda( reader->readValue("QuadPointLambda", getQuadPointLambda()) ); setSurfacePointLambda( reader->readValue("SurfacePointLambda", getSurfacePointLambda()) ); setSurfaceTripleLineLambda( reader->readValue("SurfaceTripleLineLambda", getSurfaceTripleLineLambda()) ); setSurfaceQuadPointLambda( reader->readValue("SurfaceQuadPointLambda", getSurfaceQuadPointLambda()) ); setSurfaceMeshNodeTypeArrayPath(reader->readDataArrayPath("SurfaceMeshNodeTypeArrayPath", getSurfaceMeshNodeTypeArrayPath() ) ); setSurfaceMeshFaceLabelsArrayPath(reader->readDataArrayPath("SurfaceMeshFaceLabelsArrayPath", getSurfaceMeshFaceLabelsArrayPath() ) ); reader->closeFilterGroup(); }
// ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- void LaplacianSmoothing::setupFilterParameters() { FilterParameterVector parameters; parameters.push_back(IntFilterParameter::New("Iteration Steps", "IterationSteps", getIterationSteps(), FilterParameter::Parameter)); parameters.push_back(DoubleFilterParameter::New("Default Lambda", "Lambda", getLambda(), FilterParameter::Parameter)); parameters.push_back(DoubleFilterParameter::New("Triple Line Lambda", "TripleLineLambda", getTripleLineLambda(), FilterParameter::Parameter)); parameters.push_back(DoubleFilterParameter::New("Quadruple Points Lambda", "QuadPointLambda", getQuadPointLambda(), FilterParameter::Parameter)); parameters.push_back(DoubleFilterParameter::New("Outer Points Lambda", "SurfacePointLambda", getSurfacePointLambda(), FilterParameter::Parameter)); parameters.push_back(DoubleFilterParameter::New("Outer Triple Line Lambda", "SurfaceTripleLineLambda", getSurfaceTripleLineLambda(), FilterParameter::Parameter)); parameters.push_back(DoubleFilterParameter::New("Outer Quadruple Points Lambda", "SurfaceQuadPointLambda", getSurfaceQuadPointLambda(), FilterParameter::Parameter)); parameters.push_back(SeparatorFilterParameter::New("Vertex Data", FilterParameter::RequiredArray)); parameters.push_back(DataArraySelectionFilterParameter::New("Node Type", "SurfaceMeshNodeTypeArrayPath", getSurfaceMeshNodeTypeArrayPath(), FilterParameter::RequiredArray)); parameters.push_back(SeparatorFilterParameter::New("Face Data", FilterParameter::RequiredArray)); parameters.push_back(DataArraySelectionFilterParameter::New("Face Labels", "SurfaceMeshFaceLabelsArrayPath", getSurfaceMeshFaceLabelsArrayPath(), FilterParameter::RequiredArray)); setFilterParameters(parameters); }
TEST_F(ThermoPhase_Fixture, SetAndGetElementPotentials) { initializeElements(); // Check that getElementPotentials returns false if no element potentials have been set yet. vector_fp getLambda(3); EXPECT_FALSE(test_phase.getElementPotentials(&getLambda[0])); vector_fp tooSmall(2); EXPECT_THROW(test_phase.setElementPotentials(tooSmall), CanteraError); vector_fp setLambda(3); setLambda[0] = 1.; setLambda[1] = 2.; setLambda[2] = 3.; test_phase.setElementPotentials(setLambda); EXPECT_TRUE(test_phase.getElementPotentials(&getLambda[0])); EXPECT_DOUBLE_EQ(setLambda[0], getLambda[0]); EXPECT_DOUBLE_EQ(setLambda[1], getLambda[1]); EXPECT_DOUBLE_EQ(setLambda[2], getLambda[2]); }
// ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- void LaplacianSmoothing::setupFilterParameters() { FilterParameterVector parameters; parameters.push_back(IntFilterParameter::New("Iteration Steps", "IterationSteps", getIterationSteps(), FilterParameter::Parameter)); parameters.push_back(DoubleFilterParameter::New("Default Lambda", "Lambda", getLambda(), FilterParameter::Parameter)); parameters.push_back(DoubleFilterParameter::New("Triple Line Lambda", "TripleLineLambda", getTripleLineLambda(), FilterParameter::Parameter)); parameters.push_back(DoubleFilterParameter::New("Quadruple Points Lambda", "QuadPointLambda", getQuadPointLambda(), FilterParameter::Parameter)); parameters.push_back(DoubleFilterParameter::New("Outer Points Lambda", "SurfacePointLambda", getSurfacePointLambda(), FilterParameter::Parameter)); parameters.push_back(DoubleFilterParameter::New("Outer Triple Line Lambda", "SurfaceTripleLineLambda", getSurfaceTripleLineLambda(), FilterParameter::Parameter)); parameters.push_back(DoubleFilterParameter::New("Outer Quadruple Points Lambda", "SurfaceQuadPointLambda", getSurfaceQuadPointLambda(), FilterParameter::Parameter)); parameters.push_back(SeparatorFilterParameter::New("Vertex Data", FilterParameter::RequiredArray)); { DataArraySelectionFilterParameter::RequirementType req = DataArraySelectionFilterParameter::CreateRequirement(SIMPL::TypeNames::Int8, 1, SIMPL::AttributeMatrixType::Vertex, SIMPL::GeometryType::TriangleGeometry); parameters.push_back(DataArraySelectionFilterParameter::New("Node Type", "SurfaceMeshNodeTypeArrayPath", getSurfaceMeshNodeTypeArrayPath(), FilterParameter::RequiredArray, req)); } parameters.push_back(SeparatorFilterParameter::New("Face Data", FilterParameter::RequiredArray)); { DataArraySelectionFilterParameter::RequirementType req = DataArraySelectionFilterParameter::CreateRequirement(SIMPL::TypeNames::Int32, 2, SIMPL::AttributeMatrixType::Face, SIMPL::GeometryType::TriangleGeometry); parameters.push_back(DataArraySelectionFilterParameter::New("Face Labels", "SurfaceMeshFaceLabelsArrayPath", getSurfaceMeshFaceLabelsArrayPath(), FilterParameter::RequiredArray, req)); } setFilterParameters(parameters); }
int runLRS(string fName, int numSamples, bool silent) { srand((unsigned(time(NULL)))); cout << "numSamples: " << numSamples << endl; cout << "Getting gammas..." << endl; int best = INT_MAX; vector<double> gammaIn; vector<LPEdge> hkSoln = getHKSolutions(fName, silent); vector<ModEdge> graph = xToZ(lpToMod(hkSoln)); vector<double> lambda = getLambda(graph); weightGraph(graph, lambda); int numNodes = getNumNodes(graph); Graph g = Graph(fName, silent); cout << "Done getting gammas" << endl; int numErrs = 0; #pragma omp parallel num_threads(4) shared(gammaIn, graph, lambda, g, numNodes) { #pragma omp for for (int i = 0; i < numSamples; i++) { int n = numNodes; int cur = getLRSTourFast(graph, lambda, g, n); #pragma omp critical { if (cur < best) best = cur; if (cur == INT_MAX) numErrs++; #pragma omp flush(best) } } } cout << "Number of errors: " << numErrs << " out of " << numSamples << " samples" << endl; return best; }
double XC::MDEvolutionLaw::getKp( EPState *EPS , double dummy) { //clog << "el-pl EPS: " << *EPS ; //========================================================================= //calculate n_ij XC::stresstensor S = EPS->getStress().deviator(); double p = EPS->getStress().p_hydrostatic(); XC::stresstensor alpha = EPS->getTensorVar( 1 ); // alpha_ij XC::stresstensor r = S * (1.0 / p); //r.reportshort("r"); XC::stresstensor r_bar = r - alpha; XC::stresstensor norm2 = r_bar("ij") * r_bar("ij"); double norm = sqrt( norm2.trace() ); XC::stresstensor n; if ( norm >= d_macheps() ){ n = ( r - alpha ) *(1.0 / norm ); } else { ::printf(" \n\n n_ij not defined!!!! Program exits\n"); exit(1); } //========================================================================= //calculating b_ij //Calculate the state parameters xi double e = EPS->getScalarVar(3); double ec = getec_ref() - getLambda() * log( p/getp_ref() ); double xi = e - ec; //Calculating the lode angle theta double J2_bar = r_bar.Jinvariant2(); double J3_bar = r_bar.Jinvariant3(); double tempd = 3.0*pow(3.0, 0.5)/2.0*J3_bar/ pow( J2_bar, 1.5); if (tempd > 1.0 ) tempd = 1.0; //bug. if tempd = 1.00000000003, acos gives nan if (tempd < -1.0 ) tempd = -1.0; double theta = acos( tempd ) / 3.0; //calculate the alpha_theta_b and alpha_theta_d double m = EPS->getScalarVar(1); double c = getMe() / getMc(); double cd = getke_d() / getkc_d(); XC::stresstensor alpha_theta_d = n("ij") * (g_WW(theta, c) * Mc + g_WW(theta, cd) * kc_d * xi - m) * pow(2.0/3.0, 0.5); double cb = getke_b() / getkc_b(); if ( xi > 0.0 ) xi = 0.0; // < -xi > XC::stresstensor alpha_theta_b = n("ij") * (g_WW(theta, c) * Mc - g_WW(theta, cb) * kc_b * xi - m) * pow(2.0/3.0, 0.5); alpha_theta_b.null_indices(); //========================================================================= // calculating h XC::stresstensor b; b = alpha_theta_b - alpha; b.null_indices(); XC::stresstensor d; d = alpha_theta_d - alpha; d.null_indices(); double alpha_c_b = g_WW(0.0, c) * Mc + g_WW(0.0, cb) * kc_b * (-xi) - m; double b_ref = 2.0 * pow(2.0/3.0, 0.5) * alpha_c_b; BJtensor temp1 = b("ij") * n("ij"); double bn = temp1.trace(); temp1 = d("ij") * n("ij"); double dn = temp1.trace(); // Calculating A XC::stresstensor F = EPS->getTensorVar( 2 ); // getting F_ij from XC::EPState temp1 = F("ij") * n("ij"); double temp = temp1.trace(); if (temp < 0) temp = 0; double A = Ao*(1.0 + temp); double h = getho() * fabs(bn) / ( b_ref - fabs(bn) ); clog << "ho =" << getho() << " h =" << h << std::endl; //========================================================================= double Kp = h * bn + pow(2.0/3.0, 0.5) * getCm() * ( 1.0 + geteo() ) * A * dn; //double Kp = pow(2.0/3.0, 0.5) * getCm() * ( 1.0 + geteo() ) * A * dn; Kp = Kp * p; return Kp; }
void XC::MDEvolutionLaw::UpdateAllVars( EPState *EPS, double dlamda) { //========================================================================= //calculate n_ij XC::stresstensor S = EPS->getStress().deviator(); double p = EPS->getStress().p_hydrostatic(); XC::stresstensor alpha = EPS->getTensorVar( 1 ); // alpha_ij // Find the norm of alpha BJtensor norm_alphat = alpha("ij") * alpha("ij"); double norm_alpha = sqrt( norm_alphat.trace() ); XC::stresstensor r = S * (1.0 / p); //r.reportshort("r"); XC::stresstensor r_bar = r - alpha; XC::stresstensor norm2 = r_bar("ij") * r_bar("ij"); double norm = sqrt( norm2.trace() ); XC::stresstensor n; if ( norm >= d_macheps() ){ n = ( r - alpha ) *(1.0 / norm ); } else { ::printf(" \n\n n_ij not defined!!!! Program exits\n"); exit(1); } //EPS->setTensorVar( 3, n); //update n_ij// // Update E_Young corresponding to current stress state double p_atm = 100.0; //Kpa, atmospheric pressure double E = EPS->getE(); // old E_Young double E_new = EPS->getEo() * pow( (p/p_atm), geta() ); EPS->setE( E_new ); // Update void ratio double e = EPS->getScalarVar(3); double D = EPS->getScalarVar(2); double elastic_strain_vol = EPS->getdElasticStrain().Iinvariant1(); double plastic_strain_vol = EPS->getdPlasticStrain().Iinvariant1(); double de_p = -( 1.0 + e ) * plastic_strain_vol; // plastic change of void ratio ?? e or eo? double de_e = -( 1.0 + e ) * elastic_strain_vol; // elastic change of void ratio ???? clog << "get dPlasticStrain-vol" << plastic_strain_vol << std::endl; clog << "get dElasticStrain-vol" << elastic_strain_vol << std::endl; clog << "^^^^^^^^^^^ de_e = " << de_e << " de_p = " << de_p << std::endl; double new_e = e + de_p + de_e; EPS->setScalarVar( 3, new_e ); // Updating e //Calculate the state parameters xi double ec = getec_ref() - getLambda() * log( p/getp_ref() ); double xi = e - ec; // Update D double m = EPS->getScalarVar(1); XC::stresstensor F = EPS->getTensorVar( 2 ); // getting F_ij from XC::EPState BJtensor temp_tensor = F("ij") * n("ij"); double temp = temp_tensor.trace(); if (temp < 0) temp = 0; double A = Ao*(1.0 + temp); //Calculating the lode angle theta double J2_bar = r_bar.Jinvariant2(); double J3_bar = r_bar.Jinvariant3(); double tempd = 3.0*pow(3.0, 0.5)/2.0*J3_bar/ pow( J2_bar, 1.5); if (tempd > 1.0 ) tempd = 1.0; //bug. if tempd = 1.00000000003, acos gives nan if (tempd < -1.0 ) tempd = -1.0; double theta = acos( tempd ) / 3.0; //========================================================================= //calculate the alpha_theta_b and alpha_theta_d double c = getMe() / getMc(); double cd = getke_d() / getkc_d(); double alpha_theta_dd = (g_WW(theta, c) * Mc + g_WW(theta, cd) * kc_d * xi - m); XC::stresstensor alpha_theta_d = n("ij") * alpha_theta_dd * pow(2.0/3.0, 0.5); double cb = getke_b() / getkc_b(); if ( xi > 0 ) xi = 0.0; // < -xi > double alpha_theta_bd = (g_WW(theta, c) * Mc + g_WW(theta, cb) * kc_b * (-xi) - m); XC::stresstensor alpha_theta_b = n("ij") *alpha_theta_bd * pow(2.0/3.0, 0.5); alpha_theta_b.null_indices(); XC::stresstensor b; b = alpha_theta_b - alpha; b.null_indices(); XC::stresstensor d; d = alpha_theta_d - alpha; d.null_indices(); BJtensor temp1 = d("ij") * n("ij"); temp1.null_indices(); double D_new = temp1.trace() * A; //Check the restrictions on D if ( (xi > 0.0) && ( D_new < 0.0) ) D_new = 0.0; EPS->setScalarVar(2, D_new); // Updating D //EPS->setScalarVar(2, 0.0); // Updating D //========================================================================= // Update m double dm = dlamda * getCm() * ( 1.0 + e ) * D; EPS->setScalarVar(1, m + dm); // Updating m clog << std::endl << "dm = " << dm << std::endl; //========================================================================= // Update alpha //calculate b_ref double alpha_c_b = g_WW(0.0, c) * Mc + g_WW(0.0, cb) * kc_b * (-xi) - m; double b_ref = 2.0 * pow(2.0/3.0, 0.5) * alpha_c_b; temp1 = b("ij") * n("ij"); double bn = temp1.trace(); clog << "xxxxxxxxxxxxxxxxxxx bn " << bn << std::endl; double h = getho() * fabs(bn) / ( b_ref - fabs(bn) ); //h = h + pow(2.0/3.0, 0.5) * getCm() * ( 1.0 + geteo() ) * A * bn; clog << " ||b|| " << (alpha_theta_bd - norm_alpha) << std::endl; clog << " dlamda " << dlamda << " h = " << h << std::endl; XC::stresstensor dalpha; dalpha = dlamda * h * b("ij"); //dalpha.null_indices(); clog << "delta alpha =" << dalpha << std::endl; //dalpha.reportshortpqtheta("\n dalpha "); alpha = alpha + dalpha; alpha.null_indices(); //alpha.reportshort("Alpha"); EPS->setTensorVar(1, alpha); //========================================================================= // Update F XC::stresstensor dF; if ( D > 0.0 ) D = 0.0; dF = dlamda * getCf() * (-D) * ( getFmax() * n("ij") + F("ij") ); //clog << "dF" << dF; F = F - dF; EPS->setTensorVar(2, F); }
void XC::MDEvolutionLaw::setInitD(EPState *EPS) { //========================================================================= //calculate n_ij XC::stresstensor S = EPS->getStress().deviator(); double p = EPS->getStress().p_hydrostatic(); XC::stresstensor alpha = EPS->getTensorVar( 1 ); // alpha_ij // Find the norm of alpha BJtensor norm_alphat = alpha("ij") * alpha("ij"); double norm_alpha = sqrt( norm_alphat.trace() ); XC::stresstensor r = S * (1.0 / p); //r.reportshort("r"); XC::stresstensor r_bar = r - alpha; XC::stresstensor norm2 = r_bar("ij") * r_bar("ij"); double norm = sqrt( norm2.trace() ); XC::stresstensor n; if ( norm >= d_macheps() ){ n = ( r - alpha ) *(1.0 / norm ); } else { ::printf(" \n\n n_ij not defined!!!! Program exits\n"); exit(1); } //Calculate the state parameters xi double e = EPS->getScalarVar(3); double ec = getec_ref() - getLambda() * log( p/getp_ref() ); double xi = e - ec; //calculating A double m = EPS->getScalarVar(1); XC::stresstensor F = EPS->getTensorVar( 2 ); // getting F_ij from XC::EPState BJtensor temp_tensor = F("ij") * n("ij"); double temp = temp_tensor.trace(); if (temp < 0) temp = 0; double A = Ao*(1.0 + temp); //Calculating the lode angle theta double J2_bar = r_bar.Jinvariant2(); double J3_bar = r_bar.Jinvariant3(); double tempd = 3.0*pow(3.0, 0.5)/2.0*J3_bar/ pow( J2_bar, 1.5); if (tempd > 1.0 ) tempd = 1.0; //bug. if tempd = 1.00000000003, acos gives nan if (tempd < -1.0 ) tempd = -1.0; double theta = acos( tempd ) / 3.0; //========================================================================= //calculate the alpha_theta_b and alpha_theta_d double c = getMe() / getMc(); double cd = getke_d() / getkc_d(); double alpha_theta_dd = (g_WW(theta, c) * Mc + g_WW(theta, cd) * kc_d * xi - m); XC::stresstensor alpha_theta_d = n("ij") * alpha_theta_dd * pow(2.0/3.0, 0.5); XC::stresstensor d; d = alpha_theta_d - alpha; d.null_indices(); BJtensor temp1 = d("ij") * n("ij"); temp1.null_indices(); double D_new = temp1.trace() * A; //Check the restrictions on D if ( (xi > 0.0) && ( D_new < 0.0) ) D_new = 0.0; EPS->setScalarVar(2, D_new); // Updating D }
double CKM::gets12() { return getLambda(); }
double QFFCSMaxEntEvaluationItem::getDLSQ(QFRawDataRecord *r, int index, int model) const { return 4.0*M_PI*getRefIndx(r, index, model)/(getLambda(r, index, model)/1e3)*sin(getTheta(r, index, model)/180.0*M_PI/2.0); }
double QFFCSMaxEntEvaluationItem::getDLSQ() const { return 4.0*M_PI*getRefIndx()/(getLambda()/1e3)*sin(getTheta()/180.0*M_PI/2.0); }