Trisurf Monte Carlo simulator
Samo Penic
2014-03-08 0fb40c28545e8418469cf7d3600547dfe4083edb
commit | author | age
d7639a 1 #include<stdio.h>
SP 2 #include<math.h>
3 #include "general.h"
4 #include "vertex.h"
a10dd5 5 #include "bond.h"
a2a676 6 #include "triangle.h"
bb77ca 7 #include "cell.h"
7958e9 8 #include "vesicle.h"
a6b1b5 9 #include "io.h"
7958e9 10 #include "initial_distribution.h"
dac2e5 11 #include "frame.h"
aec47d 12 #include "timestep.h"
8db569 13 #include "poly.h"
d7639a 14
SP 15 /** Entrance function to the program
16   * @param argv is a number of parameters used in program call (including the program name
17   * @param argc is a pointer to strings (character arrays) which holds the arguments
18   * @returns returns 0 on success, any other number on fail.
19 */
20
21 int main(int argv, char *argc[]){
d7a113 22 ts_uint inititer,mcsweeps, iterations;
3c1ac1 23 ts_vesicle *vesicle, *vesicle1;
083e03 24
SP 25
26 parse_args(argv,argc);
27
b14a8d 28 /* THIS SHOULD GO INTO UNIT TEST
d7639a 29 ts_bool retval;
3131dc 30     ts_vertex_list *vlist=init_vertex_list(5);
b01cc1 31 ts_vertex_list *vlist1;
a10dd5 32 ts_bond_list *blist=init_bond_list();
a2a676 33 ts_triangle_list *tlist=init_triangle_list();
bb77ca 34 ts_cell_list *clist=init_cell_list(3,3,3,0.3);
d7639a 35
a10dd5 36 retval=vtx_add_cneighbour(blist,vlist->vtx[1],vlist->vtx[0]);
d7639a 37 if(retval==TS_FAIL) printf("1. already a member or vertex is null!\n");
a10dd5 38
e19e79 39 retval=vtx_add_neighbour(vlist->vtx[0],vlist->vtx[1]);
d7639a 40 if(retval==TS_FAIL) printf("2. already a member or vertex is null!\n");
306559 41 fprintf(stderr,"Was here");
e19e79 42 retval=vtx_remove_neighbour(vlist->vtx[1],vlist->vtx[0]);
9802f1 43 vtx_add_neighbour(vlist->vtx[0],vlist->vtx[1]);
306559 44 fprintf(stderr,"Was here too!\n");
9802f1 45
8f6a69 46 vlist->vtx[0]->x=1.0;
SP 47 vlist->vtx[0]->x=1.1;
b01cc1 48 vlist1=vertex_list_copy(vlist);
a10dd5 49 bond_add(blist, vlist->vtx[1],vlist->vtx[0]);
a2a676 50 triangle_add(tlist,vlist->vtx[1],vlist->vtx[2],vlist->vtx[3]);
a10dd5 51
a2a676 52 triangle_add(tlist,vlist->vtx[1],vlist->vtx[2],vlist->vtx[3]);
SP 53
34d3de 54 printf("Cell idx=1 has vertices=%u\n",clist->cell[0]->nvertex);
bb77ca 55 cell_add_vertex(clist->cell[0], vlist->vtx[0]);
34d3de 56 printf("Cell idx=1 has vertices=%u\n",clist->cell[0]->nvertex);
8f6a69 57 printf("Cell idx=1 has vertex[0] has x coordinate=%e\n",clist->cell[0]->vertex[0]->x);
bb77ca 58 cell_list_cell_occupation_clear(clist);
34d3de 59 printf("Cell idx=1 has vertices=%u\n",clist->cell[0]->nvertex);
bb77ca 60 cell_add_vertex(clist->cell[0], vlist->vtx[0]);
SP 61
62
a2a676 63 triangle_list_free(tlist);
a10dd5 64 bond_list_free(blist);
73f967 65 vtx_list_free(vlist);
bb77ca 66 cell_list_free(clist);
7958e9 67
b01cc1 68 vtx_list_free(vlist1);
SP 69 printf("Tests complete.\n");
b14a8d 70 */
083e03 71 if(force_from_tape){
SP 72 ts_fprintf(stdout,"****************************************************\n");
73 ts_fprintf(stdout,"**** Reinitializing initial geometry from tape *****\n");
74 ts_fprintf(stdout,"****************************************************\n\n");
75 vesicle=parsetape(&mcsweeps, &inititer, &iterations);
76 } else {
77
78 ts_fprintf(stdout,"**********************************************************************\n");
79 ts_fprintf(stdout,"**** Recreating vesicle from dump file and continuing simulation *****\n");
80 ts_fprintf(stdout,"**********************************************************************\n\n");
063289 81 vesicle1=parsetape(&mcsweeps, &inititer, &iterations);
86f5e7 82 vesicle=restore_state();
083e03 83 vesicle_free(vesicle1);
SP 84 }
85
86 run_simulation(vesicle, mcsweeps, inititer, iterations);
a6b1b5 87 write_master_xml_file("test.pvd");
3131dc 88 write_dout_fcompat_file(vesicle,"dout");
7958e9 89 vesicle_free(vesicle);
SP 90
d7639a 91 return 0; //program finished perfectly ok. We return 0.
SP 92