Ignore:
Timestamp:
Aug 25, 2010, 12:04:11 PM (15 years ago)
Author:
Tillmann Crueger <crueger@…>
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
Message:

Made all parts of the programm use the new thermostat structure

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/atom_trajectoryparticle.cpp

    r8d1dd4 r14c57a  
    144144};
    145145
    146 /** Scales velocity of atom according to Woodcock thermostat.
    147  * \param ScaleTempFactor factor to scale the velocities with (i.e. sqrt of energy scale factor)
    148  * \param Step MD step to scale
    149  * \param *ekin sum of kinetic energy
    150  */
    151 void TrajectoryParticle::Thermostat_Woodcock(double ScaleTempFactor, int Step, double *ekin)
    152 {
    153   Vector &U = Trajectory.U.at(Step);
    154   if (FixedIon == 0) // even FixedIon moves, only not by other's forces
    155     for (int d=0; d<NDIM; d++) {
    156       U[d] *= ScaleTempFactor;
    157       *ekin += 0.5*getType()->mass * U[d]*U[d];
    158     }
    159 };
    160 
    161 /** Scales velocity of atom according to Gaussian thermostat.
    162  * \param Step MD step to scale
    163  * \param *G
    164  * \param *E
    165  */
    166 void TrajectoryParticle::Thermostat_Gaussian_init(int Step, double *G, double *E)
    167 {
    168   Vector &U = Trajectory.U.at(Step);
    169   Vector &F = Trajectory.F.at(Step);
    170   if (FixedIon == 0) // even FixedIon moves, only not by other's forces
    171     for (int d=0; d<NDIM; d++) {
    172       *G += U[d] * F[d];
    173       *E += U[d]*U[d]*getType()->mass;
    174     }
    175 };
    176 
    177 /** Determines scale factors according to Gaussian thermostat.
    178  * \param Step MD step to scale
    179  * \param GE G over E ratio
    180  * \param *ekin sum of kinetic energy
    181  * \param *configuration configuration class with TempFrequency and TargetTemp
    182  */
    183 void TrajectoryParticle::Thermostat_Gaussian_least_constraint(int Step, double G_over_E, double *ekin, config *configuration)
    184 {
    185   Vector &U = Trajectory.U.at(Step);
    186   if (FixedIon == 0) // even FixedIon moves, only not by other's forces
    187     for (int d=0; d<NDIM; d++) {
    188       U[d] += configuration->Deltat/getType()->mass * ( (G_over_E) * (U[d]*getType()->mass) );
    189       *ekin += getType()->mass * U[d]*U[d];
    190     }
    191 };
    192 
    193 /** Scales velocity of atom according to Langevin thermostat.
    194  * \param Step MD step to scale
    195  * \param *r random number generator
    196  * \param *ekin sum of kinetic energy
    197  * \param *configuration configuration class with TempFrequency and TargetTemp
    198  */
    199 void TrajectoryParticle::Thermostat_Langevin(int Step, gsl_rng * r, double *ekin, config *configuration)
    200 {
    201   double sigma  = sqrt(configuration->Thermostats->TargetTemp/getType()->mass); // sigma = (k_b T)/m (Hartree/atomicmass = atomiclength/atomictime)
    202   Vector &U = Trajectory.U.at(Step);
    203   if (FixedIon == 0) { // even FixedIon moves, only not by other's forces
    204     // throw a dice to determine whether it gets hit by a heat bath particle
    205     if (((((rand()/(double)RAND_MAX))*configuration->Thermostats->TempFrequency) < 1.)) {
    206       DoLog(3) && (Log() << Verbose(3) << "Particle " << *this << " was hit (sigma " << sigma << "): " << sqrt(U[0]*U[0]+U[1]*U[1]+U[2]*U[2]) << " -> ");
    207       // pick three random numbers from a Boltzmann distribution around the desired temperature T for each momenta axis
    208       for (int d=0; d<NDIM; d++) {
    209         U[d] = gsl_ran_gaussian (r, sigma);
    210       }
    211       DoLog(2) && (Log() << Verbose(2) << sqrt(U[0]*U[0]+U[1]*U[1]+U[2]*U[2]) << endl);
    212     }
    213     for (int d=0; d<NDIM; d++)
    214       *ekin += 0.5*getType()->mass * U[d]*U[d];
    215   }
    216 };
    217 
    218 /** Scales velocity of atom according to Berendsen thermostat.
    219  * \param Step MD step to scale
    220  * \param ScaleTempFactor factor to scale energy (not velocity!) with
    221  * \param *ekin sum of kinetic energy
    222  * \param *configuration configuration class with TempFrequency and Deltat
    223  */
    224 void TrajectoryParticle::Thermostat_Berendsen(int Step, double ScaleTempFactor, double *ekin, config *configuration)
    225 {
    226   Vector &U = Trajectory.U.at(Step);
    227   if (FixedIon == 0) { // even FixedIon moves, only not by other's forces
    228     for (int d=0; d<NDIM; d++) {
    229       U[d] *= sqrt(1+(configuration->Deltat/configuration->Thermostats->TempFrequency)*(ScaleTempFactor-1));
    230       *ekin += 0.5*getType()->mass * U[d]*U[d];
    231     }
    232   }
    233 };
    234 
    235 /** Initializes current run of NoseHoover thermostat.
    236  * \param Step MD step to scale
    237  * \param *delta_alpha additional sum of kinetic energy on return
    238  */
    239 void TrajectoryParticle::Thermostat_NoseHoover_init(int Step, double *delta_alpha)
    240 {
    241   Vector &U = Trajectory.U.at(Step);
    242   if (FixedIon == 0) { // even FixedIon moves, only not by other's forces
    243     for (int d=0; d<NDIM; d++) {
    244       *delta_alpha += U[d]*U[d]*getType()->mass;
    245     }
    246   }
    247 };
    248 
    249 /** Initializes current run of NoseHoover thermostat.
    250  * \param Step MD step to scale
    251  * \param *ekin sum of kinetic energy
    252  * \param *configuration configuration class with TempFrequency and Deltat
    253  */
    254 void TrajectoryParticle::Thermostat_NoseHoover_scale(int Step, double *ekin, config *configuration)
    255 {
    256   Vector &U = Trajectory.U.at(Step);
    257   if (FixedIon == 0) { // even FixedIon moves, only not by other's forces
    258     for (int d=0; d<NDIM; d++) {
    259         U[d] += configuration->Deltat/getType()->mass * (configuration->Thermostats->alpha * (U[d] * getType()->mass));
    260         *ekin += (0.5*getType()->mass) * U[d]*U[d];
    261       }
    262   }
    263 };
    264 
    265 
    266146std::ostream & TrajectoryParticle::operator << (std::ostream &ost) const
    267147{
Note: See TracChangeset for help on using the changeset viewer.