Trisurf Monte Carlo simulator
Samo Penic
2014-06-13 a61c001cd35ff70a314ef417c4beda9c7e68d3ad
commit | author | age
d7639a 1 #ifndef _GENERAL_H
SP 2 #define _GENERAL_H
3
4 #include<stdarg.h>
7958e9 5 #include<stdio.h>
459ff9 6 #include<gsl/gsl_complex.h>
d7639a 7 /* @brief This is a header file, defining general constants and structures.
SP 8   * @file header.h
9   * @author Samo Penic
10   * @date 5.3.2001
311301 11   * 
d7639a 12   * Header file for general inclusion in all the code, defining data structures
SP 13   * and general constans. All datatypes used in the code is also defined here.
14   *
311301 15   * Miha: branch trisurf-polyel
d7639a 16   */
SP 17
18 /* Defines */
19 /** @brief Return value of type bz_bool that indiceates successful function finish 
20   *
21   * Function usualy return some value, which are the result of certain operation. Functions that don't
22   * return any parameters can return value, that indicates if the function call finished successfully.
23   * In case of successful function run, the functions should return TS_SUCCESS to the caller. This define
24   * is set here to get uniformity among all the functions used in program.
25   *
26   * Example of usage:
27   *        ts_boot somefunction(ts_int param1, ....){
28   *            ...
29   *            return TS_SUCCESS;
30   *        }
31   */
32 #define TS_SUCCESS 0
33
34 /** @brief Return value of type bz_bool that indicates unsuccessful function finish 
35   *
36   * Function usualy return some value, which are the result of certain operation. Functions that don't
37   * return any parameters can return value, that indicates if the function call finished successfully.
38   * In case of unsuccessful function run, the functions should return TS_FAIL to the caller. This define
39   * is set here to get uniformity among all the functions used in program.
40   *
41   * Example of usage:
42   *
43   *        ts_boot somefunction(ts_int param1, ....){
44   *            ...
45   *            return TS_FAIL;
46   *        }
47   */
48 #define TS_FAIL 1
49
50 /* CONSTANTS */
51
ea1cce 52 #define TS_ID_FILAMENT 1
M 53
d7639a 54 /* DATA TYPES */
SP 55 /** @brief Sets the default datatype for ts_double
56  *
57  * Requred for some functions to work, like "pow" from math.h. If ts_double is defined as
58  * float program must run with "powf". Where type dependant function is used it checks this
59  * define directive to decide which version to compile in. Available options
60  *
61  *    TS_DOUBLE_FLOAT
62  *    TS_DOUBLE_DOUBLE
63  *    TS_DOUBLE_LONGDOUBLE
64 */
65 #define TS_DOUBLE_DOUBLE
66
67 /** For the purpose of greater flexibility all data types used in the program
68  *  shouldn't use standard C types, but should use types defined here.
69  *    ts_int (uses int)
70  */
71 typedef int ts_int;
72 /** For the purpose of greater flexibility all data types used in the program
73  *  shouldn't use standard C types, but should use types defined here.
74  *    ts_uint (uses unsigned int)
75  */
76 typedef unsigned int ts_uint;
77 /** For the purpose of greater flexibility all data types used in the program
78  *  shouldn't use standard C types, but should use types defined here.
79  *    ts_long (uses long)
80  */
81 typedef long ts_long;
82 /** For the purpose of greater flexibility all data types used in the program
83  *  shouldn't use standard C types, but should use types defined here.
84  *    ts_ulong (uses unsigned long)
85  */
86 typedef unsigned long ts_ulong;
87 /** For the purpose of greater flexibility all data types used in the program
88  *  shouldn't use standard C types, but should use types defined here.
89  *    ts_float (uses float)
90  */
91 typedef float ts_float;
92 /** For the purpose of greater flexibility all data types used in the program
93  *  shouldn't use standard C types, but should use types defined here.
94  *    ts_double (uses double)
95  */
96 typedef double ts_double;
97 /** For the purpose of greater flexibility all data types used in the program
98  *  shouldn't use standard C types, but should use types defined here.
99  *    ts_char (uses char)
100  */
101 typedef char ts_char;
102 /** For the purpose of greater flexibility all data types used in the program
103  *  shouldn't use standard C types, but should use types defined here.
104  *    ts_uchar (uses unsigned char)
105  */
106 typedef unsigned char ts_uchar;
107 /** For the purpose of greater flexibility all data types used in the program
108  *  shouldn't use standard C types, but should use types defined here.
109  *    ts_bool (uses char)
110  */
111 typedef char ts_bool;
112
113
114 /* STRUCTURES */
115
523bf1 116
SP 117 /** @brief Data structure for keeping the coordinates in selected coordinate
118  * system
119  */
120 #define TS_COORD_CARTESIAN 0
121 #define TS_COORD_SPHERICAL 1
122 #define TS_COORD_CYLINDRICAL 2
123
124 typedef struct {
125     ts_double e1;
126     ts_double e2;
127     ts_double e3;
128     ts_uint coord_type;
129 } ts_coord;
130
0af0cf 131
SP 132 typedef struct {
d27c07 133     ts_uint n;
SP 134     ts_coord **coord;
0af0cf 135 } ts_coord_list;
SP 136
d7639a 137 /** @brief Data structure of all data connected to a vertex
SP 138  *
8f6a69 139  *  ts_vertex holds the data for one single point (bead, vertex). To understand how to use it
d7639a 140  *  here is a detailed description of the fields in the data structure. */
8f6a69 141 struct ts_vertex {
SP 142         ts_uint idx;
a10dd5 143         ts_double x; /**< The x coordinate of vertex. */
d7639a 144         ts_double y; /**< The y coordinate of vertex. */
SP 145         ts_double z; /**< The z coordinate of vertex. */
146         ts_uint neigh_no; /**< The number of neighbours. */
a10dd5 147         struct ts_vertex **neigh; /**< The pointer that holds neigh_no pointers to this structure. */
SP 148         ts_double *bond_length; /**< Obsolete! The bond lenght is moved to ts_bond */
149         ts_double *bond_length_dual; /**< Obsolete! Bond length in dual lattice is moved to ts_bond! */
d7639a 150         ts_double curvature;
SP 151         ts_double energy;
152         ts_double energy_h;
153         ts_uint tristar_no;
a10dd5 154         struct ts_triangle **tristar; /**< The list of triangles this vertex belongs to. This is an array of pointers to ts_triangle structure of tristar_no length */
SP 155         ts_uint bond_no;
156         struct ts_bond **bond; /**< Array of pointers of lenght bond_no that stores information on bonds. */
157         struct ts_cell *cell; /**< Which cell do we belong to? */
d7639a 158         ts_double xk;
SP 159         ts_double c;
160         ts_uint id;
523bf1 161         ts_double projArea;
SP 162         ts_double relR;
163         ts_double solAngle;
1d5dff 164     struct ts_poly *grafted_poly;
737714 165 };
d7639a 166 typedef struct ts_vertex ts_vertex;
SP 167
73f967 168 typedef struct {
SP 169     ts_uint n;
a10dd5 170     ts_vertex **vtx;
73f967 171
SP 172 } ts_vertex_list;
173
e016c4 174 struct ts_bond {
fedf2b 175         ts_uint idx;
d7639a 176     ts_vertex *vtx1;
SP 177     ts_vertex *vtx2;
58230a 178         ts_double bond_length;
M 179         ts_double bond_length_dual;
180     ts_bool tainted; //TODO: remove
fedf2b 181     ts_double energy;
58230a 182     ts_double x,y,z;
a10dd5 183 };
SP 184 typedef struct ts_bond ts_bond;
185
186 struct ts_bond_list {
187     ts_uint n;
188     ts_bond **bond;
189 };
190 typedef struct ts_bond_list ts_bond_list;
191
41a035 192 struct ts_triangle {
SP 193     ts_uint idx;
d7639a 194     ts_vertex *vertex[3];
SP 195     ts_uint neigh_no;
196     struct ts_triangle **neigh;
197     ts_double xnorm;
198     ts_double ynorm;
199     ts_double znorm;
523bf1 200     ts_double area; // firstly needed for sh.c
c9d07c 201     ts_double volume; // firstly needed for sh.c
a10dd5 202 };
d7639a 203 typedef struct ts_triangle ts_triangle;
a10dd5 204
SP 205 struct ts_triangle_list{
206     ts_uint n;
207     ts_triangle **tria;
208 };
a2a676 209 typedef struct ts_triangle_list ts_triangle_list;
d7639a 210
SP 211
bb77ca 212 typedef struct ts_cell {
SP 213     ts_uint idx;
34d3de 214     ts_vertex **vertex;
SP 215     ts_uint nvertex;
bb77ca 216 } ts_cell; 
SP 217
218 typedef struct ts_cell_list{
219     ts_uint ncmax[3];
220     ts_uint cellno;
221     ts_cell **cell;
d7639a 222     ts_double dcell;
SP 223     ts_double shift;
224     ts_double max_occupancy;
ea1cce 225     ts_double dmin_interspecies;
bb77ca 226 } ts_cell_list;
SP 227
228
229 typedef struct {
523bf1 230     ts_uint l;
SP 231     ts_double **ulm;
459ff9 232     gsl_complex **ulmComplex;
262607 233     ts_double **sumUlm2;
SP 234     ts_uint N;
621830 235     ts_double **co;
eb8605 236     ts_double ***Ylmi;
523bf1 237 } ts_spharm;
SP 238
239
240
1d5dff 241 struct ts_poly {
M 242     ts_vertex_list *vlist;
243     ts_bond_list *blist;
244     ts_vertex *grafted_vtx;
48bb92 245     ts_double k;
1d5dff 246 };
M 247 typedef struct ts_poly ts_poly;
248
249
250 struct ts_poly_list {
251     ts_uint    n;
252     ts_poly **poly;
253 };
254 typedef struct ts_poly_list ts_poly_list;
255
256
257
9166cb 258 typedef struct {
SP 259     long int nshell;
260     long int ncxmax;
261     long int ncymax;
262     long int nczmax;
263     long int npoly;
264     long int nmono;
265     long int nfil;
266     long int nfono;
267     long int R_nucleus;
268     long int pswitch;
269     long int constvolswitch;
43c042 270     ts_double constvolprecision;
9166cb 271         char *multiprocessing;
SP 272        long int brezveze0;
273         long int brezveze1;
274         long int brezveze2;
275         ts_double xk0;
276     ts_double dmax;
277     ts_double dmin_interspecies;
278     ts_double stepsize;
279     ts_double kspring;
280     ts_double xi;
281     ts_double pressure;
282     long int iterations;
283     long int inititer;
284     long int mcsweeps;
285     long int quiet;
286     long int shc;
287 } ts_tape;
288
289
290
1d5dff 291
523bf1 292 typedef struct {
bb77ca 293     ts_vertex_list *vlist;
SP 294     ts_bond_list *blist;
295     ts_triangle_list *tlist;
48bb92 296     ts_cell_list *clist;
bb77ca 297     ts_uint nshell;
48bb92 298     ts_double bending_rigidity;
M 299     ts_double dmax;
300     ts_double stepsize;
301        ts_double cm[3];
302     ts_double volume;
303     ts_spharm *sphHarmonics;
624f81 304 // Polymers outside the vesicle and attached to the vesicle membrane (polymer brush):
1d5dff 305     ts_poly_list *poly_list;
624f81 306 // Filaments inside the vesicle (not attached to the vesicel membrane:
M 307     ts_poly_list *filament_list;
308
48bb92 309     ts_double spring_constant;
e86357 310     ts_double pressure;
b866cf 311     ts_int pswitch;
9166cb 312     ts_tape *tape;
624f81 313     ts_double R_nucleus;
M 314
d7639a 315 } ts_vesicle;
SP 316
317
523bf1 318
d7639a 319 /* GLOBAL VARIABLES */
SP 320
321 int quiet;
322
323
324 /* FUNCTIONS */
325
326 /** Non-fatal error function handler:
327  *      @param text is a description of an error
328  *      @returns doesn't return anything
329 */
330 void err(char *text);
331
332 /** Fatal error function handler:
333  *      @param text is a description of an error
334  *      @param errcode is a (non-zero) error code
335  *      @returns terminates the execution of program with errcode set
336 */
337 void fatal(char *text, ts_int errcode);
338
7958e9 339 ts_uint ts_fprintf(FILE *fd, char *fmt, ...);
d7639a 340
737714 341 #define VTX(n) &(vlist->vtx[n])
SP 342 #define VTX_DATA(n) vlist->vtx[n].data
73f967 343
d7639a 344 #endif