1 // Voro++, a 3D cell-based Voronoi library
3 // Author : Chris H. Rycroft (LBL / UC Berkeley)
4 // Email : chr@alum.mit.edu
5 // Date : July 1st 2008
8 * \brief Header file for the dynamic extension classes, which add
9 * functionality for a variety of dynamic particle motions. */
11 #ifndef VOROPP_DYNAMIC_HH
12 #define VOROPP_DYNAMIC_HH
16 inline bool test(fpoint cx
,fpoint cy
,fpoint cz
) {return true;}
19 class velocity_internal
{
21 velocity_internal(fpoint
**&ive
) : track_ve(true), ve(ive
) {};
22 inline void vel(int ijk
,int q
,fpoint
&x
,fpoint
&y
,fpoint
&z
) {
32 class velocity_brownian
{
34 velocity_brownian() : track_ve(false), mag(0.05), tmag(2*mag
) {};
35 inline void vel(int ijk
,int q
,fpoint
&x
,fpoint
&y
,fpoint
&z
) {
42 const fpoint mag
,tmag
;
43 inline fpoint
rnd() {return fpoint(rand())/RAND_MAX
;}
46 class velocity_brownian2
{
48 velocity_brownian2() : track_ve(false), mag(0.02), tmag(2*mag
) {};
49 inline void vel(int ijk
,int q
,fpoint
&x
,fpoint
&y
,fpoint
&z
) {
55 } while (dx
*dx
+dy
*dy
+dz
*dz
>=mag
*mag
);
56 x
+=dx
/*+0.0001*sin(y*3.1415926535897932384626433832795/20)*/;y
+=dy
;z
+=dz
;
60 const fpoint mag
,tmag
;
61 inline fpoint
rnd() {return fpoint(rand())/RAND_MAX
;}
64 class velocity_constant
{
66 velocity_constant(fpoint idx
,fpoint idy
,fpoint idz
) : track_ve(false),
67 dx(idx
), dy(idy
), dz(idz
) {};
68 inline void vel(int ijk
,int q
,fpoint
&x
,fpoint
&y
,fpoint
&z
) {
73 const fpoint dx
,dy
,dz
;
76 class velocity_gaussian
{
78 velocity_gaussian(fpoint icx
,fpoint icy
,fpoint icz
,fpoint idx
,fpoint idy
,fpoint idz
,fpoint idec
)
79 : track_ve(false), cx(idx
), cy(idy
), cz(idz
), dx(idx
), dy(idy
), dz(idz
), dec(idec
) {};
80 inline void vel(int ijk
,int q
,fpoint
&x
,fpoint
&y
,fpoint
&z
) {
81 fpoint ex
=x
-cx
,ey
=y
-cy
,ez
=z
-cz
;
82 ex
=exp(-dec
*(ex
*ex
+ey
*ey
+ez
*ez
));
83 x
+=ex
*dx
;y
+=ex
*dy
;z
+=ex
*dz
;
87 const fpoint cx
,cy
,cz
;
88 const fpoint dx
,dy
,dz
;
92 template<class r_option
>
93 class container_dynamic_base
: public container_base
<r_option
> {
95 container_dynamic_base(fpoint xa
,fpoint xb
,fpoint ya
,fpoint yb
,fpoint za
,
96 fpoint zb
,int xn
,int yn
,int zn
,const bool xper
,const bool yper
,const bool zper
,int memi
);
97 ~container_dynamic_base();
98 using container_base
<r_option
>::xperiodic
;
99 using container_base
<r_option
>::yperiodic
;
100 using container_base
<r_option
>::zperiodic
;
101 using container_base
<r_option
>::ax
;
102 using container_base
<r_option
>::ay
;
103 using container_base
<r_option
>::az
;
104 using container_base
<r_option
>::bx
;
105 using container_base
<r_option
>::by
;
106 using container_base
<r_option
>::bz
;
107 using container_base
<r_option
>::nx
;
108 using container_base
<r_option
>::ny
;
109 using container_base
<r_option
>::nz
;
110 using container_base
<r_option
>::nxyz
;
111 using container_base
<r_option
>::xsp
;
112 using container_base
<r_option
>::ysp
;
113 using container_base
<r_option
>::zsp
;
114 using container_base
<r_option
>::co
;
115 using container_base
<r_option
>::p
;
116 using container_base
<r_option
>::sz
;
117 using container_base
<r_option
>::id
;
118 using container_base
<r_option
>::radius
;
119 using container_base
<r_option
>::wall_number
;
120 using container_base
<r_option
>::walls
;
121 using container_base
<r_option
>::mem
;
122 inline void clear_velocities();
123 inline void damp_velocities(fpoint damp
);
124 void wall_diagnostic();
125 int count(fpoint x
,fpoint y
,fpoint z
,fpoint r
);
126 void spot(fpoint cx
,fpoint cy
,fpoint cz
,fpoint dx
,fpoint dy
,fpoint dz
,fpoint rad
);
127 void gauss_spot(fpoint cx
,fpoint cy
,fpoint cz
,fpoint dx
,fpoint dy
,fpoint dz
,fpoint dec
,fpoint rad
);
128 void relax(fpoint cx
,fpoint cy
,fpoint cz
,fpoint rad
,fpoint alpha
);
129 template<class cond_class
>
130 void neighbor_distribution(int *bb
,fpoint dr
,int max
);
131 template<class cond_class
>
132 fpoint
packing_badness();
133 void full_relax(fpoint alpha
);
134 template<class v_class
>
135 void local_move(v_class
&vcl
,fpoint cx
,fpoint cy
,fpoint cz
,fpoint rad
);
136 template<class v_class
>
137 inline void move() {v_class vcl
;move(vcl
);}
138 template<class v_class
>
139 void move(v_class
&vcl
);
140 void add_particle_memory(int i
);
141 inline int full_count();
142 #ifdef YEAST_ROUTINES
143 void stick(fpoint alpha
);
144 void draw_yeast_pov(const char *filename
);
145 void draw_yeast_pov(ostream
&os
);
150 velocity_internal v_inter
;
152 inline int step_mod(int a
,int b
);
153 inline int step_div(int a
,int b
);
154 inline int step_int(fpoint a
);
155 inline void wall_contribution(int s
,int l
,fpoint cx
,fpoint cy
,fpoint cz
,fpoint alpha
);
156 inline void wall_badness(fpoint cx
,fpoint cy
,fpoint cz
,fpoint
&badcount
);
159 /** The basic dynamic container class. */
160 typedef container_dynamic_base
<radius_mono
> container_dynamic
;
162 /** The polydisperse dynamic container class. */
163 typedef container_dynamic_base
<radius_poly
> container_dynamic_poly
;