<?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: Large /tmp/ files</title>
		<link>http://www.k-wave.org/forum/topic/large-tmp-files</link>
		<description>Support for the k-Wave MATLAB toolbox</description>
		<language>en-US</language>
		<pubDate>Tue, 12 May 2026 23:28:13 +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/large-tmp-files" rel="self" type="application/rss+xml" />

		<item>
			<title>Bradley Treeby on "Large /tmp/ files"</title>
			<link>http://www.k-wave.org/forum/topic/large-tmp-files#post-7934</link>
			<pubDate>Tue, 24 Nov 2020 23:28:16 +0000</pubDate>
			<dc:creator>Bradley Treeby</dc:creator>
			<guid isPermaLink="false">7934@http://www.k-wave.org/forum/</guid>
			<description>&#60;p&#62;Hi Bastien,&#60;/p&#62;
&#60;p&#62;Thanks for your patience - it took me a while to find time to take a look. Here's my explanation.&#60;/p&#62;
&#60;p&#62;To calculate the components of the average acoustic intensity, you want integrate &#60;code&#62;p*u&#60;/code&#62; over an acoustic period. For a monochromatic source of frequency &#60;code&#62;w&#60;/code&#62; the period is &#60;code&#62;T = 2*pi/w&#60;/code&#62;. The pressure and the components of the particle velocity can be written as:&#60;/p&#62;
&#60;pre&#62;&#60;code&#62;p = a1*sin(w*t + p1)
u = a2*sin(w*t + p2)&#60;/code&#62;&#60;/pre&#62;
&#60;p&#62;where &#60;code&#62;a1&#60;/code&#62; and &#60;code&#62;a2&#60;/code&#62; are the amplitudes, and &#60;code&#62;p1&#60;/code&#62; and &#60;code&#62;p2&#60;/code&#62; are the phases (similarly for all the vector components of &#60;code&#62;u&#60;/code&#62;). Multiplying these together, integrating over time from 0 to T, and dividing by T to take the average then gives:&#60;/p&#62;
&#60;pre&#62;&#60;code&#62;I_avg = integral(p*u) / T
I_avg = integral(a1*sin(w*t + p1)*a2*sin(w*t + p2)) / T
I_avg = a1*a2*cos(p1 - p2)/2&#60;/code&#62;&#60;/pre&#62;
&#60;p&#62;Now if the wave is fairly planar, the phase components &#60;code&#62;p1&#60;/code&#62; and &#60;code&#62;p2&#60;/code&#62; will be similar, and the &#60;code&#62;cos(p1 - p2)&#60;/code&#62; term will be approximately one. This leaves:&#60;/p&#62;
&#60;p&#62;&#60;code&#62;I_avg ≈ a1*a2 / 2 = p_rms * u_rms&#60;/code&#62;&#60;/p&#62;
&#60;p&#62;which is what you've calculated.&#60;/p&#62;
&#60;p&#62;I coded this up for a simple focused field example in 2D, and the errors are on the order of 5% for this approach, compared to 10% for the plane wave approximation. I've also plotted the cosine terms, which for the &#60;code&#62;p*ux&#60;/code&#62; components (which is the dominant one) is close to 1 in central part of the field. You can &#60;a href=&#34;http://www.k-wave.org/downloads/forum_compare_intensity_calculations.m&#34;&#62;download my code here&#60;/a&#62;. Actually, it surprised me that it worked quite a bit better than the conventional plane wave approximation. &#60;/p&#62;
&#60;p&#62;Let me know any queries or comments.&#60;/p&#62;
&#60;p&#62;Brad
&#60;/p&#62;</description>
		</item>
		<item>
			<title>bastg on "Large /tmp/ files"</title>
			<link>http://www.k-wave.org/forum/topic/large-tmp-files#post-7850</link>
			<pubDate>Wed, 23 Sep 2020 21:12:30 +0000</pubDate>
			<dc:creator>bastg</dc:creator>
			<guid isPermaLink="false">7850@http://www.k-wave.org/forum/</guid>
			<description>&#60;p&#62;A follow-up: The &#34;plane wave method&#34;, which computes I_avg ~ &#38;lt;P&#38;gt;^2/(2*rho*c) gives an error of 0.0120 whereas the &#34;separable method&#34;, which computes I_avg ~ &#38;lt;P&#38;gt;*&#38;lt;U&#38;gt;, has an error of 0.0014 (after correctly de-staggering ux, uy and uz as mentioned in previous post). This is for a 100kHz simulation, curved transducer with R=80mm and aperture=61mm in a uniform water bath.&#60;/p&#62;
&#60;p&#62;This means that the separable method is ~8X more accurate than the plane wave method in this particular situation. In addition, the error of the separable method is mostly in the very near field, close to the focus the error is only ~2%.&#60;/p&#62;
&#60;p&#62;I have also ran a comparison @ 500kHz, and I found an even more pronounced difference: The plane wave method error at the focus is ~48%. The error of the separable approximation at the focus is ~1%.&#60;/p&#62;
&#60;p&#62;This is all anecdotal, and such a comparison should be done in a more rigorous way, but I thought it 1) could be interesting to other folks and 2) spark a discussion about why the separable method seem to work so well. I would be interested in hearing what the developers of k-wave think of this (and maybe see if they can reproduce this).&#60;/p&#62;
&#60;p&#62;Thanks -- Bastien
&#60;/p&#62;</description>
		</item>
		<item>
			<title>Bradley Treeby on "Large /tmp/ files"</title>
			<link>http://www.k-wave.org/forum/topic/large-tmp-files#post-7841</link>
			<pubDate>Tue, 22 Sep 2020 13:38:34 +0000</pubDate>
			<dc:creator>Bradley Treeby</dc:creator>
			<guid isPermaLink="false">7841@http://www.k-wave.org/forum/</guid>
			<description>&#60;p&#62;Hi bastg,&#60;/p&#62;
&#60;p&#62;If your simulations are linear, the most memory efficient way would be using a plane wave approximation with the pressure amplitude extracted using &#60;code&#62;p_max_all&#60;/code&#62;:&#60;/p&#62;
&#60;p&#62;&#60;code&#62;I = sensor_data.p_max_all.^2 ./ (2 * medium.density .* medium.sound_speed);&#60;/code&#62;&#60;/p&#62;
&#60;p&#62;Provided the time step is small enough, taking the maximum pressure will be a reasonable approximation to the actual spectral amplitude.&#60;/p&#62;
&#60;p&#62;If you want to record the particle velocity on the regular grid (instead of spatially staggered), you can record &#60;code&#62;u_non_staggered&#60;/code&#62;. The particle velocity components are all staggered in different directions (i.e., ux is staggered in x, uy in y, etc), which is why the error goes up using your code.&#60;/p&#62;
&#60;p&#62;One of Jiri's students has been working on a &#60;a href=&#34;https://www.mdpi.com/2078-2489/9/7/155&#34;&#62;memory efficient way&#60;/a&#62; to extract the intensity directly using the C++ code, but I think it's a little way from the production version at this point.&#60;/p&#62;
&#60;p&#62;Hope that helps,&#60;/p&#62;
&#60;p&#62;Brad
&#60;/p&#62;</description>
		</item>
		<item>
			<title>bastg on "Large /tmp/ files"</title>
			<link>http://www.k-wave.org/forum/topic/large-tmp-files#post-7833</link>
			<pubDate>Fri, 18 Sep 2020 18:21:03 +0000</pubDate>
			<dc:creator>bastg</dc:creator>
			<guid isPermaLink="false">7833@http://www.k-wave.org/forum/</guid>
			<description>&#60;p&#62;A follow up on this thread: I understand that the exact computation of the acoustic intensity requires dumping the entire P and U solutions (in time &#38;amp; space) on disk. For realistic simulations in 3D, this results in files well over 1TB (as mentioned many times on this forum), which is not feasible.&#60;/p&#62;
&#60;p&#62;I wonder if there is an approximate solution to this problem. I just tried, on a small example, saving p_rms and u_rms, and then computed the averaged intensity as I_rms = abs(p_rms ) .* sqrt( ux_rms.^2 + uy_rms.^2 + uz_rms.^2 ). This is strictly speaking incorrect as this assumes that one can permute the temporal averaging with the multiplication, i.e. I am assuming that &#38;lt;P*U&#38;gt; = &#38;lt;P&#38;gt;*&#38;lt;U&#38;gt;. That being said, the error is not that bad. For F=100kHz, dt=10us and a focused transducer, I am finding a mean error of 2% and a peak error of 18%. Honestly, given that the acoustic properties are probably within ~30% of reality (I am simulating the human skull), this kind of error seems acceptable.&#60;/p&#62;
&#60;p&#62;The other source of error is that P and U are staggered in space. I tried correcting this shift using the following code:&#60;br /&#62;
&#38;gt;&#38;gt; p2 = fourierShift( p , 1/2 , 1 );&#60;br /&#62;
&#38;gt;&#38;gt; p3 = fourierShift( p2 , 1/2 , 2 );&#60;br /&#62;
&#38;gt;&#38;gt; p4 = fourierShift( p3 , 1/2 , 3 );&#60;br /&#62;
and using p4 instead of p in the calculation of I_rms, but the error goes up instead of going down (it also goes up when using a -1/2 shift). I may not be correcting the spatial staggering properly...&#60;/p&#62;
&#60;p&#62;My overall question is this: What is the best approximate estimate of the acoustic intensity that one can obtain using only the averaged variables (in time) that are outputted by K-WAVE?
&#60;/p&#62;</description>
		</item>
		<item>
			<title>Jiri Jaros on "Large /tmp/ files"</title>
			<link>http://www.k-wave.org/forum/topic/large-tmp-files#post-5689</link>
			<pubDate>Tue, 27 Sep 2016 11:40:37 +0000</pubDate>
			<dc:creator>Jiri Jaros</dc:creator>
			<guid isPermaLink="false">5689@http://www.k-wave.org/forum/</guid>
			<description>&#60;p&#62;Hi wgrissom,&#60;/p&#62;
&#60;p&#62;The problem is in the intensity 'I_avg'. The problem is that pressure and velocity are spatially and temporally staggered. So to calculate avarage intensity, we need to shift velocity and pressure in space (easy), but unfortunately in time as well. Since the GPU doesn't have enough memory to buffer more timesteps, we need to flush data on disk.&#60;/p&#62;
&#60;p&#62;And this is the core of the problem. You sample the whole simulation domain, over 1362 timestep. A single timestep costs you 316 x 183 x 183 * 4B * 4 matrices ~ 160MB. Since you're sampling over 1362 timesteps, it sums up to 214 GB. &#60;/p&#62;
&#60;p&#62;There are two questions:&#60;br /&#62;
(1) Do you really have to sample intensity over the whole domain? If not, make the sensor mask smaller (just to cover the focus area).&#60;br /&#62;
(2) Do you really have to sample intensity over the whole time period? For most of the time there's nothing in the domain (until the wave comes...). I'd recommend to sample 1 period of the signal after it reaches a steady state.&#60;/p&#62;
&#60;p&#62;Jiri
&#60;/p&#62;</description>
		</item>
		<item>
			<title>wgrissom on "Large /tmp/ files"</title>
			<link>http://www.k-wave.org/forum/topic/large-tmp-files#post-5685</link>
			<pubDate>Thu, 22 Sep 2016 18:36:18 +0000</pubDate>
			<dc:creator>wgrissom</dc:creator>
			<guid isPermaLink="false">5685@http://www.k-wave.org/forum/</guid>
			<description>&#60;p&#62;Hi, I am running a relatively small 3D simulation, but it generates enormous (&#38;gt; 100 GB) hd5 files in my /tmp/ folder, and I run out of disk space. I am using k-Wave with the multi-threaded CUDA executable on Ubuntu 16.04, calling it from MATLAB R2015a. I have about 140 GB free on the drive, and I have 96 GB of RAM and dual 6-core Xeons. &#60;/p&#62;
&#60;p&#62;The output is below. My question is, should the files really be that big for this problem size? I am trying to record 'p_max', 'p_min', 'p_rms', 'I_avg' at each location in the simulated volume. Could that be my issue (i.e., I need to reduce my number of sensors, and perhaps repeat with multiple sensor positions)? Thank you for any help. &#60;/p&#62;
&#60;p&#62;Running k-Wave simulation...&#60;br /&#62;
  start time: 21-Sep-2016 22:37:19&#60;br /&#62;
  reference sound speed: 1484m/s&#60;br /&#62;
  dt: 80.8625ns, t_end: 110.0539us, time steps: 1362&#60;br /&#62;
  input grid size: 316 by 183 by 183 grid points (126.4 by 73.2 by 73.2mm)&#60;br /&#62;
  maximum supported frequency: 1.855MHz by 1.8449MHz by 1.8449MHz&#60;br /&#62;
kspaceFirstOrder_saveToDisk&#60;br /&#62;
  precomputation completed in 26.3772s&#60;br /&#62;
  saving input files to disk...&#60;br /&#62;
  completed in 1min 14.5148s&#60;br /&#62;
┌───────────────────────────────────────────────────────────────┐&#60;br /&#62;
│                 kspaceFirstOrder3D-CUDA v1.1                  │&#60;br /&#62;
├───────────────────────────────────────────────────────────────┤&#60;br /&#62;
│ Reading simulation configuration:                        Done │&#60;br /&#62;
│ Selected GPU device id:                                     0 │&#60;br /&#62;
│ GPU device name:                                   Tesla K20c │&#60;br /&#62;
│ Number of CPU threads:                                     24 │&#60;br /&#62;
├───────────────────────────────────────────────────────────────┤&#60;br /&#62;
│                      Simulation details                       │&#60;br /&#62;
├───────────────────────────────────────────────────────────────┤&#60;br /&#62;
│ Domain dimensions:                            316 x 183 x 183 │&#60;br /&#62;
│ Simulation time steps:                                   1362 │&#60;br /&#62;
├───────────────────────────────────────────────────────────────┤&#60;br /&#62;
│                        Initialization                         │&#60;br /&#62;
├───────────────────────────────────────────────────────────────┤&#60;br /&#62;
│ Memory allocation:                                       Done │&#60;br /&#62;
│ Data loading:                                            Done │&#60;br /&#62;
│ Elapsed time:                                           0.44s │&#60;br /&#62;
├───────────────────────────────────────────────────────────────┤&#60;br /&#62;
│ FFT plans creation:                                      Done │&#60;br /&#62;
│ Pre-processing phase:                                    Done │&#60;br /&#62;
│ Elapsed time:                                           0.11s │&#60;br /&#62;
├───────────────────────────────────────────────────────────────┤&#60;br /&#62;
│                    Computational resources                    │&#60;br /&#62;
├───────────────────────────────────────────────────────────────┤&#60;br /&#62;
│ Current host memory in use:                            1647MB │&#60;br /&#62;
│ Current device memory in use:                          3649MB │&#60;br /&#62;
├───────────────────────────────────────────────────────────────┤&#60;br /&#62;
│                          Simulation                           │&#60;br /&#62;
├──────────┬────────────────┬──────────────┬────────────────────┤&#60;br /&#62;
│ Progress │  Elapsed time  │  Time to go  │  Est. finish time  │&#60;br /&#62;
├──────────┼────────────────┼──────────────┼────────────────────┤&#60;br /&#62;
│     0%   │        1.665s  │   1131.926s  │  21/09/16 22:58:00 │&#60;br /&#62;
│     5%   │      104.034s  │   1920.166s  │  21/09/16 23:12:51 │&#60;br /&#62;
│    10%   │      197.664s  │   1753.197s  │  21/09/16 23:11:38 │&#60;br /&#62;
│    15%   │      314.691s  │   1765.936s  │  21/09/16 23:13:47 │&#60;br /&#62;
│    20%   │      426.971s  │   1695.417s  │  21/09/16 23:14:29 │&#60;br /&#62;
│    25%   │      540.264s  │   1611.315s  │  21/09/16 23:14:59 │&#60;br /&#62;
│    30%   │      655.427s  │   1521.870s  │  21/09/16 23:15:24 │&#60;br /&#62;
│    35%   │      777.675s  │   1438.210s  │  21/09/16 23:16:03 │&#60;br /&#62;
│    40%   │      908.100s  │   1357.161s  │  21/09/16 23:16:52 │&#60;br /&#62;
│    45%   │     1019.975s  │   1242.575s  │  21/09/16 23:16:49 │&#60;br /&#62;
│    50%   │     1135.512s  │   1128.862s  │  21/09/16 23:16:51 │&#60;br /&#62;
└──────────┴────────────────┴──────────────┴────────────────────┘&#60;br /&#62;
┌───────────────────────────────────────────────────────────────┐&#60;br /&#62;
│            !!! K-Wave experienced a fatal error !!!           │&#60;br /&#62;
├───────────────────────────────────────────────────────────────┤&#60;br /&#62;
│ Error: Could not write into &#34;&#34; dataset.                       │&#60;br /&#62;
├───────────────────────────────────────────────────────────────┤&#60;br /&#62;
│                      Execution terminated                     │&#60;br /&#62;
└───────────────────────────────────────────────────────────────┘&#60;br /&#62;
/bin/bash: line 1: 15377 Segmentation fault      (core dumped) ./kspaceFirstOrder3D-CUDA -i /tmp/kwave_input_data21-Sep-2016-22-37-19.h5 -o /tmp/kwave_output_data21-Sep-2016-22-37-19.h5 --p_max --p_min --p_rms --u_non_staggered_raw --p_raw&#60;br /&#62;
export LD_LIBRARY_PATH=; cd /buffyexport/home/grissowa/Dropbox/code/zebrography/sim/kWave/k-wave-toolbox-version-1.1.1/k-Wave/binaries/; ./kspaceFirstOrder3D-CUDA -i /tmp/kwave_input_data21-Sep-2016-22-37-19.h5 -o /tmp/kwave_output_data21-Sep-2016-22-37-19.h5 --p_max --p_min --p_rms --u_non_staggered_raw --p_raw: Segmentation fault&#60;br /&#62;
Error using h5readc&#60;br /&#62;
The HDF5 library encountered an error and produced the following stack trace information:&#60;/p&#62;
&#60;p&#62;    H5F_super_read    file signature not found&#60;br /&#62;
    H5F_open          unable to read superblock&#60;br /&#62;
    H5Fopen           unable to open file
&#60;/p&#62;</description>
		</item>

	</channel>
</rss>
