Trisurf Monte Carlo simulator
Samo Penic
2019-03-09 4df6ed05246cf8bc9fe0cb0c8766ebc368d2f512
Added stretching energy plugin
1 files added
4 files modified
124 ■■■■■ changed files
src/main.c 7 ●●●● patch | view | raw | blame | history
src/plugins/Makefile 18 ●●●● patch | view | raw | blame | history
src/plugins/Makefile.am 6 ●●●● patch | view | raw | blame | history
src/plugins/Makefile.in 18 ●●●● patch | view | raw | blame | history
src/plugins/stretching_energy.c 75 ●●●●● patch | view | raw | blame | history
src/main.c
@@ -32,20 +32,23 @@
    ts_char *plugin3 = (ts_char *)calloc(255,sizeof(ts_char));
    ts_char *plugin4 = (ts_char *)calloc(255,sizeof(ts_char));
    ts_char *plugin5 = (ts_char *)calloc(255,sizeof(ts_char));
    ts_char *plugin6 = (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");
    strcpy(plugin2,"/home/samo/programiranje/trisurf-ng/src/plugins/.libs/plane_confinement.so");
    strcpy(plugin3,"/home/samo/programiranje/trisurf-ng/src/plugins/.libs/pressure.so");
    strcpy(plugin4,"/home/samo/programiranje/trisurf-ng/src/plugins/.libs/constant_volume.so");
    strcpy(plugin5,"/home/samo/programiranje/trisurf-ng/src/plugins/.libs/constant_area.so");
    ts_char **plugins=(ts_char **)calloc(6,sizeof(ts_char *));
    strcpy(plugin6,"/home/samo/programiranje/trisurf-ng/src/plugins/.libs/stretching_energy.so");
    ts_char **plugins=(ts_char **)calloc(7,sizeof(ts_char *));
    plugins[0]=plugin0;
    plugins[1]=plugin1;
    plugins[2]=plugin2;
    plugins[3]=plugin3;
    plugins[4]=plugin4;
    plugins[5]=plugin5;
    ts_plugin_list *plist=init_plugin_list(plugins,6);
    plugins[6]=plugin6;
    ts_plugin_list *plist=init_plugin_list(plugins,7);
    //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
@@ -170,6 +170,13 @@
pressure_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
    $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
    $(pressure_la_LDFLAGS) $(LDFLAGS) -o $@
stretching_energy_la_LIBADD =
am_stretching_energy_la_OBJECTS = constant_area.lo
stretching_energy_la_OBJECTS = $(am_stretching_energy_la_OBJECTS)
stretching_energy_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC \
    $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CCLD) \
    $(AM_CFLAGS) $(CFLAGS) $(stretching_energy_la_LDFLAGS) \
    $(LDFLAGS) -o $@
vmdefaulthardconstraints_la_LIBADD =
am_vmdefaulthardconstraints_la_OBJECTS = default_hard_constraints.lo
vmdefaulthardconstraints_la_OBJECTS =  \
@@ -215,11 +222,13 @@
SOURCES = $(constant_area_la_SOURCES) $(constant_volume_la_SOURCES) \
    $(demoplugin_la_SOURCES) $(nucleus_la_SOURCES) \
    $(plane_confinement_la_SOURCES) $(pressure_la_SOURCES) \
    $(stretching_energy_la_SOURCES) \
    $(vmdefaulthardconstraints_la_SOURCES)
DIST_SOURCES = $(constant_area_la_SOURCES) \
    $(constant_volume_la_SOURCES) $(demoplugin_la_SOURCES) \
    $(nucleus_la_SOURCES) $(plane_confinement_la_SOURCES) \
    $(pressure_la_SOURCES) $(vmdefaulthardconstraints_la_SOURCES)
    $(pressure_la_SOURCES) $(stretching_energy_la_SOURCES) \
    $(vmdefaulthardconstraints_la_SOURCES)
am__can_run_installinfo = \
  case $$AM_UPDATE_INFO_DIR in \
    n|no|NO) false;; \
@@ -368,7 +377,7 @@
top_builddir = ../..
top_srcdir = ../..
AM_CFLAGS = -Wall -Werror -DTS_VERSION=\"$(GITVERSION)\" -fgnu89-inline -Wno-error=date-time -I..
lib_LTLIBRARIES = demoplugin.la vmdefaulthardconstraints.la nucleus.la plane_confinement.la pressure.la constant_volume.la constant_area.la
lib_LTLIBRARIES = demoplugin.la vmdefaulthardconstraints.la nucleus.la plane_confinement.la pressure.la constant_volume.la constant_area.la stretching_energy.la
demoplugin_la_SOURCES = demo_plugin.c
demoplugin_la_LDFLAGS = -module -avoid-version -export-dynamic
vmdefaulthardconstraints_la_SOURCES = default_hard_constraints.c
@@ -383,6 +392,8 @@
constant_volume_la_LDFLAGS = -module -avoid-version -export-dynamic
constant_area_la_SOURCES = constant_area.c 
constant_area_la_LDFLAGS = -module -avoid-version -export-dynamic
stretching_energy_la_SOURCES = constant_area.c
stretching_energy_la_LDFLAGS = -module -avoid-version -export-dynamic
all: all-am
.SUFFIXES:
@@ -470,6 +481,9 @@
pressure.la: $(pressure_la_OBJECTS) $(pressure_la_DEPENDENCIES) $(EXTRA_pressure_la_DEPENDENCIES) 
    $(AM_V_CCLD)$(pressure_la_LINK) -rpath $(libdir) $(pressure_la_OBJECTS) $(pressure_la_LIBADD) $(LIBS)
stretching_energy.la: $(stretching_energy_la_OBJECTS) $(stretching_energy_la_DEPENDENCIES) $(EXTRA_stretching_energy_la_DEPENDENCIES)
    $(AM_V_CCLD)$(stretching_energy_la_LINK) -rpath $(libdir) $(stretching_energy_la_OBJECTS) $(stretching_energy_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)
src/plugins/Makefile.am
@@ -1,5 +1,5 @@
AM_CFLAGS = -Wall -Werror -DTS_VERSION=\"$(GITVERSION)\" -fgnu89-inline -Wno-error=date-time -I..
lib_LTLIBRARIES= demoplugin.la vmdefaulthardconstraints.la nucleus.la plane_confinement.la pressure.la constant_volume.la constant_area.la
lib_LTLIBRARIES= demoplugin.la vmdefaulthardconstraints.la nucleus.la plane_confinement.la pressure.la constant_volume.la constant_area.la stretching_energy.la
demoplugin_la_SOURCES= demo_plugin.c
demoplugin_la_LDFLAGS = -module -avoid-version -export-dynamic
@@ -21,3 +21,7 @@
constant_area_la_SOURCES = constant_area.c 
constant_area_la_LDFLAGS = -module -avoid-version -export-dynamic
stretching_energy_la_SOURCES = constant_area.c
stretching_energy_la_LDFLAGS = -module -avoid-version -export-dynamic
src/plugins/Makefile.in
@@ -170,6 +170,13 @@
pressure_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
    $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
    $(pressure_la_LDFLAGS) $(LDFLAGS) -o $@
stretching_energy_la_LIBADD =
am_stretching_energy_la_OBJECTS = constant_area.lo
stretching_energy_la_OBJECTS = $(am_stretching_energy_la_OBJECTS)
stretching_energy_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC \
    $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CCLD) \
    $(AM_CFLAGS) $(CFLAGS) $(stretching_energy_la_LDFLAGS) \
    $(LDFLAGS) -o $@
vmdefaulthardconstraints_la_LIBADD =
am_vmdefaulthardconstraints_la_OBJECTS = default_hard_constraints.lo
vmdefaulthardconstraints_la_OBJECTS =  \
@@ -215,11 +222,13 @@
SOURCES = $(constant_area_la_SOURCES) $(constant_volume_la_SOURCES) \
    $(demoplugin_la_SOURCES) $(nucleus_la_SOURCES) \
    $(plane_confinement_la_SOURCES) $(pressure_la_SOURCES) \
    $(stretching_energy_la_SOURCES) \
    $(vmdefaulthardconstraints_la_SOURCES)
DIST_SOURCES = $(constant_area_la_SOURCES) \
    $(constant_volume_la_SOURCES) $(demoplugin_la_SOURCES) \
    $(nucleus_la_SOURCES) $(plane_confinement_la_SOURCES) \
    $(pressure_la_SOURCES) $(vmdefaulthardconstraints_la_SOURCES)
    $(pressure_la_SOURCES) $(stretching_energy_la_SOURCES) \
    $(vmdefaulthardconstraints_la_SOURCES)
am__can_run_installinfo = \
  case $$AM_UPDATE_INFO_DIR in \
    n|no|NO) false;; \
@@ -368,7 +377,7 @@
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 nucleus.la plane_confinement.la pressure.la constant_volume.la constant_area.la
lib_LTLIBRARIES = demoplugin.la vmdefaulthardconstraints.la nucleus.la plane_confinement.la pressure.la constant_volume.la constant_area.la stretching_energy.la
demoplugin_la_SOURCES = demo_plugin.c
demoplugin_la_LDFLAGS = -module -avoid-version -export-dynamic
vmdefaulthardconstraints_la_SOURCES = default_hard_constraints.c
@@ -383,6 +392,8 @@
constant_volume_la_LDFLAGS = -module -avoid-version -export-dynamic
constant_area_la_SOURCES = constant_area.c 
constant_area_la_LDFLAGS = -module -avoid-version -export-dynamic
stretching_energy_la_SOURCES = constant_area.c
stretching_energy_la_LDFLAGS = -module -avoid-version -export-dynamic
all: all-am
.SUFFIXES:
@@ -470,6 +481,9 @@
pressure.la: $(pressure_la_OBJECTS) $(pressure_la_DEPENDENCIES) $(EXTRA_pressure_la_DEPENDENCIES) 
    $(AM_V_CCLD)$(pressure_la_LINK) -rpath $(libdir) $(pressure_la_OBJECTS) $(pressure_la_LIBADD) $(LIBS)
stretching_energy.la: $(stretching_energy_la_OBJECTS) $(stretching_energy_la_DEPENDENCIES) $(EXTRA_stretching_energy_la_DEPENDENCIES)
    $(AM_V_CCLD)$(stretching_energy_la_LINK) -rpath $(libdir) $(stretching_energy_la_OBJECTS) $(stretching_energy_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)
src/plugins/stretching_energy.c
New file
@@ -0,0 +1,75 @@
#include <stdlib.h>
#include<math.h>
#include "general.h"
#include "vertex.h"
#include "cell.h"
#include "vesicle.h"
#include "frame.h"
char plugin_name[] = "Stretching energy";
char plugin_description[]= "Plugin adds stretching energy to Monte Carlo steps";
char plugin_author[] = "SAMO PENIC";
typedef struct {
    ts_double dstretchenergy;
    ts_double A0;
    ts_double epsarea;
} plugin_data;
ts_plugin_details *init (){
    ts_plugin_details *details=(ts_plugin_details *)calloc(1,sizeof(ts_plugin_details));
    details->name = plugin_name;
    details->data = (plugin_data *)calloc(1,sizeof(plugin_data)); //storing data
    return details;
}
/*
ts_vesicle *after_vesicle_init(ts_vesicle *vesicle){
    plugin_data *data=(plugin_data *)vesicle->plist->pointer->plugin->details->data;
    ts_fprintf(stdout,"area volume initialized\n");
    centermass(vesicle);
    cell_occupation(vesicle);
    vesicle_area(vesicle);
    data->A0=vesicle->area;
    data->epsarea=data->A0/(ts_double)vesicle->tlist->n;
    return vesicle;
}
*/
void vm_energy_before_prepare(ts_vesicle *vesicle, ts_vertex *vtx){
    if(vesicle->tape->stretchswitch==1){
        plugin_data *data=(plugin_data *)vesicle->plist->pointer->plugin->details->data;
        ts_uint i;
        data->dstretchenergy=0.0;
        for(i=0;i<vtx->tristar_no;i++) data->dstretchenergy-=vtx->tristar[i]->energy;
    }
}
ts_double vm_energy_after_execute(ts_vesicle *vesicle, ts_vertex *vtx){
    //stretching energy 2 of 3
    if(vesicle->tape->stretchswitch==1){
        plugin_data *data=(plugin_data *)vesicle->plist->pointer->plugin->details->data;
        ts_uint i;
        for(i=0;i<vtx->tristar_no;i++){
            stretchenergy(vesicle, vtx->tristar[i]);
            data->dstretchenergy+=vtx->tristar[i]->energy;
            }
    }
    return data->dstretchenergy;
}
void vm_new_state_rejected(ts_vesicle *vesicle, ts_vertex *vtx, ts_vertex *old_vtx){
    //stretching energy 3 of 3
    if(vesicle->tape->stretchswitch==1){
        ts_uint i;
        for(i=0;i<vtx->tristar_no;i++){
            stretchenergy(vesicle,vtx->tristar[i]);
            }
    }
}