Trisurf Monte Carlo simulator
Samo Penic
2014-04-23 f06f5f9ad1e42a10d6a9367513e66c0c06295de2
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"
dc77e8 14 #include "sh.h"
459ff9 15 #include "shcomplex.h"
d7639a 16
SP 17 /** Entrance function to the program
18   * @param argv is a number of parameters used in program call (including the program name
19   * @param argc is a pointer to strings (character arrays) which holds the arguments
20   * @returns returns 0 on success, any other number on fail.
21 */
22
23 int main(int argv, char *argc[]){
1ab449 24     ts_vesicle *vesicle;
SP 25     ts_tape *tape;
8a6614 26     ts_uint start_iteration=0;
152052 27     force_from_tape=0;
8a6614 28     parse_args(argv,argc); // sets global variable command_line_args (defined in io.h)
SP 29     ts_fprintf(stdout,"Starting program...\n\n");
152052 30     if(command_line_args.force_from_tape){
8a6614 31         ts_fprintf(stdout,"************************************************\n");
SP 32         ts_fprintf(stdout,"**** Generating initial geometry from tape *****\n");
33         ts_fprintf(stdout,"************************************************\n\n");
34         tape=parsetape("tape");
35         vesicle=create_vesicle_from_tape(tape);
36     } else {
083e03 37
8a6614 38         ts_fprintf(stdout,"**********************************************************************\n");
SP 39         ts_fprintf(stdout,"**** Recreating vesicle from dump file and continuing simulation *****\n");
40         ts_fprintf(stdout,"**********************************************************************\n\n");
41         tape=parsetape("tape");
42         vesicle=restore_state(&start_iteration);
3f5c83 43         if(vesicle==NULL){
SP 44             ts_fprintf(stderr, "Dump file does not exist or is not a regular file! Did you mean to invoke trisurf with --force-from-tape option?\n\n");
45             return 1;
46         }
152052 47         // nove vrednosti iz tapea...
d9cb01 48         vesicle->bending_rigidity=tape->xk0;
M 49         vtx_set_global_values(vesicle);
bc9583 50         vesicle->pswitch =tape->pswitch;
152052 51         vesicle->pressure=tape->pressure;
2dcc65 52         vesicle->dmax=tape->dmax*tape->dmax;
bcf455 53         poly_assign_filament_xi(vesicle,tape);
ea1cce 54         vesicle->clist->dmin_interspecies = tape->dmin_interspecies*tape->dmin_interspecies;
632960 55         /* spherical harmonics */
SP 56         if(tape->shc>0){
459ff9 57             vesicle->sphHarmonics=complex_sph_init(vesicle->vlist,tape->shc);
632960 58         }
SP 59         else {
60             vesicle->sphHarmonics=NULL;
61         }
d9cb01 62
144784 63         if(command_line_args.reset_iteration_count) start_iteration=tape->inititer;
8a6614 64         else start_iteration++;
083e03 65
8a6614 66         if(start_iteration>=tape->iterations){
SP 67             ts_fprintf(stdout, "Simulation already completed. if you want to rerun it try with --force-from-tape or --reset-iteration-count\n\n");
68             return 0;
69         }
70     }
71
72     run_simulation(vesicle, tape->mcsweeps, tape->inititer, tape->iterations, start_iteration);
73     write_master_xml_file("test.pvd");
74     write_dout_fcompat_file(vesicle,"dout");
75     vesicle_free(vesicle);
76     tape_free(tape);
77     return 0; //program finished perfectly ok. We return 0.
d7639a 78