Added constant volume plugin (partially)
1 files added
7 files modified
| | |
| | | ts_double (*vm_energy_before_execute)(void *vesicle, ts_vertex *vtx); |
| | | ts_double (*vm_energy_after_prepare)(void *vesicle, ts_vertex *vtx); |
| | | ts_double (*vm_energy_after_execute)(void *vesicle, ts_vertex *vtx); |
| | | ts_double (*vm_before_montecarlo_constraint)(void *vesicle, ts_vertex *vtx, ts_vertex *old_vtx); |
| | | ts_double (*vm_new_state_accepted)(void *vesicle, ts_vertex *vtx); |
| | | ts_double (*vm_new_state_rejected)(void *vesicle, ts_vertex *vtx); |
| | | void (*cleanup)(void); |
| | |
| | | ts_plugin_chain *vm_hard_constraint; |
| | | ts_plugin_chain *vm_energy_before_prepare; |
| | | ts_plugin_chain *vm_energy_after_execute; |
| | | ts_plugin_chain *vm_before_montecarlo_constraint; |
| | | ts_plugin_chain *cleanup; |
| | | } ts_plugin_chains; |
| | | |
| | |
| | | ts_char *plugin1 = (ts_char *)calloc(255,sizeof(ts_char)); |
| | | ts_char *plugin2 = (ts_char *)calloc(255,sizeof(ts_char)); |
| | | ts_char *plugin3 = (ts_char *)calloc(255,sizeof(ts_char)); |
| | | ts_char *plugin4 = (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"); |
| | | ts_char **plugins=(ts_char **)calloc(4,sizeof(ts_char *)); |
| | | *plugins=plugin0; |
| | | strcpy(plugin4,"/home/samo/programiranje/trisurf-ng/src/plugins/.libs/constant_volume.so"); |
| | | ts_char **plugins=(ts_char **)calloc(5,sizeof(ts_char *)); |
| | | plugins[0]=plugin0; |
| | | plugins[1]=plugin1; |
| | | plugins[2]=plugin2; |
| | | plugins[3]=plugin3; |
| | | ts_plugin_list *plist=init_plugin_list(plugins,4); |
| | | plugins[4]=plugin4; |
| | | ts_plugin_list *plist=init_plugin_list(plugins,5); |
| | | //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; |
| | |
| | | |
| | | vesicle->plist=plist; |
| | | /* Entry point for plugin after_vesicle_init() function */ |
| | | ptr=plist->chain->after_vesicle_init; |
| | | while(ptr!=NULL){ |
| | | ptr->plugin->function->after_vesicle_init(vesicle); |
| | | ptr=ptr->next; |
| | | vesicle->plist->pointer=vesicle->plist->chain->after_vesicle_init; |
| | | while(vesicle->plist->pointer!=NULL){ |
| | | vesicle=vesicle->plist->pointer->plugin->function->after_vesicle_init(vesicle); |
| | | vesicle->plist->pointer=vesicle->plist->pointer->next; |
| | | } |
| | | |
| | | run_simulation(vesicle, tape->mcsweeps, tape->inititer, tape->iterations, start_iteration); |
| | |
| | | |
| | | ts_plugin *init_plugin(ts_char *filename){ |
| | | ts_plugin *plugin = (ts_plugin *)calloc(1, sizeof(ts_plugin)); |
| | | plugin->filename=(ts_char *)calloc(strlen(filename),sizeof(ts_char)); |
| | | plugin->filename=(ts_char *)calloc(strlen(filename)+1,sizeof(ts_char)); |
| | | strcpy(plugin->filename,filename); |
| | | plugin->libhandle = dlopen(plugin->filename, RTLD_NOW); |
| | | if(!plugin->libhandle){ |
| | | ts_fprintf(stderr,"Error loading plugin: %s\n", filename); |
| | | ts_fprintf(stderr,"Error loading plugin: %s\n", plugin->filename); |
| | | fatal("Exiting",235); |
| | | } |
| | | ts_plugin_details* (*get_plugin_details)(void) = dlsym(plugin->libhandle, "init"); |
| | | if(get_plugin_details==NULL){ |
| | | ts_fprintf(stderr,"Plugin %s invalid. No init() function.\n", filename); |
| | | fatal("Exiting", 235); |
| | | ts_fprintf(stderr,"Plugin %s invalid. No init() function.\n", plugin->filename); |
| | | fatal("Exiting", 236); |
| | | } |
| | | plugin->details = get_plugin_details(); |
| | | plugin->function = (ts_plugin_function *)calloc(1,sizeof(ts_plugin_function)); |
| | |
| | | plugin->function->vm_energy_before_execute = dlsym(plugin->libhandle, "vm_energy_before_execute"); |
| | | plugin->function->vm_energy_after_prepare = dlsym(plugin->libhandle, "vm_energy_after_prepare"); |
| | | plugin->function->vm_energy_after_execute = dlsym(plugin->libhandle, "vm_energy_after_execute"); |
| | | plugin->function->vm_before_montecarlo_constraint = dlsym(plugin->libhandle, "vm_before_montecarlo_constraint"); |
| | | plugin->function->vm_new_state_rejected = dlsym(plugin->libhandle, "vm_new_state_rejected"); |
| | | plugin->function->vm_new_state_accepted = dlsym(plugin->libhandle, "vm_new_state_accepted"); |
| | | |
| | |
| | | if(plist->plugin[i]->function->at_start!=NULL){ |
| | | plist->chain->at_start=plugin_to_chain(plist->chain->at_start, plist->plugin[i]); |
| | | } |
| | | if(plist->plugin[i]->function->after_vesicle_init!=NULL){ |
| | | plist->chain->after_vesicle_init=plugin_to_chain(plist->chain->after_vesicle_init, plist->plugin[i]); |
| | | } |
| | | if(plist->plugin[i]->function->vm_hard_constraint!=NULL){ |
| | | plist->chain->vm_hard_constraint=plugin_to_chain(plist->chain->vm_hard_constraint, plist->plugin[i]); |
| | | } |
| | |
| | | if(plist->plugin[i]->function->vm_energy_after_execute!=NULL){ |
| | | plist->chain->vm_energy_after_execute=plugin_to_chain(plist->chain->vm_energy_after_execute, plist->plugin[i]); |
| | | } |
| | | |
| | | if(plist->plugin[i]->function->vm_before_montecarlo_constraint!=NULL){ |
| | | plist->chain->vm_before_montecarlo_constraint=plugin_to_chain(plist->chain->vm_before_montecarlo_constraint, plist->plugin[i]); |
| | | } |
| | | } |
| | | plist->n=number_of_plugins; |
| | | return plist; |
| | |
| | | } |
| | | am__installdirs = "$(DESTDIR)$(libdir)" |
| | | LTLIBRARIES = $(lib_LTLIBRARIES) |
| | | demoplugin_la_LIBADD = |
| | | am_demoplugin_la_OBJECTS = demo_plugin.lo |
| | | demoplugin_la_OBJECTS = $(am_demoplugin_la_OBJECTS) |
| | | constant_volume_la_LIBADD = |
| | | am_constant_volume_la_OBJECTS = constant_volume.lo |
| | | constant_volume_la_OBJECTS = $(am_constant_volume_la_OBJECTS) |
| | | AM_V_lt = $(am__v_lt_$(V)) |
| | | am__v_lt_ = $(am__v_lt_$(AM_DEFAULT_VERBOSITY)) |
| | | am__v_lt_0 = --silent |
| | | am__v_lt_1 = |
| | | constant_volume_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC \ |
| | | $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CCLD) \ |
| | | $(AM_CFLAGS) $(CFLAGS) $(constant_volume_la_LDFLAGS) \ |
| | | $(LDFLAGS) -o $@ |
| | | demoplugin_la_LIBADD = |
| | | am_demoplugin_la_OBJECTS = demo_plugin.lo |
| | | demoplugin_la_OBJECTS = $(am_demoplugin_la_OBJECTS) |
| | | demoplugin_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ |
| | | $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ |
| | | $(demoplugin_la_LDFLAGS) $(LDFLAGS) -o $@ |
| | |
| | | am__v_CCLD_ = $(am__v_CCLD_$(AM_DEFAULT_VERBOSITY)) |
| | | am__v_CCLD_0 = @echo " CCLD " $@; |
| | | am__v_CCLD_1 = |
| | | SOURCES = $(demoplugin_la_SOURCES) $(nucleus_la_SOURCES) \ |
| | | $(plane_confinement_la_SOURCES) $(pressure_la_SOURCES) \ |
| | | $(vmdefaulthardconstraints_la_SOURCES) |
| | | DIST_SOURCES = $(demoplugin_la_SOURCES) $(nucleus_la_SOURCES) \ |
| | | $(plane_confinement_la_SOURCES) $(pressure_la_SOURCES) \ |
| | | $(vmdefaulthardconstraints_la_SOURCES) |
| | | SOURCES = $(constant_volume_la_SOURCES) $(demoplugin_la_SOURCES) \ |
| | | $(nucleus_la_SOURCES) $(plane_confinement_la_SOURCES) \ |
| | | $(pressure_la_SOURCES) $(vmdefaulthardconstraints_la_SOURCES) |
| | | DIST_SOURCES = $(constant_volume_la_SOURCES) $(demoplugin_la_SOURCES) \ |
| | | $(nucleus_la_SOURCES) $(plane_confinement_la_SOURCES) \ |
| | | $(pressure_la_SOURCES) $(vmdefaulthardconstraints_la_SOURCES) |
| | | am__can_run_installinfo = \ |
| | | case $$AM_UPDATE_INFO_DIR in \ |
| | | n|no|NO) false;; \ |
| | |
| | | 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 |
| | | lib_LTLIBRARIES = demoplugin.la vmdefaulthardconstraints.la nucleus.la plane_confinement.la pressure.la constant_volume.la |
| | | demoplugin_la_SOURCES = demo_plugin.c |
| | | demoplugin_la_LDFLAGS = -module -avoid-version -export-dynamic |
| | | vmdefaulthardconstraints_la_SOURCES = default_hard_constraints.c |
| | |
| | | plane_confinement_la_LDFLAGS = -module -avoid-version -export-dynamic |
| | | pressure_la_SOURCES = pressure.c |
| | | pressure_la_LDFLAGS = -module -avoid-version -export-dynamic |
| | | constant_volume_la_SOURCES = constant_volume.c |
| | | constant_volume_la_LDFLAGS = -module -avoid-version -export-dynamic |
| | | all: all-am |
| | | |
| | | .SUFFIXES: |
| | |
| | | rm -f $${locs}; \ |
| | | } |
| | | |
| | | constant_volume.la: $(constant_volume_la_OBJECTS) $(constant_volume_la_DEPENDENCIES) $(EXTRA_constant_volume_la_DEPENDENCIES) |
| | | $(AM_V_CCLD)$(constant_volume_la_LINK) -rpath $(libdir) $(constant_volume_la_OBJECTS) $(constant_volume_la_LIBADD) $(LIBS) |
| | | |
| | | 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) |
| | | |
| | |
| | | distclean-compile: |
| | | -rm -f *.tab.c |
| | | |
| | | include ./$(DEPDIR)/constant_volume.Plo |
| | | include ./$(DEPDIR)/default_hard_constraints.Plo |
| | | include ./$(DEPDIR)/demo_plugin.Plo |
| | | include ./$(DEPDIR)/nucleus.Plo |
| | |
| | | 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 |
| | | lib_LTLIBRARIES= demoplugin.la vmdefaulthardconstraints.la nucleus.la plane_confinement.la pressure.la constant_volume.la |
| | | demoplugin_la_SOURCES= demo_plugin.c |
| | | demoplugin_la_LDFLAGS = -module -avoid-version -export-dynamic |
| | | |
| | |
| | | pressure_la_SOURCES = pressure.c |
| | | pressure_la_LDFLAGS = -module -avoid-version -export-dynamic |
| | | |
| | | constant_volume_la_SOURCES = constant_volume.c |
| | | constant_volume_la_LDFLAGS = -module -avoid-version -export-dynamic |
| | | |
| | |
| | | } |
| | | am__installdirs = "$(DESTDIR)$(libdir)" |
| | | LTLIBRARIES = $(lib_LTLIBRARIES) |
| | | demoplugin_la_LIBADD = |
| | | am_demoplugin_la_OBJECTS = demo_plugin.lo |
| | | demoplugin_la_OBJECTS = $(am_demoplugin_la_OBJECTS) |
| | | constant_volume_la_LIBADD = |
| | | am_constant_volume_la_OBJECTS = constant_volume.lo |
| | | constant_volume_la_OBJECTS = $(am_constant_volume_la_OBJECTS) |
| | | AM_V_lt = $(am__v_lt_@AM_V@) |
| | | am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@) |
| | | am__v_lt_0 = --silent |
| | | am__v_lt_1 = |
| | | constant_volume_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC \ |
| | | $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CCLD) \ |
| | | $(AM_CFLAGS) $(CFLAGS) $(constant_volume_la_LDFLAGS) \ |
| | | $(LDFLAGS) -o $@ |
| | | demoplugin_la_LIBADD = |
| | | am_demoplugin_la_OBJECTS = demo_plugin.lo |
| | | demoplugin_la_OBJECTS = $(am_demoplugin_la_OBJECTS) |
| | | demoplugin_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ |
| | | $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ |
| | | $(demoplugin_la_LDFLAGS) $(LDFLAGS) -o $@ |
| | |
| | | am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@) |
| | | am__v_CCLD_0 = @echo " CCLD " $@; |
| | | am__v_CCLD_1 = |
| | | SOURCES = $(demoplugin_la_SOURCES) $(nucleus_la_SOURCES) \ |
| | | $(plane_confinement_la_SOURCES) $(pressure_la_SOURCES) \ |
| | | $(vmdefaulthardconstraints_la_SOURCES) |
| | | DIST_SOURCES = $(demoplugin_la_SOURCES) $(nucleus_la_SOURCES) \ |
| | | $(plane_confinement_la_SOURCES) $(pressure_la_SOURCES) \ |
| | | $(vmdefaulthardconstraints_la_SOURCES) |
| | | SOURCES = $(constant_volume_la_SOURCES) $(demoplugin_la_SOURCES) \ |
| | | $(nucleus_la_SOURCES) $(plane_confinement_la_SOURCES) \ |
| | | $(pressure_la_SOURCES) $(vmdefaulthardconstraints_la_SOURCES) |
| | | DIST_SOURCES = $(constant_volume_la_SOURCES) $(demoplugin_la_SOURCES) \ |
| | | $(nucleus_la_SOURCES) $(plane_confinement_la_SOURCES) \ |
| | | $(pressure_la_SOURCES) $(vmdefaulthardconstraints_la_SOURCES) |
| | | am__can_run_installinfo = \ |
| | | case $$AM_UPDATE_INFO_DIR in \ |
| | | n|no|NO) false;; \ |
| | |
| | | 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 |
| | | lib_LTLIBRARIES = demoplugin.la vmdefaulthardconstraints.la nucleus.la plane_confinement.la pressure.la constant_volume.la |
| | | demoplugin_la_SOURCES = demo_plugin.c |
| | | demoplugin_la_LDFLAGS = -module -avoid-version -export-dynamic |
| | | vmdefaulthardconstraints_la_SOURCES = default_hard_constraints.c |
| | |
| | | plane_confinement_la_LDFLAGS = -module -avoid-version -export-dynamic |
| | | pressure_la_SOURCES = pressure.c |
| | | pressure_la_LDFLAGS = -module -avoid-version -export-dynamic |
| | | constant_volume_la_SOURCES = constant_volume.c |
| | | constant_volume_la_LDFLAGS = -module -avoid-version -export-dynamic |
| | | all: all-am |
| | | |
| | | .SUFFIXES: |
| | |
| | | rm -f $${locs}; \ |
| | | } |
| | | |
| | | constant_volume.la: $(constant_volume_la_OBJECTS) $(constant_volume_la_DEPENDENCIES) $(EXTRA_constant_volume_la_DEPENDENCIES) |
| | | $(AM_V_CCLD)$(constant_volume_la_LINK) -rpath $(libdir) $(constant_volume_la_OBJECTS) $(constant_volume_la_LIBADD) $(LIBS) |
| | | |
| | | 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) |
| | | |
| | |
| | | distclean-compile: |
| | | -rm -f *.tab.c |
| | | |
| | | @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/constant_volume.Plo@am__quote@ |
| | | @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@ |
New file |
| | |
| | | #include <stdlib.h> |
| | | #include<math.h> |
| | | |
| | | #include "general.h" |
| | | #include "vertex.h" |
| | | #include "cell.h" |
| | | #include "vesicle.h" |
| | | #include "frame.h" |
| | | char plugin_name[] = "Constant volume"; |
| | | char plugin_description[]= "Plugin that enables constant volume of the vesicle."; |
| | | char plugin_author[] = "SAMO PENIC"; |
| | | |
| | | |
| | | typedef struct { |
| | | ts_double dvol; |
| | | ts_double V0; |
| | | ts_double epsvol; |
| | | } 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,"constant volume initialized\n"); |
| | | |
| | | centermass(vesicle); |
| | | cell_occupation(vesicle); |
| | | vesicle_volume(vesicle); //needed for constant volume at this moment |
| | | |
| | | data->V0=vesicle->volume; |
| | | data->epsvol=4.0*sqrt(2.0*M_PI)/pow(3.0,3.0/4.0)*data->V0/pow(vesicle->tlist->n,3.0/2.0); |
| | | return vesicle; |
| | | } |
| | | |
| | | |
| | | void vm_energy_before_prepare(ts_vesicle *vesicle, ts_vertex *vtx){ |
| | | if(vesicle->tape->constvolswitch>0){ |
| | | plugin_data *data=(plugin_data *)vesicle->plist->pointer->plugin->details->data; |
| | | data->dvol=0; |
| | | ts_uint i; |
| | | for(i=0;i<vtx->tristar_no;i++) data->dvol-=vtx->tristar[i]->volume; |
| | | } |
| | | } |
| | | |
| | | ts_double vm_before_montecarlo_constraint(ts_vesicle *vesicle, ts_vertex *vtx, ts_vertex *old_vtx){ |
| | | if(vesicle->tape->constvolswitch >0){ |
| | | plugin_data *data=(plugin_data *)vesicle->plist->pointer->plugin->details->data; |
| | | ts_uint i; |
| | | for(i=0;i<vtx->tristar_no;i++) data->dvol+=vtx->tristar[i]->volume; |
| | | if(fabs(vesicle->volume+data->dvol-data->V0)>data->epsvol) return TS_FAIL; |
| | | } |
| | | return TS_SUCCESS; |
| | | // if(vesicle->tape->constvolswitch==2){ |
| | | // /*check whether the dvol is gt than epsvol */ |
| | | // if(fabs(vesicle->volume+data->dvol-data->V0)>data->epsvol) return TS_FAIL; |
| | | //This part doesn't work as expected yet. Delta_energy_cv shoould be accounted for in the total energy change. |
| | | |
| | | /* }else if(vesicle->tape->constvolswitch == 1){ |
| | | retval=constvolume(vesicle, vtx, -dvol, &delta_energy_cv, &constvol_vtx_moved,&constvol_vtx_backup); |
| | | if(retval==TS_FAIL){ // if we couldn't move the vertex to assure constant volume |
| | | return TS_FAIL; |
| | | } */ |
| | | return TS_SUCCESS; |
| | | |
| | | } |
| | |
| | | ts_uint i; |
| | | ts_bool retval; |
| | | ts_uint cellidx; |
| | | ts_double delta_energy, delta_energy_cv,oenergy,dvol=0.0, darea=0.0, dstretchenergy=0.0; |
| | | ts_double delta_energy, oenergy,dvol=0.0, darea=0.0, dstretchenergy=0.0; |
| | | ts_double costheta,sintheta,phi,r; |
| | | //This will hold all the information of vtx and its neighbours |
| | | ts_vertex backupvtx[20], *constvol_vtx_moved=NULL, *constvol_vtx_backup=NULL; |
| | |
| | | |
| | | |
| | | /* Entry point for plugin vm_hard_constraint() function */ |
| | | ts_plugin_chain *ptr=vesicle->plist->chain->vm_hard_constraint; |
| | | while(ptr!=NULL){ |
| | | retval = ptr->plugin->function->vm_hard_constraint(vesicle,vtx, &backupvtx[0]); |
| | | vesicle->plist->pointer=vesicle->plist->chain->vm_hard_constraint; |
| | | while(vesicle->plist->pointer!=NULL){ |
| | | retval = vesicle->plist->pointer->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; |
| | | vesicle->plist->pointer=vesicle->plist->pointer->next; |
| | | } |
| | | /* End of vm_hard_constraint() */ |
| | | |
| | |
| | | while(vesicle->plist->pointer!=NULL){ |
| | | vesicle->plist->pointer->plugin->function->vm_energy_before_prepare(vesicle, vtx); |
| | | vesicle->plist->pointer=vesicle->plist->pointer->next; |
| | | } |
| | | /* Calculate energy for vtx and neighbours */ |
| | | if(vesicle->pswitch == 1 || vesicle->tape->constvolswitch>0){ |
| | | for(i=0;i<vtx->tristar_no;i++) dvol-=vtx->tristar[i]->volume; |
| | | } |
| | | |
| | | if(vesicle->tape->constareaswitch==2){ |
| | |
| | | delta_energy+=vtx->neigh[i]->xk*(vtx->neigh[i]->energy-oenergy); |
| | | } |
| | | |
| | | if(vesicle->pswitch == 1 || vesicle->tape->constvolswitch >0){ |
| | | for(i=0;i<vtx->tristar_no;i++) dvol+=vtx->tristar[i]->volume; |
| | | if(vesicle->pswitch==1) delta_energy-=vesicle->pressure*dvol; |
| | | }; |
| | | |
| | | /* Entry point for plugin vm_energy_after_execute() */ |
| | | |
| | | vesicle->plist->pointer=vesicle->plist->chain->vm_energy_after_execute; |
| | | while(vesicle->plist->pointer!=NULL){ |
| | | delta_energy+=vesicle->plist->pointer->plugin->function->vm_energy_after_execute(vesicle, vtx); |
| | | vesicle->plist->pointer=vesicle->plist->pointer->next; |
| | | } |
| | | |
| | | |
| | | |
| | | if(vesicle->tape->constareaswitch==2){ |
| | | /* check whether the darea is gt epsarea */ |
| | |
| | | |
| | | } |
| | | |
| | | if(vesicle->tape->constvolswitch==2){ |
| | | /*check whether the dvol is gt than epsvol */ |
| | | //fprintf(stderr,"DVOL=%1.16e\n",dvol); |
| | | if(fabs(vesicle->volume+dvol-V0)>epsvol){ |
| | | //restore old state. |
| | | vtx=memcpy((void *)vtx,(void *)&backupvtx[0],sizeof(ts_vertex)); |
| | | for(i=0;i<vtx->neigh_no;i++){ |
| | | vtx->neigh[i]=memcpy((void *)vtx->neigh[i],(void *)&backupvtx[i+1],sizeof(ts_vertex)); |
| | | } |
| | | for(i=0;i<vtx->tristar_no;i++) triangle_normal_vector(vtx->tristar[i]); |
| | | //fprintf(stderr,"fajlam!\n"); |
| | | return TS_FAIL; |
| | | } |
| | | |
| | | } else |
| | | // vesicle_volume(vesicle); |
| | | // fprintf(stderr,"Volume before=%1.16e\n", vesicle->volume); |
| | | if(vesicle->tape->constvolswitch == 1){ |
| | | retval=constvolume(vesicle, vtx, -dvol, &delta_energy_cv, &constvol_vtx_moved,&constvol_vtx_backup); |
| | | if(retval==TS_FAIL){ // if we couldn't move the vertex to assure constant volume |
| | | vtx=memcpy((void *)vtx,(void *)&backupvtx[0],sizeof(ts_vertex)); |
| | | for(i=0;i<vtx->neigh_no;i++){ |
| | | vtx->neigh[i]=memcpy((void *)vtx->neigh[i],(void *)&backupvtx[i+1],sizeof(ts_vertex)); |
| | | } |
| | | for(i=0;i<vtx->tristar_no;i++) triangle_normal_vector(vtx->tristar[i]); |
| | | // fprintf(stderr,"fajlam!\n"); |
| | | return TS_FAIL; |
| | | } |
| | | // vesicle_volume(vesicle); |
| | | // fprintf(stderr,"Volume after=%1.16e\n", vesicle->volume); |
| | | // fprintf(stderr,"Volume after-dvol=%1.16e\n", vesicle->volume-dvol); |
| | | // fprintf(stderr,"Denergy before=%e\n",delta_energy); |
| | | |
| | | delta_energy+=delta_energy_cv; |
| | | // fprintf(stderr,"Denergy after=%e\n",delta_energy); |
| | | } |
| | | /* Vertices with spontaneous curvature may have spontaneous force perpendicular to the surface of the vesicle. additional delta energy is calculated in this function */ |
| | | delta_energy+=direct_force_energy(vesicle,vtx,backupvtx); |
| | | |
| | |
| | | } |
| | | } |
| | | |
| | | |
| | | /* Entry point for plugin vm_before_montecarlo_constraint() function */ |
| | | vesicle->plist->pointer=vesicle->plist->chain->vm_before_montecarlo_constraint; |
| | | while(vesicle->plist->pointer!=NULL){ |
| | | retval = vesicle->plist->pointer->plugin->function->vm_before_montecarlo_constraint(vesicle,vtx, &backupvtx[0]); |
| | | if(retval==TS_FAIL){ |
| | | vtx=memcpy((void *)vtx,(void *)&backupvtx[0],sizeof(ts_vertex)); |
| | | for(i=0;i<vtx->neigh_no;i++){ |
| | | vtx->neigh[i]=memcpy((void *)vtx->neigh[i],(void *)&backupvtx[i+1],sizeof(ts_vertex)); |
| | | } |
| | | for(i=0;i<vtx->tristar_no;i++) triangle_normal_vector(vtx->tristar[i]); |
| | | return TS_FAIL; |
| | | } |
| | | vesicle->plist->pointer=vesicle->plist->pointer->next; |
| | | } |
| | | /* End of vm_before_montecarlo_constraint() */ |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | // fprintf(stderr, "DE=%f\n",delta_energy); |
| | | //MONTE CARLOOOOOOOO |
| | | // if(vtx->c!=0.0) printf("DE=%f\n",delta_energy); |
| | | if(delta_energy>=0){ |
| | | #ifdef TS_DOUBLE_DOUBLE |
| | | if(exp(-delta_energy)< drand48()) |