ParM  parm
A molecular dynamics library
collection.hpp
Go to the documentation of this file.
1 #ifndef COLLECTION_H
2 #define COLLECTION_H
3 
4 #include "vecrand.hpp"
5 #include "interaction.hpp"
6 #include "constraints.hpp"
7 #include <cstdio>
8 #include <vector>
9 #include <set>
10 #include <boost/shared_ptr.hpp>
11 
12 
20 class Collection {
21  protected:
22  sptr<Box> box;
23  sptr<AtomGroup> atoms;
24  vector<sptr<Interaction> > interactions;
25  vector<sptr<StateTracker> > trackers;
26  vector<sptr<Constraint> > constraints;
27 
30  void update_trackers();
31 
38  virtual flt set_forces_get_pressure(bool constraints_and_a=true);
39 
40  public:
41  Collection(sptr<Box> box,
42  sptr<AtomGroup> atoms,
43  vector<sptr<Interaction> > interactions=vector<sptr<Interaction> >(),
44  vector<sptr<StateTracker> > trackers=vector<sptr<StateTracker> >(),
45  vector<sptr<Constraint> > constraints=vector<sptr<Constraint> >(),
46  bool should_initialize=true);
47 
48  virtual void initialize();
49 
50  //Timestepping Methods /////////////////////////////////////////////////////////////////////
53  virtual void set_forces(bool constraints_and_a=true);
54 
56  virtual void timestep()=0;
57 
61 
62  //Statistical Methods //////////////////////////////////////////////////////////////////////
65  flt energy();
66  virtual flt temp(bool minuscomv=true);
67  virtual flt kinetic_energy(){return atoms->kinetic_energy();};
68  virtual flt virial();
69  virtual flt pressure();
70  sptr<Box> get_box(){return box;};
71  inline Vec com(){return atoms->com();};
72  inline Vec com_velocity(){return atoms->com_velocity();};
73  #ifdef VEC3D
74  inline Vec angular_momentum(const Vec &loc){return atoms->angular_momentum(loc);};
77  inline Vec angular_momentum(){return atoms->angular_momentum(com());};
78  #elif defined VEC2D
79  inline flt angular_momentum(const Vec &loc){return atoms->angular_momentum(loc);};
82  inline flt angular_momentum(){return atoms->angular_momentum(com());};
83  #endif
84  flt gyradius(); // Radius of gyration
85  virtual ~Collection(){};
86 
88  void reset_com_velocity(){atoms->reset_com_velocity();};
90  void reset_L(){atoms->reset_L();};
92  void scale_velocities(flt scaleby);
94  void scale_velocities_to_temp(flt T, bool minuscomv=true);
97 
98  void add_interaction(sptr<Interaction> inter){
99  interactions.push_back(inter);
100  update_trackers();
101  };
102  void add_tracker(sptr<StateTracker> track){
103  trackers.push_back(track);
104  update_trackers();
105  };
106  void add_constraint(sptr<Constraint> c){
107  constraints.push_back(c);
108  update_trackers();
109  };
110  void add(sptr<Interaction> a){add_interaction(a);};
111  void add(sptr<StateTracker> a){add_tracker(a);};
112  void add(sptr<Constraint> a){add_constraint(a);};
113 
114  vector<sptr<Interaction> > get_interactions(){return interactions;};
115 };
116 
118 class StaticCollec : public Collection {
119  public:
120  StaticCollec(sptr<Box> box, sptr<AtomGroup> atoms,
121  vector<sptr<Interaction> > interactions=vector<sptr<Interaction> >(),
122  vector<sptr<StateTracker> > trackers=vector<sptr<StateTracker> >(),
123  vector<sptr<Constraint> > constraints=vector<sptr<Constraint> >())
124  : Collection(box, atoms, interactions, trackers, constraints){};
125 
127  virtual void timestep(){};
128  void update(){
129  update_trackers();
133  };
134 };
135 
137 
180 class CollectionSol : public Collection {
181  protected:
193  flt c0, c1, c2;
195  void set_constants();
196 
197  public:
200  sptr<Box> box,
202  sptr<AtomGroup> atoms,
204  const flt dt,
206  const flt damping,
208  const flt desired_temperature,
210  vector<sptr<Interaction> > interactions=vector<sptr<Interaction> >(),
212  vector<sptr<StateTracker> > trackers=vector<sptr<StateTracker> >(),
214  vector<sptr<Constraint> > constraints=vector<sptr<Constraint> >());
216  void change_temperature(const flt damp, const flt desired_temperature){
217  damping = damp; force_mag=damp; desT = desired_temperature; set_constants();};
218  void change_force(const flt damp, const flt fmag, const flt desired_temperature){
220  damping = damp; force_mag=fmag; desT = desired_temperature; set_constants();};
221  void set_dt(const flt newdt){dt = newdt; set_constants();};
222  void timestep();
223  //void seed(uint n){gauss.seed(n);};
224  //void seed(){gauss.seed();};
225 };
226 
228 
234 class CollectionDamped : public Collection {
235 
236  protected:
239  flt c0, c1, c2;
240  void set_constants();
241 
242  public:
243  CollectionDamped(sptr<Box> box, sptr<AtomGroup> atoms,
244  const flt dt, const flt damping,
245  vector<sptr<Interaction> > interactions=vector<sptr<Interaction> >(),
246  vector<sptr<StateTracker> > trackers=vector<sptr<StateTracker> >(),
247  vector<sptr<Constraint> > constraints=vector<sptr<Constraint> >());
248  void change_damping(const flt damp){
249  damping = damp; set_constants();};
250  void set_dt(const flt newdt){dt = newdt; set_constants();};
251  void timestep();
252 };
253 
282 class CollectionSolHT : public Collection {
283  protected:
286  flt desT; // desired temperature
288  void set_gauss();
289 
290  public:
291  CollectionSolHT(sptr<Box> box, sptr<AtomGroup> atoms,
292  const flt dt, const flt damping, const flt desired_temperature,
293  vector<sptr<Interaction> > interactions=vector<sptr<Interaction> >(),
294  vector<sptr<StateTracker> > trackers=vector<sptr<StateTracker> >(),
295  vector<sptr<Constraint> > constraints=vector<sptr<Constraint> >());
296  void change_temperature(const flt newdt, const flt damp, const flt desired_temperature){
297  dt = newdt; damping = damp; desT = desired_temperature; set_gauss();};
298  void timestep();
299  //void seed(uint n){gauss.seed(n);};
300  //void seed(){gauss.seed();};
301 };
302 
308 class CollectionVerlet : public Collection {
309  // for use in fixed-E simulations
310  protected:
312 
313  public:
314  CollectionVerlet(sptr<Box> box, sptr<AtomGroup> atoms, const flt dt,
315  vector<sptr<Interaction> > interactions=vector<sptr<Interaction> >(),
316  vector<sptr<StateTracker> > trackers=vector<sptr<StateTracker> >(),
317  vector<sptr<Constraint> > constraints=vector<sptr<Constraint> >()) :
318  Collection(box, atoms, interactions, trackers, constraints), dt(dt){};
319  void timestep();
320  void set_dt(flt newdt){dt=newdt;};
321 };
322 
324  // over-damped simulation, v = gamma * f
325  protected:
327 
328  public:
329  CollectionOverdamped(sptr<Box> box, sptr<AtomGroup> atoms,
330  const flt dt, const flt gamma=1.0,
331  vector<sptr<Interaction> > interactions=vector<sptr<Interaction> >(),
332  vector<sptr<StateTracker> > trackers=vector<sptr<StateTracker> >(),
333  vector<sptr<Constraint> > constraints=vector<sptr<Constraint> >()) :
334  Collection(box, atoms, interactions, trackers, constraints),
335  dt(dt), gamma(gamma){};
336  void timestep();
337  void set_dt(flt newdt){dt=newdt;};
338 };
339 
345 class CollectionNLCG : public Collection {
346  // Conjugate-Gradient energy minimization, with
347  // H = H0(x₁, x₂, …, L) + P V
348  // More specifically, we take the Nose-Hoover NPH hamiltonian,
349  // H = ½m V^⅔ Σṡᵢ² + ½Q V̇² + U(V^⅔ ⃗sᵢ…) + P₀ V
350  // and E = U(V^⅔ ⃗sᵢ…) + P₀ V
351  // We minimize using ⃗sᵢ and κ ln V as the dN+1 variables
352 
353  public:
354  // Parameters
360 
361  // Goal pressure
363 
364  // To keep between iterations
367  flt vl, fl, al;
368 
369  // For tracking purposes
372 
373  virtual void stepx(flt dx);
375  flt fdota();
376  flt fdotf();
377  flt fdotv();
378  flt vdotv();
379  //~ void resizedl(flt dl);
380 
381  public:
382  CollectionNLCG(sptr<OriginBox> box, sptr<AtomGroup> atoms,
383  const flt dt, const flt P0,
384  vector<sptr<Interaction> > interactions=vector<sptr<Interaction> >(),
385  vector<sptr<StateTracker> > trackers=vector<sptr<StateTracker> >(),
386  vector<sptr<Constraint> > constraints=vector<sptr<Constraint> >(),
387  const flt kappa=10.0, const flt kmax=1000,
388  const uint secmax=40, const flt seceps = 1e-20);
389 
390  flt kinetic_energy(); // Note: masses are ignored
391  flt pressure();
392  flt hamiltonian();
393  void set_forces(bool constraints_and_a=true){set_forces(constraints_and_a,true);};
394  void set_forces(bool constraints_and_a, bool setV);
395 
396  void timestep();
397  void descend(); // use steepest descent
398  void reset();
399 
400  void set_dt(flt newdt){dt=newdt; reset();};
401  void set_pressure_goal(flt P){P0 = P; reset();};
403  void set_kappa(flt k){kappa=k; reset();};
404  void set_max_alpha(flt a){alphamax=a;};
405  void set_max_alpha_fraction(flt a){afrac=a;};
406  void set_max_dx(flt d){dxmax=d;};
407  void set_max_step(flt m){stepmax=m;};
408 
409 };
410 
412  public:
413  CollectionNLCGFixedL(sptr<OriginBox> box, sptr<AtomGroup> atoms,
414  const flt dt, const flt P0,
415  vector<sptr<Interaction> > interactions=vector<sptr<Interaction> >(),
416  vector<sptr<StateTracker> > trackers=vector<sptr<StateTracker> >(),
417  vector<sptr<Constraint> > constraints=vector<sptr<Constraint> >(),
418  const flt kappa=10.0, const flt kmax=1000,
419  const uint secmax=40, const flt seceps = 1e-20) :
420  CollectionNLCG(box, atoms, dt, P0, interactions, trackers,
421  constraints, kappa, kmax, secmax, seceps){};
422  void stepx(flt dx);
423 };
424 
425 class CollectionNLCGV : public Collection {
426  // Conjugate-Gradient energy minimization, with
427  // and E = U(⃗rᵢ…)
428 
429  public:
430  // Parameters
431  flt dt; // initial step attempt
434 
435  // secmax is the max number of iterations within a timestep
436  // seceps is the minimum alpha * v before we call it "close enough"
438  // alpha is how much larger the next step is, proportionally
439  // if alpha < afrac * dxsum, we break, its "close enough"
440  // alphamax is the largest proportion
441  // dxmax is the maximum "step" you take in one "timestep"; the full
442  // step is v * dxsum
443  // stepmax is the largest v*dxsum allowed
444  // We reset after kmax iterations
445 
446  // To keep between iterations
449  flt vl, fl, al;
450 
451  // For tracking purposes
453  // alpha is how much bigger one iteration is than the previous
454  // beta is how much we use of the previous v
455  // betaused is after we take into account 0 <= beta <= 1
456  // dxsum is the total of alphas over a timestep; atoms move v*dxsum in one timestep
457  // alphavmax = (last alpha) * sqrt(v dot v)
459 
460  void stepx(flt dx);
461 
462  flt fdota();
463  flt fdotf();
464  flt fdotv();
465  flt vdotv();
466  //~ void resizedl(flt dl);
467 
468  public:
469  CollectionNLCGV(sptr<Box> box, sptr<AtomGroup> atoms, const flt dt,
470  vector<sptr<Interaction> > interactions=vector<sptr<Interaction> >(),
471  vector<sptr<StateTracker> > trackers=vector<sptr<StateTracker> >(),
472  vector<sptr<Constraint> > constraints=vector<sptr<Constraint> >(),
473  const flt kmax=1000, const uint secmax=10,
474  const flt seceps = 1e-4);
475 
476  flt pressure();
477 
478  void reset();
479  void descend(); // use steepest descent
480  void timestep();
481 
482  void set_dt(flt newdt){dt=newdt; reset();};
483  void set_max_alpha(flt a){alphamax=a;};
484  void set_max_alpha_fraction(flt a){afrac=a;};
485  void set_max_dx(flt d){dxmax=d;};
486  void set_max_step(flt m){stepmax=m;};
487 };
488 
489 flt solve_cubic_fast(flt b, flt c, flt d);
490 
491 template <typename T> int sgn(T val) {
492  return (T(0) < val) - (val < T(0));
493 }
494 
495 flt solve_cubic(flt a1, flt a2, flt a3, flt closeto=0);
496 
498  // NVT
499  protected:
500  flt dt, Q, T;
502 
503  public:
504  CollectionNoseHoover(sptr<Box> box, sptr<AtomGroup> atoms,
505  const flt dt, const flt Q, const flt T,
506  vector<sptr<Interaction> > interactions=vector<sptr<Interaction> >(),
507  vector<sptr<StateTracker> > trackers=vector<sptr<StateTracker> >(),
508  vector<sptr<Constraint> > constraints=vector<sptr<Constraint> >()) :
509  Collection(box, atoms, interactions, trackers, constraints),
510  dt(dt), Q(Q), T(T){
511  xi = 0; lns = 0;
512  };
513  void set_dt(flt newdt){dt=newdt;};
514  void set_Q(flt newQ){Q=newQ;};
515  void reset_bath(){xi=0;lns=0;};
516 
517  void timestep();
518  flt hamiltonian();
519  flt get_xi(){return xi;};
520  flt get_lns(){return lns;};
521 };
522 
524  // Gaussian Constraint thermostat
525  // NVT
526  protected:
529  flt set_xi();
530 
531  public:
532  CollectionGaussianT(sptr<Box> box, sptr<AtomGroup> atoms,
533  const flt dt,
534  vector<sptr<Interaction> > interactions=vector<sptr<Interaction> >(),
535  vector<sptr<StateTracker> > trackers=vector<sptr<StateTracker> >(),
536  vector<sptr<Constraint> > constraints=vector<sptr<Constraint> >()) :
537  Collection(box, atoms, interactions, trackers, constraints),
538  dt(dt), xi(0){};
539  void set_dt(flt newdt){dt=newdt;};
540  void set_forces(bool constraints_and_a=true){set_forces(true,true);};
541  void set_forces(bool constraints_and_a, bool set_xi);
542  void timestep();
543 };
544 
545 class CollectionGear3A : public Collection {
546  // for use in fixed-E simulations
547  protected:
549 
550  public:
551  CollectionGear3A(sptr<Box> box, sptr<AtomGroup> atoms, const flt dt,
552  vector<sptr<Interaction> > interactions=vector<sptr<Interaction> >(),
553  vector<sptr<StateTracker> > trackers=vector<sptr<StateTracker> >(),
554  vector<sptr<Constraint> > constraints=vector<sptr<Constraint> >()) :
555  Collection(box, atoms, interactions, trackers, constraints), dt(dt){};
556  void timestep();
557  void set_dt(flt newdt){dt=newdt;};
558 };
559 
560 class CollectionGear4A : public Collection {
561  // for use in fixed-E simulations
562  protected:
565  vector<Vec> bs;
566  void resetbs(){
567  bs.resize(atoms->size(), Vec::Zero());
568  }
569 
570  public:
571  CollectionGear4A(sptr<Box> box, sptr<AtomGroup> atoms,
572  const flt dt, uint ncorrectionsteps,
573  vector<sptr<Interaction> > interactions=vector<sptr<Interaction> >(),
574  vector<sptr<StateTracker> > trackers=vector<sptr<StateTracker> >(),
575  vector<sptr<Constraint> > constraints=vector<sptr<Constraint> >()) :
576  Collection(box, atoms, interactions, trackers,
577  constraints), dt(dt), ncorrec(ncorrectionsteps){
578  resetbs();
579  };
580  CollectionGear4A(sptr<Box> box, sptr<AtomGroup> atoms,
581  const flt dt,
582  vector<sptr<Interaction> > interactions=vector<sptr<Interaction> >(),
583  vector<sptr<StateTracker> > trackers=vector<sptr<StateTracker> >(),
584  vector<sptr<Constraint> > constraints=vector<sptr<Constraint> >()) :
585  Collection(box, atoms, interactions, trackers, constraints),
586  dt(dt), ncorrec(1) {resetbs();};
587  void timestep();
588  void set_dt(flt newdt){dt=newdt;};
589 };
590 
591 class CollectionGear5A : public Collection {
592  // for use in fixed-E simulations
593  protected:
596  vector<Vec> bs, cs;
597  void resetbcs(){
598  uint Natoms = atoms->size();
599  bs.resize(Natoms, Vec::Zero());
600  cs.resize(Natoms, Vec::Zero());
601  }
602 
603  public:
604  CollectionGear5A(sptr<Box> box, sptr<AtomGroup> atoms,
605  const flt dt, uint ncorrectionsteps,
606  vector<sptr<Interaction> > interactions=vector<sptr<Interaction> >(),
607  vector<sptr<StateTracker> > trackers=vector<sptr<StateTracker> >(),
608  vector<sptr<Constraint> > constraints=vector<sptr<Constraint> >()) :
609  Collection(box, atoms, interactions, trackers, constraints),
610  dt(dt), ncorrec(ncorrectionsteps){resetbcs();};
611  CollectionGear5A(sptr<Box> box, const flt dt,
612  sptr<AtomGroup> atoms,
613  vector<sptr<Interaction> > interactions=vector<sptr<Interaction> >(),
614  vector<sptr<StateTracker> > trackers=vector<sptr<StateTracker> >(),
615  vector<sptr<Constraint> > constraints=vector<sptr<Constraint> >()) :
616  Collection(box, atoms, interactions, trackers, constraints),
617  dt(dt), ncorrec(1) {resetbcs();};
618  void timestep();
619  void set_dt(flt newdt){dt=newdt;};
620 };
621 
622 class CollectionGear6A : public Collection {
623  // for use in fixed-E simulations
624  protected:
627  vector<Vec> bs, cs, ds;
628  void resetbcds(){
629  uint Natoms = atoms->size();
630  bs.clear(); cs.clear(); ds.clear();
631  bs.resize(Natoms, Vec::Zero());
632  cs.resize(Natoms, Vec::Zero());
633  ds.resize(Natoms, Vec::Zero());
634  }
635 
636  public:
637  CollectionGear6A(sptr<Box> box, sptr<AtomGroup> atoms,
638  const flt dt, uint ncorrectionsteps,
639  vector<sptr<Interaction> > interactions=vector<sptr<Interaction> >(),
640  vector<sptr<StateTracker> > trackers=vector<sptr<StateTracker> >(),
641  vector<sptr<Constraint> > constraints=vector<sptr<Constraint> >()) :
642  Collection(box, atoms, interactions, trackers, constraints),
643  dt(dt), ncorrec(ncorrectionsteps){resetbcds();};
644  CollectionGear6A(sptr<Box> box, sptr<AtomGroup> atoms, const flt dt,
645  vector<sptr<Interaction> > interactions=vector<sptr<Interaction> >(),
646  vector<sptr<StateTracker> > trackers=vector<sptr<StateTracker> >(),
647  vector<sptr<Constraint> > constraints=vector<sptr<Constraint> >()) :
648  Collection(box, atoms, interactions, trackers, constraints),
649  dt(dt), ncorrec(1) {resetbcds();};
650  void timestep();
651  void set_dt(flt newdt){dt=newdt;};
652 };
653 
654 struct RK4data {
656 };
657 
658 class CollectionRK4 : public Collection {
659  // for use in fixed-E simulations
660  protected:
662  vector<RK4data> data;
663 
664  public:
665  CollectionRK4(sptr<Box> box, sptr<AtomGroup> ratoms, const flt dt,
666  vector<sptr<Interaction> > interactions=vector<sptr<Interaction> >(),
667  vector<sptr<StateTracker> > trackers=vector<sptr<StateTracker> >(),
668  vector<sptr<Constraint> > constraints=vector<sptr<Constraint> >()) :
669  Collection(box, ratoms, interactions,
670  trackers, constraints), dt(dt), data(ratoms->vec().size()){
671  set_forces(true);
672  };
673  void timestep();
674  void set_dt(flt newdt){dt=newdt;};
675 };
676 
678  // for use in fixed-E, fixed-NPH simulations
679  // Nose-Hoover, right?
680  protected:
682  flt P, Q; // goal pressure, damping
683  flt dV, ddV, dddV; // that's dV²/dt², dV/dt
685  vector<Vec> bs;
686  void resetbs(){
687  bs.resize(atoms->size(), Vec::Zero());
688  }
689 
690  public:
691  CollectionGear4NPH(sptr<OriginBox> box, sptr<AtomGroup> atoms,
692  const flt dt, const flt P,
693  const flt Q, uint ncorrectionsteps,
694  vector<sptr<Interaction> > interactions=vector<sptr<Interaction> >(),
695  vector<sptr<StateTracker> > trackers=vector<sptr<StateTracker> >(),
696  vector<sptr<Constraint> > constraints=vector<sptr<Constraint> >()) :
697  Collection(box, atoms, interactions, trackers,
698  constraints), dt(dt), P(P), Q(Q), dV(0), ddV(0), dddV(0),
699  ncorrec(ncorrectionsteps){
700  resetbs();
701  };
702  CollectionGear4NPH(sptr<OriginBox> box, sptr<AtomGroup> atoms,
703  const flt dt, const flt P, const flt Q,
704  vector<sptr<Interaction> > interactions=vector<sptr<Interaction> >(),
705  vector<sptr<StateTracker> > trackers=vector<sptr<StateTracker> >(),
706  vector<sptr<Constraint> > constraints=vector<sptr<Constraint> >()) :
707  Collection(box, atoms, interactions, trackers, constraints),
708  dt(dt), P(P), Q(Q), dV(0), ddV(0), dddV(0), ncorrec(1) {resetbs();};
709  void timestep();
711  flt temp(bool minuscomv=true);
713  return kinetic_energy() + (Q/2*dV*dV) + potential_energy() + P*(boost::static_pointer_cast<OriginBox>(box)->V());
714  }
715  flt get_dV(){return dV;};
716  flt getddV(){return ddV;};
717  void set_dt(flt newdt){dt=newdt;};
718 };
719 
720 class XRPSummer : public FPairXFunct {
721  private:
722  sptr<Box> box;
723  public:
725  XRPSummer(sptr<Box> box) : box(box), xsum(0), rpxsum(0), vfsum(0), rfsum(0){};
726  virtual void run (ForcePairX*);
727  inline void reset(){xsum = 0; rpxsum=0; vfsum=0; rfsum=0;};
728 };
729 
731  // for use in fixed-NPT simulations
732  // Gaussian Constraint formulation
733  public:
738  vector<Vec> xs1, xs2, xs3;
739  vector<Vec> vs2, vs3;
740  void resetbs(){
741  uint Natoms = atoms->size();
742  xs1.resize(Natoms, Vec::Zero());
743  xs2.resize(Natoms, Vec::Zero());
744  xs3.resize(Natoms, Vec::Zero());
745  vs2.resize(Natoms, Vec::Zero());
746  vs3.resize(Natoms, Vec::Zero());
747  V1 = V2 = V3 = 0;
748  }
749  static vector<sptr<Interaction> > tointerpair(vector<sptr<InteractionPairsX> >&);
750 
751  public:
752  CollectionGear4NPT(sptr<OriginBox> box, sptr<AtomGroup> atoms,
753  const flt dt, uint ncorrectionsteps,
754  vector<sptr<InteractionPairsX> > interactions=vector<sptr<InteractionPairsX> >(),
755  vector<sptr<StateTracker> > trackers=vector<sptr<StateTracker> >(),
756  vector<sptr<Constraint> > constraints=vector<sptr<Constraint> >()) :
757  Collection(box, atoms, tointerpair(interactions), trackers,
758  constraints), dt(dt), xrpsums(box),
759  ncorrec(ncorrectionsteps), chi(0), chixi(0){
760  resetbs();
761  };
762  CollectionGear4NPT(sptr<OriginBox> box, const flt dt,
763  sptr<AtomGroup> atoms,
764  vector<sptr<InteractionPairsX> > interactions=vector<sptr<InteractionPairsX> >(),
765  vector<sptr<StateTracker> > trackers=vector<sptr<StateTracker> >(),
766  vector<sptr<Constraint> > constraints=vector<sptr<Constraint> >()) :
767  Collection(box, atoms, tointerpair(interactions),
768  trackers, constraints),
769  dt(dt), xrpsums(box), ncorrec(1), chi(0), chixi(0) {
770  resetbs();
771  };
772  void set_forces(bool constraints_and_a=true);
773  void timestep();
774 };
775 
776 
777 
779  // From Toxvaerd 1993, PRE Vol. 47, No. 1, http://dx.doi.org/10.1103/PhysRevE.47.343
780  // Parameter equivalences (in the form code: paper):
781  // degrees_of_freedom() or ndof: g
782  // QT: g k T t_\eta^2
783  // QP: N k T t_\xi^2
784  // where N is the number of particles
785  public:
788  flt etasum; // for calculating the "hamiltonian"
789  vector<Vec> vhalf;
790  flt P, QP, T, QT, curP;
791  void resetvhalf();
792 
793  public:
794  CollectionVerletNPT(sptr<OriginBox> box, sptr<AtomGroup> atoms,
795  const flt dt, const flt P,
796  const flt QP, const flt T, const flt QT,
797  vector<sptr<Interaction> > interactions=vector<sptr<Interaction> >(),
798  vector<sptr<StateTracker> > trackers=vector<sptr<StateTracker> >(),
799  vector<sptr<Constraint> > constraints=vector<sptr<Constraint> >()) :
800  Collection(box, atoms, interactions, trackers, constraints),
801  dt(dt), eta(0), xidot(0), lastxidot(0), lastV(box->V()), etasum(0), P(P),
802  QP(QP), T(T), QT(QT), curP(0){resetvhalf();};
803  void timestep();
804  void set_dt(flt newdt){dt=newdt;};
805 
806 
812 
813  flt get_eta(){return eta;};
814  flt det_xi_dot(){return xidot;};
815  flt get_pressure(){return curP;};
816  Vec get_vhalf(uint n){return vhalf[n];};
817 
818  // note that this is a constant of the motion, but not a real hamiltonian
819  // and also only such at constant T
821  // regular energy
823 
824  if(QT > 0){
825  flt gkT = degrees_of_freedom()*T;
826  H +=gkT*etasum;
827  H+= eta*eta*QT/2;
828  }
829  return H;
830  }
831 };
832 
833 struct Event {
834  flt t; // when it will occur
835  AtomID a; // Atom 1
836  AtomID b; // Atom 2
837 
838  bool operator<(const Event& other ) const {
839  if (t < other.t) { return true;};
840  if (t > other.t) { return false;};
841  if (a < other.a) { return true;};
842  if (a > other.a) { return false;};
843  if (b < other.b) { return true;};
844  return false;
845  };
846 
847 };
848 
849 flt get_max(vector<flt> v);
850 
852 class CollectionCD : public Collection {
853  protected:
855  long long numevents;
856  set<Event> events; // note that this a sorted binary tree
857  vector<flt> atomsizes;
858 
859  void reset_events();
860  void line_advance(flt deltat);
861 
862  public:
863  CollectionCD(sptr<OriginBox> box, sptr<AtomGroup> atoms,
864  const flt dt,
865  vector<flt> sizes = vector<flt>(),
866  vector<sptr<Interaction> > interactions=vector<sptr<Interaction> >(),
867  vector<sptr<StateTracker> > trackers=vector<sptr<StateTracker> >(),
868  vector<sptr<Constraint> > constraints=vector<sptr<Constraint> >()) :
869  Collection(box, atoms, interactions, trackers, constraints),
870  dt(dt), curt(0), numevents(0), atomsizes(sizes) {
871  assert(atomsizes.size() == atoms->size());
872  };
873 
874  void reset_velocities(flt T);
875  bool take_step(flt tlim=-1); // returns true if it collides, false if it hits the tlim
876  void timestep();
877  long long events_processed(){return numevents;}; // only counts collision-type events
878 };
879 
884 class CollectionCDgrid : public Collection {
885  public:
887  long long numevents;
888  set<Event> events; // note that this a sorted binary tree
889  vector<flt> atomsizes;
891 
892  void reset_events(bool force=true);
893  void line_advance(flt deltat);
894 
896  flt gridt; // when it was updated
897 
899 
900  public:
901  CollectionCDgrid(sptr<OriginBox> box, sptr<AtomGroup> atoms,
902  const flt dt,
903  vector<flt> sizes = vector<flt>(),
904  vector<sptr<Interaction> > interactions=vector<sptr<Interaction> >(),
905  vector<sptr<StateTracker> > trackers=vector<sptr<StateTracker> >(),
906  vector<sptr<Constraint> > constraints=vector<sptr<Constraint> >()) :
907  Collection(box, atoms, interactions, trackers, constraints),
908  dt(dt), curt(0), numevents(0), atomsizes(sizes), edge_epsilon(1e-8),
909  grid(box, atoms, get_max(sizes) * (1 + edge_epsilon*10), 2.0),
910  gridt(0) {
911  assert(atomsizes.size() == atoms->size());
912  };
913 
914  void update_grid(bool force=true);
915  Grid &get_grid(){return grid;};
917  void set_epsilon(flt eps){edge_epsilon = eps;};
918  void reset_velocities(flt T);
919  bool take_step(flt tlim=-1); // returns true if it collides, false if it hits the tlim
920  void timestep();
921  long long events_processed(){return numevents;}; // only counts collision-type events
922 };
923 
925 class CollectionCDBD : public CollectionCD {
926  protected:
928  public:
929  CollectionCDBD(sptr<OriginBox> box, sptr<AtomGroup> atoms,
930  const flt dt, const flt T,
931  vector<flt> sizes = vector<flt>(),
932  vector<sptr<Interaction> > interactions=vector<sptr<Interaction> >(),
933  vector<sptr<StateTracker> > trackers=vector<sptr<StateTracker> >(),
934  vector<sptr<Constraint> > constraints=vector<sptr<Constraint> >()) :
935  CollectionCD(box, atoms, dt, sizes, interactions, trackers, constraints),
936  T(T){};
937 
938  void timestep(){
939  reset_velocities(T);
941  };
942 };
943 
946  protected:
948  public:
949  CollectionCDBDgrid(sptr<OriginBox> box, sptr<AtomGroup> atoms,
950  const flt dt, const flt T,
951  vector<flt> sizes = vector<flt>(),
952  vector<sptr<Interaction> > interactions=vector<sptr<Interaction> >(),
953  vector<sptr<StateTracker> > trackers=vector<sptr<StateTracker> >(),
954  vector<sptr<Constraint> > constraints=vector<sptr<Constraint> >()) :
955  CollectionCDgrid(box, atoms, dt, sizes, interactions, trackers, constraints),
956  T(T){};
957 
958  void timestep(){
959  reset_velocities(T);
961  };
962 };
963 #endif
flt rpxsum
Definition: collection.hpp:724
flt vdotv()
Definition: collection.cpp:621
vector< Vec > bs
Definition: collection.hpp:627
vector< Vec > vs3
Definition: collection.hpp:739
flt set_xi()
Definition: collection.cpp:1164
Definition: collection.hpp:654
Vec vec()
A one-liner for creating a Vec object, occasionally useful from within Python.
Definition: vecrand.hpp:72
flt kmax
Definition: collection.hpp:359
void timestep()
Take one step forward in time.
Definition: collection.cpp:1404
sptr< Box > get_box()
Definition: collection.hpp:70
uint ncorrec
Definition: collection.hpp:684
void add_constraint(sptr< Constraint > c)
Definition: collection.hpp:106
void scale_velocities(flt scaleby)
Scale all velocities by a factor.
Definition: collection.cpp:20
Vec Kvc
Definition: collection.hpp:655
Definition: collection.hpp:677
long long numevents
Definition: collection.hpp:855
void set_dt(flt newdt)
Definition: collection.hpp:400
void reset_events(bool force=true)
Definition: collection.cpp:1839
void set_forces(bool constraints_and_a=true)
Set forces.
Definition: collection.hpp:540
virtual flt temp(bool minuscomv=true)
Definition: collection.cpp:130
CollectionCDBDgrid(sptr< OriginBox > box, sptr< AtomGroup > atoms, const flt dt, const flt T, vector< flt > sizes=vector< flt >(), vector< sptr< Interaction > > interactions=vector< sptr< Interaction > >(), vector< sptr< StateTracker > > trackers=vector< sptr< StateTracker > >(), vector< sptr< Constraint > > constraints=vector< sptr< Constraint > >())
Definition: collection.hpp:949
flt desT
desired temperature
Definition: collection.hpp:189
virtual void timestep()=0
Take one step forward in time.
flt xi
Definition: collection.hpp:528
void set_constants()
Set c0, c1, c2, sigmar, sigmav, corr from desT, dt, and damping.
Definition: collection.cpp:220
Definition: collection.hpp:20
CollectionVerletNPT(sptr< OriginBox > box, sptr< AtomGroup > atoms, const flt dt, const flt P, const flt QP, const flt T, const flt QT, vector< sptr< Interaction > > interactions=vector< sptr< Interaction > >(), vector< sptr< StateTracker > > trackers=vector< sptr< StateTracker > >(), vector< sptr< Constraint > > constraints=vector< sptr< Constraint > >())
Definition: collection.hpp:794
CollectionNLCG(sptr< OriginBox > box, sptr< AtomGroup > atoms, const flt dt, const flt P0, vector< sptr< Interaction > > interactions=vector< sptr< Interaction > >(), vector< sptr< StateTracker > > trackers=vector< sptr< StateTracker > >(), vector< sptr< Constraint > > constraints=vector< sptr< Constraint > >(), const flt kappa=10.0, const flt kmax=1000, const uint secmax=40, const flt seceps=1e-20)
Definition: collection.cpp:468
flt etasum
Definition: collection.hpp:788
flt dt
Definition: collection.hpp:563
A class for generating two random numbers from a Gaussian distribution, with a given correlation...
Definition: vecrand.hpp:212
void scale_velocities_to_energy(flt E)
Definition: collection.hpp:811
long long events_processed()
Definition: collection.hpp:921
flt dxmax
Definition: collection.hpp:359
void resetbcds()
Definition: collection.hpp:628
Vec com()
Definition: collection.hpp:71
Vec get_vhalf(uint n)
Definition: collection.hpp:816
CollectionCD(sptr< OriginBox > box, sptr< AtomGroup > atoms, const flt dt, vector< flt > sizes=vector< flt >(), vector< sptr< Interaction > > interactions=vector< sptr< Interaction > >(), vector< sptr< StateTracker > > trackers=vector< sptr< StateTracker > >(), vector< sptr< Constraint > > constraints=vector< sptr< Constraint > >())
Definition: collection.hpp:863
flt Q
Definition: collection.hpp:500
flt damping
Definition: collection.hpp:238
Definition: collection.hpp:884
flt potential_energy()
Definition: collection.cpp:95
flt temp(bool minuscomv=true)
Definition: collection.cpp:1494
CollectionGear4NPT(sptr< OriginBox > box, const flt dt, sptr< AtomGroup > atoms, vector< sptr< InteractionPairsX > > interactions=vector< sptr< InteractionPairsX > >(), vector< sptr< StateTracker > > trackers=vector< sptr< StateTracker > >(), vector< sptr< Constraint > > constraints=vector< sptr< Constraint > >())
Definition: collection.hpp:762
CollectionGear4NPH(sptr< OriginBox > box, sptr< AtomGroup > atoms, const flt dt, const flt P, const flt Q, vector< sptr< Interaction > > interactions=vector< sptr< Interaction > >(), vector< sptr< StateTracker > > trackers=vector< sptr< StateTracker > >(), vector< sptr< Constraint > > constraints=vector< sptr< Constraint > >())
Definition: collection.hpp:702
flt hamiltonian()
Definition: collection.hpp:712
flt gyradius()
Definition: collection.cpp:139
virtual flt pressure()
Returns (1/d V) Σ ri dot fi where d is number of dimensions note that Interaction->pressure just retu...
Definition: collection.cpp:82
A damped Collection, equivalent to CollectionSol but without the random forces.
Definition: collection.hpp:234
void set_dt(flt newdt)
Definition: collection.hpp:588
void set_dt(flt newdt)
Definition: collection.hpp:674
flt t
Definition: collection.hpp:834
flt dt
Definition: collection.hpp:311
set< Event > events
Definition: collection.hpp:888
void reset()
Definition: collection.cpp:889
flt beta
Definition: collection.hpp:370
flt energy()
Total energy, including both potential and kinetic_energy.
Definition: collection.cpp:107
flt dxmax
Definition: collection.hpp:437
void set_gauss()
Definition: collection.cpp:370
Event next_event(AtomID a)
Definition: collection.cpp:1815
bool take_step(flt tlim=-1)
Definition: collection.cpp:1980
void reset_velocities(flt T)
Definition: collection.cpp:1763
void update()
Definition: collection.hpp:128
flt dt
Definition: collection.hpp:284
unsigned int uint
Definition: vec.hpp:20
Definition: collection.hpp:282
void set_dt(flt newdt)
Definition: collection.hpp:651
flt hamiltonian()
Definition: collection.hpp:820
flt V3
Definition: collection.hpp:737
flt seceps
Definition: collection.hpp:432
flt vfsum
Definition: collection.hpp:724
flt get_pressure_goal()
Definition: collection.hpp:402
flt dddV
Definition: collection.hpp:683
void set_max_step(flt m)
Definition: collection.hpp:486
double flt
The basic floating point type used in the simulations.
Definition: vecrand.hpp:45
void set_dt(flt newdt)
Definition: collection.hpp:320
void set_dt(const flt newdt)
Definition: collection.hpp:221
void set_max_alpha_fraction(flt a)
Definition: collection.hpp:484
Vec Kvd
Definition: collection.hpp:655
flt T
Definition: collection.hpp:790
vector< Vec > vs2
Definition: collection.hpp:739
flt kinetic_energy()
Definition: collection.cpp:1484
void set_dt(flt newdt)
Definition: collection.hpp:804
void set_dt(flt newdt)
Definition: collection.hpp:482
flt stepmax
Definition: collection.hpp:437
Definition: vecrand.hpp:193
flt kinetic_energy()
Definition: collection.cpp:534
flt P0
Definition: collection.hpp:362
A rectilinear Box, with periodic boundary conditions.
Definition: box.hpp:98
flt dt
Definition: collection.hpp:854
void stepx(flt dx)
Definition: collection.cpp:798
void reset_L()
Shortcut to AtomGroup method of the same name.
Definition: collection.hpp:90
CollectionGear3A(sptr< Box > box, sptr< AtomGroup > atoms, const flt dt, vector< sptr< Interaction > > interactions=vector< sptr< Interaction > >(), vector< sptr< StateTracker > > trackers=vector< sptr< StateTracker > >(), vector< sptr< Constraint > > constraints=vector< sptr< Constraint > >())
Definition: collection.hpp:551
flt fdota()
Definition: collection.cpp:599
flt dV
Definition: collection.hpp:683
bool operator<(const Event &other) const
Definition: collection.hpp:838
flt c2
Definition: collection.hpp:193
Vec angular_momentum()
Shortcut to AtomGroup method of the same name.
Definition: collection.hpp:77
vector< sptr< Interaction > > get_interactions()
Definition: collection.hpp:114
flt k
Definition: collection.hpp:448
void timestep()
Take one step forward in time.
Definition: collection.cpp:2094
uint secmax
Definition: collection.hpp:357
flt force_mag
Definition: collection.hpp:187
Definition: collection.hpp:323
flt get_pressure()
Definition: collection.hpp:815
flt lastV
Definition: collection.hpp:787
flt QP
Definition: collection.hpp:790
flt dt
Definition: collection.hpp:661
flt pressure()
Returns (1/d V) Σ ri dot fi where d is number of dimensions note that Interaction->pressure just retu...
Definition: collection.cpp:548
flt dt
Definition: collection.hpp:355
BivariateGauss gauss
The random number generator.
Definition: collection.hpp:183
void reset()
Definition: collection.cpp:484
flt corr
Definition: collection.hpp:192
void scale_velocities_to_temp(flt T)
Definition: collection.hpp:810
flt getddV()
Definition: collection.hpp:716
void update_constraint_positions()
To be called approximately after forces have been set.
Definition: collection.cpp:49
A pointer to an Atom, that also knows its own index in an AtomVec.
Definition: box.hpp:270
void change_temperature(const flt newdt, const flt damp, const flt desired_temperature)
Definition: collection.hpp:296
virtual void timestep()
Does nothing; a no-op.
Definition: collection.hpp:127
flt QT
Definition: collection.hpp:790
void add_interaction(sptr< Interaction > inter)
Definition: collection.hpp:98
void resetbs()
Definition: collection.hpp:740
flt al
Definition: collection.hpp:367
XRPSummer xrpsums
Definition: collection.hpp:735
void update_constraint_forces()
Definition: collection.cpp:63
CollectionGear4A(sptr< Box > box, sptr< AtomGroup > atoms, const flt dt, uint ncorrectionsteps, vector< sptr< Interaction > > interactions=vector< sptr< Interaction > >(), vector< sptr< StateTracker > > trackers=vector< sptr< StateTracker > >(), vector< sptr< Constraint > > constraints=vector< sptr< Constraint > >())
Definition: collection.hpp:571
void resetbcs()
Definition: collection.hpp:597
flt get_xi()
Definition: collection.hpp:519
flt vl
Definition: collection.hpp:449
flt T
Definition: collection.hpp:927
flt dt
Definition: collection.hpp:548
flt ddV
Definition: collection.hpp:683
Definition: collection.hpp:720
vector< Vec > cs
Definition: collection.hpp:596
CollectionGear5A(sptr< Box > box, sptr< AtomGroup > atoms, const flt dt, uint ncorrectionsteps, vector< sptr< Interaction > > interactions=vector< sptr< Interaction > >(), vector< sptr< StateTracker > > trackers=vector< sptr< StateTracker > >(), vector< sptr< Constraint > > constraints=vector< sptr< Constraint > >())
Definition: collection.hpp:604
void timestep()
Take one step forward in time.
Definition: collection.cpp:250
CollectionCDgrid(sptr< OriginBox > box, sptr< AtomGroup > atoms, const flt dt, vector< flt > sizes=vector< flt >(), vector< sptr< Interaction > > interactions=vector< sptr< Interaction > >(), vector< sptr< StateTracker > > trackers=vector< sptr< StateTracker > >(), vector< sptr< Constraint > > constraints=vector< sptr< Constraint > >())
Definition: collection.hpp:901
Definition: collection.hpp:658
vector< flt > atomsizes
Definition: collection.hpp:889
vector< Vec > xs1
Definition: collection.hpp:738
void set_Q(flt newQ)
Definition: collection.hpp:514
void stepx(flt dx)
Definition: collection.cpp:830
flt curt
Definition: collection.hpp:886
flt sigmav
Definition: collection.hpp:192
void set_max_dx(flt d)
Definition: collection.hpp:406
vector< flt > atomsizes
Definition: collection.hpp:857
GaussVec gauss
Definition: collection.hpp:287
void set_dt(flt newdt)
Definition: collection.hpp:619
flt alphamax
Definition: collection.hpp:359
virtual void stepx(flt dx)
Definition: collection.cpp:560
void timestep()
Take one step forward in time.
Definition: collection.cpp:1700
static vector< sptr< Interaction > > tointerpair(vector< sptr< InteractionPairsX > > &)
Definition: collection.cpp:1580
void add_tracker(sptr< StateTracker > track)
Definition: collection.hpp:102
Definition: collection.hpp:345
void scale_velocities_to_temp(flt T, bool minuscomv=true)
Scale all velocities to get to a specific temperature.
Definition: collection.cpp:28
void set_dt(flt newdt)
Definition: collection.hpp:337
flt alphamax
Definition: collection.hpp:437
void timestep()
Take one step forward in time.
Definition: collection.cpp:445
void set_dt(flt newdt)
Definition: collection.hpp:717
CollectionDamped(sptr< Box > box, sptr< AtomGroup > atoms, const flt dt, const flt damping, vector< sptr< Interaction > > interactions=vector< sptr< Interaction > >(), vector< sptr< StateTracker > > trackers=vector< sptr< StateTracker > >(), vector< sptr< Constraint > > constraints=vector< sptr< Constraint > >())
Definition: collection.cpp:306
flt kappa
Definition: collection.hpp:358
flt dt
Definition: collection.hpp:237
void timestep()
Take one step forward in time.
Definition: collection.cpp:1939
flt afrac
Definition: collection.hpp:437
CollectionOverdamped(sptr< Box > box, sptr< AtomGroup > atoms, const flt dt, const flt gamma=1.0, vector< sptr< Interaction > > interactions=vector< sptr< Interaction > >(), vector< sptr< StateTracker > > trackers=vector< sptr< StateTracker > >(), vector< sptr< Constraint > > constraints=vector< sptr< Constraint > >())
Definition: collection.hpp:329
uint sec
Definition: collection.hpp:458
uint ncorrec
Definition: collection.hpp:626
void resetvhalf()
Definition: collection.cpp:1691
Definition: collection.hpp:778
flt curP
Definition: collection.hpp:790
vector< Vec > bs
Definition: collection.hpp:685
flt betaused
Definition: collection.hpp:370
flt dxsum
Definition: collection.hpp:370
flt dt
Definition: collection.hpp:527
flt dt
Definition: collection.hpp:886
CollectionRK4(sptr< Box > box, sptr< AtomGroup > ratoms, const flt dt, vector< sptr< Interaction > > interactions=vector< sptr< Interaction > >(), vector< sptr< StateTracker > > trackers=vector< sptr< StateTracker > >(), vector< sptr< Constraint > > constraints=vector< sptr< Constraint > >())
Definition: collection.hpp:665
virtual ~Collection()
Definition: collection.hpp:85
virtual flt virial()
Definition: collection.cpp:70
void scale_velocities(flt scaleby)
Definition: collection.hpp:809
vector< sptr< Constraint > > constraints
Definition: collection.hpp:26
flt P
Definition: collection.hpp:790
void change_force(const flt damp, const flt fmag, const flt desired_temperature)
Definition: collection.hpp:218
flt kmax
Definition: collection.hpp:437
void timestep()
Take one step forward in time.
Definition: collection.cpp:1614
void add(sptr< StateTracker > a)
Definition: collection.hpp:111
CollectionGaussianT(sptr< Box > box, sptr< AtomGroup > atoms, const flt dt, vector< sptr< Interaction > > interactions=vector< sptr< Interaction > >(), vector< sptr< StateTracker > > trackers=vector< sptr< StateTracker > >(), vector< sptr< Constraint > > constraints=vector< sptr< Constraint > >())
Definition: collection.hpp:532
flt V2
Definition: collection.hpp:737
void descend()
Definition: collection.cpp:781
void timestep()
Take one step forward in time.
Definition: collection.cpp:1509
flt damping
Definition: collection.hpp:285
vector< Vec > bs
Definition: collection.hpp:565
CollectionSolHT(sptr< Box > box, sptr< AtomGroup > atoms, const flt dt, const flt damping, const flt desired_temperature, vector< sptr< Interaction > > interactions=vector< sptr< Interaction > >(), vector< sptr< StateTracker > > trackers=vector< sptr< StateTracker > >(), vector< sptr< Constraint > > constraints=vector< sptr< Constraint > >())
Definition: collection.cpp:360
CollectionNoseHoover(sptr< Box > box, sptr< AtomGroup > atoms, const flt dt, const flt Q, const flt T, vector< sptr< Interaction > > interactions=vector< sptr< Interaction > >(), vector< sptr< StateTracker > > trackers=vector< sptr< StateTracker > >(), vector< sptr< Constraint > > constraints=vector< sptr< Constraint > >())
Definition: collection.hpp:504
flt get_max(vector< flt > v)
Definition: collection.cpp:2100
flt c0
Definition: collection.hpp:239
flt afrac
Definition: collection.hpp:359
flt fdotf()
Definition: collection.cpp:838
A Collection with a "solvent", using the Langevin equation.
Definition: collection.hpp:180
flt hamiltonian()
Definition: collection.cpp:530
void timestep()
Take one step forward in time.
Definition: collection.cpp:1320
flt al
Definition: collection.hpp:449
void set_pressure_goal(flt P)
Definition: collection.hpp:401
flt damping
Damping coefficient, .
Definition: collection.hpp:186
virtual void initialize()
Definition: collection.cpp:12
void reset_events()
diameters
Definition: collection.cpp:1961
CollectionGear5A(sptr< Box > box, const flt dt, sptr< AtomGroup > atoms, vector< sptr< Interaction > > interactions=vector< sptr< Interaction > >(), vector< sptr< StateTracker > > trackers=vector< sptr< StateTracker > >(), vector< sptr< Constraint > > constraints=vector< sptr< Constraint > >())
Definition: collection.hpp:611
Definition: collection.hpp:730
Definition: collection.hpp:523
Grid & get_grid()
Definition: collection.hpp:915
void set_max_alpha(flt a)
Definition: collection.hpp:404
flt eta
Definition: collection.hpp:787
Collision-Driven Brownian-Dynamics.
Definition: collection.hpp:925
void timestep()
Take one step forward in time.
Definition: collection.cpp:333
flt stepmax
Definition: collection.hpp:359
vector< sptr< Interaction > > interactions
Definition: collection.hpp:24
Collision-Driven Brownian-Dynamics.
Definition: collection.hpp:945
void timestep()
Take one step forward in time.
Definition: collection.cpp:415
CollectionNLCGV(sptr< Box > box, sptr< AtomGroup > atoms, const flt dt, vector< sptr< Interaction > > interactions=vector< sptr< Interaction > >(), vector< sptr< StateTracker > > trackers=vector< sptr< StateTracker > >(), vector< sptr< Constraint > > constraints=vector< sptr< Constraint > >(), const flt kmax=1000, const uint secmax=10, const flt seceps=1e-4)
Definition: collection.cpp:815
CollectionGear4NPT(sptr< OriginBox > box, sptr< AtomGroup > atoms, const flt dt, uint ncorrectionsteps, vector< sptr< InteractionPairsX > > interactions=vector< sptr< InteractionPairsX > >(), vector< sptr< StateTracker > > trackers=vector< sptr< StateTracker > >(), vector< sptr< Constraint > > constraints=vector< sptr< Constraint > >())
Definition: collection.hpp:752
flt xidot
Definition: collection.hpp:787
flt c0
Definition: collection.hpp:193
flt xsum
Definition: collection.hpp:724
Vec Kvb
Definition: collection.hpp:655
AtomID a
Definition: collection.hpp:835
flt T
Definition: collection.hpp:500
Definition: collection.hpp:425
flt dt
Definition: collection.hpp:184
flt betaused
Definition: collection.hpp:452
Collection(sptr< Box > box, sptr< AtomGroup > atoms, vector< sptr< Interaction > > interactions=vector< sptr< Interaction > >(), vector< sptr< StateTracker > > trackers=vector< sptr< StateTracker > >(), vector< sptr< Constraint > > constraints=vector< sptr< Constraint > >(), bool should_initialize=true)
Definition: collection.cpp:3
void set_dt(flt newdt)
Definition: collection.hpp:557
Grid grid
Definition: collection.hpp:895
flt desT
Definition: collection.hpp:286
CollectionGear6A(sptr< Box > box, sptr< AtomGroup > atoms, const flt dt, vector< sptr< Interaction > > interactions=vector< sptr< Interaction > >(), vector< sptr< StateTracker > > trackers=vector< sptr< StateTracker > >(), vector< sptr< Constraint > > constraints=vector< sptr< Constraint > >())
Definition: collection.hpp:644
Definition: collection.hpp:591
Definition: collection.hpp:560
Definition: collection.hpp:545
void resetbs()
Definition: collection.hpp:566
flt dt
Definition: collection.hpp:625
flt lastxidot
Definition: collection.hpp:787
flt Knew
Definition: collection.hpp:365
Definition: collection.hpp:308
Definition: collection.hpp:622
flt P
Definition: collection.hpp:682
flt alpha
Definition: collection.hpp:370
flt chi
Definition: collection.hpp:737
void update_trackers()
To be called immediately after setting particle positions and velocities; lets StateTracker instances...
Definition: collection.cpp:42
void reset()
Definition: collection.hpp:727
void timestep()
Take one step forward in time.
Definition: collection.cpp:1083
void set_epsilon(flt eps)
Definition: collection.hpp:917
flt get_lns()
Definition: collection.hpp:520
uint ncorrec
Definition: collection.hpp:564
void change_damping(const flt damp)
Definition: collection.hpp:248
Definition: interaction.hpp:739
void line_advance(flt deltat)
Definition: collection.cpp:1771
CollectionSol(sptr< Box > box, sptr< AtomGroup > atoms, const flt dt, const flt damping, const flt desired_temperature, vector< sptr< Interaction > > interactions=vector< sptr< Interaction > >(), vector< sptr< StateTracker > > trackers=vector< sptr< StateTracker > >(), vector< sptr< Constraint > > constraints=vector< sptr< Constraint > >())
Definition: collection.cpp:205
void update_constraint_velocities()
Definition: collection.cpp:56
flt get_dV()
Definition: collection.hpp:715
Collision-Driven Dynamics.
Definition: collection.hpp:852
flt dt
Definition: collection.hpp:786
vector< RK4data > data
Definition: collection.hpp:662
flt c2
Definition: collection.hpp:239
Definition: interaction.hpp:732
void set_max_alpha(flt a)
Definition: collection.hpp:483
virtual void set_forces(bool constraints_and_a=true)
Set forces.
Definition: collection.cpp:154
CollectionGear4NPH(sptr< OriginBox > box, sptr< AtomGroup > atoms, const flt dt, const flt P, const flt Q, uint ncorrectionsteps, vector< sptr< Interaction > > interactions=vector< sptr< Interaction > >(), vector< sptr< StateTracker > > trackers=vector< sptr< StateTracker > >(), vector< sptr< Constraint > > constraints=vector< sptr< Constraint > >())
Definition: collection.hpp:691
flt alphavmax
Definition: collection.hpp:370
sptr< AtomGroup > atoms
Definition: collection.hpp:23
flt fl
Definition: collection.hpp:449
vector< Vec > xs2
Definition: collection.hpp:738
flt dt
Definition: collection.hpp:594
Vec com_velocity()
Definition: collection.hpp:72
flt dt
Definition: collection.hpp:431
CollectionGear4A(sptr< Box > box, sptr< AtomGroup > atoms, const flt dt, vector< sptr< Interaction > > interactions=vector< sptr< Interaction > >(), vector< sptr< StateTracker > > trackers=vector< sptr< StateTracker > >(), vector< sptr< Constraint > > constraints=vector< sptr< Constraint > >())
Definition: collection.hpp:580
CollectionGear6A(sptr< Box > box, sptr< AtomGroup > atoms, const flt dt, uint ncorrectionsteps, vector< sptr< Interaction > > interactions=vector< sptr< Interaction > >(), vector< sptr< StateTracker > > trackers=vector< sptr< StateTracker > >(), vector< sptr< Constraint > > constraints=vector< sptr< Constraint > >())
Definition: collection.hpp:637
uint ncorrec
Definition: collection.hpp:595
void set_kappa(flt k)
Definition: collection.hpp:403
Vec Kxc
Definition: collection.hpp:655
void reset_bath()
Definition: collection.hpp:515
vector< Vec > vhalf
Definition: collection.hpp:789
CollectionVerlet(sptr< Box > box, sptr< AtomGroup > atoms, const flt dt, vector< sptr< Interaction > > interactions=vector< sptr< Interaction > >(), vector< sptr< StateTracker > > trackers=vector< sptr< StateTracker > >(), vector< sptr< Constraint > > constraints=vector< sptr< Constraint > >())
Definition: collection.hpp:314
flt curt
Definition: collection.hpp:854
flt lns
Definition: collection.hpp:501
Definition: collection.hpp:497
Vec Kxa
Definition: collection.hpp:655
flt solve_cubic(flt a1, flt a2, flt a3, flt closeto=0)
Definition: collection.cpp:2108
void timestep()
Take one step forward in time.
Definition: collection.cpp:1214
flt dxsum
Definition: collection.hpp:452
vector< Vec > cs
Definition: collection.hpp:627
flt dt
Definition: collection.hpp:681
CollectionCDBD(sptr< OriginBox > box, sptr< AtomGroup > atoms, const flt dt, const flt T, vector< flt > sizes=vector< flt >(), vector< sptr< Interaction > > interactions=vector< sptr< Interaction > >(), vector< sptr< StateTracker > > trackers=vector< sptr< StateTracker > >(), vector< sptr< Constraint > > constraints=vector< sptr< Constraint > >())
Definition: collection.hpp:929
void set_max_alpha_fraction(flt a)
Definition: collection.hpp:405
vector< Vec > bs
Definition: collection.hpp:596
flt beta
Definition: collection.hpp:452
flt get_epsilon()
Definition: collection.hpp:916
bool take_step(flt tlim=-1)
Definition: collection.cpp:1867
void timestep()
Take one step forward in time.
Definition: collection.cpp:929
XRPSummer(sptr< Box > box)
Definition: collection.hpp:725
vector< Vec > xs3
Definition: collection.hpp:738
void change_temperature(const flt damp, const flt desired_temperature)
Change the desired damping coefficient or temperature .
Definition: collection.hpp:216
Vec Kva
Definition: collection.hpp:655
void set_dt(flt newdt)
Definition: collection.hpp:513
flt V1
Definition: collection.hpp:737
void set_max_step(flt m)
Definition: collection.hpp:407
flt Knew
Definition: collection.hpp:447
void timestep()
Take one step forward in time.
Definition: collection.hpp:958
void timestep()
Take one step forward in time.
Definition: collection.cpp:1180
void resetbs()
Definition: collection.hpp:686
flt xi
Definition: collection.hpp:501
void reset_L()
Definition: collection.hpp:808
uint secmax
Definition: collection.hpp:433
flt chixi
Definition: collection.hpp:737
flt T
Definition: collection.hpp:947
void set_dt(const flt newdt)
Definition: collection.hpp:250
flt fdota()
Definition: collection.cpp:849
uint ncorrec
Definition: collection.hpp:736
flt dt
Definition: collection.hpp:734
Definition: collection.hpp:411
flt get_eta()
Definition: collection.hpp:813
void add(sptr< Interaction > a)
Definition: collection.hpp:110
flt fdotv()
Definition: collection.cpp:860
flt sigmar
note that this is sigmar/sqrt(T/m), same for sigmav corr is unitless, and correct ...
Definition: collection.hpp:192
void timestep()
Take one step forward in time.
Definition: collection.cpp:1237
void set_forces(bool constraints_and_a=true)
Set forces.
Definition: collection.hpp:393
flt vdotv()
Definition: collection.cpp:878
set< Event > events
Definition: collection.hpp:856
flt rfsum
Definition: collection.hpp:724
void timestep()
Take one step forward in time.
Definition: collection.cpp:374
sptr< Box > box
Definition: collection.hpp:22
flt maxdV
Definition: collection.hpp:370
flt alphavmax
Definition: collection.hpp:452
Eigen::Matrix< flt, NDIM, 1 > Vec
The basic physics vector.
Definition: vecrand.hpp:53
Vec Kxd
Definition: collection.hpp:655
void scale_velocities_to_energy(flt E)
Scale all velocities to get to a specific total energy.
Definition: collection.cpp:34
void reset_com_velocity()
Shortcut to AtomGroup method of the same name.
Definition: collection.hpp:88
vector< Vec > ds
Definition: collection.hpp:627
A "static" Collection, that doesn't move.
Definition: collection.hpp:118
A fast algorithm for finding all pairs of neighboring atoms.
Definition: trackers.hpp:178
flt Q
Definition: collection.hpp:682
flt c1
Definition: collection.hpp:239
void timestep()
Take one step forward in time.
Definition: collection.cpp:632
void descend()
Definition: collection.cpp:900
virtual flt set_forces_get_pressure(bool constraints_and_a=true)
Definition: collection.cpp:176
Definition: collection.hpp:833
long long events_processed()
Definition: collection.hpp:877
void add(sptr< Constraint > a)
Definition: collection.hpp:112
flt solve_cubic_fast(flt b, flt c, flt d)
Definition: collection.cpp:2154
flt fl
Definition: collection.hpp:367
flt k
Definition: collection.hpp:366
void set_max_dx(flt d)
Definition: collection.hpp:485
virtual flt kinetic_energy()
Definition: collection.hpp:67
void update_grid(bool force=true)
Definition: collection.cpp:1809
flt det_xi_dot()
Definition: collection.hpp:814
int sgn(T val)
Definition: collection.hpp:491
AtomID b
Definition: collection.hpp:836
flt dt
Definition: collection.hpp:500
flt gamma
Definition: collection.hpp:326
virtual void run(ForcePairX *)
Definition: collection.cpp:1589
flt dt
Definition: collection.hpp:326
Vec Kxb
Definition: collection.hpp:655
void set_constants()
Definition: collection.cpp:321
uint sec
Definition: collection.hpp:371
void reset_velocities(flt T)
Definition: collection.cpp:1945
void line_advance(flt deltat)
Definition: collection.cpp:1953
flt c1
Definition: collection.hpp:193
flt gridt
Definition: collection.hpp:896
flt pressure()
Returns (1/d V) Σ ri dot fi where d is number of dimensions note that Interaction->pressure just retu...
Definition: collection.cpp:915
void reset_com_velocity()
Definition: collection.hpp:807
flt fdotv()
Definition: collection.cpp:610
void set_dt(flt newdt)
Definition: collection.hpp:539
void set_forces(bool constraints_and_a=true)
Set forces.
Definition: collection.cpp:1598
void timestep()
Take one step forward in time.
Definition: collection.cpp:1277
CollectionNLCGFixedL(sptr< OriginBox > box, sptr< AtomGroup > atoms, const flt dt, const flt P0, vector< sptr< Interaction > > interactions=vector< sptr< Interaction > >(), vector< sptr< StateTracker > > trackers=vector< sptr< StateTracker > >(), vector< sptr< Constraint > > constraints=vector< sptr< Constraint > >(), const flt kappa=10.0, const flt kmax=1000, const uint secmax=40, const flt seceps=1e-20)
Definition: collection.hpp:413
StaticCollec(sptr< Box > box, sptr< AtomGroup > atoms, vector< sptr< Interaction > > interactions=vector< sptr< Interaction > >(), vector< sptr< StateTracker > > trackers=vector< sptr< StateTracker > >(), vector< sptr< Constraint > > constraints=vector< sptr< Constraint > >())
Definition: collection.hpp:120
flt get_length_squared()
Definition: collection.cpp:578
flt fdotf()
Definition: collection.cpp:588
vector< sptr< StateTracker > > trackers
Definition: collection.hpp:25
flt edge_epsilon
diameters
Definition: collection.hpp:890
long long numevents
Definition: collection.hpp:887
flt degrees_of_freedom()
Total degrees of freedom.
Definition: collection.cpp:113
void timestep()
Take one step forward in time.
Definition: collection.hpp:938
flt seceps
Definition: collection.hpp:356
flt alpha
Definition: collection.hpp:452
flt vl
Definition: collection.hpp:367
flt hamiltonian()
Definition: collection.cpp:1157