17 virtual void apply_positions(
Box &box) = 0;
18 virtual void apply_velocities(
Box &box) = 0;
19 virtual void apply_forces(
Box &box) = 0;
20 virtual int constrained_dof() = 0;
31 a(atm), loc(loc) {fixed[0] = fixx; fixed[1] = fixy; fixed[2] = fixz;};
33 a(atm), loc(a->x) {fixed[0] = fixx; fixed[1] = fixy; fixed[2] = fixz;};
35 a(atm), loc(a->x) {fixed[0] = fixed[1] = fixed[2] =
true;};
38 for(
uint i=0; i<3; i++){
39 if(not fixed[i])
continue;
44 for(
uint i=0; i<3; i++){
45 if(not fixed[i])
continue;
50 for(
uint i=0; i<3; i++){
51 if(not fixed[i])
continue;
64 a(atm), loc(loc) {fixed[0] = fixx; fixed[1] = fixy; fixed[2] = fixz;};
66 a(atm), loc(a->com()) {fixed[0] = fixx; fixed[1] = fixy; fixed[2] = fixz;};
68 a(atm), loc(a->com()) {fixed[0] = fixed[1] = fixed[2] =
true;};
70 void apply_positions(
Box &box);
71 void apply_velocities(
Box &box);
72 void apply_forces(
Box &box);
82 a1(atm1), a2(atm2), loc(loc) {
83 fixed[0] = fixx; fixed[1] = fixy; fixed[2] = fixz;};
85 a1(atm1), a2(atm2), loc(a2->x - a1->x) {
86 fixed[0] = fixx; fixed[1] = fixy; fixed[2] = fixz;};
88 a1(atm1), a2(atm2), loc(a2->x - a1->x) {
89 fixed[0] = fixed[1] = fixed[2] =
true;};
92 void apply_positions(
Box &box);
93 void apply_velocities(
Box &box);
94 void apply_forces(
Box &box);
103 a1(atm1), a2(atm2), dist(dist) {};
105 a1(atm1), a2(atm2), dist((a1->x - a2->x).norm()){};
107 void apply_positions(
Box &box);
108 void apply_velocities(
Box &box);
109 void apply_forces(
Box &box);
115 sptr<AtomGroup> atms;
123 atms(atms), dist(dist), lincom(0), I(0), M(0), lvec(
Vec::Zero()), com(
Vec::Zero()) {
124 for(
uint i = 0; i < atms->size(); i++){
126 lincom += (dist*i)*(*atms)[i].m;
130 for(
uint i = 0; i < atms->size(); i++){
131 flt dx = (dist*i - lincom);
132 I += (*atms)[i].m * dx * dx;
138 void apply_positions(
Box &box);
139 void apply_velocities(
Box &box);
140 void apply_forces(
Box &box);
147 sptr<AtomGroup> atms;
153 Eigen::JacobiSVD<Matrix> MoI_solver;
155 Eigen::Matrix<flt, Eigen::Dynamic, NDIM> expected;
171 void apply_positions(
Box &box);
172 void apply_velocities(
Box &box);
173 void apply_forces(
Box &box);
189 ContactTracker(sptr<Box> box, sptr<AtomGroup> atoms, vector<flt> dists);
190 void update(
Box &box);
196 uint N = atoms->size();
198 for(
uint i=0; i<N; ++i){
199 contacts[i].assign(i,
false);
202 unsigned long long broken(){
return breaks;};
203 unsigned long long formed(){
return formations;};
204 unsigned long long number(){
return incontact;};
208 vector<flt> newdists = vector<flt>();
209 for(
uint i=0; i<dists.size(); i++){
210 newdists.push_back(dists[i]);
227 vector<sptr<Interaction> > interactions,
uint n_skip=1)
229 interactions(interactions), N(0), n_skip(max(n_skip,1u)), n_skipped(0),
230 U0(0),Es(0),Us(0),Ks(0), Esq(0), Usq(0), Ksq(0){};
231 void update(
Box &box);
234 N=0; Es=0; Us=0; Ks=0;
241 void set_U0(
Box &box);
273 Eigen::Matrix<flt, Eigen::Dynamic, NDIM> xyz2();
274 Eigen::Matrix<flt, Eigen::Dynamic, NDIM> xyz4();
289 RsqTracker(sptr<AtomGroup> atoms, vector<unsigned long> ns,
bool usecom=
true);
292 void update(
Box &box);
294 vector<Eigen::Matrix<flt, Eigen::Dynamic, NDIM> > xyz2();
295 vector<vector<flt> > r2();
296 vector<Eigen::Matrix<flt, Eigen::Dynamic, NDIM> > xyz4();
297 vector<vector<flt> > r4();
298 vector<flt> counts();
322 vector<vector<cmplx> > ISFs();
323 vector<vector<array<cmplx, NDIM> > > ISFxyz();
337 ISFTracker(sptr<AtomGroup> atoms, vector<flt> ks,
338 vector<unsigned long> ns,
bool usecom=
false);
341 void update(
Box &box);
343 vector<vector<vector<array<cmplx, NDIM> > > > ISFxyz();
344 vector<vector<vector<cmplx> > > ISFs();
345 vector<flt> counts();
356 Eigen::Matrix<flt, Eigen::Dynamic, NDIM>
curlocs;
358 vector<Eigen::Matrix<flt, Eigen::Dynamic, NDIM> >
locs;
366 void update(
Box &box);
368 vector<Eigen::Matrix<flt, Eigen::Dynamic, NDIM> >
smooth_locs(){
return locs;};
382 RDiffs(sptr<AtomGroup> atoms,
unsigned long skip,
bool usecom=
false);
386 void update(
Box& box);
387 vector<vector<flt> >
rdiffs(){
return dists;};
407 : assigned(other.assigned), distance_squared(other.distance_squared){};
409 : assigned(other.size() + 1, 0), distance_squared(other.distance_squared + addeddist){
410 for(
uint i=0; i < other.
size(); i++){
413 assigned[assigned.size()-1] = expand;
427 list<JammingList> jlists;
428 Eigen::Matrix<flt, Eigen::Dynamic, NDIM> A;
429 Eigen::Matrix<flt, Eigen::Dynamic, NDIM> B;
431 JammingTree(sptr<Box> box, Eigen::Matrix<flt, Eigen::Dynamic, NDIM>& A, Eigen::Matrix<flt, Eigen::Dynamic, NDIM>& B)
432 : box(box), jlists(), A(A), B(B) {
434 assert(A.size() <= B.size());
439 vector<uint>& curlist = curjlist.
assigned;
440 if(curlist.size() >= (
uint) A.rows()){
445 list<JammingList> newlists = list<JammingList>();
446 for(
uint i=0; i < B.size(); i++){
447 vector<uint>::iterator found = find(curlist.begin(), curlist.end(), i);
449 if (found != curlist.end()){
454 flt newdist = box->diff(A.row(curlist.size()), B.row(i)).squaredNorm();
456 newlists.push_back(newjlist);
460 if(newlists.empty()){
469 jlists.merge(newlists);
475 for(
uint i=0; i<n; i++){
503 :
JammingList(other, expand, addeddist), rotation(other.rotation){};
513 Eigen::Matrix<flt, Eigen::Dynamic, NDIM>
A;
514 vector<Eigen::Matrix<flt, Eigen::Dynamic, NDIM> >
Bs;
518 JammingTreeRot(sptr<Box>box, Eigen::Matrix<flt, Eigen::Dynamic, NDIM>& A, Eigen::Matrix<flt, Eigen::Dynamic, NDIM>& B,
bool use_rotations=
true,
bool use_inversions=
true);
522 virtual bool expand();
526 for(
uint i=0; i<n; i++){
534 while((maxdistsq <= 0 or jlists.front().distance_squared < maxdistsq) and retval){
539 static Vec straight_diff(
Box &bx, Eigen::Matrix<flt, Eigen::Dynamic, NDIM>& A, Eigen::Matrix<flt, Eigen::Dynamic, NDIM>& B);
540 static flt straight_distsq(
Box &bx, Eigen::Matrix<flt, Eigen::Dynamic, NDIM>& A, Eigen::Matrix<flt, Eigen::Dynamic, NDIM>& B);
542 list<JammingListRot> &
my_list(){
return jlists;};
545 list<JammingListRot>::iterator last = jlists.begin();
547 return list<JammingListRot>(jlists.begin(), last);
572 Eigen::Matrix<flt, Eigen::Dynamic, NDIM> locations_B(
JammingListRot jlist);
574 Eigen::Matrix<flt, Eigen::Dynamic, NDIM> locations_A(
JammingListRot jlist);
600 Eigen::Matrix<flt, Eigen::Dynamic, NDIM>& A,
601 Eigen::Matrix<flt, Eigen::Dynamic, NDIM>& B,
603 bool use_rotations=
true,
604 bool use_inversions=
true
606 cutoff1(cutoff), cutoff2(cutoff){};
609 Eigen::Matrix<flt, Eigen::Dynamic, NDIM>& A,
610 Eigen::Matrix<flt, Eigen::Dynamic, NDIM>& B,
613 bool use_rotations=
true,
614 bool use_inversions=
true);
705 distance(other.distance), nodes(other.nodes){add(node, box);};
722 array<bool, NDIM> nonzero(
Vec diff_vec);
725 map<uint, CNodePath> circular_from(
CNode node, set<uint>& visited,
bool check_all);
733 void add(Eigen::Matrix<flt, Eigen::Dynamic, NDIM> locs, vector<flt> diameters);
735 map<uint, CNodePath> find_percolation(
bool check_all_dims=
true);
flt Usq
Definition: constraints.hpp:224
vector< CNode > nodes
Definition: constraints.hpp:699
virtual bool expand()
Definition: constraints.cpp:879
void apply_forces(Box &box)
Definition: constraints.hpp:49
list< JammingListRot > jlists
Definition: constraints.hpp:512
JammingList current_best()
Definition: constraints.hpp:483
The basic class for representing each particle.
Definition: box.hpp:229
list< JammingList > & my_list()
Definition: constraints.hpp:480
Connectivity(sptr< OriginBox > box)
Definition: constraints.hpp:728
uint size()
Definition: constraints.hpp:570
int constrained_dof()
Definition: constraints.hpp:137
vector< vector< flt > > dists
Definition: constraints.hpp:377
uint n_skipped
Definition: constraints.hpp:221
a group of atoms, such as all of them (AtomVec), or a smaller group such as a molecule, sidebranch, etc.
Definition: box.hpp:312
JammingListRot(const JammingListRot &other)
Definition: constraints.hpp:500
flt E_squared_mean()
Definition: constraints.hpp:250
virtual ~Constraint()
Definition: constraints.hpp:21
unsigned long curt
Definition: constraints.hpp:285
vector< vector< flt > > rdiffs()
Definition: constraints.hpp:387
flt K()
Definition: constraints.hpp:246
int constrained_dof()
Definition: constraints.hpp:36
vector< Eigen::Matrix< flt, Eigen::Dynamic, NDIM > > locs
Definition: constraints.hpp:358
unsigned int uint
Definition: vec.hpp:20
EnergyTracker(sptr< AtomGroup > atoms, vector< sptr< Interaction > > interactions, uint n_skip=1)
Definition: constraints.hpp:226
Vec x
location.
Definition: box.hpp:231
CoordCOMConstraint(sptr< AtomGroup > atm, bool fixx, bool fixy, bool fixz)
Definition: constraints.hpp:65
CNode()
Definition: constraints.hpp:687
vector< Eigen::Matrix< flt, Eigen::Dynamic, NDIM > > smooth_locs()
Definition: constraints.hpp:368
double flt
The basic floating point type used in the simulations.
Definition: vecrand.hpp:45
JammingListRot current_best()
Definition: constraints.hpp:551
flt distance_squared
Definition: constraints.hpp:403
bool expand()
Definition: constraints.hpp:437
bool expand_to(flt maxdistsq)
Definition: constraints.hpp:532
uint size()
Definition: constraints.hpp:707
Vec v
velocity
Definition: box.hpp:234
bool operator<(const CNode &other) const
Definition: constraints.hpp:692
vector< ISFTracker1 > singles
Definition: constraints.hpp:332
LinearConstraint(sptr< AtomGroup > atms, flt dist)
Definition: constraints.hpp:122
Vec x
Definition: constraints.hpp:685
list< JammingList > copy_list()
Definition: constraints.hpp:481
Definition: constraints.hpp:215
uint size()
Definition: constraints.hpp:491
uint smoothn
Definition: constraints.hpp:354
JammingListRot(const JammingListRot &other, uint expand, flt addeddist)
Definition: constraints.hpp:502
sptr< AtomGroup > atoms
Definition: constraints.hpp:217
A rectilinear Box, with periodic boundary conditions.
Definition: box.hpp:98
unsigned long curt
Definition: constraints.hpp:379
unsigned long get_skip()
Definition: constraints.hpp:325
void apply_velocities(Box &box)
Definition: constraints.hpp:43
vector< RsqTracker1 > singles
Definition: constraints.hpp:284
Eigen::Matrix< flt, Eigen::Dynamic, NDIM > locations_B()
Definition: constraints.hpp:573
sptr< AtomGroup > atoms
Definition: constraints.hpp:353
JammingTreeBD(sptr< Box >box, Eigen::Matrix< flt, Eigen::Dynamic, NDIM > &A, Eigen::Matrix< flt, Eigen::Dynamic, NDIM > &B, uint cutoff, bool use_rotations=true, bool use_inversions=true)
Definition: constraints.hpp:598
uint skipn
Definition: constraints.hpp:355
unsigned long get_skip()
Definition: constraints.hpp:277
A pointer to an Atom, that also knows its own index in an AtomVec.
Definition: box.hpp:270
uint cutoff2
Definition: constraints.hpp:596
flt get_U0()
Definition: constraints.hpp:242
A class that enforces rigid-body dynamics.
Definition: constraints.hpp:145
flt K_std()
Definition: constraints.hpp:248
Matrix get_MoI()
Definition: constraints.hpp:175
flt Us
Definition: constraints.hpp:223
bool operator==(const CNode &other) const
Definition: constraints.hpp:691
uint n()
Definition: constraints.hpp:255
Eigen::Matrix< flt, Eigen::Dynamic, NDIM > xyz2sums
Definition: constraints.hpp:262
vector< sptr< Interaction > > interactions
Definition: constraints.hpp:218
CNodePath(CNode node)
Definition: constraints.hpp:703
Definition: constraints.hpp:351
unsigned long skip
Definition: constraints.hpp:378
uint size() const
Definition: constraints.hpp:415
sptr< AtomGroup > atoms
Definition: constraints.hpp:331
bool expand(uint n)
Definition: constraints.hpp:473
CoordCOMConstraint(sptr< AtomGroup > atm, bool fixx, bool fixy, bool fixz, Vec loc)
Definition: constraints.hpp:63
flt E_std()
Definition: constraints.hpp:247
list< JammingListRot > copy_list(uint n)
Definition: constraints.hpp:544
bool expand(uint n)
Definition: constraints.hpp:524
CNodePath()
Definition: constraints.hpp:702
Definition: constraints.hpp:372
uint rotation
Definition: constraints.hpp:496
CNodePath(CNodePath other, CNode node, OriginBox &box)
Definition: constraints.hpp:704
int constrained_dof()
Definition: constraints.hpp:106
Definition: constraints.hpp:494
Vec f
forces
Definition: box.hpp:240
void reset()
Definition: constraints.hpp:232
Eigen::Matrix< flt, Eigen::Dynamic, NDIM > A
Definition: constraints.hpp:513
vector< uint > assigned
Definition: constraints.hpp:402
Definition: constraints.hpp:509
flt U()
Definition: constraints.hpp:245
DistConstraint(AtomID atm1, AtomID atm2)
Definition: constraints.hpp:104
unsigned long curt
Definition: constraints.hpp:359
JammingListRot(uint rot)
Definition: constraints.hpp:499
uint N
Definition: constraints.hpp:220
Eigen::Matrix< flt, Eigen::Dynamic, NDIM > locations_A()
Definition: constraints.hpp:575
int constrained_dof()
Definition: constraints.hpp:169
Definition: constraints.hpp:75
Definition: constraints.hpp:281
int constrained_dof()
Definition: constraints.hpp:90
bool operator!=(const CNode &other) const
Definition: constraints.hpp:690
sptr< AtomGroup > atoms
Definition: constraints.hpp:375
Definition: constraints.hpp:258
JammingList(const JammingList &other)
Definition: constraints.hpp:406
Eigen::Matrix< flt, Eigen::Dynamic, NDIM > pastlocs
Definition: constraints.hpp:311
flt U_std()
Definition: constraints.hpp:249
void set_U0(flt newU0)
Definition: constraints.hpp:237
set< CNode > nodes
Definition: constraints.hpp:719
uint numincur
Definition: constraints.hpp:357
Definition: constraints.hpp:113
bool usecom
Definition: constraints.hpp:334
list< JammingListRot > copy_list()
Definition: constraints.hpp:543
A 3x3 matrix, with methods for adding, subtracting, dot product, etc.
Definition: vec.hpp:360
flt E()
Definition: constraints.hpp:244
Eigen::Matrix< flt, Eigen::Dynamic, NDIM > pastlocs
Definition: constraints.hpp:261
int n
Definition: constraints.hpp:684
RelativeConstraint(Atom *atm1, Atom *atm2, bool fixx, bool fixy, bool fixz, Vec loc)
Definition: constraints.hpp:81
sptr< OriginBox > box
Definition: constraints.hpp:718
vector< Eigen::Matrix< flt, Eigen::Dynamic, NDIM > > Bs
Definition: constraints.hpp:514
void apply_positions(Box &box)
Definition: constraints.hpp:37
The general interface for a "tracker", a class that needs to be called every timestep.
Definition: trackers.hpp:16
Definition: constraints.hpp:400
bool expand(uint n)
Definition: constraints.hpp:619
unsigned long curt
Definition: constraints.hpp:333
JammingTree(sptr< Box > box, Eigen::Matrix< flt, Eigen::Dynamic, NDIM > &A, Eigen::Matrix< flt, Eigen::Dynamic, NDIM > &B)
Definition: constraints.hpp:431
Eigen::Matrix< flt, Eigen::Dynamic, NDIM > pastlocs
Definition: constraints.hpp:376
#define NDIM
Definition: vecrand.hpp:12
Definition: constraints.hpp:329
RelativeConstraint(Atom *atm1, Atom *atm2, bool fixx, bool fixy, bool fixz)
Definition: constraints.hpp:84
virtual ~JammingTreeRot()
Definition: constraints.hpp:576
sptr< Box > box
Definition: constraints.hpp:511
CNode(int n, Vec x)
Definition: constraints.hpp:688
unsigned long get_count()
Definition: constraints.hpp:326
A class for determining if two packings are the same.
Definition: constraints.hpp:424
Definition: constraints.hpp:57
Definition: constraints.hpp:716
Definition: constraints.hpp:308
vector< vector< array< cmplx, NDIM > > > ISFsums
Definition: constraints.hpp:312
flt K_squared_mean()
Definition: constraints.hpp:251
CoordConstraint(Atom *atm, bool fixx, bool fixy, bool fixz, Vec loc)
Definition: constraints.hpp:30
map< int, vector< CNode > > neighbors
Definition: constraints.hpp:720
The virtual interface for the shape of the space and its boundaries.
Definition: box.hpp:50
Definition: constraints.hpp:97
ContactTracker * ContactTrackerD(sptr< Box > box, sptr< AtomGroup > atoms, vector< double > dists)
Definition: constraints.hpp:207
Eigen::Matrix< flt, NDIM, 1 > Vec
The basic physics vector.
Definition: vecrand.hpp:53
bool usecom
Definition: constraints.hpp:286
Definition: constraints.hpp:682
JammingList()
Definition: constraints.hpp:405
CoordCOMConstraint(sptr< AtomGroup > atm)
Definition: constraints.hpp:67
unsigned long skip
Definition: constraints.hpp:265
JammingListRot()
Definition: constraints.hpp:498
sptr< AtomGroup > atoms
Definition: constraints.hpp:283
JammingList(const JammingList &other, uint expand, flt addeddist)
Definition: constraints.hpp:408
list< JammingListRot > & my_list()
Definition: constraints.hpp:542
bool operator>(const CNode &other) const
Definition: constraints.hpp:693
int constrained_dof()
Definition: constraints.hpp:69
bool usecom
Definition: constraints.hpp:380
vector< flt > r4sums
Definition: constraints.hpp:264
flt U0
Definition: constraints.hpp:222
RelativeConstraint(Atom *atm1, Atom *atm2)
Definition: constraints.hpp:87
CoordConstraint(Atom *atm)
Definition: constraints.hpp:34
bool usecom
Definition: constraints.hpp:360
DistConstraint(AtomID atm1, AtomID atm2, flt dist)
Definition: constraints.hpp:102
unsigned long get_skip()
Definition: constraints.hpp:389
unsigned long skip
Definition: constraints.hpp:314
Vec distance
Definition: constraints.hpp:698
Definition: constraints.hpp:696
vector< flt > ks
Definition: constraints.hpp:313
unsigned long get_count()
Definition: constraints.hpp:278
Eigen::Matrix< flt, Eigen::Dynamic, NDIM > curlocs
Definition: constraints.hpp:356
Definition: constraints.hpp:15
Definition: constraints.hpp:580
CoordConstraint(Atom *atm, bool fixx, bool fixy, bool fixz)
Definition: constraints.hpp:32
flt U_squared_mean()
Definition: constraints.hpp:252
Definition: constraints.hpp:24
Eigen::Matrix< flt, Eigen::Dynamic, NDIM > xyz4sums
Definition: constraints.hpp:263