| | |
| | | import multiprocessing |
| | | import django |
| | | from time import sleep |
| | | import math |
| | | |
| | | def count_bonds_with_energy(blist): |
| | | cnt=0 |
| | |
| | | cnt+=1 |
| | | return cnt |
| | | |
| | | |
| | | def average_normal_force_in_vtu(vesicle): |
| | | F=[0,0,0] |
| | | for i in range(0,vesicle.contents.vlist.contents.n): |
| | | cvtx=vesicle.contents.vlist.contents.vtx[i] |
| | | if(abs(cvtx.contents.c)>1e-15): |
| | | normal=[0,0,0] |
| | | for k in range(0,cvtx.contents.tristar_no): |
| | | normal[0]=normal[0]+cvtx.contents.tristar[k].contents.xnorm |
| | | normal[1]=normal[1]+cvtx.contents.tristar[k].contents.ynorm |
| | | normal[2]=normal[2]+cvtx.contents.tristar[k].contents.znorm |
| | | F[0]=F[0]+normal[0]/math.sqrt(pow(normal[0],2)+pow(normal[1],2)+pow(normal[2],2)) |
| | | F[1]=F[1]+normal[1]/math.sqrt(pow(normal[0],2)+pow(normal[1],2)+pow(normal[2],2)) |
| | | F[2]=F[2]+normal[2]/math.sqrt(pow(normal[0],2)+pow(normal[1],2)+pow(normal[2],2)) |
| | | #F=[f*vesicle.contents.tape.contents.F for f in F] |
| | | return F |
| | | |
| | | def sum_stretching_energy(vesicle, only_c0_c0=False): |
| | | return 0.0 |
| | | energy=0.0 |
| | | for i in range(0,vesicle.contents.tlist.contents.n): |
| | | # if (only_c0_c0 is True |
| | |
| | | l1,l2,l3=ts.gyration_eigen(vesicle) |
| | | hbar=ts.vesicle_meancurvature(vesicle)/vesicle.contents.area |
| | | count_bonds=count_bonds_with_energy(vesicle.contents.blist) |
| | | avg_normal_force=average_normal_force_in_vtu(vesicle) |
| | | retval={'volume':vesicle.contents.volume, |
| | | 'area': vesicle.contents.area, |
| | | 'hbar':hbar, |
| | |
| | | 'l3':l3, |
| | | 'Nbw/Nb':count_bonds/vesicle.contents.blist.contents.n, |
| | | 'StretchingE': sum_stretching_energy(vesicle), |
| | | 'avgFx': avg_normal_force[0], |
| | | 'avgFy': avg_normal_force[1], |
| | | 'avgFz': avg_normal_force[2] |
| | | } |
| | | return retval |
| | | |
| | |
| | | csvdict=read_csv(os.path.join(directory,'data_tspoststat.csv')) |
| | | except FileNotFoundError: |
| | | #print("no file") |
| | | csvdict={'OuterLoop':['OuterLoop', 'Volume', 'Area', 'lamdba1', 'lambda2', 'lambda3', 'Nbw/Nb', 'hbar', 'StretchingE']} |
| | | csvdict={'OuterLoop':['OuterLoop', 'Volume', 'Area', 'lamdba1', 'lambda2', 'lambda3', 'Nbw/Nb', 'hbar', 'StretchingE', 'avgFx', 'avgFy', 'avgFz']} |
| | | filedict=get_vtu_dict(directory) |
| | | modified=False |
| | | for f in filedict: |
| | |
| | | '{:.17e}'.format(p['l3']), |
| | | '{:.17e}'.format(p['Nbw/Nb']), |
| | | '{:.17e}'.format(p['hbar']), |
| | | '{:.17e}'.format(p['StretchingE'])] |
| | | '{:.17e}'.format(p['StretchingE']), |
| | | '{:.17e}'.format(p['avgFx']), |
| | | '{:.17e}'.format(p['avgFy']), |
| | | '{:.17e}'.format(p['avgFz'])] |
| | | modified=True |
| | | if modified: |
| | | write_csv(os.path.join(directory,'data_tspoststat.csv'), csvdict) |
| | | |
| | | def clean_poststat_directory(directory): |
| | | """Function deletes data_tspoststat.csv created by tspoststat in given directory, enabling forcing of re-tspostating it""" |
| | | try: |
| | | os.remove(os.path.join(directory, 'data_tspoststat.csv')) |
| | | except FileNotFoundError: |
| | | pass |
| | | |
| | | class PostProcess(multiprocessing.Process): |
| | | |
| | |
| | | self.dirlist=dirlist |
| | | def run(self): |
| | | for d in self.dirlist: |
| | | clean_poststat_directory(d) |
| | | poststat_directory(d) |
| | | print("Directory {} done".format(d)) |
| | | print("All done for this process") |