Changeset 14c57a for src/molecule_dynamics.cpp
- Timestamp:
- Aug 25, 2010, 12:04:11 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:
- 51c3e4
- Parents:
- 8d1dd4
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/molecule_dynamics.cpp
r8d1dd4 r14c57a 24 24 #include "LinearAlgebra/Plane.hpp" 25 25 #include "ThermoStatContainer.hpp" 26 #include "Thermostats/Berendsen.hpp" 26 27 27 28 #include <gsl/gsl_matrix.h> … … 615 616 ActualTemp = 0.; 616 617 ActOnAllAtoms ( &atom::CorrectVelocity, &ActualTemp, MDSteps+1, &Velocity ); 617 Thermostats(configuration, ActualTemp, Berendsen); 618 Berendsen berendsen = Berendsen(); 619 berendsen.addToContainer(configuration.Thermostats); 620 double ekin = berendsen.scaleAtoms(MDSteps,ActualTemp,atoms); 621 DoLog(1) && (Log() << Verbose(1) << "Kinetic energy is " << ekin << "." << endl); 618 622 MDSteps++; 619 623 … … 621 625 return true; 622 626 }; 623 624 /** Implementation of various thermostats.625 * All these thermostats apply an additional force which has the following forms:626 * -# Woodcock627 * \f$p_i \rightarrow \sqrt{\frac{T_0}{T}} \cdot p_i\f$628 * -# Gaussian629 * \f$ \frac{ \sum_i \frac{p_i}{m_i} \frac{\partial V}{\partial q_i}} {\sum_i \frac{p^2_i}{m_i}} \cdot p_i\f$630 * -# Langevin631 * \f$p_{i,n} \rightarrow \sqrt{1-\alpha^2} p_{i,0} + \alpha p_r\f$632 * -# Berendsen633 * \f$p_i \rightarrow \left [ 1+ \frac{\delta t}{\tau_T} \left ( \frac{T_0}{T} \right ) \right ]^{\frac{1}{2}} \cdot p_i\f$634 * -# Nose-Hoover635 * \f$\zeta p_i \f$ with \f$\frac{\partial \zeta}{\partial t} = \frac{1}{M_s} \left ( \sum^N_{i=1} \frac{p_i^2}{m_i} - g k_B T \right )\f$636 * These Thermostats either simply rescale the velocities, thus this function should be called after ion velocities have been updated, and/or637 * have a constraint force acting additionally on the ions. In the latter case, the ion speeds have to be modified638 * belatedly and the constraint force set.639 * \param *P Problem at hand640 * \param i which of the thermostats to take: 0 - none, 1 - Woodcock, 2 - Gaussian, 3 - Langevin, 4 - Berendsen, 5 - Nose-Hoover641 * \sa InitThermostat()642 */643 void molecule::Thermostats(config &configuration, double ActualTemp, int Thermostat)644 {645 double ekin = 0.;646 double E = 0., G = 0.;647 double delta_alpha = 0.;648 double ScaleTempFactor;649 gsl_rng * r;650 const gsl_rng_type * T;651 652 // calculate scale configuration653 ScaleTempFactor = configuration.Thermostats->TargetTemp/ActualTemp;654 655 // differentating between the various thermostats656 switch(Thermostat) {657 case None:658 DoLog(2) && (Log() << Verbose(2) << "Applying no thermostat..." << endl);659 break;660 case Woodcock:661 if ((configuration.Thermostats->ScaleTempStep > 0) && ((MDSteps-1) % configuration.Thermostats->ScaleTempStep == 0)) {662 DoLog(2) && (Log() << Verbose(2) << "Applying Woodcock thermostat..." << endl);663 ActOnAllAtoms( &atom::Thermostat_Woodcock, sqrt(ScaleTempFactor), MDSteps, &ekin );664 }665 break;666 case Gaussian:667 DoLog(2) && (Log() << Verbose(2) << "Applying Gaussian thermostat..." << endl);668 ActOnAllAtoms( &atom::Thermostat_Gaussian_init, MDSteps, &G, &E );669 670 DoLog(1) && (Log() << Verbose(1) << "Gaussian Least Constraint constant is " << G/E << "." << endl);671 ActOnAllAtoms( &atom::Thermostat_Gaussian_least_constraint, MDSteps, G/E, &ekin, &configuration);672 673 break;674 case Langevin:675 DoLog(2) && (Log() << Verbose(2) << "Applying Langevin thermostat..." << endl);676 // init random number generator677 gsl_rng_env_setup();678 T = gsl_rng_default;679 r = gsl_rng_alloc (T);680 // Go through each ion681 ActOnAllAtoms( &atom::Thermostat_Langevin, MDSteps, r, &ekin, &configuration );682 break;683 684 case Berendsen:685 DoLog(2) && (Log() << Verbose(2) << "Applying Berendsen-VanGunsteren thermostat..." << endl);686 ActOnAllAtoms( &atom::Thermostat_Berendsen, MDSteps, ScaleTempFactor, &ekin, &configuration );687 break;688 689 case NoseHoover:690 DoLog(2) && (Log() << Verbose(2) << "Applying Nose-Hoover thermostat..." << endl);691 // dynamically evolve alpha (the additional degree of freedom)692 delta_alpha = 0.;693 ActOnAllAtoms( &atom::Thermostat_NoseHoover_init, MDSteps, &delta_alpha );694 delta_alpha = (delta_alpha - (3.*getAtomCount()+1.) * configuration.Thermostats->TargetTemp)/(configuration.Thermostats->HooverMass*Units2Electronmass);695 configuration.Thermostats->alpha += delta_alpha*configuration.Deltat;696 DoLog(3) && (Log() << Verbose(3) << "alpha = " << delta_alpha << " * " << configuration.Deltat << " = " << configuration.Thermostats->alpha << "." << endl);697 // apply updated alpha as additional force698 ActOnAllAtoms( &atom::Thermostat_NoseHoover_scale, MDSteps, &ekin, &configuration );699 break;700 }701 DoLog(1) && (Log() << Verbose(1) << "Kinetic energy is " << ekin << "." << endl);702 };
Note:
See TracChangeset
for help on using the changeset viewer.