<?xml version="1.0" encoding="UTF-8"?>
<!-- generator="bbPress/1.0.2" -->
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
		<title>k-Wave User Forum &#187; Topic: Save snapshots of the simulation every X timesteps</title>
		<link>http://www.k-wave.org/forum/topic/save-snapshots-of-the-simulation-every-x-timesteps</link>
		<description>Support for the k-Wave MATLAB toolbox</description>
		<language>en-US</language>
		<pubDate>Tue, 12 May 2026 23:40:28 +0000</pubDate>
		<generator>http://bbpress.org/?v=1.0.2</generator>
		<textInput>
			<title><![CDATA[Search]]></title>
			<description><![CDATA[Search all topics from these forums.]]></description>
			<name>q</name>
			<link>http://www.k-wave.org/forum/search.php</link>
		</textInput>
		<atom:link href="http://www.k-wave.org/forum/rss/topic/save-snapshots-of-the-simulation-every-x-timesteps" rel="self" type="application/rss+xml" />

		<item>
			<title>bencox on "Save snapshots of the simulation every X timesteps"</title>
			<link>http://www.k-wave.org/forum/topic/save-snapshots-of-the-simulation-every-x-timesteps#post-8578</link>
			<pubDate>Wed, 13 Jul 2022 18:45:35 +0000</pubDate>
			<dc:creator>bencox</dc:creator>
			<guid isPermaLink="false">8578@http://www.k-wave.org/forum/</guid>
			<description>&#60;p&#62;Thanks guys, noted!&#60;/p&#62;
&#60;p&#62;Best wishes&#60;br /&#62;
Ben
&#60;/p&#62;</description>
		</item>
		<item>
			<title>JBAjo-Franklin on "Save snapshots of the simulation every X timesteps"</title>
			<link>http://www.k-wave.org/forum/topic/save-snapshots-of-the-simulation-every-x-timesteps#post-8564</link>
			<pubDate>Sat, 09 Jul 2022 23:10:17 +0000</pubDate>
			<dc:creator>JBAjo-Franklin</dc:creator>
			<guid isPermaLink="false">8564@http://www.k-wave.org/forum/</guid>
			<description>&#60;p&#62;Up-voting this! I'm trying to do the same thing and a space-filling sensor array is not what I'm looking for. I'm hoping to capture a quantitative snapshot of the wavefield at one point in time rather than a movie or a sensor trace. Also - great code!
&#60;/p&#62;</description>
		</item>
		<item>
			<title>3dfernando on "Save snapshots of the simulation every X timesteps"</title>
			<link>http://www.k-wave.org/forum/topic/save-snapshots-of-the-simulation-every-x-timesteps#post-8536</link>
			<pubDate>Wed, 18 May 2022 19:35:10 +0000</pubDate>
			<dc:creator>3dfernando</dc:creator>
			<guid isPermaLink="false">8536@http://www.k-wave.org/forum/</guid>
			<description>&#60;p&#62;First, thanks for this code. It's really nice to have a toolbox like k-Wave!&#60;/p&#62;
&#60;p&#62;I was wondering if there's a way of having kWave save a full snapshot of the acoustic field at predefined times (say, you run for t=linspace(0,1e-3,1000); and you want snapshots for tSnapshot=linspace(0,1e-3,10)). These snapshots would be full pictures of the pressure field, as if there were sensors everywhere.&#60;/p&#62;
&#60;p&#62;An example with the field filled up with sensors would be something like shown below; but as the code is below it does not skip any time step. This is not great for memory purposes, if the simulation is very long. Right now I'm making do with this, but I wonder if k-wave has something better!&#60;/p&#62;
&#60;p&#62;%================&#60;br /&#62;
Nx = 128;           % number of grid points in the x (row) direction&#60;br /&#62;
Ny = 128;           % number of grid points in the y (column) direction&#60;br /&#62;
dx = 1e-3;        % grid point spacing in the x direction [m]&#60;br /&#62;
dy = 1e-3;        % grid point spacing in the y direction [m]&#60;/p&#62;
&#60;p&#62;t=linspace(0,1e-3,1000);&#60;/p&#62;
&#60;p&#62;kgrid = kWaveGrid(Nx, dx, Ny, dy);&#60;br /&#62;
kgrid.t_array=t;&#60;/p&#62;
&#60;p&#62;% define the properties of the propagation medium&#60;br /&#62;
medium.sound_speed = 343;  % [m/s]&#60;br /&#62;
medium.alpha_coeff = 0.75;  % [dB/(MHz^y cm)]&#60;br /&#62;
medium.alpha_power = 1.5;&#60;br /&#62;
medium.density = 1.2 * ones(Nx, Ny);&#60;/p&#62;
&#60;p&#62;% define a single source point&#60;br /&#62;
source.p_mask = zeros(Nx, Ny);&#60;br /&#62;
source.p_mask(end - Nx/4, Ny/2) = 1;&#60;/p&#62;
&#60;p&#62;% define a time varying sinusoidal source&#60;br /&#62;
source_freq = 10e3;   % [Hz]&#60;br /&#62;
source_mag = 10;         % [Pa]&#60;br /&#62;
source.p = source_mag * sin(2 * pi * source_freq * t);&#60;/p&#62;
&#60;p&#62;sensor.mask=ones(Nx, Ny);&#60;/p&#62;
&#60;p&#62;sensor_data = kspaceFirstOrder2D(kgrid, medium, source, sensor);&#60;br /&#62;
sensor_data=reshape(sensor_data,size(sensor.mask,1),size(sensor.mask,2),length(t));&#60;/p&#62;
&#60;p&#62;%Plots the simulation&#60;br /&#62;
figure;&#60;br /&#62;
for i=1:length(t)&#60;br /&#62;
    imagesc(sensor_data(:,:,i), [-1, 1]);&#60;br /&#62;
    colormap(getColorMap);&#60;br /&#62;
    drawnow;pause(0.01)&#60;br /&#62;
end&#60;/p&#62;
&#60;p&#62;%=======
&#60;/p&#62;</description>
		</item>

	</channel>
</rss>
