-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathchain.h
185 lines (176 loc) · 4.01 KB
/
chain.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
#ifndef CHAIN_2D_H
#define CHAIN_2D_H
//# include <random>
# include "random_mars.h"
# include "units.h"
# include "solid.h"
# include "cell.h"
#define EMPTY -1
/*
struct Bond{
int size;
int *first;
int *next;
double *L0;
public:
Bond(){size=0;
first=NULL;next=NULL;L0=NULL;
}
Bond(int size_){
size = size_;
first = new int[size];
next = new int[size];
L0 = new double[size];
}
Bond& operator=(const Bond& rhs){
if (this !=&rhs){
delete [] first;
delete [] next;
delete [] L0;
size = rhs.size;
first = new int[size];
next = new int[size];
L0 = new double[size];
for (int i=0;i<size;i++){
first[i]=rhs.first[i];
next[i]=rhs.next[i];
L0[i]=rhs.L0[i];
}
}
return *this;
}
~Bond(){
delete [] first;
delete [] next;
delete [] L0;
}
};
struct Angle{
int size;
int *left;
int *middle;
int *right;
double *ang0;
public:
Angle(){size=0;
left=NULL;middle=NULL;right=NULL;ang0=NULL;
}
Angle(int size_){
size = size_;
left = new int[size];
middle = new int[size];
right = new int[size];
ang0 = new double[size];
}
Angle& operator=(const Angle& rhs){
if (this !=&rhs){
delete [] left;
delete [] middle;
delete [] right;
delete [] ang0;
size = rhs.size;
left = new int[size];
middle = new int[size];
right = new int[size];
ang0 = new double[size];
for (int i=0;i<size;i++){
left[i]=rhs.left[i];
middle[i]=rhs.middle[i];
right[i]=rhs.right[i];
ang0[i]=rhs.ang0[i];
}
}
return *this;
}
~Angle(){
delete [] left;
delete [] right;
delete [] middle;
delete [] ang0;
}
};*/
class Chain: public Solid{
public:
//Solid *pCell;
Cell *pCell;
//double *x;
double *xtmp;
//double *v;
//double *force;
Bond *pBond;
Angle *pAngle;
double rho;
double diffusionCoef;
double diffDist;
double ks;
double kb;
double kp;
double kBT; //thermal energy
//double damp;// Brownian dynamics dampping,in time units, 100
double m;
double g;
double diameter;
//double xc[2];
//int nn, nb, na;
int nb, na;
int ns;//# of cells
int nForOne;// # of nodes for each solid object
int periodicX, periodicY;
//double halfX, halfY;
//random number generator:
// this one needs c++11 suport, include headfile <random>
//std::default_random_engine generator;
//std::normal_distribution<double> ndist;
//portable random file from lammps
RanMars *random;
int seed;
//linked list cells for pairwise potential
int *lscl;//list of cell link
int *head; //head for each cell
// for particle - cell interaction
int *lscl_c;
int *head_c;
double rCut,rrCut;//cut of distance and its square
double sig2,sig6;
int cx,cy;//cell number in x,y direction
double epsilon, sigma;
double zeta;//friction coefficient
double randForce;//random force magnitude
double *drag;
public:
// creator
Chain();
~Chain();
Chain& operator=(const Chain& rhs);
void readInput(const std::string filename);
void reReadPosition(const std::string filename);
void init();
void setCells(Cell * pCell_);
// manipulator
void update();
void updateHalf();
void nondimension(const Units&);
void computeEquilibrium();
void computeForce();
void bondHarmonicForce();
void angleBendForce();
void velocityVerletIntegration();
void moveTo(double x,double y);
void randomForce();
void randomDisplacement();
void penetrationRemoval();
void initLJ();
void buildLinkList();
void pairWiseInteraction();
//void cellParticleInteraction();
void LJForce(int i,int j);
void particleCellLJForce(int i,int j);
int particleInsideCell(double xp, double yp, int idx);
void moveOutside(double xp, double yp, int idc, int idp);
// acessor
void writeGeometry(const std::string filename);
void writeForce(const std::string filename);
void writeVelocity(const std::string filename);
void writeLog(const std::string filename);
};
#endif