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