From 2a1e3d528265c3d366dab9ad4b0c4d3d65e1c4ed Mon Sep 17 00:00:00 2001
From: Samo Penic <samo.penic@gmail.com>
Date: Mon, 13 Apr 2020 12:13:50 +0000
Subject: [PATCH] Storing previously debugged version
---
src/cell.c | 6 +-
src/main.c | 1
/dev/null | 90 ------------------------------
src/timestep.c | 3
src/snapshot.c | 2
src/io.c | 25 ++------
src/tape | 10 +-
src/bondflip.c | 6 +-
src/bond.c | 2
src/initial_distribution.c | 3
src/io.h | 1
11 files changed, 23 insertions(+), 126 deletions(-)
diff --git a/src/bond.c b/src/bond.c
index 21b7b56..da963b5 100644
--- a/src/bond.c
+++ b/src/bond.c
@@ -23,7 +23,7 @@
blist->n++;
blist->bond=(ts_bond **)realloc(blist->bond,blist->n*sizeof(ts_bond *));
if(blist->bond==NULL) fatal("Cannot reallocate memory for additional **ts_bond.",100);
- blist->bond[blist->n-1]=(ts_bond *)malloc(sizeof(ts_bond));
+ blist->bond[blist->n-1]=(ts_bond *)calloc(1,sizeof(ts_bond));
if(blist->bond[blist->n-1]==NULL) fatal("Cannot allocate memory for additional *ts_bond.",100);
//NOW insert vertices into data!
diff --git a/src/bondflip.c b/src/bondflip.c
index 13ec263..8eb6da9 100644
--- a/src/bondflip.c
+++ b/src/bondflip.c
@@ -32,7 +32,7 @@
ts_vertex *k=bond->vtx2;
ts_uint nei,neip,neim;
ts_uint i,j;
- ts_double oldenergy, delta_energy, dvol=0.0, darea=0.0;
+ ts_double oldenergy=0.0, delta_energy=0.0, dvol=0.0, darea=0.0;
ts_triangle *lm=NULL,*lp=NULL, *lp1=NULL, *lm2=NULL;
ts_vertex *kp,*km;
@@ -163,7 +163,7 @@
/* end backup vertex */
/* Save old energy */
- oldenergy=0;
+ oldenergy=0.0;
oldenergy+=k->xk* k->energy;
oldenergy+=kp->xk* kp->energy;
oldenergy+=km->xk* km->energy;
@@ -181,7 +181,7 @@
/* Calculating the new energy */
- delta_energy=0;
+ delta_energy=0.0;
delta_energy+=k->xk* k->energy;
delta_energy+=kp->xk* kp->energy;
delta_energy+=km->xk* km->energy;
diff --git a/src/cell.c b/src/cell.c
index 2015be7..3df15ea 100644
--- a/src/cell.c
+++ b/src/cell.c
@@ -6,7 +6,7 @@
ts_cell_list *init_cell_list(ts_uint ncmax1, ts_uint ncmax2, ts_uint ncmax3, ts_double stepsize){
ts_uint i;
ts_uint nocells=ncmax1*ncmax2*ncmax3;
- ts_cell_list *clist=(ts_cell_list *)malloc(sizeof(ts_cell_list));
+ ts_cell_list *clist=(ts_cell_list *)calloc(1,sizeof(ts_cell_list));
if(clist==NULL) fatal("Error while allocating memory for cell list!",100);
clist->ncmax[0]=ncmax1;
@@ -15,8 +15,8 @@
clist->cellno=nocells;
clist->dcell=1.0/(1.0 + stepsize);
clist->shift=(ts_double) clist->ncmax[0]/2;
-
- clist->cell=(ts_cell **)malloc(nocells*sizeof(ts_cell *));
+ clist->max_occupancy=16; /* hard coded max occupancy? */
+ clist->cell=(ts_cell **)calloc(nocells,sizeof(ts_cell *));
if(clist->cell==NULL) fatal("Error while allocating memory for cell list! ncmax too large?",101);
for(i=0;i<nocells;i++){
diff --git a/src/initial_distribution.c b/src/initial_distribution.c
index 87cfb68..21eda68 100644
--- a/src/initial_distribution.c
+++ b/src/initial_distribution.c
@@ -103,7 +103,8 @@
vesicle->clist->ncmax[0]=tape->ncxmax;
vesicle->clist->ncmax[1]=tape->ncymax;
vesicle->clist->ncmax[2]=tape->nczmax;
- vesicle->clist->max_occupancy=16; /* hard coded max occupancy? */
+//THIS IS NOW HARDCODED IN CELL.C
+// vesicle->clist->max_occupancy=16; /* hard coded max occupancy? */
vesicle->pressure= tape->pressure;
vesicle->pswitch=tape->pswitch;
diff --git a/src/io.c b/src/io.c
index 30bd4d6..8fa652c 100644
--- a/src/io.c
+++ b/src/io.c
@@ -424,7 +424,8 @@
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=16;
+//THIS IS HARDCODED IN CELL.C NOW
+// vesicle->clist->max_occupancy=16;
// vesicle->tape=(ts_tape *)malloc(sizeof(ts_tape));
// retval=fread(vesicle->tape, sizeof(ts_tape),1,fh);
retval=fread(iteration,sizeof(ts_uint),1,fh);
@@ -750,22 +751,6 @@
}
-ts_bool write_dout_fcompat_file(ts_vesicle *vesicle, ts_char *filename){
- FILE *fh;
- fh=fopen(filename, "w");
- if(fh==NULL){
- err("Cannot open file %s for writing");
- return TS_FAIL;
- }
- fprintf(fh,"%.17E\n%.17E\n",vesicle->stepsize,vesicle->dmax);
- fprint_vertex_list(fh,vesicle->vlist);
- fprint_tristar(fh,vesicle);
- fprint_triangle_list(fh,vesicle);
- fprint_vertex_data(fh,vesicle->vlist);
- fprint_bonds(fh,vesicle);
- fclose(fh);
- return TS_SUCCESS;
-}
ts_bool read_tape_fcompat_file(ts_vesicle *vesicle, ts_char *filename){
FILE *fh;
@@ -845,7 +830,8 @@
ts_uint monono=0, polyno=0, poly_idx=0, filno=0, fonono=0;
ts_bool poly=0, fil=0;
if(vesicle->poly_list!=NULL){
- if(vesicle->poly_list->poly[0]!=NULL){
+ if(vesicle->poly_list->n!=0){
+ //if(vesicle->poly_list->poly[0]!=NULL){
polyno=vesicle->poly_list->n;
monono=vesicle->poly_list->poly[0]->vlist->n;
poly=1;
@@ -853,7 +839,8 @@
}
if(vesicle->filament_list!=NULL){
- if(vesicle->filament_list->poly[0]!=NULL){
+ if(vesicle->filament_list->n!=0){
+ //if(vesicle->filament_list->poly[0]!=NULL){
filno=vesicle->filament_list->n;
fonono=vesicle->filament_list->poly[0]->vlist->n;
fil=1;
diff --git a/src/io.h b/src/io.h
index 6ca8331..265992b 100644
--- a/src/io.h
+++ b/src/io.h
@@ -61,7 +61,6 @@
ts_bool fprint_triangle_list(FILE *fh, ts_vesicle *vesicle);
ts_bool fprint_vertex_data(FILE *fh,ts_vertex_list *vlist);
ts_bool fprint_bonds(FILE *fh,ts_vesicle *vesicle);
-ts_bool write_dout_fcompat_file(ts_vesicle *vesicle, ts_char *filename);
ts_bool read_tape_fcompat_file(ts_vesicle *vesicle, ts_char *filename);
diff --git a/src/main.c b/src/main.c
index 3f91f43..ee462aa 100644
--- a/src/main.c
+++ b/src/main.c
@@ -133,7 +133,6 @@
//write_vertex_xml_file(vesicle,1000);
run_simulation(vesicle, tape->mcsweeps, tape->inititer, tape->iterations, start_iteration);
write_master_xml_file(command_line_args.output_fullfilename);
- write_dout_fcompat_file(vesicle,"dout");
vesicle_free(vesicle);
tape_free(tape);
return 0; //program finished perfectly ok. We return 0.
diff --git a/src/snapshot.c b/src/snapshot.c
index da21498..46534dc 100644
--- a/src/snapshot.c
+++ b/src/snapshot.c
@@ -23,7 +23,7 @@
/* outputs additional data into paraview xml file */
ts_bool xml_trisurf_data(FILE *fh, ts_vesicle *vesicle){
- ts_string *data=(ts_string *)malloc(sizeof(ts_sprintf));
+ ts_string *data=(ts_string *)malloc(sizeof(ts_string));
data->string=(char *)malloc(5120000*sizeof(char)); /*TODO: warning, can break if the string is to long */
data->beg=0;
diff --git a/src/spherical_trisurf.c b/src/spherical_trisurf.c
deleted file mode 100644
index 06a84f4..0000000
--- a/src/spherical_trisurf.c
+++ /dev/null
@@ -1,107 +0,0 @@
-/* vim: set ts=4 sts=4 sw=4 noet : */
-#include<stdio.h>
-#include<math.h>
-#include "general.h"
-#include "vertex.h"
-#include "bond.h"
-#include "triangle.h"
-#include "cell.h"
-#include "vesicle.h"
-#include "io.h"
-#include "initial_distribution.h"
-#include "frame.h"
-#include "timestep.h"
-#include "sh.h"
-
-/** Entrance function to the program
- * @param argv is a number of parameters used in program call (including the program name
- * @param argc is a pointer to strings (character arrays) which holds the arguments
- * @returns returns 0 on success, any other number on fail.
-*/
-ts_bool saveAvgUlm2(ts_vesicle *vesicle);
-int main(int argv, char *argc[]){
-ts_uint i,j,k;
-ts_vesicle *vesicle;
-ts_double r0;
-vesicle=initial_distribution_dipyramid(17,60,60,60,0.15);
-//parsetape(vesicle,&i);
-
-//similar to nmax in fortran code
-ts_uint nmax;
-
-//these four must come from parsetype!
-vesicle->dmax=1.67*1.67;
-vesicle->stepsize=0.15;
-vesicle->clist->max_occupancy=8;
-vesicle->bending_rigidity=25.0;
-//fprintf(stderr,"xk=%f",vesicle->bending_rigidity);
-
- centermass(vesicle);
-cell_occupation(vesicle);
-
-//test if the structure is internally organized into cells correctly
-ts_uint cind;
-for(i=0;i<vesicle->vlist->n;i++){
- cind=vertex_self_avoidance(vesicle, vesicle->vlist->vtx[i]);
-
- if(vesicle->clist->cell[cind]==vesicle->vlist->vtx[i]->cell){
- //fprintf(stdout,"(T) Idx match!\n");
- } else {
- fprintf(stderr,"(T) ***** Idx don't match!\n");
-
- }
-}
-//end test
-vesicle->sphHarmonics=sph_init(vesicle->vlist, 21);
-
-vesicle_volume(vesicle);
-r0=getR0(vesicle);
-
-preparationSh(vesicle,r0);
-calculateYlmi(vesicle);
-calculateUlm(vesicle);
-
-//preloop:
-ts_double vmsr, bfsr;
-for(i=0;i<1000;i++){
- cell_occupation(vesicle);
- for(j=0;j<1000;j++){
- single_timestep(vesicle, &vmsr, &bfsr);
- }
- centermass(vesicle);
- fprintf(stderr, "Preloop %d completed.\n",i+1);
-}
-
-nmax=1000;
-for(i=0;i<nmax;i++){
- for(j=0;j<200;j++){
- cell_occupation(vesicle);
- for(k=0;k<5;k++){
- single_timestep(vesicle, &vmsr, &bfsr);
- }
- centermass(vesicle);
- }
- vesicle_volume(vesicle);
- r0=getR0(vesicle);
-
- preparationSh(vesicle,r0);
- calculateYlmi(vesicle);
- calculateUlm(vesicle);
-
- storeUlm2(vesicle);
- saveAvgUlm2(vesicle);
-
- write_vertex_xml_file(vesicle,i);
- fprintf(stderr, "Loop %d out of %d completed.\n",i+1,nmax);
-
-}
-
-write_master_xml_file("test.pvd");
-write_dout_fcompat_file(vesicle,"dout");
-vesicle_free(vesicle);
-
-return 0; //program finished perfectly ok. We return 0.
-}
-
-
-
diff --git a/src/spherical_trisurf_ff.c b/src/spherical_trisurf_ff.c
deleted file mode 100644
index 8a0902f..0000000
--- a/src/spherical_trisurf_ff.c
+++ /dev/null
@@ -1,90 +0,0 @@
-/* vim: set ts=4 sts=4 sw=4 noet : */
-#include<stdio.h>
-#include<math.h>
-#include "general.h"
-#include "vertex.h"
-#include "bond.h"
-#include "triangle.h"
-#include "cell.h"
-#include "vesicle.h"
-#include "io.h"
-#include "initial_distribution.h"
-#include "frame.h"
-#include "timestep.h"
-#include "sh.h"
-
-/** Entrance function to the program
- * @param argv is a number of parameters used in program call (including the program name
- * @param argc is a pointer to strings (character arrays) which holds the arguments
- * @returns returns 0 on success, any other number on fail.
-*/
-ts_bool saveAvgUlm2(ts_vesicle *vesicle);
-int main(int argv, char *argc[]){
-ts_uint i,j;
-ts_vesicle *vesicle;
-ts_double r0;
-vesicle=initial_distribution_dipyramid(17,60,60,60,0.15);
-//parsetape(vesicle,&i);
-
-//these four must come from parsetype!
-vesicle->dmax=1.67*1.67;
-vesicle->stepsize=0.15;
-vesicle->clist->max_occupancy=8;
-vesicle->bending_rigidity=30.0*30.0;
-for(i=0;i<vesicle->vlist->n;i++){
- vesicle->vlist->vtx[i]->xk=vesicle->bending_rigidity;
-}
-//fprintf(stderr,"xk=%f",vesicle->bending_rigidity);
-
- centermass(vesicle);
-vesicle->sphHarmonics=sph_init(vesicle->vlist, 21);
-
-vesicle_volume(vesicle);
-r0=getR0(vesicle);
-
-preparationSh(vesicle,r0);
-calculateYlmi(vesicle);
-calculateUlm(vesicle);
-ts_double vmsr,bfsr;
-for(i=0;i<500;i++){
- cell_occupation(vesicle);
- for(j=0;j<1000;j++){
- single_timestep(vesicle,&vmsr,&bfsr);
- }
- centermass(vesicle);
- fprintf(stderr, "Preloop %d completed.\n",i+1);
-}
-
-vesicle->bending_rigidity=25.0;
-for(i=0;i<vesicle->vlist->n;i++){
- vesicle->vlist->vtx[i]->xk=vesicle->bending_rigidity;
-}
-
-
-for(i=0;i<10000;i++){
- cell_occupation(vesicle);
- for(j=0;j<1000;j++){
- single_timestep(vesicle,&vmsr,&bfsr);
- }
- centermass(vesicle);
- vesicle_volume(vesicle);
- r0=getR0(vesicle);
-
- preparationSh(vesicle,r0);
- calculateYlmi(vesicle);
- calculateUlm(vesicle);
-
- storeUlm2(vesicle);
- saveAvgUlm2(vesicle);
-
- write_vertex_xml_file(vesicle,i);
- fprintf(stderr, "Loop %d completed.\n",i+1);
-}
-write_master_xml_file("test.pvd");
-write_dout_fcompat_file(vesicle,"dout");
-vesicle_free(vesicle);
-
-return 0; //program finished perfectly ok. We return 0.
-}
-
-
diff --git a/src/tape b/src/tape
index bdce9e7..d2965a6 100644
--- a/src/tape
+++ b/src/tape
@@ -1,6 +1,6 @@
####### Vesicle definitions ###########
# nshell is a number of divisions of dipyramid
-nshell=17
+nshell=7
# dmax is the max. bond length (in units l_min)
dmax=1.7
# dmin_interspecies in the min. dist. between different vertex species (in units l_min)
@@ -25,7 +25,7 @@
#Stretching
-stretchswitch=1
+stretchswitch=0
xkA0=1.0
####### Polymer (brush) definitions ###########
@@ -67,7 +67,7 @@
inititer=0
#how many records do you want on the disk iteration are there in a run?
#10000
-iterations=100
+iterations=10
###### Spherical harmonics ###########
@@ -92,7 +92,7 @@
#number of vertices with spontaneous curvature (integer)
-number_of_vertices_with_c0=100
+number_of_vertices_with_c0=0
#c0/2 is spontaneous curvature. c0 is used as (c1+c1-c0)^2 in energy term (float)
c0=0.5
#energy of attraction of vertices with spontaneous curvature (float, positive value for attraction)
@@ -103,7 +103,7 @@
#plane confinement
-plane_confinement_switch=1
+plane_confinement_switch=0
#final plane distance (float in lmin)
plane_d=10
#plane to vesicle repulsion force while closing
diff --git a/src/timestep.c b/src/timestep.c
index 81101bf..66b3a39 100644
--- a/src/timestep.c
+++ b/src/timestep.c
@@ -124,7 +124,8 @@
bfsr/=(ts_double)mcsweeps;
centermass(vesicle);
cell_occupation(vesicle);
- dump_state(vesicle,i);
+/* BINARY DUMPS ARE OBSOLETE. SHOULD WORK AS OF MAR 2020, BUT NO LONGER MAINTAINED */
+// dump_state(vesicle,i);
vesicle_volume(vesicle); //calculates just volume.
vesicle_area(vesicle); //calculates area.
if(vesicle->tape->constvolswitch==0){
--
Gitblit v1.8.0