def sinogram(): # SIMULATION PARAMETERS ----------------------------------------------- G = 1.0 # Grueneisen parameter c0 = 150000. # speed of sound (cm/s) R = 0.5001 # OBTAIN ABSORBED ENERGY WITHIN SOURCE VOLUME ------------------------- (x,y,z), (x0,y0,z0), Wxyz = modelSourceVolume() detPos = detectorPositions((x0,z0+0.2),R) for (phi,xD,zD) in detPos: sys.stderr.write("# phi=%lf \n"%(phi)) print "# phi, xD, zD = ", phi, xD, zD print "# D = ", abs(zD-0.1)*2/24/0.15/0.15 # COMPUTE OA EXCESS PRESSURE SIGNAL ----------------------------------- t, p = ps.pressure(((x,y,z),G*Wxyz),(xD,y0,z0+zD),c0) # LIST RESULTS -------------------------------------------------------- tau = t + zD/c0 # retarded time print "# (t in s) (c0 tau in cm) (p(tau) in au)" norm = 1./max(p) for i in range(tau.size): print phi, c0*t[i], c0*tau[i], p[i], p[i]*norm print
def main(): # SIMULATION PARAMETERS ----------------------------------------------- G = 1.0 # Grueneisen parameter c0 = 150000. # speed of sound (cm/s) zD = -0.5 # detector location # OBTAIN ABSORBED ENERGY WITHIN SOURCE VOLUME ------------------------- (x, y, z), (x0, y0, z0), Wxyz = modelSourceVolume() # COMPUTE OA EXCESS PRESSURE SIGNAL ----------------------------------- t, p = ps.pressure(((x, y, z), G * Wxyz), (x0, y0, z0 + zD), c0) # LIST RESULTS -------------------------------------------------------- tau = t + zD / c0 # retarded time print "# (t in s) (c0 tau in cm) (p(tau) in au)" for i in range(tau.size): print t[i], c0 * tau[i], p[i]
def main(): # SIMULATION PARAMETERS ----------------------------------------------- G = 1.0 # Grueneisen parameter c0 = 150000. # speed of sound (cm/s) zD = -0.12 # detector location ftd = float(sys.argv[1]) # flat-top diameter (cm) ma = float(sys.argv[2]) # absorption coefficient (cm^-1) # OBTAIN ABSORBED ENERGY WITHIN SOURCE VOLUME ------------------------- (x, y, z), (x0, y0, z0), Wxyz = modelSourceVolume(ma, ftd) # COMPUTE OA EXCESS PRESSURE SIGNAL ----------------------------------- t, p = ps.pressure(((x, y, z), G * Wxyz), (x0, y0, z0 + zD), c0) # LIST RESULTS -------------------------------------------------------- tau = t + zD / c0 # retarded time print "# (t in s) (c0 tau in cm) (p(tau) in au)" for i in range(tau.size): print t[i], c0 * tau[i], p[i]
def main(): # SIMULATION PARAMETERS ----------------------------------------------- basePath = "../inputData/skinvessel" G = 0.138 # Grueneisen parameter c0 = 150000. # speed of sound (cm/s) xD = float(sys.argv[1]) # detector x-position (cm) yD = float(sys.argv[2]) # detector y-position (cm) zD = float(sys.argv[3]) # detector z-position (cm) # VOLUMETRIC ENERGY DENSITY PER VOXEL --------------------------------- ((x,y,z), Wxyz) = io.mcxyzio.getEnergyDensity(basePath) # OA EXCESS PRESSURE SIGNAL ------------------------------------------- t, p = ps.pressure(((x,y,z),G*Wxyz),(xD,yD,zD),c0) tau = t + zD/c0 print "# (c0 tau) (p(tau))" for i in range(tau.size): print c0*tau[i],p[i]
def main(): # SIMULATION PARAMETERS ----------------------------------------------- G = 0.11 # Grueneisen parameter c0 = 150000. # speed of sound (cm/s) zD = -0.1 # detector location # OBTAIN ABSORBED ENERGY WITHIN SOURCE VOLUME ------------------------- (x, y, z), (x0, y0, z0), Wxyz = modelSourceVolume() # STORE SOURCE VOLUME SLICE AT y0 ------------------------------------- #io.gpl.writeROI(x,z,Wxyz[:,y.size/2,:],'./dataUseCase1/Wxy0z.prof') # COMPUTE OA EXCESS PRESSURE SIGNAL ----------------------------------- t, p = ps.pressure(((x, y, z), G * Wxyz), (x0, y0, z0 + zD), c0) # LIST RESULTS -------------------------------------------------------- tau = t + zD / c0 # retarded time print "# (t in s) (c0 tau in cm) (p(tau) in bar)" for i in range(tau.size): print t[i], c0 * tau[i], p[i]
def main2(): # SIMULATION PARAMETERS ----------------------------------------------- G = 1.0 # Grueneisen parameter c0 = 1.5 # speed of sound (cm/s) zD = 3.250 # detector location rDList = np.linspace(0., 1.5, 20, endpoint=True) # OBTAIN ABSORBED ENERGY WITHIN SOURCE VOLUME ------------------------- (x, y, z), (x0, y0, z0), Wxyz = modelSourceVolume() for idx, rD in enumerate(rDList): # COMPUTE OA EXCESS PRESSURE SIGNAL ----------------------------------- t, p = ps.pressure(((x, y, z), G * Wxyz), (x0 + rD, y0, zD), c0) tau = t + zD / c0 # retarded time print "# (t in s) (c0 tau in cm) (p(tau) in bar)" for i in range(tau.size): print rD, t[i], c0 * tau[i], p[i] print
def main(): # SIMUMATION PARAMETERS ----------------------------------------------- iPath = "../inputData/skinvessel" G = 0.138 # Grueneisen parameter c0 = 150000. # speed of sound (cm/s) # VOLUMETRIC ENERGY DENSITY PER VOXEL --------------------------------- ((x,y,z), Wxyz) = io.mcxyzio.getEnergyDensity(iPath) # GENERAL FIGURE SETTINGS --------------------------------------------- plt.rc('font',family='serif',size=12) plt.figure(figsize=(7.,9.0)) # FIG (a): x-scan ----------------------------------------------------- ax11= plt.subplot2grid((3,2), (0,0)) ax11.set_aspect('equal') ax11.contourf(y,z,Wxyz[:,:,x.size/2]/1000,100,lw=0.1) c1 = ax11.contourf(y,z,Wxyz[:,:,x.size/2]/1000,100) divider1 = make_axes_locatable(ax11) cax11 = divider1.append_axes("right", "5%", pad="3%") c1Bar = plt.colorbar(c1,cax=cax11) c1Bar.set_label('$W(x_0,y,z)$ (kJ/m$^2$)',fontsize=10) c1Bar.ax.tick_params(labelsize=10) ax11.set_ylabel('$z$ (cm)') ax11.set_xlabel('$y$ (cm)') ax11.text(0.,1.05,'(a)',transform=ax11.transAxes,fontsize=12) # FIG (b): y-scan ----------------------------------------------------- ax12= plt.subplot2grid((3,2), (0,1)) ax12.set_aspect('equal') ax12.contour(x,z,Wxyz[:,y.size/2,:]/1000,100,lw=0.1) c2 = ax12.contourf(x,z,Wxyz[:,y.size/2,:]/1000,100) divider2 = make_axes_locatable(ax12) cax12 = divider2.append_axes("right", "5%", pad="3%") c2Bar = plt.colorbar(c2,cax=cax12) c2Bar.set_label('$W(x,y_0,z)$ (kJ/m$^2$)',fontsize=10) c2Bar.ax.tick_params(labelsize=10) ax12.set_ylabel('$z$ (cm)') ax12.set_xlabel('$x$ (cm)') ax12.text(0.,1.05,'(b)',transform=ax12.transAxes,fontsize=12) # FIG (c): OFF-AXIS OA SIGNALS ---------------------------------------- ax21 = plt.subplot2grid((3,2), (1,0), colspan=2) ax21.text(0.5,0.75,'$x_D$=0.05 cm\n$z_D$=-0.20 cm',transform=ax21.transAxes,fontsize=10) xD=0.05 zD=-0.20 for yD in [0.01, 0.03, 0.05]: t, p = ps.pressure(((x,y,z),G*Wxyz/1000),(xD,yD,zD),c0) ax21.plot(c0*t+zD,p, label='$y_D$=%3.2lf cm'%(yD)) ax21.set_xlim([-0.002,0.06]) ax21.set_ylabel('$p$ (kPa per J)') ax21.set_xlabel('$c \\tau$ (cm)') ax21.axhline(y=0,color='black', ls='--') ax21.legend(loc='upper right', prop={'size':10}, frameon=False) ax21.text(0.,1.05,'(c)',transform=ax21.transAxes,fontsize=12) # FIG (d): ON-AXIS OA SIGNALS ----------------------------------------- ax31 = plt.subplot2grid((3,2), (2,0), colspan=2) ax31.text(0.5,0.75,'$x_D$=0.05 cm\n$y_D$=0.05 cm',transform=ax31.transAxes,fontsize=10) xD=0.05 yD=0.05 for zD in [-0.1, -0.4, -1.6]: t, p = ps.pressure(((x,y,z),G*Wxyz/1000),(xD,yD,zD),c0) ax31.plot(c0*t+zD,p, label='$z_D$=%3.2lf cm'%(zD)) ax31.set_xlim([-0.002,0.06]) ax31.set_ylabel('$p$ (kPa per J)') ax31.set_xlabel('$c \\tau$ (cm)') ax31.axhline(y=0,color='black', ls='--') ax31.legend(loc='upper right', prop={'size':10}, frameon=False) ax31.text(0.,1.05,'(d)',transform=ax31.transAxes,fontsize=12) plt.tight_layout() plt.savefig('useCase_mcxyz_abcd.eps',dpi=600,format='eps')
def figure(): # SIMULATION PARAMETERS ----------------------------------------------- G = 0.11 # Grueneisen parameter c0 = 150000. # speed of sound (cm/s) zD = -0.1 # detector location # GENERAL FIGURE SETTINGS --------------------------------------------- plt.rc('font', family='serif', size=12) plt.figure(figsize=(7., 7.)) #io.gpl.writeROI(x,z,Wxyz[:,y.size/2,:],'./dataUseCase1/Wxy0z.prof') # FIG (a): FLAT-TOP ISP ax12 = plt.subplot2grid((2, 2), (0, 0)) ax12.set_aspect('equal') (x, y, z), (x0, y0, z0), Wxyz = modelSourceVolume(0.025) ax12.contour(x, z, Wxyz[:, y.size / 2, :] / 10**6, 100, lw=0.1) c2 = ax12.contourf(x, z, Wxyz[:, y.size / 2, :] / 10**6, 100) divider2 = make_axes_locatable(ax12) cax12 = divider2.append_axes("right", "5%", pad="3%") c2Bar = plt.colorbar(c2, cax=cax12) c2Bar.set_label('$W(x,y_0,z)$ (MJ/m$^2$)', fontsize=10) c2Bar.ax.tick_params(labelsize=10) ax12.set_ylabel('$z$ (cm)') ax12.set_xlabel('$x$ (cm)') ax12.text(0., 1.05, '(a)', transform=ax12.transAxes, fontsize=12) ax12.text(0.05, 0.9, '$a = 0.025$ cm', transform=ax12.transAxes, fontsize=12, color='white') # FIG (b): FLAT-TOP ISP ax13 = plt.subplot2grid((2, 2), (0, 1)) ax13.set_aspect('equal') (x, y, z), (x0, y0, z0), Wxyz = modelSourceVolume(0.194) ax13.contour(x, z, Wxyz[:, y.size / 2, :] / 10**6, 100, lw=0.1) c3 = ax13.contourf(x, z, Wxyz[:, y.size / 2, :] / 10**6, 100) divider3 = make_axes_locatable(ax13) cax13 = divider3.append_axes("right", "5%", pad="3%") c3Bar = plt.colorbar(c3, cax=cax13) c3Bar.set_label('$W(x,y_0,z)$ (MJ/m$^2$)', fontsize=10) c3Bar.ax.tick_params(labelsize=10) ax13.set_ylabel('$z$ (cm)') ax13.set_xlabel('$x$ (cm)') ax13.text(0., 1.05, '(b)', transform=ax13.transAxes, fontsize=12) ax13.text(0.05, 0.9, '$a = 0.194$ cm', transform=ax13.transAxes, fontsize=12, color='white') ax21 = plt.subplot2grid((2, 2), (1, 0), colspan=2) for fta in [0.025, 0.05, 0.075, 0.1, 0.194]: #for fta in [0.025, 0.194]: # OBTAIN ABSORBED ENERGY WITHIN SOURCE VOLUME --------------------- (x, y, z), (x0, y0, z0), Wxyz = modelSourceVolume(fta) # COMPUTE OA EXCESS PRESSURE SIGNAL ------------------------------- t, p = ps.pressure(((x, y, z), G * Wxyz), (x0, y0, z0 + zD), c0) # ADD OA SIGNAL TO PLOT ------------------------------------------- ax21.plot((t + zD / c0) * 10**6, p / 10**5, label='$a$=%3.2lf cm' % (fta)) ax21.set_xlim([-0.01 * 10**6 / c0, 0.23 * 10**6 / c0]) ax21.set_ylabel('$p$ (bar)') ax21.set_xlabel('$\\tau$ ($\\mu$s)') ax21.axhline(y=0, color='black', ls='--') ax21.legend(loc='upper right', prop={'size': 10}, frameon=False) ax21.text(0., 1.05, '(c)', transform=ax21.transAxes, fontsize=12) ax21.text(0.5, 0.92, '$z_D = -0.1$ cm', transform=ax21.transAxes) plt.tight_layout() plt.savefig('useCase_pureAbs_abc.eps', dpi=600, format='eps')