Trisurf Monte Carlo simulator
Samo Penic
2014-09-11 464443e958f806fdc2b64ae77661a67c199b6204
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");
267db5 35         tape=parsetape(command_line_args.tape_fullfilename);
8a6614 36         vesicle=create_vesicle_from_tape(tape);
SP 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");
267db5 42         tape=parsetape(command_line_args.tape_fullfilename);
8a6614 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         }
a752b5 76
SP 77     /* if requested in tape, we can have smaller number of polymeres attached to membrane than the number of polymeres in dump file */
78         if(vesicle->tape->npoly != vesicle->poly_list->n){
79
80         ts_fprintf(stdout,"(INFO) the number of polymeres attached to membrane in tape is different than a number of polymeres in dump file!\n");
81         if(vesicle->tape->npoly > vesicle->poly_list->n){
82             ts_fprintf(stdout,"(INFO) It is possible to decrease the number of polymeres on the membrane, but it is not allowed to increase its number. The maximal allowed number in tape is %d The execution of program will terminate!\n",vesicle->poly_list->n);
83             fatal("Terminating due to increase of number of polymeres",1);
84         } else {
85             remove_random_polymeres(vesicle->poly_list, vesicle->poly_list->n - vesicle->tape->npoly);
86             ts_fprintf(stdout,"(INFO)\n(INFO) The new number of polymeres from tape is %d.\n\n",vesicle->poly_list->n);
87
88         }
89         }
8a6614 90     }
SP 91
92     run_simulation(vesicle, tape->mcsweeps, tape->inititer, tape->iterations, start_iteration);
267db5 93     write_master_xml_file(command_line_args.output_fullfilename);
8a6614 94     write_dout_fcompat_file(vesicle,"dout");
SP 95     vesicle_free(vesicle);
96     tape_free(tape);
97     return 0; //program finished perfectly ok. We return 0.
d7639a 98