# r_sq_box = ((r_box[:, :, :, 0] - location[0]) / radius[0])**2 + \
#        ((r_box[:, :, :, 1] - location[1]) / radius[1])**2 + \
#        ((r_box[:, :, :, 2] - location[2]) / radius[2])**2
# idx_scat_box = (r_sq_box <= 1)

idx_scat_box = (np.abs(r_box[:, :, :, 0] - slab_centre[0]) < slab_width / 2)

# Voxel permittivities
Mr_box = np.zeros((L_box, M_box, N_box), dtype=np.complex128)
Mr_box[idx_scat_box] = refInd**2 - 1
'''         Solve scattering problem only over inhomogeneous region         '''
# FIXME: come up with a better name for J
sol, J, u_sca = vie_solver(Mr_box, r_box, idx_scat_box, P_inc[0][idx_scat], k1)
'''          Evaluate total field over total domain (u_inc + u_sca)         '''
# Toeplitz operator
T = k1**2 * volume_potential(k1, r)

# Circulant embedding of Toeplitz operator
circ = circulant_embed_fftw(T, L, M, N)

# Voxel permittivities
Mr = np.zeros((L, M, N), dtype=np.complex128)
Mr[idx_scat] = refInd**2 - 1

RHO = rho * np.ones((L, M, N), dtype=np.complex128)
RHO[idx_scat] = rho_scat

C = c * np.ones((L, M, N), dtype=np.complex128)
C[idx_scat] = c_scat

BETA = beta * np.ones((L, M, N), dtype=np.complex128)
Example #2
0
           cmap=plt.cm.get_cmap('viridis'),
           interpolation='spline16')
plt.xlabel(r'$x$ (cm)')
plt.ylabel(r'$y$ (cm)')
cbar = plt.colorbar()
cbar.ax.set_ylabel('Pressure (MPa)')
fig.savefig('results/H101.png')
plt.close()
'''      Compute the next harmonics by evaluating the volume potential      '''
for i_harm in range(1, n_harm):
    f2 = (i_harm + 1) * f1
    k2 = 2 * np.pi * f2 / c + 1j * attenuation(f2, alpha0, eta)

    # Assemble volume potential Toeplitz operator perform circulant embedding
    start = time.time()
    toep_op = volume_potential(k2, r)

    circ_op = circulant_embed_fftw(toep_op, L, M, N)
    end = time.time()
    print('Operator assembly and its circulant embedding:', end - start)

    # Create vector for matrix-vector product
    if i_harm == 1:
        # Second harmonic
        xIn = -2 * beta * omega**2 / (rho * c**4) * P[0] * P[0]
    elif i_harm == 2:
        # Third harmonic
        xIn = -9 * beta * omega**2 / (rho * c**4) * P[0] * P[1]
    elif i_harm == 3:
        # Fourth harmonic
        xIn = -8 * beta * omega**2 / (rho * c**4) * \
Example #3
0
ax.set_xlabel('$x$')
ax.set_ylabel('$y$')
ax.set_zlabel('$z$')
set_axes_equal(ax)
fig.savefig('results/sphere_voxels.png')
plt.close()

# Get plane wave incident field
Uinc = PlaneWave(Ao, ko, direction, r)

# Voxel permittivities
Mr = np.zeros((L, M, N), dtype=np.complex128)
Mr[idx] = refInd**2 - 1

# Assemble volume potential operator
toep = volume_potential(ko, r)
toep = ko**2 * toep

# Circulant embedding of volume potential operator
circ_op = circulant_embed_fftw(toep, L, M, N)

# Create array that has the incident field values in sphere, and zero outside
xIn = np.zeros((L, M, N), dtype=np.complex128)
xIn[idx] = Uinc[idx]
xInVec = xIn.reshape((L * M * N, 1), order='F')


def mvp(x):
    'Matrix-vector product operator'
    return mvp_vec_fftw(x, circ_op, idx, Mr)
# Get mesh geometry and interior wavelength
r, idx, res, P, lambda_int = shape(geom, refInd, lam, radius, nPerLam, 1)

(L, M, N) = r.shape[0:3]  # number of voxels in x-, y-, z-directions

# Shift the coordinates
r[:, :, :, 0] = r[:, :, :, 0] + scat_loc[0]

points = r.reshape(L * M * N, 3, order='F')

# Voxel permittivities
Mr = np.zeros((L, M, N), dtype=np.complex128)
Mr[idx] = refInd**2 - 1

# Assemble volume potential operator
toep = volume_potential(k1, r)
toep = k1**2 * toep

# Circulant embedding of volume potential operator
circ_op = circulant_embed_fftw(toep, L, M, N)

# Generate incident field
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 +
                          points[:, 2]**2)
idx_near = np.abs(dist_from_focus - roc) < 5e-4
Example #5
0
#        ((r_box[:, :, :, 2] - location[2]) / radius[2])**2
# idx_scat_box = (r_sq_box <= 1)

idx_scat_box = (np.abs(r_box[:, :, :, 0] - slab_centre[0]) < slab_width/2)

# Voxel permittivities
Mr_box = np.zeros((L_box, M_box, N_box), dtype=np.complex128)
Mr_box[idx_scat_box] = refInd**2 - 1

'''         Solve scattering problem only over inhomogeneous region         '''
# FIXME: come up with a better name for J
sol, J, u_sca = vie_solver(Mr_box, r_box, idx_scat_box, P_inc[0][idx_scat], k1)

'''          Evaluate total field over total domain (u_inc + u_sca)         '''
# Toeplitz operator
T = k1**2 * volume_potential(k1, r)

# Circulant embedding of Toeplitz operator
circ = circulant_embed_fftw(T, L, M, N)

# Voxel permittivities
Mr = np.zeros((L, M, N), dtype=np.complex128)
Mr[idx_scat] = refInd**2 - 1

RHO = rho * np.ones((L, M, N), dtype=np.complex128)
RHO[idx_scat] = rho_scat

C = c * np.ones((L, M, N), dtype=np.complex128)
C[idx_scat] = c_scat

J_domain = np.zeros((L, M, N), dtype=np.complex128)