@@ -434,91 +434,90 @@ class repliedTrajectory: public AtomDistribution {
434434public:
435435 static constexpr auto id=" reply" ;
436436 static constexpr auto doc=R"=( replicate the box by the given in all the directions:
437- usage (must be used with 3 paramenters):
438- reply x y z
439- )=" ;
437+ usage:
438+ reply x y z)=" ;
440439
441440 static std::unique_ptr<AtomDistribution> decorate (std::unique_ptr<AtomDistribution>&& d,
442- std::string_view cmd) {
443- unpackedLine lines;
444- Tools::getWordsSimple (lines,cmd);
445- unsigned repeatX;
446- unsigned repeatY;
447- unsigned repeatZ;
448- plumed_assert (lines.size () ==4 ) << id << " supports exacly three inputs: x y z" ;
449-
450- Tools::convert (std::string (lines[1 ]),repeatX);
451- Tools::convert (std::string (lines[2 ]),repeatY);
452- Tools::convert (std::string (lines[3 ]),repeatZ);
453- return std::make_unique<repliedTrajectory>(std::move (d),
454- repeatX,
455- repeatY,
456- repeatZ);
457- }
441+ std::string_view cmd) {
442+ unpackedLine lines;
443+ Tools::getWordsSimple (lines,cmd);
444+ unsigned repeatX;
445+ unsigned repeatY;
446+ unsigned repeatZ;
447+ plumed_assert (lines.size () ==4 ) << id << " supports exacly three inputs: x y z" ;
448+
449+ Tools::convert (std::string (lines[1 ]),repeatX);
450+ Tools::convert (std::string (lines[2 ]),repeatY);
451+ Tools::convert (std::string (lines[3 ]),repeatZ);
452+ return std::make_unique<repliedTrajectory>(std::move (d),
453+ repeatX,
454+ repeatY,
455+ repeatZ);
456+ }
458457
459458 repliedTrajectory (std::unique_ptr<AtomDistribution>&& d,
460459 const unsigned repeatX,
461460 const unsigned repeatY,
462461 const unsigned repeatZ) :
463- distribution (std::move(d)),
464- rX (repeatX),
465- rY (repeatY),
466- rZ (repeatZ)
467- {}
462+ distribution (std::move(d)),
463+ rX (repeatX),
464+ rY (repeatY),
465+ rZ (repeatZ)
466+ {}
468467
469468// /Generates the inner trajectory of `(nat)/(rX*rY*rZ)`, where `nat` is the dimension of the vector view, then it replicate the atoms in the various directions
470469 void frame (View<Vector> posToUpdate,
471470 View<double ,9 > box,
472471 unsigned step,
473472 Random& rng) override {
474- plumed_assert ((posToUpdate.size () % (rX*rY*rZ)==0 ));
475- const auto nat = posToUpdate.size ()/(rX*rY*rZ);
476- auto coordinates=posToUpdate.subview (0 ,nat);
477- distribution->frame (coordinates,box,step,rng);
478-
479- // repetitions
480- auto p = posToUpdate.begin ()+nat;
481-
482- assert ((rX*rY*rZ)*nat == posToUpdate.size ());
483-
484- Vector boxX (box[0 ],box[1 ],box[2 ]);
485- Vector boxY (box[3 ],box[4 ],box[5 ]);
486- Vector boxZ (box[6 ],box[7 ],box[8 ]);
487- for (unsigned x=0 ; x<rX; ++x) {
488- for (unsigned y=0 ; y<rY; ++y) {
489- for (unsigned z=0 ; z<rZ; ++z) {
490- if (x==0 &&y==0 &&z==0 ) {
491- continue ;
492- }
493- for (unsigned i=0 ; i<nat; ++i) {
494- *p=coordinates[i]
495- + x * boxX
496- + y * boxY
497- + z * boxZ;
498- ++p;
473+ plumed_assert ((posToUpdate.size () % (rX*rY*rZ)==0 ));
474+ const auto nat = posToUpdate.size ()/(rX*rY*rZ);
475+ auto coordinates=posToUpdate.subview (0 ,nat);
476+ distribution->frame (coordinates,box,step,rng);
477+
478+ // repetitions
479+ auto p = posToUpdate.begin ()+nat;
480+
481+ assert ((rX*rY*rZ)*nat == posToUpdate.size ());
482+
483+ Vector boxX (box[0 ],box[1 ],box[2 ]);
484+ Vector boxY (box[3 ],box[4 ],box[5 ]);
485+ Vector boxZ (box[6 ],box[7 ],box[8 ]);
486+ for (unsigned x=0 ; x<rX; ++x) {
487+ for (unsigned y=0 ; y<rY; ++y) {
488+ for (unsigned z=0 ; z<rZ; ++z) {
489+ if (x==0 &&y==0 &&z==0 ) {
490+ continue ;
491+ }
492+ for (unsigned i=0 ; i<nat; ++i) {
493+ *p=coordinates[i]
494+ + x * boxX
495+ + y * boxY
496+ + z * boxZ;
497+ ++p;
498+ }
499499 }
500500 }
501501 }
502- }
503- box[0 ]*=rX;
504- box[1 ]*=rX;
505- box[2 ]*=rX;
502+ box[0 ]*=rX;
503+ box[1 ]*=rX;
504+ box[2 ]*=rX;
506505
507- box[3 ]*=rY;
508- box[4 ]*=rY;
509- box[5 ]*=rY;
506+ box[3 ]*=rY;
507+ box[4 ]*=rY;
508+ box[5 ]*=rY;
510509
511- box[6 ]*=rZ;
512- box[7 ]*=rZ;
513- box[8 ]*=rZ;
514- }
510+ box[6 ]*=rZ;
511+ box[7 ]*=rZ;
512+ box[8 ]*=rZ;
513+ }
515514
516515// /See the documentation the AtomDistribution
517516 bool overrideNat (unsigned & natoms) override {
518- distribution->overrideNat (natoms);
519- natoms *= (rX*rY*rZ);
520- return true ;
521- }
517+ distribution->overrideNat (natoms);
518+ natoms *= (rX*rY*rZ);
519+ return true ;
520+ }
522521};
523522
524523// /a decorator for scaling the atomic positions
@@ -529,48 +528,47 @@ class scaledTrajectory: public AtomDistribution {
529528 static constexpr auto id=" scale" ;
530529 static constexpr auto doc=R"=( scales the atoms by a certain amount
531530usage:
532- scale (optional: mults=2.0)
533- )=" ;
531+ scale (optional: mults=2.0))=" ;
534532
535533 static std::unique_ptr<AtomDistribution> decorate (std::unique_ptr<AtomDistribution>&& d,
536- std::string_view cmd) {
537- unpackedLine lines;
538- Tools::getWordsSimple (lines,cmd);
539- plumed_assert (lines.size () <=2 ) << id << " supports maximum one input" ;
540- if (lines.size ()==2 ) {
541- double mult=2.0 ;
542- Tools::convert (std::string (lines[1 ]), mult);
543- return std::make_unique<scaledTrajectory>(std::move (d),mult);
544- }
534+ std::string_view cmd) {
535+ unpackedLine lines;
536+ Tools::getWordsSimple (lines,cmd);
537+ plumed_assert (lines.size () <=2 ) << id << " supports maximum one input" ;
538+ if (lines.size ()==2 ) {
539+ double mult=2.0 ;
540+ Tools::convert (std::string (lines[1 ]), mult);
541+ return std::make_unique<scaledTrajectory>(std::move (d),mult);
542+ }
545543
546- // the default value is specified in the header
547- return std::make_unique<scaledTrajectory>(std::move (d));
548- }
544+ // the default value is specified in the header
545+ return std::make_unique<scaledTrajectory>(std::move (d));
546+ }
549547
550548 scaledTrajectory (std::unique_ptr<AtomDistribution>&& d,
551- double mult=2.0 ):
552- distribution (std::move(d)),
553- multiplier (mult)
554- {}
549+ double mult=2.0 ):
550+ distribution (std::move(d)),
551+ multiplier (mult)
552+ {}
555553
556554 void frame (View<Vector> posToUpdate,
557555 View<double ,9 > box,
558556 unsigned step,
559557 Random& rng) override {
560- distribution->frame (posToUpdate,box,step,rng);
558+ distribution->frame (posToUpdate,box,step,rng);
561559
562- for (auto & p:posToUpdate) {
563- p*=multiplier;
564- }
560+ for (auto & p:posToUpdate) {
561+ p*=multiplier;
562+ }
565563
566- for (auto & b:box) {
567- b*=multiplier;
564+ for (auto & b:box) {
565+ b*=multiplier;
566+ }
568567 }
569- }
570568
571- bool overrideNat (unsigned & natoms) override {
572- return distribution->overrideNat (natoms);
573- }
569+ bool overrideNat (unsigned & natoms) override {
570+ return distribution->overrideNat (natoms);
571+ }
574572};
575573
576574
@@ -581,45 +579,44 @@ class wiggleTrajectory: public AtomDistribution {
581579 double radius;
582580public:
583581 static constexpr auto id=" wiggle" ;
584- static constexpr auto doc=R"=( displaces all the atoms by a certain amunt
582+ static constexpr auto doc=R"=( displaces all the atoms by a certain amount
585583usage:
586- wiggle (optional: sphere radius=0.1)
587- )=" ;
584+ wiggle (optional: sphere radius=0.1))=" ;
588585 static std::unique_ptr<AtomDistribution> decorate (
589- std::unique_ptr<AtomDistribution>&& d,
586+ std::unique_ptr<AtomDistribution>&& d,
590587 std::string_view cmd) {
591- unpackedLine lines;
592- Tools::getWordsSimple (lines,cmd);
593- plumed_assert (lines.size () <=2 ) << id << " supports maximum one input" ;
594- if (lines.size ()==2 ) {
595- double displacement=0.1 ;
596- Tools::convert (std::string (lines[1 ]), displacement);
597- return std::make_unique<wiggleTrajectory>(std::move (d),displacement);
598- }
599- // the default value is specified in the header
600- return std::make_unique<wiggleTrajectory>(std::move (d));
601- }
588+ unpackedLine lines;
589+ Tools::getWordsSimple (lines,cmd);
590+ plumed_assert (lines.size () <=2 ) << id << " supports maximum one input" ;
591+ if (lines.size ()==2 ) {
592+ double displacement=0.1 ;
593+ Tools::convert (std::string (lines[1 ]), displacement);
594+ return std::make_unique<wiggleTrajectory>(std::move (d),displacement);
595+ }
596+ // the default value is specified in the header
597+ return std::make_unique<wiggleTrajectory>(std::move (d));
598+ }
602599
603600 wiggleTrajectory (std::unique_ptr<AtomDistribution>&& d,
604- double amount=0.1 ) :
605- distribution (std::move(d)),
606- radius (amount)
607- {}
601+ double amount=0.1 ) :
602+ distribution (std::move(d)),
603+ radius (amount)
604+ {}
608605
609606 void frame (View<Vector> posToUpdate,
610607 View<double ,9 > box,
611608 unsigned step,
612609 Random& rng) override {
613- distribution->frame (posToUpdate,box,step,rng);
610+ distribution->frame (posToUpdate,box,step,rng);
614611
615- UniformSphericalVector usv (radius);
616- for (auto & v: posToUpdate) {
617- v+= usv (rng);
612+ UniformSphericalVector usv (radius);
613+ for (auto & v: posToUpdate) {
614+ v+= usv (rng);
615+ }
618616 }
619- }
620617 bool overrideNat (unsigned & natoms) override {
621- return distribution->overrideNat (natoms);
622- }
618+ return distribution->overrideNat (natoms);
619+ }
623620};
624621
625622
@@ -632,9 +629,9 @@ class forceBoxTrajectory: public AtomDistribution {
632629 static constexpr auto id=" box" ;
633630 static constexpr auto doc=R"=( Forces a box on the atom distribution
634631usage:
635- " box xx yy zz"
636- or
637- " box xx xy xy yx yy yz zx zy zz" )=" ;
632+ box xx yy zz
633+ or
634+ box xx xy xy yx yy yz zx zy zz)=" ;
638635
639636 static std::unique_ptr<AtomDistribution> decorate (
640637 std::unique_ptr<AtomDistribution>&& d,
@@ -705,7 +702,7 @@ class fixedTrajectory: public AtomDistribution {
705702 static constexpr auto id=" fix" ;
706703 static constexpr auto doc=R"=( Fixes the trajectory for stride steps, or forever if stride is 0
707704usage:
708- " fix stride (optional)" )=" ;
705+ fix (optional stride=0) )=" ;
709706
710707 static std::unique_ptr<AtomDistribution> decorate (
711708 std::unique_ptr<AtomDistribution>&& d,
0 commit comments