Changeset 105b72 for src/Parser/PdbParser.cpp
- Timestamp:
- Mar 18, 2013, 1:31:46 PM (12 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:
- 1f5e97
- Parents:
- e9bdef
- git-author:
- Frederik Heber <heber@…> (02/26/13 09:45:40)
- git-committer:
- Frederik Heber <heber@…> (03/18/13 13:31:46)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Parser/PdbParser.cpp
re9bdef r105b72 51 51 #include "WorldTime.hpp" 52 52 53 #include <algorithm> 54 #include <cmath> 53 55 #include <map> 54 56 #include <vector> … … 276 278 for (size_t i=0; i<NDIM;++i) { 277 279 stringstream position; 278 position << set w(8) << fixed << setprecision(3) << (*atomIt)->getPositionAtStep(step).at(i);280 position << setprecision(7) << (*atomIt)->getPositionAtStep(step).at(i); 279 281 atomInfo.set(PositionEnumMap[i], position.str()); 280 282 } … … 368 370 } 369 371 return additionalAtomData[_atom->getId()]; 372 } 373 374 /** Tiny helper function to print a float with a most 8 digits. 375 * 376 * A few examples best give the picture: 377 * 1234.678 378 * 1.234 379 * 0.001 380 * 0.100 381 * 1234567. 382 * 123456.7 383 * -1234.56 384 * 385 * \param value 386 * \return string representation 387 */ 388 const std::string FormatParser< pdb >::printCoordinate( 389 const double value) 390 { 391 size_t meaningful_bits=7; // one for decimal dot 392 if (value < 0) //one for the minus sign 393 --meaningful_bits; 394 // count digits before dot (without minus and round towards zero!) 395 const int full = floor(fabs(value)); 396 size_t bits_before_dot = 1; 397 { 398 int tmp = full; 399 for (;bits_before_dot < meaningful_bits;++bits_before_dot) { 400 // even if value is 0...somethingish, we still must start at one digit 401 tmp = tmp/10; 402 if (tmp == 0) 403 break; 404 } 405 } 406 // this fixes bits available after dot 407 const size_t bits_after_dot = std::min((int)meaningful_bits - (int)bits_before_dot, 3); 408 stringstream position; 409 if (bits_after_dot > 0) { 410 if (value < 0) 411 position << "-"; 412 const int remainder = round((abs(value)-full)*pow(10,bits_after_dot)); 413 position << full << "." << setfill('0') << setw(bits_after_dot) << remainder; 414 if (bits_after_dot == 2) 415 ELOG(2, "PdbParser is writing coordinates with just a two decimal places."); 416 if (bits_after_dot == 1) 417 ELOG(1, "PdbParser is writing coordinates with just a single decimal places."); 418 } else { 419 ELOG(0, "PdbParser is writing coordinates without any decimal places."); 420 position << full << "."; 421 } 422 return position.str(); 370 423 } 371 424 … … 406 459 // only act on these 407 460 for (size_t i=0;i<NDIM;++i) { 408 stringstream position; 409 position << fixed << setprecision(3) << showpoint 410 << atomInfo.get<double>(PositionEnumMap[i]); 411 *file << setfill(' ') << right << setw(8) << position.str(); 461 *file << setfill(' ') << right << setw(8) 462 << printCoordinate(atomInfo.get<double>(PositionEnumMap[i])); 412 463 } 413 464 {
Note:
See TracChangeset
for help on using the changeset viewer.