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