Trisurf Monte Carlo simulator
Samo Penic
2018-06-21 0a1e99fea2e3d92e073231707361932b5af9cd81
commit | author | age
7f6076 1 /* vim: set ts=4 sts=4 sw=4 noet : */
aec47d 2 #include<stdlib.h>
SP 3 #include<math.h>
4 #include "general.h"
5 #include "vertex.h"
6 #include "bond.h"
7 #include "triangle.h"
8 #include "vesicle.h"
9 #include "energy.h"
10 #include "timestep.h"
11 #include "cell.h"
30ee9c 12 #include "bondflip.h"
aec47d 13 //#include "io.h"
SP 14 #include<stdio.h>
2870ab 15 #include<string.h>
fbcbdf 16 #include "constvol.h"
aec47d 17
SP 18 ts_bool single_bondflip_timestep(ts_vesicle *vesicle, ts_bond *bond, ts_double *rn){
19 /*c  Vertex and triangle (lm and lp) indexing for bond flip:
20 c      +----- k-------+              +----- k ------+
21 c      |lm1 / | \ lp1 |              |lm1 /   \ lp1 |
22 c      |  /   |   \   |              |  /       \   |
23 c      |/     |     \ |     FLIP     |/    lm     \ |
24 c     km  lm  | lp   kp    --->      km ---------- kp  
25 c      |\     |     / |              |\    lp     / |  
26 c      |  \   |   /   |              |  \       /   |
27 c      |lm2 \ | / lp2 |              |lm2 \   / lp2 |
28 c      +------it------+              +----- it -----+
29 c
30 */
31     ts_vertex *it=bond->vtx1;
32     ts_vertex *k=bond->vtx2;
33     ts_uint nei,neip,neim;
b866cf 34     ts_uint i,j;
c0ae90 35     ts_double oldenergy, delta_energy, dvol=0.0, darea=0.0;
b866cf 36     ts_triangle *lm=NULL,*lp=NULL, *lp1=NULL, *lm2=NULL;
aec47d 37
SP 38     ts_vertex *kp,*km;
fbcbdf 39
SP 40     ts_double delta_energy_cv;
41     ts_vertex *constvol_vtx_moved, *constvol_vtx_backup;
42     ts_bool retval;
620ba7 43     ts_double temp_area=0.0;
aec47d 44
SP 45     if(it->neigh_no< 3) return TS_FAIL;
46     if(k->neigh_no< 3) return TS_FAIL;
47     if(k==NULL || it==NULL){
48         fatal("In bondflip, number of neighbours of k or it is less than 3!",999);
49     }
50
30ee9c 51     nei=0;
aec47d 52     for(i=0;i<it->neigh_no;i++){ // Finds the nn of it, that is k 
SP 53         if(it->neigh[i]==k){
54             nei=i;
55             break;
56         }
57     }
58     neip=nei+1;  // I don't like it.. Smells like I must have it in correct order
59     neim=nei-1;
60     if(neip>=it->neigh_no) neip=0;
61     if((ts_int)neim<0) neim=it->neigh_no-1; /* casting is essential... If not
62 there the neim is never <0 !!! */
63   //  fprintf(stderr,"The numbers are: %u %u\n",neip, neim);
64     km=it->neigh[neim];  // We located km and kp
65     kp=it->neigh[neip];
66
67     if(km==NULL || kp==NULL){
68         fatal("In bondflip, cannot determine km and kp!",999);
69     }
70
71   //  fprintf(stderr,"I WAS HERE! after the 4 vertices are known!\n");
72
73 /* test if the membrane is wrapped too much, so that kp is nearest neighbour of
74  * km. If it is true, then don't flip! */
75     for(i=0;i<km->neigh_no;i++){
76         if(km->neigh[i] == kp) return TS_FAIL;
77     }
78  //   fprintf(stderr,"Membrane didn't wrap too much.. Continue.\n");
79 /* if bond would be too long, return... */
30ee9c 80     if(vtx_distance_sq(km,kp) > vesicle->dmax ) return TS_FAIL;
aec47d 81  //   fprintf(stderr,"Bond will not be too long.. Continue.\n");
SP 82
83 /* we make a bond flip. this is different than in original fortran */
b866cf 84 // find lm, lp
aec47d 85 // 1. step. We find lm and lp from k->tristar !
SP 86     for(i=0;i<it->tristar_no;i++){
87         for(j=0;j<k->tristar_no;j++){
88             if((it->tristar[i] == k->tristar[j])){ //ce gre za skupen trikotnik
89                 if((it->tristar[i]->vertex[0] == km || it->tristar[i]->vertex[1]
90 == km || it->tristar[i]->vertex[2]== km )){
91                 lm=it->tristar[i];
92          //       lmidx=i;
93                 }
94                 else
95                 {
96                 lp=it->tristar[i];
97          //       lpidx=i;
98                 }
99
100             }
101         }
102     }
103 if(lm==NULL || lp==NULL) fatal("ts_flip_bond: Cannot find triangles lm and lp!",999);
104
105 //we look for important triangles lp1 and lm2.
106
107  for(i=0;i<k->tristar_no;i++){
108         for(j=0;j<kp->tristar_no;j++){
109                 if((k->tristar[i] == kp->tristar[j]) && k->tristar[i]!=lp){ //ce gre za skupen trikotnik
110                     lp1=k->tristar[i];
111             }
112         }
113 }
114
115  for(i=0;i<it->tristar_no;i++){
116         for(j=0;j<km->tristar_no;j++){
117             if((it->tristar[i] == km->tristar[j]) && it->tristar[i]!=lm){ //ce gre za skupen trikotnik
118                     lm2=it->tristar[i];
119             } 
120         }
121     }
122
123 if(lm2==NULL || lp1==NULL) fatal("ts_flip_bond: Cannot find triangles lm2 and lp1!",999);
2870ab 124
SP 125
126 /* backup old structure */
127 /* need to backup:
128  * vertices k, kp, km, it
129  * triangles lm, lp, lm2, lp1
130  * bond
131  */
132 ts_vertex *bck_vtx[4];
133 ts_triangle *bck_tria[4];
134 ts_bond *bck_bond;
135 ts_vertex *orig_vtx[]={k,it,kp,km};
7efbb1 136 ts_triangle *orig_tria[]={lm,lp,lm2,lp1};
2870ab 137
7efbb1 138 //fprintf(stderr,"Backuping!!!\n");
SP 139     bck_bond=(ts_bond *)malloc(sizeof(ts_bond));
2870ab 140 for(i=0;i<4;i++){
7efbb1 141 /*    fprintf(stderr,"vtx neigh[%d]=",i);
SP 142     for(j=0;j<orig_vtx[i]->neigh_no;j++) fprintf(stderr," %d", orig_vtx[i]->neigh[j]->idx);
143     fprintf(stderr,"\n");
144 */
2870ab 145     bck_vtx[i]=(ts_vertex *)malloc(sizeof(ts_vertex));
SP 146     bck_tria[i]=(ts_triangle *)malloc(sizeof(ts_triangle));
7efbb1 147     memcpy((void *)bck_vtx[i],(void *)orig_vtx[i],sizeof(ts_vertex));
SP 148     memcpy((void *)bck_tria[i],(void *)orig_tria[i],sizeof(ts_triangle));
2870ab 149     /* level 2 pointers */
7efbb1 150
2870ab 151     bck_vtx[i]->neigh=(ts_vertex **)malloc(orig_vtx[i]->neigh_no*sizeof(ts_vertex *));
SP 152     bck_vtx[i]->tristar=(ts_triangle **)malloc(orig_vtx[i]->tristar_no*sizeof(ts_triangle *));
153     bck_vtx[i]->bond=(ts_bond **)malloc(orig_vtx[i]->bond_no*sizeof(ts_bond *));
154     bck_tria[i]->neigh=(ts_triangle **)malloc(orig_tria[i]->neigh_no*sizeof(ts_triangle *));
155
7efbb1 156     memcpy((void *)bck_vtx[i]->neigh,(void *)orig_vtx[i]->neigh,orig_vtx[i]->neigh_no*sizeof(ts_vertex *));
SP 157     memcpy((void *)bck_vtx[i]->tristar,(void *)orig_vtx[i]->tristar,orig_vtx[i]->tristar_no*sizeof(ts_triangle *));
158     memcpy((void *)bck_vtx[i]->bond,(void *)orig_vtx[i]->bond,orig_vtx[i]->bond_no*sizeof(ts_bond *));
b866cf 159     
7efbb1 160     memcpy((void *)bck_tria[i]->neigh,(void *)orig_tria[i]->neigh,orig_tria[i]->neigh_no*sizeof(ts_triangle *));    
SP 161 }
162     memcpy(bck_bond,bond,sizeof(ts_bond));
163 //fprintf(stderr,"Backup complete!!!\n");
164 /* end backup vertex */
165
414b8a 166 /* Save old energy */
b866cf 167   oldenergy=0;
M 168   oldenergy+=k->xk* k->energy;
169   oldenergy+=kp->xk* kp->energy;
170   oldenergy+=km->xk* km->energy;
171   oldenergy+=it->xk* it->energy;
032273 172   oldenergy+=bond->energy; /* attraction with neighboring vertices, that have spontaneous curvature */
414b8a 173   //Neigbours of k, it, km, kp don't change its energy.
aec47d 174
1121fa 175     if(vesicle->pswitch == 1 || vesicle->tape->constvolswitch>0){dvol = -lm->volume - lp->volume;}
c0ae90 176     if(vesicle->tape->constareaswitch==2){darea=-lm->area-lp->area;} 
dd5aca 177 /*    vesicle_volume(vesicle);
SP 178     fprintf(stderr,"Volume in the beginning=%1.16e\n", vesicle->volume);
179 */
620ba7 180     if(vesicle->tape->stretchswitch==1){
SP 181         temp_area=vesicle->area-lm->area-lp->area;
182     }
414b8a 183 /* fix data structure for flipped bond */
032273 184     ts_flip_bond(k,it,km,kp, bond,lm, lp, lm2, lp1, vesicle->tape->w);
aec47d 185
SP 186
b866cf 187 /* Calculating the new energy */
M 188   delta_energy=0;
189   delta_energy+=k->xk* k->energy;
190   delta_energy+=kp->xk* kp->energy;
191   delta_energy+=km->xk* km->energy;
192   delta_energy+=it->xk* it->energy;
032273 193   delta_energy+=bond->energy; /* attraction with neighboring vertices, that have spontaneous curvature */
414b8a 194   //Neigbours of k, it, km, kp don't change its energy.
7ec6fb 195     if(vesicle->tape->stretchswitch==1){
620ba7 196 /*        oldenergy+=lm->energy+lp->energy;
7ec6fb 197         stretchenergy(vesicle,lm);
SP 198         stretchenergy(vesicle,lp);
199         delta_energy+=lm->energy+lp->energy;
620ba7 200     */
SP 201         temp_area=temp_area+lm->area+lp->area;
0a1e99 202         delta_energy+=0.5*vesicle->tape->xkA0*(stretchenergy2(temp_area,vesicle->tlist->a0*vesicle->tlist->n)-stretchenergy2(vesicle->area,vesicle->tlist->a0*vesicle->tlist->n));
7ec6fb 203     }
414b8a 204
fbcbdf 205     delta_energy-=oldenergy;
1121fa 206     if(vesicle->pswitch == 1 || vesicle->tape->constvolswitch>0){
414b8a 207         dvol = dvol + lm->volume + lp->volume;
fbcbdf 208         if(vesicle->pswitch==1) delta_energy-= vesicle->pressure*dvol;
414b8a 209     }
c0ae90 210     if(vesicle->tape->constareaswitch==2){
SP 211         darea=darea+lm->area+lp->area; 
212 /*check whether the dvol is gt than epsvol */
213         if(fabs(vesicle->area+darea-A0)>epsarea){
214             //restore old state.
215             /* restoration procedure copied from few lines below */
216                 for(i=0;i<4;i++){
217             //            fprintf(stderr,"Restoring vtx neigh[%d] with neighbours %d\n",i, orig_vtx[i]->neigh_no );
218                 free(orig_vtx[i]->neigh);
219                 free(orig_vtx[i]->tristar);
220                 free(orig_vtx[i]->bond);
221                 free(orig_tria[i]->neigh);
222                 memcpy((void *)orig_vtx[i],(void *)bck_vtx[i],sizeof(ts_vertex));
223                 memcpy((void *)orig_tria[i],(void *)bck_tria[i],sizeof(ts_triangle));
224             //            fprintf(stderr,"Restored vtx neigh[%d] with neighbours %d\n",i, orig_vtx[i]->neigh_no );
225                 /* level 2 pointers are redirected*/
226                 }
227                 memcpy(bond,bck_bond,sizeof(ts_bond));
228                 for(i=0;i<4;i++){
229                 free(bck_vtx[i]);
230                 free(bck_tria[i]);
231             /*            fprintf(stderr,"Restoring vtx neigh[%d] with neighbours %d =",i, orig_vtx[i]->neigh_no );
232                 for(j=0;j<orig_vtx[i]->neigh_no;j++) fprintf(stderr," %d", orig_vtx[i]->neigh[j]->idx);
233                 fprintf(stderr,"\n"); */
234                 }
235                 free(bck_bond);
236                 return TS_FAIL;
237
238         }
239     }
240
241
242
fbcbdf 243
1121fa 244     if(vesicle->tape->constvolswitch == 2){
SP 245         /*check whether the dvol is gt than epsvol */
246         if(fabs(vesicle->volume+dvol-V0)>epsvol){
247             //restore old state.
248             /* restoration procedure copied from few lines below */
249                 for(i=0;i<4;i++){
250             //            fprintf(stderr,"Restoring vtx neigh[%d] with neighbours %d\n",i, orig_vtx[i]->neigh_no );
251                 free(orig_vtx[i]->neigh);
252                 free(orig_vtx[i]->tristar);
253                 free(orig_vtx[i]->bond);
254                 free(orig_tria[i]->neigh);
255                 memcpy((void *)orig_vtx[i],(void *)bck_vtx[i],sizeof(ts_vertex));
256                 memcpy((void *)orig_tria[i],(void *)bck_tria[i],sizeof(ts_triangle));
257             //            fprintf(stderr,"Restored vtx neigh[%d] with neighbours %d\n",i, orig_vtx[i]->neigh_no );
258                 /* level 2 pointers are redirected*/
259                 }
260                 memcpy(bond,bck_bond,sizeof(ts_bond));
261                 for(i=0;i<4;i++){
262                 free(bck_vtx[i]);
263                 free(bck_tria[i]);
264             /*            fprintf(stderr,"Restoring vtx neigh[%d] with neighbours %d =",i, orig_vtx[i]->neigh_no );
265                 for(j=0;j<orig_vtx[i]->neigh_no;j++) fprintf(stderr," %d", orig_vtx[i]->neigh[j]->idx);
266                 fprintf(stderr,"\n"); */
267                 }
268                 free(bck_bond);
269                 return TS_FAIL;
270
271         }
272
273     } else
fbcbdf 274     if(vesicle->tape->constvolswitch == 1){
dd5aca 275         retval=constvolume(vesicle, it, -dvol, &delta_energy_cv, &constvol_vtx_moved,&constvol_vtx_backup);
fbcbdf 276         if(retval==TS_FAIL){
SP 277 /* restoration procedure copied from few lines below */
dd5aca 278             for(i=0;i<4;i++){
SP 279     //            fprintf(stderr,"Restoring vtx neigh[%d] with neighbours %d\n",i, orig_vtx[i]->neigh_no );
280                 free(orig_vtx[i]->neigh);
281                 free(orig_vtx[i]->tristar);
282                 free(orig_vtx[i]->bond);
283                 free(orig_tria[i]->neigh);
284                 memcpy((void *)orig_vtx[i],(void *)bck_vtx[i],sizeof(ts_vertex));
285                 memcpy((void *)orig_tria[i],(void *)bck_tria[i],sizeof(ts_triangle));
286     //            fprintf(stderr,"Restored vtx neigh[%d] with neighbours %d\n",i, orig_vtx[i]->neigh_no );
287                 /* level 2 pointers are redirected*/
288             }
289             memcpy(bond,bck_bond,sizeof(ts_bond));
290             for(i=0;i<4;i++){
291                 free(bck_vtx[i]);
292                 free(bck_tria[i]);
293     /*            fprintf(stderr,"Restoring vtx neigh[%d] with neighbours %d =",i, orig_vtx[i]->neigh_no );
294                 for(j=0;j<orig_vtx[i]->neigh_no;j++) fprintf(stderr," %d", orig_vtx[i]->neigh[j]->idx);
295                 fprintf(stderr,"\n"); */
296             }
297             free(bck_bond);
298             return TS_FAIL;
fbcbdf 299         }
b2fa8c 300         delta_energy+=delta_energy_cv;
fbcbdf 301     }
SP 302
414b8a 303
b866cf 304 /* MONTE CARLO */
M 305     if(delta_energy>=0){
306 #ifdef TS_DOUBLE_DOUBLE
fbcbdf 307         if(exp(-delta_energy)< drand48())
b866cf 308 #endif
M 309 #ifdef TS_DOUBLE_FLOAT
310         if(expf(-delta_energy)< (ts_float)drand48())
311 #endif
312 #ifdef TS_DOUBLE_LONGDOUBLE
313         if(expl(-delta_energy)< (ts_ldouble)drand48())
314 #endif
315         {
316             //not accepted, reverting changes
7efbb1 317         //restore all backups
SP 318 //        fprintf(stderr,"Restoring!!!\n");
b2fa8c 319         if(vesicle->tape->constvolswitch == 1){
SP 320             constvolumerestore(constvol_vtx_moved,constvol_vtx_backup);
321         }
aec47d 322
7efbb1 323         for(i=0;i<4;i++){
SP 324 //            fprintf(stderr,"Restoring vtx neigh[%d] with neighbours %d\n",i, orig_vtx[i]->neigh_no );
325             free(orig_vtx[i]->neigh);
326             free(orig_vtx[i]->tristar);
327             free(orig_vtx[i]->bond);
328             free(orig_tria[i]->neigh);
329             memcpy((void *)orig_vtx[i],(void *)bck_vtx[i],sizeof(ts_vertex));
330             memcpy((void *)orig_tria[i],(void *)bck_tria[i],sizeof(ts_triangle));
331 //            fprintf(stderr,"Restored vtx neigh[%d] with neighbours %d\n",i, orig_vtx[i]->neigh_no );
332             /* level 2 pointers are redirected*/
333         }
334         memcpy(bond,bck_bond,sizeof(ts_bond));
2870ab 335
7efbb1 336         for(i=0;i<4;i++){
SP 337             free(bck_vtx[i]);
338             free(bck_tria[i]);
339 /*            fprintf(stderr,"Restoring vtx neigh[%d] with neighbours %d =",i, orig_vtx[i]->neigh_no );
340             for(j=0;j<orig_vtx[i]->neigh_no;j++) fprintf(stderr," %d", orig_vtx[i]->neigh[j]->idx);
341             fprintf(stderr,"\n"); */
342         }
2870ab 343
SP 344         free(bck_bond);
fbcbdf 345
7efbb1 346 //        fprintf(stderr,"Restoration complete!!!\n");
dd5aca 347 //    vesicle_volume(vesicle);
SP 348 //    fprintf(stderr,"Volume after fail=%1.16e\n", vesicle->volume);
620ba7 349 /*    if(vesicle->tape->stretchswitch==1){
7ec6fb 350         stretchenergy(vesicle,lm);
SP 351         stretchenergy(vesicle,lp);
352     }
620ba7 353 */
7efbb1 354         return TS_FAIL;
b866cf 355         }
M 356     }
357      /* IF BONDFLIP ACCEPTED, THEN RETURN SUCCESS! */
fbcbdf 358 //            fprintf(stderr,"SUCCESS!!!\n");
2870ab 359
c0ae90 360     if(vesicle->tape->constvolswitch == 2){
SP 361         vesicle->volume+=dvol;
362     } else if(vesicle->tape->constvolswitch == 1){
b2fa8c 363         constvolumeaccept(vesicle,constvol_vtx_moved,constvol_vtx_backup);
SP 364     }
c0ae90 365     if(vesicle->tape->constareaswitch==2){
SP 366         vesicle->area+=darea;
367     }
620ba7 368     if(vesicle->tape->stretchswitch==1){
SP 369         vesicle->area=temp_area;
370     }
371
2870ab 372     // delete all backups
SP 373     for(i=0;i<4;i++){
7efbb1 374     free(bck_vtx[i]->neigh);
SP 375     free(bck_vtx[i]->bond);
376     free(bck_vtx[i]->tristar);
377     free(bck_vtx[i]);
2870ab 378      free(bck_tria[i]->neigh);
SP 379         free(bck_tria[i]);
7efbb1 380 /*    fprintf(stderr,"Afret backup deletion vtx neigh[%d]=",i);
SP 381     for(j=0;j<orig_vtx[i]->neigh_no;j++) fprintf(stderr," %d", orig_vtx[i]->neigh[j]->idx);
382     fprintf(stderr,"\n");
383 */    
2870ab 384     }
7efbb1 385     free(bck_bond);
SP 386
dd5aca 387 //    vesicle_volume(vesicle);
SP 388 //    fprintf(stderr,"Volume after success=%1.16e\n", vesicle->volume);
b866cf 389     return TS_SUCCESS;
aec47d 390 }
SP 391
392
b866cf 393 ts_bool ts_flip_bond(ts_vertex *k,ts_vertex *it,ts_vertex *km, ts_vertex *kp,
032273 394 ts_bond *bond, ts_triangle *lm, ts_triangle *lp, ts_triangle *lm2, ts_triangle *lp1, ts_double w_energy){
b866cf 395
M 396     ts_uint i; //lmidx, lpidx;
397 if(k==NULL || it==NULL || km==NULL || kp==NULL){
398     fatal("ts_flip_bond: You called me with invalid pointers to vertices",999);
399 }
aec47d 400 // 2. step. We change the triangle vertices... (actual bond flip)
SP 401     for(i=0;i<3;i++) if(lm->vertex[i]== it) lm->vertex[i]= kp;
402     for(i=0;i<3;i++) if(lp->vertex[i]== k) lp->vertex[i]= km;
e19e79 403 //fprintf(stderr,"2. step: actual bondflip made\n");
aec47d 404 // 2a. step. If any changes in triangle calculations must be done, do it here!
SP 405 //   * normals are recalculated here
406     triangle_normal_vector(lp);
407     triangle_normal_vector(lm);
e19e79 408 //fprintf(stderr,"2a. step: triangle normals recalculated\n");
aec47d 409 // 3. step. Correct neighbours in vertex_list
SP 410
411
30ee9c 412             vtx_remove_neighbour(k,it);
306559 413 //            vtx_remove_neighbour(it,k);
e19e79 414 //fprintf(stderr,"3. step (PROGRESS): removed k and it neighbours\n");
306559 415     
aec47d 416             //Tukaj pa nastopi tezava... Kam dodati soseda?
30ee9c 417             vtx_insert_neighbour(km,kp,k);
SP 418             vtx_insert_neighbour(kp,km,it);
aec47d 419 //            vertex_add_neighbour(km,kp); //pazi na vrstni red.
SP 420 //            vertex_add_neighbour(kp,km);
e19e79 421 //fprintf(stderr,"3. step: vertex neighbours corrected\n");
aec47d 422
SP 423 // 3a. step. If any changes to ts_vertex, do it here!
424 //   bond_length calculatons not required for it is done in energy.c
425
426 // 4. step. Correct bond_list (don't know why I still have it!)
427             bond->vtx1=km;
428             bond->vtx2=kp;
429 //fprintf(stderr,"4. step: bondlist corrected\n");
430
431
432 // 5. step. Correct neighbouring triangles 
433    
434     triangle_remove_neighbour(lp,lp1);
e19e79 435   //  fprintf(stderr,".\n");
aec47d 436     triangle_remove_neighbour(lp1,lp);
SP 437   //  fprintf(stderr,".\n");
438     triangle_remove_neighbour(lm,lm2);
439   //  fprintf(stderr,".\n");
440     triangle_remove_neighbour(lm2,lm);
441    
442     triangle_add_neighbour(lm,lp1);    
443     triangle_add_neighbour(lp1,lm);
444     triangle_add_neighbour(lp,lm2);  //Vrstni red?!
445     triangle_add_neighbour(lm2,lp);
446
447 //fprintf(stderr,"5. step: triangle neigbours corrected\n");
448
449
450 // 6. step. Correct tristar for vertices km, kp, k and it
451             vertex_add_tristar(km,lp);  // Preveri vrstni red!
452             vertex_add_tristar(kp,lm);
30ee9c 453             vtx_remove_tristar(it,lm);
SP 454             vtx_remove_tristar(k,lp);
aec47d 455 //fprintf(stderr,"6. step: tristar corrected\n");
SP 456   energy_vertex(k);
457   energy_vertex(kp);
458   energy_vertex(km);
459   energy_vertex(it);
032273 460   attraction_bond_energy(bond, w_energy);
aec47d 461 // END modifications to data structure!
SP 462     return TS_SUCCESS;
463 }