Based on calculations from the K-wave manual the simulation I am running requires an incredibly small time step to remain stable and prevent phase error(~e-11), I am currently having issues storing the matrix of transmit receive values and cannot find a way to store the values at certain time intervals, eg every 500 steps, in the k-wave code and documentation, I was wondering if one is available?
k-Wave
A MATLAB toolbox for the time-domain
simulation of acoustic wave fields
Time between saving steps
(5 posts) (2 voices)-
Posted 11 years ago #
-
it appears that I have miscalculated that time step, although the question about storing data at intervals still stands, thanks.
Posted 11 years ago # -
In the current code there is no way to only store the data at some of the time steps. However, that would be relatively easy to implement. For example, in the 3D MATLAB code, on line 979 change
(t_index >= sensor.record_start_index)
to
(rem(t_index, save_step) == 0)
where
save_step
is an integer which defines how often you want to save the data. Note that this modification would also need some changes to hownum_recorded_time_points
is defined in/private/kspaceFirstOrder_createStorageVariables
.It is currently possible to set when the recording starts by defining
sensor.record_start_index
. This is useful if you're only interested in storing the wave-field after it reaches steady state (for example).Brad.
Posted 11 years ago # -
I have posted the changes I made below, in case anyone else needs to implement this.
I changed kspaceFirstOrder2D line 886 to add the further condition
&& mod(t_index,save_step)==0
and line 891 to
file_index = floor(t_index/save_step) - sensor.record_start_index + 1
I changed line 73 of /private/kspaceFirstOrder_createStorageVariables
num_recorded_time_points = floor(kgrid.Nt/save_step) - sensor.record_start_index + 1;
the final change I made was to add the input option using 'SaveFreq' to input_args by adding the following after line 739
case 'SaveFreq' save_step = varargin{input_index + 1};
also, thanks for the help.
Posted 11 years ago # -
Glad you got it to work, and thanks for posting your code!
Posted 11 years ago #
Reply
You must log in to post.