Trisurf Monte Carlo simulator
Samo Penic
2014-09-11 267db570e1ff394eca2f26ace11188e3b113577e
Command line parameters parsing works. Also, filenames and directories are customizable now.
4 files modified
51 ■■■■■ changed files
src/io.c 17 ●●●●● patch | view | raw | blame | history
src/main.c 6 ●●●● patch | view | raw | blame | history
src/sh.c 9 ●●●●● patch | view | raw | blame | history
src/timestep.c 19 ●●●●● patch | view | raw | blame | history
src/io.c
@@ -21,7 +21,7 @@
    /* save current state with wrong pointers. Will fix that later */
    ts_uint i,j,k;
    FILE *fh=fopen("dump.bin","wb");
    FILE *fh=fopen(command_line_args.dump_fullfilename,"wb");
    /* dump vesicle */
    fwrite(vesicle, sizeof(ts_vesicle),1,fh);
@@ -180,10 +180,10 @@
/** RESTORE DUMP FROM DISK **/
ts_vesicle *restore_state(ts_uint *iteration){
    ts_uint i,j,k;
    FILE *fh=fopen("dump.bin","rb");
    FILE *fh=fopen(command_line_args.dump_fullfilename,"rb");
    struct stat sb;
    if (stat("dump.bin", &sb) == -1) {
    if (stat(command_line_args.dump_fullfilename, &sb) == -1) {
        //dump file does not exist.
        return NULL;
    }
@@ -418,7 +418,7 @@
                vesicle->filament_list->poly[i]->blist->bond[j]->vtx2=vesicle->filament_list->poly[i]->vlist->vtx[idx];
        }
    }
    vesicle->tape=parsetape("tape");
    vesicle->tape=parsetape(command_line_args.tape_fullfilename);
// recreating space for cells // 
    vesicle->clist=init_cell_list(vesicle->tape->ncxmax, vesicle->tape->ncymax, vesicle->tape->nczmax, vesicle->tape->stepsize);
    vesicle->clist->max_occupancy=8;
@@ -745,7 +745,7 @@
        }
    fprintf(fh,"<?xml version=\"1.0\"?>\n<VTKFile type=\"Collection\" version=\"0.1\" byte_order=\"LittleEndian\" compressor=\"vtkZLibDataCompressor\">\n<Collection>");
    DIR *dir = opendir(".");
    DIR *dir = opendir(command_line_args.path);
    if(dir){
        struct dirent *ent;
        tstep=0;
@@ -774,10 +774,13 @@
    ts_bond_list *blist=vesicle->blist;
    ts_vertex **vtx=vlist->vtx;
    ts_uint i,j;
        char filename[255];
        char filename[10000];
        char just_name[255];
    FILE *fh;
        strcpy(filename,command_line_args.path);
        sprintf(just_name,"timestep_%.6u.vtu",timestepno);
        strcat(filename,just_name);
        sprintf(filename,"timestep_%.6u.vtu",timestepno);
    fh=fopen(filename, "w");
    if(fh==NULL){
        err("Cannot open file %s for writing");
src/main.c
@@ -32,14 +32,14 @@
        ts_fprintf(stdout,"************************************************\n");
        ts_fprintf(stdout,"**** Generating initial geometry from tape *****\n");
        ts_fprintf(stdout,"************************************************\n\n");
        tape=parsetape("tape");
        tape=parsetape(command_line_args.tape_fullfilename);
        vesicle=create_vesicle_from_tape(tape);
    } else {
        ts_fprintf(stdout,"**********************************************************************\n");
        ts_fprintf(stdout,"**** Recreating vesicle from dump file and continuing simulation *****\n");
        ts_fprintf(stdout,"**********************************************************************\n\n");
        tape=parsetape("tape");
        tape=parsetape(command_line_args.tape_fullfilename);
        vesicle=restore_state(&start_iteration);
        if(vesicle==NULL){
            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");
@@ -90,7 +90,7 @@
    }
    run_simulation(vesicle, tape->mcsweeps, tape->inititer, tape->iterations, start_iteration);
    write_master_xml_file("test.pvd");
    write_master_xml_file(command_line_args.output_fullfilename);
    write_dout_fcompat_file(vesicle,"dout");
    vesicle_free(vesicle);
    tape_free(tape);
src/sh.c
@@ -2,7 +2,8 @@
#include<stdlib.h>
#include "general.h"
#include "sh.h"
#include "io.h"
#include <string.h>
ts_spharm *sph_init(ts_vertex_list *vlist, ts_uint l){
@@ -402,8 +403,10 @@
ts_bool saveAvgUlm2(ts_vesicle *vesicle){
    FILE *fh;
    fh=fopen("sph2out.dat", "w");
    char filename[10000];
    strcpy(filename, command_line_args.path);
    strcat(filename, "sph2out.dat");
    fh=fopen(filename, "w");
    if(fh==NULL){
        err("Cannot open file %s for writing");
        return TS_FAIL;
src/timestep.c
@@ -14,7 +14,7 @@
#include "vesicle.h"
#include<gsl/gsl_complex.h>
#include<gsl/gsl_complex_math.h>
#include<string.h>
ts_bool run_simulation(ts_vesicle *vesicle, ts_uint mcsweeps, ts_uint inititer, ts_uint iterations, ts_uint start_iteration){
    ts_uint i, j,k,l,m;
@@ -22,15 +22,19 @@
    ts_double l1,l2,l3,volume=0.0,area=0.0,vmsr,bfsr, vmsrt, bfsrt;
    ts_ulong epochtime;
    FILE *fd1,*fd2=NULL;
//     char filename[255];
    FILE *fd=fopen("statistics.csv","w");
     char filename[10000];
    strcpy(filename,command_line_args.path);
    strcat(filename,"statistics.csv");
    FILE *fd=fopen(filename,"w");
    if(fd==NULL){
        fatal("Cannot open statistics.csv file for writing",1);
    }
    fprintf(fd, "Epoch OuterLoop VertexMoveSucessRate BondFlipSuccessRate Volume Area lamdba1 lambda2 lambda3 Kc(2-9) Kc(6-9) Kc(2-end) Kc(3-6)\n");
     if(vesicle->sphHarmonics!=NULL){
        fd2=fopen("ulm2.csv","w");
        strcpy(filename,command_line_args.path);
        strcat(filename,"ulm2.csv");
        fd2=fopen(filename,"w");
        if(fd2==NULL){
            fatal("Cannot open ulm2.csv file for writing",1);
        }
@@ -70,7 +74,7 @@
            dump_state(vesicle,i);
        if(i>=inititer){
            write_vertex_xml_file(vesicle,i-inititer);
            write_master_xml_file("test.pvd");
            write_master_xml_file(command_line_args.output_fullfilename);
            epochtime=get_epoch();            
            gyration_eigen(vesicle, &l1, &l2, &l3);
            vesicle_volume(vesicle); //calculates just volume. Area is not added to ts_vesicle yet!
@@ -86,8 +90,9 @@
                kc2=calculateKc(vesicle, 6,9);
                kc3=calculateKc(vesicle, 2,vesicle->sphHarmonics->l);
                kc4=calculateKc(vesicle, 3,6);
                fd1=fopen("state.dat","w");
                strcpy(filename,command_line_args.path);
                strcat(filename,"state.dat");
                fd1=fopen(filename,"w");
                fprintf(fd1,"%e %e\n",vesicle->volume, getR0(vesicle));
                for(k=0;k<vesicle->vlist->n;k++){
                    fprintf(fd1,"%e %e %e %e %e\n",