Ejemplo n.º 1
0
# Mesh resolution (number of voxels per fundamental wavelength)
nPerLam = 5

# Create voxel mesh
dx = lam / nPerLam

# Dimension of computation domain
x_start = roc - 0.02
x_end = roc + 0.02
wx = x_end - x_start
wy = outer_D * 0.3
wz = wy
# embed()

start = time.time()
r, L, M, N = generatedomain(dx, wx, wy, wz)
# Adjust r
r[:, :, :, 0] = r[:, :, :, 0] - r[0, 0, 0, 0] + x_start
end = time.time()
print('Mesh generation time:', end - start)
# embed()
points = r.reshape(L * M * N, 3, order='F')

print('Number of voxels = ', L * M * N)

# Generate incident field
start = time.time()
n_elements = 2**12
x, y, z, p = bowl_transducer_rotate(k1, roc, focus, outer_D / 2, n_elements,
                                    inner_D / 2, points.T, 'x', rot_angle)
end = time.time()
# Dimension of computation domain
# x_start needs to be close to the transducer
# x_end can be just beyond the focus
# the width in the y,z directions should be around the width of outer_D,
# but you can shrink this to speed up computations if required
# x_start = 0.001
x_start = roc - 0.99 * np.sqrt(roc**2 - (outer_D / 2)**2)
x_end = roc + 0.01
wx = x_end - x_start
wy = outer_D * 1
wz = wy

start_to_focus = roc - x_start

start = time.time()
r, L, M, N = generatedomain(dx, wx, wy, wz)
# Adjust r
r[:, :, :, 0] = r[:, :, :, 0] - r[0, 0, 0, 0] + x_start
end = time.time()
print('Mesh generation time:', end - start)
points = r.reshape(L * M * N, 3, order='F')

print('Number of voxels = ', L * M * N)

start = time.time()
n_elements = 2**12
x, y, z, p = bowl_transducer(k1, roc, focus, outer_D / 2, n_elements,
                             inner_D / 2, points.T, 'x')
end = time.time()
print('Incident field evaluation time (s):', end - start)
dist_from_focus = np.sqrt((points[:, 0] - focus[0])**2 + points[:, 1]**2 +
Ejemplo n.º 3
0
                    linestyle=':')
ax.add_artist(circle)
plt.colorbar()
fig.savefig('results/sphere_focused.pdf')
plt.close()

# Create a bigger grid over which we evaluate the total field
dx = res
wx = max(r[:, 0, 0, 0]) - min(r[:, 0, 0, 0]) + 4 * dx
wy = max(r[0, :, 0, 1]) - min(r[0, :, 0, 1]) + 4 * dx
wz = max(r[0, 0, :, 2]) - min(r[0, 0, :, 2]) + 4 * dx
# embed()

start = time.time()
from vines.geometry.geometry import generatedomain, grid3d
r_b, L_b, M_b, N_b = generatedomain(dx, wx, wy, wz)
# r_b[:, :, :, 0] = r_b[:, :, :, 0] + scat_loc[0]
# Adjust r
# r[:, :, :, 0] = r[:, :, :, 0] - r[0, 0, 0, 0] + x_start
# end = time.time()
# print('Mesh generation time:', end-start)
# embed()

from IPython import embed
embed()

# Find the indices of the voxels within the sphere
r_sq = r_b[:, :, :, 0]**2 + r_b[:, :, :, 1]**2 + r_b[:, :, :, 2]**2
idx_b = (r_sq <= radius**2)

r_b[:, :, :, 0] = r_b[:, :, :, 0] + scat_loc[0]
Ejemplo n.º 4
0
# x_start = -0.98 * np.sqrt(focal_length**2 - radius**2) # just to the right of bowl
# x_end = 0.01
# wx = x_end - x_start
# wy = 2 * 0.83 * radius # slightly narrower than bowl
# # wy = 2 * radius # same width as bowl
# wz = wy
x_start = 0.0005
x_end = 0.06

wx = x_end - x_start
wy = 2 * radius 
wz = wy
# embed()
import time
start = time.time()
r, L, M, N = generatedomain(res, wx, wy, wz)
# Adjust r
r[:, :, :, 0]  = r[:, :, :, 0] - r[0, 0, 0, 0] + x_start
end = time.time()
print('Mesh generation time:', end-start)
# embed()
points = r.reshape(L*M*N, 3, order='F')

start = time.time()
p = plane_circular_piston(radius, k1, points.T)
p *= pressure_surface * 2j * k1
P = p.reshape(L, M, N, order='F')
end = time.time()
print('Incident field evaluation time (s):', end-start)