Trisurf Monte Carlo simulator
Samo Penic
2019-02-28 b5cd8cc72380e9ca576ec942753391df85a2a436
Many new plugins :D
2 files added
7 files modified
186 ■■■■ changed files
src/general.h 1 ●●●● patch | view | raw | blame | history
src/main.c 7 ●●●● patch | view | raw | blame | history
src/plugins/Makefile 33 ●●●●● patch | view | raw | blame | history
src/plugins/Makefile.am 9 ●●●● patch | view | raw | blame | history
src/plugins/Makefile.in 33 ●●●●● patch | view | raw | blame | history
src/plugins/default_hard_constraints.c 16 ●●●●● patch | view | raw | blame | history
src/plugins/nucleus.c 33 ●●●●● patch | view | raw | blame | history
src/plugins/plane_confinement.c 26 ●●●●● patch | view | raw | blame | history
src/vertexmove.c 28 ●●●● patch | view | raw | blame | history
src/general.h
@@ -340,6 +340,7 @@
typedef struct {
    ts_plugin_chain *at_start;
    ts_plugin_chain *after_vesicle_init;
    ts_plugin_chain *vm_hard_constraint;
    ts_plugin_chain *cleanup;
} ts_plugin_chains;
src/main.c
@@ -28,12 +28,15 @@
int main(int argv, char *argc[]){
    ts_char *plugin0 = (ts_char *)calloc(255,sizeof(ts_char));
    ts_char *plugin1 = (ts_char *)calloc(255,sizeof(ts_char));
    ts_char *plugin2 = (ts_char *)calloc(255,sizeof(ts_char));
    strcpy(plugin0,"/home/samo/programiranje/trisurf-ng/src/plugins/.libs/demoplugin.so");
    strcpy(plugin1,"/home/samo/programiranje/trisurf-ng/src/plugins/.libs/vmdefaulthardconstraints.so");
    ts_char **plugins=(ts_char **)calloc(2,sizeof(ts_char *));
    strcpy(plugin2,"/home/samo/programiranje/trisurf-ng/src/plugins/.libs/plane_confinement.so");
    ts_char **plugins=(ts_char **)calloc(3,sizeof(ts_char *));
    *plugins=plugin0;
    plugins[1]=plugin1;
    ts_plugin_list *plist=init_plugin_list(plugins,2);
    plugins[2]=plugin2;
    ts_plugin_list *plist=init_plugin_list(plugins,3);
    //printf("%s", plist->chain->at_start->next->plugin->filename);
    //ts_fprintf(stdout, "TRISURF in PRVI PLUGIN %s\n", plist->plugin[0]->details->name);
    ts_vesicle *vesicle;
src/plugins/Makefile
@@ -137,6 +137,19 @@
demoplugin_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
    $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
    $(demoplugin_la_LDFLAGS) $(LDFLAGS) -o $@
nucleus_la_LIBADD =
am_nucleus_la_OBJECTS = nucleus.lo
nucleus_la_OBJECTS = $(am_nucleus_la_OBJECTS)
nucleus_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
    $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
    $(nucleus_la_LDFLAGS) $(LDFLAGS) -o $@
plane_confinement_la_LIBADD =
am_plane_confinement_la_OBJECTS = plane_confinement.lo
plane_confinement_la_OBJECTS = $(am_plane_confinement_la_OBJECTS)
plane_confinement_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC \
    $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CCLD) \
    $(AM_CFLAGS) $(CFLAGS) $(plane_confinement_la_LDFLAGS) \
    $(LDFLAGS) -o $@
vmdefaulthardconstraints_la_LIBADD =
am_vmdefaulthardconstraints_la_OBJECTS = default_hard_constraints.lo
vmdefaulthardconstraints_la_OBJECTS =  \
@@ -179,9 +192,11 @@
am__v_CCLD_ = $(am__v_CCLD_$(AM_DEFAULT_VERBOSITY))
am__v_CCLD_0 = @echo "  CCLD    " $@;
am__v_CCLD_1 = 
SOURCES = $(demoplugin_la_SOURCES) \
SOURCES = $(demoplugin_la_SOURCES) $(nucleus_la_SOURCES) \
    $(plane_confinement_la_SOURCES) \
    $(vmdefaulthardconstraints_la_SOURCES)
DIST_SOURCES = $(demoplugin_la_SOURCES) \
DIST_SOURCES = $(demoplugin_la_SOURCES) $(nucleus_la_SOURCES) \
    $(plane_confinement_la_SOURCES) \
    $(vmdefaulthardconstraints_la_SOURCES)
am__can_run_installinfo = \
  case $$AM_UPDATE_INFO_DIR in \
@@ -331,11 +346,15 @@
top_builddir = ../..
top_srcdir = ../..
AM_CFLAGS = -Wall -Werror -DTS_VERSION=\"$(GITVERSION)\" -fgnu89-inline -Wno-error=date-time -I..
lib_LTLIBRARIES = demoplugin.la vmdefaulthardconstraints.la
lib_LTLIBRARIES = demoplugin.la vmdefaulthardconstraints.la nucleus.la plane_confinement.la
demoplugin_la_SOURCES = demo_plugin.c
demoplugin_la_LDFLAGS = -module -avoid-version -export-dynamic
vmdefaulthardconstraints_la_SOURCES = default_hard_constraints.c
vmdefaulthardconstraints_la_LDFLAGS = -module -avoid-version -export-dynamic
nucleus_la_SOURCES = nucleus.c
nucleus_la_LDFLAGS = -module -avoid-version -export-dynamic
plane_confinement_la_SOURCES = plane_confinement.c
plane_confinement_la_LDFLAGS = -module -avoid-version -export-dynamic
all: all-am
.SUFFIXES:
@@ -408,6 +427,12 @@
demoplugin.la: $(demoplugin_la_OBJECTS) $(demoplugin_la_DEPENDENCIES) $(EXTRA_demoplugin_la_DEPENDENCIES) 
    $(AM_V_CCLD)$(demoplugin_la_LINK) -rpath $(libdir) $(demoplugin_la_OBJECTS) $(demoplugin_la_LIBADD) $(LIBS)
nucleus.la: $(nucleus_la_OBJECTS) $(nucleus_la_DEPENDENCIES) $(EXTRA_nucleus_la_DEPENDENCIES)
    $(AM_V_CCLD)$(nucleus_la_LINK) -rpath $(libdir) $(nucleus_la_OBJECTS) $(nucleus_la_LIBADD) $(LIBS)
plane_confinement.la: $(plane_confinement_la_OBJECTS) $(plane_confinement_la_DEPENDENCIES) $(EXTRA_plane_confinement_la_DEPENDENCIES)
    $(AM_V_CCLD)$(plane_confinement_la_LINK) -rpath $(libdir) $(plane_confinement_la_OBJECTS) $(plane_confinement_la_LIBADD) $(LIBS)
vmdefaulthardconstraints.la: $(vmdefaulthardconstraints_la_OBJECTS) $(vmdefaulthardconstraints_la_DEPENDENCIES) $(EXTRA_vmdefaulthardconstraints_la_DEPENDENCIES) 
    $(AM_V_CCLD)$(vmdefaulthardconstraints_la_LINK) -rpath $(libdir) $(vmdefaulthardconstraints_la_OBJECTS) $(vmdefaulthardconstraints_la_LIBADD) $(LIBS)
@@ -419,6 +444,8 @@
include ./$(DEPDIR)/default_hard_constraints.Plo
include ./$(DEPDIR)/demo_plugin.Plo
include ./$(DEPDIR)/nucleus.Plo
include ./$(DEPDIR)/plane_confinement.Plo
.c.o:
    $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
src/plugins/Makefile.am
@@ -1,7 +1,14 @@
AM_CFLAGS = -Wall -Werror -DTS_VERSION=\"$(GITVERSION)\" -fgnu89-inline -Wno-error=date-time -I..
lib_LTLIBRARIES= demoplugin.la vmdefaulthardconstraints.la
lib_LTLIBRARIES= demoplugin.la vmdefaulthardconstraints.la nucleus.la plane_confinement.la
demoplugin_la_SOURCES= demo_plugin.c
demoplugin_la_LDFLAGS = -module -avoid-version -export-dynamic
vmdefaulthardconstraints_la_SOURCES = default_hard_constraints.c
vmdefaulthardconstraints_la_LDFLAGS = -module -avoid-version -export-dynamic
nucleus_la_SOURCES = nucleus.c
nucleus_la_LDFLAGS = -module -avoid-version -export-dynamic
plane_confinement_la_SOURCES = plane_confinement.c
plane_confinement_la_LDFLAGS = -module -avoid-version -export-dynamic
src/plugins/Makefile.in
@@ -137,6 +137,19 @@
demoplugin_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
    $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
    $(demoplugin_la_LDFLAGS) $(LDFLAGS) -o $@
nucleus_la_LIBADD =
am_nucleus_la_OBJECTS = nucleus.lo
nucleus_la_OBJECTS = $(am_nucleus_la_OBJECTS)
nucleus_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
    $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
    $(nucleus_la_LDFLAGS) $(LDFLAGS) -o $@
plane_confinement_la_LIBADD =
am_plane_confinement_la_OBJECTS = plane_confinement.lo
plane_confinement_la_OBJECTS = $(am_plane_confinement_la_OBJECTS)
plane_confinement_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC \
    $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CCLD) \
    $(AM_CFLAGS) $(CFLAGS) $(plane_confinement_la_LDFLAGS) \
    $(LDFLAGS) -o $@
vmdefaulthardconstraints_la_LIBADD =
am_vmdefaulthardconstraints_la_OBJECTS = default_hard_constraints.lo
vmdefaulthardconstraints_la_OBJECTS =  \
@@ -179,9 +192,11 @@
am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@)
am__v_CCLD_0 = @echo "  CCLD    " $@;
am__v_CCLD_1 = 
SOURCES = $(demoplugin_la_SOURCES) \
SOURCES = $(demoplugin_la_SOURCES) $(nucleus_la_SOURCES) \
    $(plane_confinement_la_SOURCES) \
    $(vmdefaulthardconstraints_la_SOURCES)
DIST_SOURCES = $(demoplugin_la_SOURCES) \
DIST_SOURCES = $(demoplugin_la_SOURCES) $(nucleus_la_SOURCES) \
    $(plane_confinement_la_SOURCES) \
    $(vmdefaulthardconstraints_la_SOURCES)
am__can_run_installinfo = \
  case $$AM_UPDATE_INFO_DIR in \
@@ -331,11 +346,15 @@
top_builddir = @top_builddir@
top_srcdir = @top_srcdir@
AM_CFLAGS = -Wall -Werror -DTS_VERSION=\"$(GITVERSION)\" -fgnu89-inline -Wno-error=date-time -I..
lib_LTLIBRARIES = demoplugin.la vmdefaulthardconstraints.la
lib_LTLIBRARIES = demoplugin.la vmdefaulthardconstraints.la nucleus.la plane_confinement.la
demoplugin_la_SOURCES = demo_plugin.c
demoplugin_la_LDFLAGS = -module -avoid-version -export-dynamic
vmdefaulthardconstraints_la_SOURCES = default_hard_constraints.c
vmdefaulthardconstraints_la_LDFLAGS = -module -avoid-version -export-dynamic
nucleus_la_SOURCES = nucleus.c
nucleus_la_LDFLAGS = -module -avoid-version -export-dynamic
plane_confinement_la_SOURCES = plane_confinement.c
plane_confinement_la_LDFLAGS = -module -avoid-version -export-dynamic
all: all-am
.SUFFIXES:
@@ -408,6 +427,12 @@
demoplugin.la: $(demoplugin_la_OBJECTS) $(demoplugin_la_DEPENDENCIES) $(EXTRA_demoplugin_la_DEPENDENCIES) 
    $(AM_V_CCLD)$(demoplugin_la_LINK) -rpath $(libdir) $(demoplugin_la_OBJECTS) $(demoplugin_la_LIBADD) $(LIBS)
nucleus.la: $(nucleus_la_OBJECTS) $(nucleus_la_DEPENDENCIES) $(EXTRA_nucleus_la_DEPENDENCIES)
    $(AM_V_CCLD)$(nucleus_la_LINK) -rpath $(libdir) $(nucleus_la_OBJECTS) $(nucleus_la_LIBADD) $(LIBS)
plane_confinement.la: $(plane_confinement_la_OBJECTS) $(plane_confinement_la_DEPENDENCIES) $(EXTRA_plane_confinement_la_DEPENDENCIES)
    $(AM_V_CCLD)$(plane_confinement_la_LINK) -rpath $(libdir) $(plane_confinement_la_OBJECTS) $(plane_confinement_la_LIBADD) $(LIBS)
vmdefaulthardconstraints.la: $(vmdefaulthardconstraints_la_OBJECTS) $(vmdefaulthardconstraints_la_DEPENDENCIES) $(EXTRA_vmdefaulthardconstraints_la_DEPENDENCIES) 
    $(AM_V_CCLD)$(vmdefaulthardconstraints_la_LINK) -rpath $(libdir) $(vmdefaulthardconstraints_la_OBJECTS) $(vmdefaulthardconstraints_la_LIBADD) $(LIBS)
@@ -419,6 +444,8 @@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/default_hard_constraints.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/demo_plugin.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/nucleus.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/plane_confinement.Plo@am__quote@
.c.o:
@am__fastdepCC_TRUE@    $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
src/plugins/default_hard_constraints.c
@@ -4,23 +4,13 @@
#include "vertex.h"
#include "cell.h"
char plugin_name[] = "Default hard constraints for vertex move";
char plugin_description[]= "Checks proximity with neighbors and with foreign vertices";
char plugin_description[]= "Checks proximity with neighbors, vertices in neighboring cells and with foreign vertices that may be in vicinity";
char plugin_author[] = "SAMO PENIC";
ts_plugin_details *init (){
//    ts_fprintf(stdout,"Hello. Plugin %s is initiating. This will load the details section of the plugin\n", plugin_name);
    ts_plugin_details *details=(ts_plugin_details *)calloc(1,sizeof(ts_plugin_details));
    details->name = plugin_name;
    return details;    
}
void at_start(int argc, char **argv){
}
void *after_vesicle_init(ts_vesicle *vesicle){
    ts_fprintf(stdout,"Plugin \"%s\" is loaded.\n", plugin_name);
    return vesicle;
}
ts_bool vm_hard_constraint(ts_vesicle *vesicle, ts_vertex *vtx, ts_vertex *ovtx){
@@ -28,7 +18,6 @@
    ts_uint cellidx;
    ts_double dist;
    ts_bool retval;
//distance with neighbours check
    for(i=0;i<vtx->neigh_no;i++){
        dist=vtx_distance_sq(vtx,vtx->neigh[i]);
@@ -55,6 +44,3 @@
    return TS_SUCCESS;
}
void cleanup(){
    ts_fprintf(stdout,"Goodbye from plugin %s. This functions clears what would be created in init...\n",plugin_name);
}
src/plugins/nucleus.c
New file
@@ -0,0 +1,33 @@
#include "plugins.h"
#include <stdlib.h>
#include "general.h"
#include "vertex.h"
#include "cell.h"
char plugin_name[] = "Nucleus";
char plugin_description[]= "This plugin adds nucleus to the center of the vesicle. For now only vertexmove constraint is implemented.";
char plugin_author[] = "SAMO PENIC";
ts_plugin_details *init (){
    ts_plugin_details *details=(ts_plugin_details *)calloc(1,sizeof(ts_plugin_details));
    details->name = plugin_name;
    return details;
}
ts_bool vm_hard_constraint(ts_vesicle *vesicle, ts_vertex *vtx, ts_vertex *ovtx){
// TODO: Maybe faster if checks only nucleus-neighboring cells
// Nucleus penetration check:
//#define SQ(x) x*x
if(vesicle->R_nucleus>0.0){
    if ((vtx->x-vesicle->nucleus_center[0])*(vtx->x-vesicle->nucleus_center[0])+ (vtx->y-vesicle->nucleus_center[1])*(vtx->y-vesicle->nucleus_center[1]) + (vtx->z-vesicle->nucleus_center[2])*(vtx->z-vesicle->nucleus_center[2]) < vesicle->R_nucleus){
        return TS_FAIL;
    }
} else if(vesicle->R_nucleusX>0.0){
    if ((vtx->x-vesicle->nucleus_center[0])*(vtx->x-vesicle->nucleus_center[0])/vesicle->R_nucleusX + (vtx->y-vesicle->nucleus_center[1])*(vtx->y-vesicle->nucleus_center[1])/vesicle->R_nucleusY + (vtx->z-vesicle->nucleus_center[2])*(vtx->z-vesicle->nucleus_center[2])/vesicle->R_nucleusZ < 1.0){
        return TS_FAIL;
    }
}
    return TS_SUCCESS;
}
src/plugins/plane_confinement.c
New file
@@ -0,0 +1,26 @@
#include <stdlib.h>
#include "general.h"
#include "vertex.h"
#include "cell.h"
char plugin_name[] = "Plane confimenent";
char plugin_description[]= "Confines vesicle between two planes d/2 above z=0 and d/2 below z=0. The plates squeeze vesicle with some predefined force.";
char plugin_author[] = "SAMO PENIC";
ts_plugin_details *init (){
    ts_plugin_details *details=(ts_plugin_details *)calloc(1,sizeof(ts_plugin_details));
    details->name = plugin_name;
    return details;
}
ts_bool vm_hard_constraint(ts_vesicle *vesicle, ts_vertex *vtx, ts_vertex *ovtx){
// plane confinement check whether the new position of vertex will be out of bounds
    if(vesicle->tape->plane_confinement_switch){
        if(vtx->z>vesicle->confinement_plane.z_max || vtx->z<vesicle->confinement_plane.z_min){
        return TS_FAIL;
        }
    }
    return TS_SUCCESS;
}
src/vertexmove.c
@@ -35,26 +35,6 @@
    vtx->y=vtx->y+r*sintheta*sin(phi);
    vtx->z=vtx->z+r*costheta;
// TODO: Maybe faster if checks only nucleus-neighboring cells
// Nucleus penetration check:
//#define SQ(x) x*x
if(vesicle->R_nucleus>0.0){
    if ((vtx->x-vesicle->nucleus_center[0])*(vtx->x-vesicle->nucleus_center[0])+ (vtx->y-vesicle->nucleus_center[1])*(vtx->y-vesicle->nucleus_center[1]) + (vtx->z-vesicle->nucleus_center[2])*(vtx->z-vesicle->nucleus_center[2]) < vesicle->R_nucleus){
        vtx=memcpy((void *)vtx,(void *)&backupvtx[0],sizeof(ts_vertex));
        return TS_FAIL;
    }
} else if(vesicle->R_nucleusX>0.0){
//    fprintf(stderr,"DEBUG, (Rx, Ry,Rz)^2=(%f,%f,%f)\n",vesicle->R_nucleusX, vesicle->R_nucleusY, vesicle->R_nucleusZ);
//    if (SQ(vtx->x-vesicle->nucleus_center[0])/vesicle->R_nucleusX + SQ(vtx->y-vesicle->nucleus_center[1])/vesicle->R_nucleusY + SQ(vtx->z-vesicle->nucleus_center[2])/vesicle->R_nucleusZ < 1.0){
    if ((vtx->x-vesicle->nucleus_center[0])*(vtx->x-vesicle->nucleus_center[0])/vesicle->R_nucleusX + (vtx->y-vesicle->nucleus_center[1])*(vtx->y-vesicle->nucleus_center[1])/vesicle->R_nucleusY + (vtx->z-vesicle->nucleus_center[2])*(vtx->z-vesicle->nucleus_center[2])/vesicle->R_nucleusZ < 1.0){
//    if (SQ(vtx->x)/vesicle->R_nucleusX + SQ(vtx->y)/vesicle->R_nucleusY + SQ(vtx->z)/vesicle->R_nucleusZ < 1.0){
        vtx=memcpy((void *)vtx,(void *)&backupvtx[0],sizeof(ts_vertex));
        return TS_FAIL;
    }
}
    // plane confinement check whether the new position of vertex will be out of bounds
    if(vesicle->tape->plane_confinement_switch){
        if(vtx->z>vesicle->confinement_plane.z_max || vtx->z<vesicle->confinement_plane.z_min){
@@ -62,18 +42,20 @@
        return TS_FAIL;
        }
    }
//#undef SQ
/* Entry point for plugin vm_hard_constraint() function */
    for(i=0; i<vesicle->plist->n;i++){
        retval = vesicle->plist->plugin[i]->function->vm_hard_constraint(vesicle,vtx,&backupvtx[0]);
    ts_plugin_chain *ptr=vesicle->plist->chain->vm_hard_constraint;
    while(ptr!=NULL){
        retval = ptr->plugin->function->vm_hard_constraint(vesicle,vtx, &backupvtx[0]);
        if(retval==TS_FAIL){
            vtx=memcpy((void *)vtx,(void *)&backupvtx[0],sizeof(ts_vertex));
            return TS_FAIL;
        }
        ptr=ptr->next;
    }
 
//if all the tests are successful, then energy for vtx and neighbours is calculated
    for(i=0;i<vtx->neigh_no;i++){
    memcpy((void *)&backupvtx[i+1],(void *)vtx->neigh[i],sizeof(ts_vertex));