Changeset a67d19 for src/vector.cpp
- Timestamp:
- Apr 22, 2010, 2:00:03 PM (15 years ago)
- Branches:
- Action_Thermostats, Add_AtomRandomPerturbation, Add_FitFragmentPartialChargesAction, Add_RotateAroundBondAction, Add_SelectAtomByNameAction, Added_ParseSaveFragmentResults, AddingActions_SaveParseParticleParameters, Adding_Graph_to_ChangeBondActions, Adding_MD_integration_tests, Adding_ParticleName_to_Atom, Adding_StructOpt_integration_tests, AtomFragments, Automaking_mpqc_open, AutomationFragmentation_failures, Candidate_v1.5.4, Candidate_v1.6.0, Candidate_v1.6.1, ChangeBugEmailaddress, ChangingTestPorts, ChemicalSpaceEvaluator, CombiningParticlePotentialParsing, Combining_Subpackages, Debian_Package_split, Debian_package_split_molecuildergui_only, Disabling_MemDebug, Docu_Python_wait, EmpiricalPotential_contain_HomologyGraph, EmpiricalPotential_contain_HomologyGraph_documentation, Enable_parallel_make_install, Enhance_userguide, Enhanced_StructuralOptimization, Enhanced_StructuralOptimization_continued, Example_ManyWaysToTranslateAtom, Exclude_Hydrogens_annealWithBondGraph, FitPartialCharges_GlobalError, Fix_BoundInBox_CenterInBox_MoleculeActions, Fix_ChargeSampling_PBC, Fix_ChronosMutex, Fix_FitPartialCharges, Fix_FitPotential_needs_atomicnumbers, Fix_ForceAnnealing, Fix_IndependentFragmentGrids, Fix_ParseParticles, Fix_ParseParticles_split_forward_backward_Actions, Fix_PopActions, Fix_QtFragmentList_sorted_selection, Fix_Restrictedkeyset_FragmentMolecule, Fix_StatusMsg, Fix_StepWorldTime_single_argument, Fix_Verbose_Codepatterns, Fix_fitting_potentials, Fixes, ForceAnnealing_goodresults, ForceAnnealing_oldresults, ForceAnnealing_tocheck, ForceAnnealing_with_BondGraph, ForceAnnealing_with_BondGraph_continued, ForceAnnealing_with_BondGraph_continued_betteresults, ForceAnnealing_with_BondGraph_contraction-expansion, FragmentAction_writes_AtomFragments, FragmentMolecule_checks_bonddegrees, GeometryObjects, Gui_Fixes, Gui_displays_atomic_force_velocity, ImplicitCharges, IndependentFragmentGrids, IndependentFragmentGrids_IndividualZeroInstances, IndependentFragmentGrids_IntegrationTest, IndependentFragmentGrids_Sole_NN_Calculation, JobMarket_RobustOnKillsSegFaults, JobMarket_StableWorkerPool, JobMarket_unresolvable_hostname_fix, MoreRobust_FragmentAutomation, ODR_violation_mpqc_open, PartialCharges_OrthogonalSummation, PdbParser_setsAtomName, PythonUI_with_named_parameters, QtGui_reactivate_TimeChanged_changes, Recreated_GuiChecks, Rewrite_FitPartialCharges, RotateToPrincipalAxisSystem_UndoRedo, SaturateAtoms_findBestMatching, SaturateAtoms_singleDegree, StoppableMakroAction, Subpackage_CodePatterns, Subpackage_JobMarket, Subpackage_LinearAlgebra, Subpackage_levmar, Subpackage_mpqc_open, Subpackage_vmg, Switchable_LogView, ThirdParty_MPQC_rebuilt_buildsystem, TrajectoryDependenant_MaxOrder, TremoloParser_IncreasedPrecision, TremoloParser_MultipleTimesteps, TremoloParser_setsAtomName, Ubuntu_1604_changes, stable
- Children:
- 299554
- Parents:
- 6613ec
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/vector.cpp
r6613ec ra67d19 253 253 Direction.SubtractVector(Origin); 254 254 Direction.Normalize(); 255 Log() << Verbose(1) << "INFO: Direction is " << Direction << "." << endl;255 DoLog(1) && (Log() << Verbose(1) << "INFO: Direction is " << Direction << "." << endl); 256 256 //Log() << Verbose(1) << "INFO: PlaneNormal is " << *PlaneNormal << " and PlaneOffset is " << *PlaneOffset << "." << endl; 257 257 factor = Direction.ScalarProduct(PlaneNormal); 258 258 if (fabs(factor) < MYEPSILON) { // Uniqueness: line parallel to plane? 259 Log() << Verbose(1) << "BAD: Line is parallel to plane, no intersection." << endl;259 DoLog(1) && (Log() << Verbose(1) << "BAD: Line is parallel to plane, no intersection." << endl); 260 260 return false; 261 261 } … … 264 264 factor = helper.ScalarProduct(PlaneNormal)/factor; 265 265 if (fabs(factor) < MYEPSILON) { // Origin is in-plane 266 Log() << Verbose(1) << "GOOD: Origin of line is in-plane." << endl;266 DoLog(1) && (Log() << Verbose(1) << "GOOD: Origin of line is in-plane." << endl); 267 267 CopyVector(Origin); 268 268 return true; … … 271 271 Direction.Scale(factor); 272 272 CopyVector(Origin); 273 Log() << Verbose(1) << "INFO: Scaled direction is " << Direction << "." << endl;273 DoLog(1) && (Log() << Verbose(1) << "INFO: Scaled direction is " << Direction << "." << endl); 274 274 AddVector(&Direction); 275 275 … … 278 278 helper.SubtractVector(PlaneOffset); 279 279 if (helper.ScalarProduct(PlaneNormal) < MYEPSILON) { 280 Log() << Verbose(1) << "GOOD: Intersection is " << *this << "." << endl;280 DoLog(1) && (Log() << Verbose(1) << "GOOD: Intersection is " << *this << "." << endl); 281 281 return true; 282 282 } else { … … 359 359 //} 360 360 if (fabs(M->Determinant()) > MYEPSILON) { 361 Log() << Verbose(1) << "Determinant of coefficient matrix is NOT zero." << endl;361 DoLog(1) && (Log() << Verbose(1) << "Determinant of coefficient matrix is NOT zero." << endl); 362 362 return false; 363 363 } 364 Log() << Verbose(1) << "INFO: Line1a = " << *Line1a << ", Line1b = " << *Line1b << ", Line2a = " << *Line2a << ", Line2b = " << *Line2b << "." << endl;364 DoLog(1) && (Log() << Verbose(1) << "INFO: Line1a = " << *Line1a << ", Line1b = " << *Line1b << ", Line2a = " << *Line2a << ", Line2b = " << *Line2b << "." << endl); 365 365 366 366 … … 378 378 d.CopyVector(Line2b); 379 379 d.SubtractVector(Line1b); 380 Log() << Verbose(1) << "INFO: a = " << a << ", b = " << b << ", c = " << c << "." << endl;380 DoLog(1) && (Log() << Verbose(1) << "INFO: a = " << a << ", b = " << b << ", c = " << c << "." << endl); 381 381 if ((a.NormSquared() < MYEPSILON) || (b.NormSquared() < MYEPSILON)) { 382 382 Zero(); 383 Log() << Verbose(1) << "At least one of the lines is ill-defined, i.e. offset equals second vector." << endl;383 DoLog(1) && (Log() << Verbose(1) << "At least one of the lines is ill-defined, i.e. offset equals second vector." << endl); 384 384 return false; 385 385 } … … 394 394 if ((factor >= -MYEPSILON) && (factor - 1. < MYEPSILON)) { 395 395 CopyVector(Line2a); 396 Log() << Verbose(1) << "Lines conincide." << endl;396 DoLog(1) && (Log() << Verbose(1) << "Lines conincide." << endl); 397 397 return true; 398 398 } else { … … 402 402 if ((factor >= -MYEPSILON) && (factor - 1. < MYEPSILON)) { 403 403 CopyVector(Line2b); 404 Log() << Verbose(1) << "Lines conincide." << endl;404 DoLog(1) && (Log() << Verbose(1) << "Lines conincide." << endl); 405 405 return true; 406 406 } 407 407 } 408 Log() << Verbose(1) << "Lines are parallel." << endl;408 DoLog(1) && (Log() << Verbose(1) << "Lines are parallel." << endl); 409 409 Zero(); 410 410 return false; … … 418 418 temp2.CopyVector(&a); 419 419 temp2.VectorProduct(&b); 420 Log() << Verbose(1) << "INFO: temp1 = " << temp1 << ", temp2 = " << temp2 << "." << endl;420 DoLog(1) && (Log() << Verbose(1) << "INFO: temp1 = " << temp1 << ", temp2 = " << temp2 << "." << endl); 421 421 if (fabs(temp2.NormSquared()) > MYEPSILON) 422 422 s = temp1.ScalarProduct(&temp2)/temp2.NormSquared(); 423 423 else 424 424 s = 0.; 425 Log() << Verbose(1) << "Factor s is " << temp1.ScalarProduct(&temp2) << "/" << temp2.NormSquared() << " = " << s << "." << endl;425 DoLog(1) && (Log() << Verbose(1) << "Factor s is " << temp1.ScalarProduct(&temp2) << "/" << temp2.NormSquared() << " = " << s << "." << endl); 426 426 427 427 // construct intersection … … 429 429 Scale(s); 430 430 AddVector(Line1a); 431 Log() << Verbose(1) << "Intersection is at " << *this << "." << endl;431 DoLog(1) && (Log() << Verbose(1) << "Intersection is at " << *this << "." << endl); 432 432 433 433 return true; … … 702 702 void Vector::Output() const 703 703 { 704 Log() << Verbose(0) << "(";704 DoLog(0) && (Log() << Verbose(0) << "("); 705 705 for (int i=0;i<NDIM;i++) { 706 Log() << Verbose(0) << x[i];706 DoLog(0) && (Log() << Verbose(0) << x[i]); 707 707 if (i != 2) 708 Log() << Verbose(0) << ",";709 } 710 Log() << Verbose(0) << ")";708 DoLog(0) && (Log() << Verbose(0) << ","); 709 } 710 DoLog(0) && (Log() << Verbose(0) << ")"); 711 711 }; 712 712 … … 843 843 projection = ScalarProduct(n)/n->ScalarProduct(n); // remove constancy from n (keep as logical one) 844 844 // withdraw projected vector twice from original one 845 Log() << Verbose(1) << "Vector: ";845 DoLog(1) && (Log() << Verbose(1) << "Vector: "); 846 846 Output(); 847 Log() << Verbose(0) << "\t";847 DoLog(0) && (Log() << Verbose(0) << "\t"); 848 848 for (int i=NDIM;i--;) 849 849 x[i] -= 2.*projection*n->x[i]; 850 Log() << Verbose(0) << "Projected vector: ";850 DoLog(0) && (Log() << Verbose(0) << "Projected vector: "); 851 851 Output(); 852 Log() << Verbose(0) << endl;852 DoLog(0) && (Log() << Verbose(0) << endl); 853 853 }; 854 854 … … 954 954 double norm; 955 955 956 Log() << Verbose(4);956 DoLog(4) && (Log() << Verbose(4)); 957 957 GivenVector->Output(); 958 Log() << Verbose(0) << endl;958 DoLog(0) && (Log() << Verbose(0) << endl); 959 959 for (j=NDIM;j--;) 960 960 Components[j] = -1; … … 963 963 if (fabs(GivenVector->x[j]) > MYEPSILON) 964 964 Components[Last++] = j; 965 Log() << Verbose(4) << Last << " Components != 0: (" << Components[0] << "," << Components[1] << "," << Components[2] << ")" << endl;965 DoLog(4) && (Log() << Verbose(4) << Last << " Components != 0: (" << Components[0] << "," << Components[1] << "," << Components[2] << ")" << endl); 966 966 967 967 switch(Last) { … … 1013 1013 1014 1014 for (j=0;j<num;j++) { 1015 Log() << Verbose(1) << j << "th atom's vector: ";1015 DoLog(1) && (Log() << Verbose(1) << j << "th atom's vector: "); 1016 1016 (vectors[j])->Output(); 1017 Log() << Verbose(0) << endl;1017 DoLog(0) && (Log() << Verbose(0) << endl); 1018 1018 } 1019 1019 … … 1135 1135 j += i+1; 1136 1136 do { 1137 Log() << Verbose(0) << coords[i] << "[0.." << cell_size[j] << "]: ";1137 DoLog(0) && (Log() << Verbose(0) << coords[i] << "[0.." << cell_size[j] << "]: "); 1138 1138 cin >> x[i]; 1139 1139 } while (((x[i] < 0) || (x[i] >= cell_size[j])) && (check)); … … 1166 1166 B2 = cos(beta) * x2->Norm() * c; 1167 1167 C = c * c; 1168 Log() << Verbose(2) << "A " << A << "\tB " << B1 << "\tC " << C << endl;1168 DoLog(2) && (Log() << Verbose(2) << "A " << A << "\tB " << B1 << "\tC " << C << endl); 1169 1169 int flag = 0; 1170 1170 if (fabs(x1->x[0]) < MYEPSILON) { // check for zero components for the later flipping and back-flipping … … 1205 1205 D2 = -y->x[0]/x1->x[0]*x1->x[2]+y->x[2]; 1206 1206 D3 = y->x[0]/x1->x[0]*A-B1; 1207 Log() << Verbose(2) << "D1 " << D1 << "\tD2 " << D2 << "\tD3 " << D3 << "\n";1207 DoLog(2) && (Log() << Verbose(2) << "D1 " << D1 << "\tD2 " << D2 << "\tD3 " << D3 << "\n"); 1208 1208 if (fabs(D1) < MYEPSILON) { 1209 Log() << Verbose(2) << "D1 == 0!\n";1209 DoLog(2) && (Log() << Verbose(2) << "D1 == 0!\n"); 1210 1210 if (fabs(D2) > MYEPSILON) { 1211 Log() << Verbose(3) << "D2 != 0!\n";1211 DoLog(3) && (Log() << Verbose(3) << "D2 != 0!\n"); 1212 1212 x[2] = -D3/D2; 1213 1213 E1 = A/x1->x[0] + x1->x[2]/x1->x[0]*D3/D2; 1214 1214 E2 = -x1->x[1]/x1->x[0]; 1215 Log() << Verbose(3) << "E1 " << E1 << "\tE2 " << E2 << "\n";1215 DoLog(3) && (Log() << Verbose(3) << "E1 " << E1 << "\tE2 " << E2 << "\n"); 1216 1216 F1 = E1*E1 + 1.; 1217 1217 F2 = -E1*E2; 1218 1218 F3 = E1*E1 + D3*D3/(D2*D2) - C; 1219 Log() << Verbose(3) << "F1 " << F1 << "\tF2 " << F2 << "\tF3 " << F3 << "\n";1219 DoLog(3) && (Log() << Verbose(3) << "F1 " << F1 << "\tF2 " << F2 << "\tF3 " << F3 << "\n"); 1220 1220 if (fabs(F1) < MYEPSILON) { 1221 Log() << Verbose(4) << "F1 == 0!\n";1222 Log() << Verbose(4) << "Gleichungssystem linear\n";1221 DoLog(4) && (Log() << Verbose(4) << "F1 == 0!\n"); 1222 DoLog(4) && (Log() << Verbose(4) << "Gleichungssystem linear\n"); 1223 1223 x[1] = F3/(2.*F2); 1224 1224 } else { 1225 1225 p = F2/F1; 1226 1226 q = p*p - F3/F1; 1227 Log() << Verbose(4) << "p " << p << "\tq " << q << endl;1227 DoLog(4) && (Log() << Verbose(4) << "p " << p << "\tq " << q << endl); 1228 1228 if (q < 0) { 1229 Log() << Verbose(4) << "q < 0" << endl;1229 DoLog(4) && (Log() << Verbose(4) << "q < 0" << endl); 1230 1230 return false; 1231 1231 } … … 1234 1234 x[0] = A/x1->x[0] - x1->x[1]/x1->x[0]*x[1] + x1->x[2]/x1->x[0]*x[2]; 1235 1235 } else { 1236 Log() << Verbose(2) << "Gleichungssystem unterbestimmt\n";1236 DoLog(2) && (Log() << Verbose(2) << "Gleichungssystem unterbestimmt\n"); 1237 1237 return false; 1238 1238 } … … 1240 1240 E1 = A/x1->x[0]+x1->x[1]/x1->x[0]*D3/D1; 1241 1241 E2 = x1->x[1]/x1->x[0]*D2/D1 - x1->x[2]; 1242 Log() << Verbose(2) << "E1 " << E1 << "\tE2 " << E2 << "\n";1242 DoLog(2) && (Log() << Verbose(2) << "E1 " << E1 << "\tE2 " << E2 << "\n"); 1243 1243 F1 = E2*E2 + D2*D2/(D1*D1) + 1.; 1244 1244 F2 = -(E1*E2 + D2*D3/(D1*D1)); 1245 1245 F3 = E1*E1 + D3*D3/(D1*D1) - C; 1246 Log() << Verbose(2) << "F1 " << F1 << "\tF2 " << F2 << "\tF3 " << F3 << "\n";1246 DoLog(2) && (Log() << Verbose(2) << "F1 " << F1 << "\tF2 " << F2 << "\tF3 " << F3 << "\n"); 1247 1247 if (fabs(F1) < MYEPSILON) { 1248 Log() << Verbose(3) << "F1 == 0!\n";1249 Log() << Verbose(3) << "Gleichungssystem linear\n";1248 DoLog(3) && (Log() << Verbose(3) << "F1 == 0!\n"); 1249 DoLog(3) && (Log() << Verbose(3) << "Gleichungssystem linear\n"); 1250 1250 x[2] = F3/(2.*F2); 1251 1251 } else { 1252 1252 p = F2/F1; 1253 1253 q = p*p - F3/F1; 1254 Log() << Verbose(3) << "p " << p << "\tq " << q << endl;1254 DoLog(3) && (Log() << Verbose(3) << "p " << p << "\tq " << q << endl); 1255 1255 if (q < 0) { 1256 Log() << Verbose(3) << "q < 0" << endl;1256 DoLog(3) && (Log() << Verbose(3) << "q < 0" << endl); 1257 1257 return false; 1258 1258 } … … 1292 1292 for (j=2;j>=0;j--) { 1293 1293 k = (i & pot(2,j)) << j; 1294 Log() << Verbose(2) << "k " << k << "\tpot(2,j) " << pot(2,j) << endl;1294 DoLog(2) && (Log() << Verbose(2) << "k " << k << "\tpot(2,j) " << pot(2,j) << endl); 1295 1295 sign[j] = (k == 0) ? 1. : -1.; 1296 1296 } 1297 Log() << Verbose(2) << i << ": sign matrix is " << sign[0] << "\t" << sign[1] << "\t" << sign[2] << "\n";1297 DoLog(2) && (Log() << Verbose(2) << i << ": sign matrix is " << sign[0] << "\t" << sign[1] << "\t" << sign[2] << "\n"); 1298 1298 // apply sign matrix 1299 1299 for (j=NDIM;j--;) … … 1301 1301 // calculate angle and check 1302 1302 ang = x2->Angle (this); 1303 Log() << Verbose(1) << i << "th angle " << ang << "\tbeta " << cos(beta) << " :\t";1303 DoLog(1) && (Log() << Verbose(1) << i << "th angle " << ang << "\tbeta " << cos(beta) << " :\t"); 1304 1304 if (fabs(ang - cos(beta)) < MYEPSILON) { 1305 1305 break;
Note:
See TracChangeset
for help on using the changeset viewer.