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