Trisurf Monte Carlo simulator
Samo Penic
2014-04-28 9166cbcd0e28d61a69646911af35bb7895ff9203
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);
9166cb 54         tape_free(vesicle->tape);
SP 55         vesicle->tape=tape;
ea1cce 56         vesicle->clist->dmin_interspecies = tape->dmin_interspecies*tape->dmin_interspecies;
632960 57         /* spherical harmonics */
SP 58         if(tape->shc>0){
459ff9 59             vesicle->sphHarmonics=complex_sph_init(vesicle->vlist,tape->shc);
632960 60         }
SP 61         else {
62             vesicle->sphHarmonics=NULL;
63         }
d9cb01 64
144784 65         if(command_line_args.reset_iteration_count) start_iteration=tape->inititer;
8a6614 66         else start_iteration++;
083e03 67
8a6614 68         if(start_iteration>=tape->iterations){
SP 69             ts_fprintf(stdout, "Simulation already completed. if you want to rerun it try with --force-from-tape or --reset-iteration-count\n\n");
70             return 0;
71         }
72     }
73
74     run_simulation(vesicle, tape->mcsweeps, tape->inititer, tape->iterations, start_iteration);
75     write_master_xml_file("test.pvd");
76     write_dout_fcompat_file(vesicle,"dout");
77     vesicle_free(vesicle);
78     tape_free(tape);
79     return 0; //program finished perfectly ok. We return 0.
d7639a 80