Trisurf Monte Carlo simulator
Samo Penic
2014-09-03 a752b502e11eababc1bae73434b9dde9380c0c59
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
d7639a 131 /** @brief Data structure of all data connected to a vertex
SP 132  *
8f6a69 133  *  ts_vertex holds the data for one single point (bead, vertex). To understand how to use it
d7639a 134  *  here is a detailed description of the fields in the data structure. */
8f6a69 135 struct ts_vertex {
SP 136         ts_uint idx;
a10dd5 137         ts_double x; /**< The x coordinate of vertex. */
d7639a 138         ts_double y; /**< The y coordinate of vertex. */
SP 139         ts_double z; /**< The z coordinate of vertex. */
140         ts_uint neigh_no; /**< The number of neighbours. */
a10dd5 141         struct ts_vertex **neigh; /**< The pointer that holds neigh_no pointers to this structure. */
SP 142         ts_double *bond_length; /**< Obsolete! The bond lenght is moved to ts_bond */
143         ts_double *bond_length_dual; /**< Obsolete! Bond length in dual lattice is moved to ts_bond! */
d7639a 144         ts_double curvature;
SP 145         ts_double energy;
146         ts_double energy_h;
147         ts_uint tristar_no;
a10dd5 148         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 149         ts_uint bond_no;
150         struct ts_bond **bond; /**< Array of pointers of lenght bond_no that stores information on bonds. */
151         struct ts_cell *cell; /**< Which cell do we belong to? */
d7639a 152         ts_double xk;
SP 153         ts_double c;
154         ts_uint id;
523bf1 155         ts_double projArea;
SP 156         ts_double relR;
157         ts_double solAngle;
1d5dff 158     struct ts_poly *grafted_poly;
737714 159 };
d7639a 160 typedef struct ts_vertex ts_vertex;
SP 161
73f967 162 typedef struct {
SP 163     ts_uint n;
a10dd5 164     ts_vertex **vtx;
73f967 165
SP 166 } ts_vertex_list;
167
e016c4 168 struct ts_bond {
fedf2b 169         ts_uint idx;
d7639a 170     ts_vertex *vtx1;
SP 171     ts_vertex *vtx2;
58230a 172         ts_double bond_length;
M 173         ts_double bond_length_dual;
174     ts_bool tainted; //TODO: remove
fedf2b 175     ts_double energy;
58230a 176     ts_double x,y,z;
a10dd5 177 };
SP 178 typedef struct ts_bond ts_bond;
179
180 struct ts_bond_list {
181     ts_uint n;
182     ts_bond **bond;
183 };
184 typedef struct ts_bond_list ts_bond_list;
185
41a035 186 struct ts_triangle {
SP 187     ts_uint idx;
d7639a 188     ts_vertex *vertex[3];
SP 189     ts_uint neigh_no;
190     struct ts_triangle **neigh;
191     ts_double xnorm;
192     ts_double ynorm;
193     ts_double znorm;
523bf1 194     ts_double area; // firstly needed for sh.c
c9d07c 195     ts_double volume; // firstly needed for sh.c
a10dd5 196 };
d7639a 197 typedef struct ts_triangle ts_triangle;
a10dd5 198
SP 199 struct ts_triangle_list{
200     ts_uint n;
201     ts_triangle **tria;
202 };
a2a676 203 typedef struct ts_triangle_list ts_triangle_list;
d7639a 204
SP 205
bb77ca 206 typedef struct ts_cell {
SP 207     ts_uint idx;
34d3de 208     ts_vertex **vertex;
SP 209     ts_uint nvertex;
bb77ca 210 } ts_cell; 
SP 211
212 typedef struct ts_cell_list{
213     ts_uint ncmax[3];
214     ts_uint cellno;
215     ts_cell **cell;
d7639a 216     ts_double dcell;
SP 217     ts_double shift;
218     ts_double max_occupancy;
ea1cce 219     ts_double dmin_interspecies;
bb77ca 220 } ts_cell_list;
SP 221
222
223 typedef struct {
523bf1 224     ts_uint l;
SP 225     ts_double **ulm;
459ff9 226     gsl_complex **ulmComplex;
262607 227     ts_double **sumUlm2;
SP 228     ts_uint N;
621830 229     ts_double **co;
eb8605 230     ts_double ***Ylmi;
523bf1 231 } ts_spharm;
SP 232
233
234
1d5dff 235 struct ts_poly {
M 236     ts_vertex_list *vlist;
237     ts_bond_list *blist;
238     ts_vertex *grafted_vtx;
48bb92 239     ts_double k;
1d5dff 240 };
M 241 typedef struct ts_poly ts_poly;
242
243
244 struct ts_poly_list {
245     ts_uint    n;
246     ts_poly **poly;
247 };
248 typedef struct ts_poly_list ts_poly_list;
249
250
251
9166cb 252 typedef struct {
SP 253     long int nshell;
254     long int ncxmax;
255     long int ncymax;
256     long int nczmax;
257     long int npoly;
258     long int nmono;
259     long int nfil;
260     long int nfono;
261     long int R_nucleus;
262     long int pswitch;
263     long int constvolswitch;
43c042 264     ts_double constvolprecision;
9166cb 265         char *multiprocessing;
SP 266        long int brezveze0;
267         long int brezveze1;
268         long int brezveze2;
269         ts_double xk0;
270     ts_double dmax;
271     ts_double dmin_interspecies;
272     ts_double stepsize;
273     ts_double kspring;
274     ts_double xi;
275     ts_double pressure;
276     long int iterations;
277     long int inititer;
278     long int mcsweeps;
279     long int quiet;
280     long int shc;
281 } ts_tape;
282
283
284
1d5dff 285
523bf1 286 typedef struct {
bb77ca 287     ts_vertex_list *vlist;
SP 288     ts_bond_list *blist;
289     ts_triangle_list *tlist;
48bb92 290     ts_cell_list *clist;
bb77ca 291     ts_uint nshell;
48bb92 292     ts_double bending_rigidity;
M 293     ts_double dmax;
294     ts_double stepsize;
295        ts_double cm[3];
296     ts_double volume;
297     ts_spharm *sphHarmonics;
624f81 298 // Polymers outside the vesicle and attached to the vesicle membrane (polymer brush):
1d5dff 299     ts_poly_list *poly_list;
624f81 300 // Filaments inside the vesicle (not attached to the vesicel membrane:
M 301     ts_poly_list *filament_list;
302
48bb92 303     ts_double spring_constant;
e86357 304     ts_double pressure;
b866cf 305     ts_int pswitch;
9166cb 306     ts_tape *tape;
624f81 307     ts_double R_nucleus;
M 308
d7639a 309 } ts_vesicle;
SP 310
311
523bf1 312
d7639a 313 /* GLOBAL VARIABLES */
SP 314
315 int quiet;
316
317
318 /* FUNCTIONS */
319
320 /** Non-fatal error function handler:
321  *      @param text is a description of an error
322  *      @returns doesn't return anything
323 */
324 void err(char *text);
325
326 /** Fatal error function handler:
327  *      @param text is a description of an error
328  *      @param errcode is a (non-zero) error code
329  *      @returns terminates the execution of program with errcode set
330 */
331 void fatal(char *text, ts_int errcode);
332
7958e9 333 ts_uint ts_fprintf(FILE *fd, char *fmt, ...);
d7639a 334
737714 335 #define VTX(n) &(vlist->vtx[n])
SP 336 #define VTX_DATA(n) vlist->vtx[n].data
73f967 337
d7639a 338 #endif