Trisurf Monte Carlo simulator
Miha
2014-02-06 fedf2b217113800a15f367e111e2dbcad4a3c92c
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
SP 7 /* @brief This is a header file, defining general constants and structures.
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
52 /* DATA TYPES */
53 /** @brief Sets the default datatype for ts_double
54  *
55  * Requred for some functions to work, like "pow" from math.h. If ts_double is defined as
56  * float program must run with "powf". Where type dependant function is used it checks this
57  * define directive to decide which version to compile in. Available options
58  *
59  *    TS_DOUBLE_FLOAT
60  *    TS_DOUBLE_DOUBLE
61  *    TS_DOUBLE_LONGDOUBLE
62 */
63 #define TS_DOUBLE_DOUBLE
64
65 /** For the purpose of greater flexibility all data types used in the program
66  *  shouldn't use standard C types, but should use types defined here.
67  *    ts_int (uses int)
68  */
69 typedef int ts_int;
70 /** For the purpose of greater flexibility all data types used in the program
71  *  shouldn't use standard C types, but should use types defined here.
72  *    ts_uint (uses unsigned int)
73  */
74 typedef unsigned int ts_uint;
75 /** For the purpose of greater flexibility all data types used in the program
76  *  shouldn't use standard C types, but should use types defined here.
77  *    ts_long (uses long)
78  */
79 typedef long ts_long;
80 /** For the purpose of greater flexibility all data types used in the program
81  *  shouldn't use standard C types, but should use types defined here.
82  *    ts_ulong (uses unsigned long)
83  */
84 typedef unsigned long ts_ulong;
85 /** For the purpose of greater flexibility all data types used in the program
86  *  shouldn't use standard C types, but should use types defined here.
87  *    ts_float (uses float)
88  */
89 typedef float ts_float;
90 /** For the purpose of greater flexibility all data types used in the program
91  *  shouldn't use standard C types, but should use types defined here.
92  *    ts_double (uses double)
93  */
94 typedef double ts_double;
95 /** For the purpose of greater flexibility all data types used in the program
96  *  shouldn't use standard C types, but should use types defined here.
97  *    ts_char (uses char)
98  */
99 typedef char ts_char;
100 /** For the purpose of greater flexibility all data types used in the program
101  *  shouldn't use standard C types, but should use types defined here.
102  *    ts_uchar (uses unsigned char)
103  */
104 typedef unsigned char ts_uchar;
105 /** For the purpose of greater flexibility all data types used in the program
106  *  shouldn't use standard C types, but should use types defined here.
107  *    ts_bool (uses char)
108  */
109 typedef char ts_bool;
110
111
112 /* STRUCTURES */
113
523bf1 114
SP 115 /** @brief Data structure for keeping the coordinates in selected coordinate
116  * system
117  */
118 #define TS_COORD_CARTESIAN 0
119 #define TS_COORD_SPHERICAL 1
120 #define TS_COORD_CYLINDRICAL 2
121
122 typedef struct {
123     ts_double e1;
124     ts_double e2;
125     ts_double e3;
126     ts_uint coord_type;
127 } ts_coord;
128
d7639a 129 /** @brief Data structure of all data connected to a vertex
SP 130  *
8f6a69 131  *  ts_vertex holds the data for one single point (bead, vertex). To understand how to use it
d7639a 132  *  here is a detailed description of the fields in the data structure. */
8f6a69 133 struct ts_vertex {
SP 134         ts_uint idx;
a10dd5 135         ts_double x; /**< The x coordinate of vertex. */
d7639a 136         ts_double y; /**< The y coordinate of vertex. */
SP 137         ts_double z; /**< The z coordinate of vertex. */
138         ts_uint neigh_no; /**< The number of neighbours. */
a10dd5 139         struct ts_vertex **neigh; /**< The pointer that holds neigh_no pointers to this structure. */
SP 140         ts_double *bond_length; /**< Obsolete! The bond lenght is moved to ts_bond */
141         ts_double *bond_length_dual; /**< Obsolete! Bond length in dual lattice is moved to ts_bond! */
d7639a 142         ts_double curvature;
SP 143         ts_double energy;
144         ts_double energy_h;
145         ts_uint tristar_no;
a10dd5 146         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 147         ts_uint bond_no;
148         struct ts_bond **bond; /**< Array of pointers of lenght bond_no that stores information on bonds. */
149         struct ts_cell *cell; /**< Which cell do we belong to? */
d7639a 150         ts_double xk;
SP 151         ts_double c;
152         ts_uint id;
523bf1 153         ts_double projArea;
SP 154         ts_double relR;
155         ts_double solAngle;
1d5dff 156     struct ts_poly *grafted_poly;
737714 157 };
d7639a 158 typedef struct ts_vertex ts_vertex;
SP 159
73f967 160 typedef struct {
SP 161     ts_uint n;
a10dd5 162     ts_vertex **vtx;
73f967 163
SP 164 } ts_vertex_list;
165
e016c4 166 struct ts_bond {
fedf2b 167         ts_uint idx;
d7639a 168     ts_vertex *vtx1;
SP 169     ts_vertex *vtx2;
170     ts_double bond_length;
171     ts_double bond_length_dual;
a63f17 172     ts_bool tainted;
fedf2b 173     ts_double energy;
a10dd5 174 };
SP 175 typedef struct ts_bond ts_bond;
176
177 struct ts_bond_list {
178     ts_uint n;
179     ts_bond **bond;
180 };
181 typedef struct ts_bond_list ts_bond_list;
182
41a035 183 struct ts_triangle {
SP 184     ts_uint idx;
d7639a 185     ts_vertex *vertex[3];
SP 186     ts_uint neigh_no;
187     struct ts_triangle **neigh;
188     ts_double xnorm;
189     ts_double ynorm;
190     ts_double znorm;
523bf1 191     ts_double area; // firstly needed for sh.c
c9d07c 192     ts_double volume; // firstly needed for sh.c
a10dd5 193 };
d7639a 194 typedef struct ts_triangle ts_triangle;
a10dd5 195
SP 196 struct ts_triangle_list{
197     ts_uint n;
198     ts_triangle **tria;
199 };
a2a676 200 typedef struct ts_triangle_list ts_triangle_list;
d7639a 201
SP 202
bb77ca 203 typedef struct ts_cell {
SP 204     ts_uint idx;
34d3de 205     ts_vertex **vertex;
SP 206     ts_uint nvertex;
bb77ca 207 } ts_cell; 
SP 208
209 typedef struct ts_cell_list{
210     ts_uint ncmax[3];
211     ts_uint cellno;
212     ts_cell **cell;
d7639a 213     ts_double dcell;
SP 214     ts_double shift;
215     ts_double max_occupancy;
bb77ca 216 } ts_cell_list;
SP 217
218
219 typedef struct {
523bf1 220     ts_uint l;
SP 221     ts_double **ulm;
262607 222     ts_double **sumUlm2;
SP 223     ts_uint N;
621830 224     ts_double **co;
eb8605 225     ts_double ***Ylmi;
523bf1 226 } ts_spharm;
SP 227
228
229
1d5dff 230 struct ts_poly {
M 231     ts_vertex_list *vlist;
232     ts_bond_list *blist;
233     ts_vertex *grafted_vtx;
48bb92 234     ts_double k;
1d5dff 235 };
M 236 typedef struct ts_poly ts_poly;
237
238
239 struct ts_poly_list {
240     ts_uint    n;
241     ts_poly **poly;
242 };
243 typedef struct ts_poly_list ts_poly_list;
244
245
246
247
523bf1 248 typedef struct {
bb77ca 249     ts_vertex_list *vlist;
SP 250     ts_bond_list *blist;
251     ts_triangle_list *tlist;
48bb92 252     ts_cell_list *clist;
bb77ca 253     ts_uint nshell;
48bb92 254     ts_double bending_rigidity;
M 255     ts_double dmax;
256     ts_double stepsize;
257        ts_double cm[3];
258     ts_double volume;
259     ts_spharm *sphHarmonics;
260
1d5dff 261     ts_poly_list *poly_list;
48bb92 262     ts_double spring_constant;
d7639a 263 } ts_vesicle;
SP 264
265
523bf1 266
SP 267
d7639a 268 /* GLOBAL VARIABLES */
SP 269
270 int quiet;
271
272
273 /* FUNCTIONS */
274
275 /** Non-fatal error function handler:
276  *      @param text is a description of an error
277  *      @returns doesn't return anything
278 */
279 void err(char *text);
280
281 /** Fatal error function handler:
282  *      @param text is a description of an error
283  *      @param errcode is a (non-zero) error code
284  *      @returns terminates the execution of program with errcode set
285 */
286 void fatal(char *text, ts_int errcode);
287
7958e9 288 ts_uint ts_fprintf(FILE *fd, char *fmt, ...);
d7639a 289
737714 290 #define VTX(n) &(vlist->vtx[n])
SP 291 #define VTX_DATA(n) vlist->vtx[n].data
73f967 292
d7639a 293 #endif