I am new to kwave and planning to model a 2D array transducer of 32x32 element and I am a bit confused as most of the examples are for the 1D array can you check my code as the transducer is my sensor and grid size is 192x192x192 and dx=0.73 mm, my pressure source is varying with time. The code below is for 1D array how to generalize it for 2D array?
% create empty array
karray = kWaveArray;
sensor_focus = 100e-3; % focal length [m]
element_num = 32; % number of elements
element_width = 3.65e-3; % width [m]
element_length = 3.65e-3; % elevation height [m]
element_pitch = 0.2e-3; % pitch [m]
% set indices for each element of the array transducer
if rem(element_num, 2)
ids = (1:element_num) - ceil(element_num/2);
else
ids = (1:element_num) - (element_num + 1)/2;
end
% create empty kWaveArray
karray = kWaveArray('BLITolerance', 0.05, 'UpsamplingRate', 10);
for ind = 1:element_num
% set element y position
x_pos(ind) = 0 - (element_num * element_width / 2 - element_width / 2) + (ind - 1) * element_width;
% add element (see note in header)
karray.addRectElement([x_pos(ind), 0, kgrid.z_vec(1)], element_width, element_length,[0,0,0]);
end
% assign binary mask
sensor.mask = karray.getArrayBinaryMask(kgrid);