From 2c4278db6ead5c27e30a3000097ed898c968534e Mon Sep 17 00:00:00 2001 From: Samo Penic <samo.penic@gmail.com> Date: Sat, 09 Mar 2019 19:45:22 +0000 Subject: [PATCH] Added direct force plugin and fixes in stretching energy --- src/plugins.c | 32 ++++++++++++++++++++++++++------ 1 files changed, 26 insertions(+), 6 deletions(-) diff --git a/src/plugins.c b/src/plugins.c index 84983aa..3146c2a 100644 --- a/src/plugins.c +++ b/src/plugins.c @@ -95,17 +95,17 @@ 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)); @@ -118,6 +118,7 @@ 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"); @@ -155,9 +156,28 @@ 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_before_prepare!=NULL){ + plist->chain->vm_energy_before_prepare=plugin_to_chain(plist->chain->vm_energy_before_prepare, 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]); + } + if(plist->plugin[i]->function->vm_new_state_accepted!=NULL){ + plist->chain->vm_new_state_accepted=plugin_to_chain(plist->chain->vm_new_state_accepted, plist->plugin[i]); + } + if(plist->plugin[i]->function->vm_new_state_rejected!=NULL){ + plist->chain->vm_new_state_rejected=plugin_to_chain(plist->chain->vm_new_state_rejected, plist->plugin[i]); + } } - //printf("%s", plist->chain->at_start->next->plugin->filename); plist->n=number_of_plugins; return plist; } -- Gitblit v1.9.3