Skip to content

NumCalc

Fabian Brinkmann edited this page Mar 20, 2026 · 7 revisions

The folder NumCalc in the Mesh2HRTF repository contains the source code for calculating HRTFs in the folder src, the compiled binary in the folder bin (see installation), and functions/scripts to optimally run NumCalc on Mesh2HRTF projects. The following explains how different ways to run NumCalc.

Single instance use

So most basic use is to run the command NumCalc in a terminal in a sub-directory NumCalc/source_x of a Mesh2HRTF project folder (directories containing a file named NC.inp). This will start a single NumCalc instance that will calculate the HRTF frequency by frequency.

The results are saved in the the folder be.out, and the shell output is written to the file NC.out. For details refer to Mesh2HRTF Project Folder.

Manual multiple instance use (introduced in Mesh2HRTF 1.0.0)

Multiple NumCalc instances can run in parallel to speed up the calculations using the parameters istart and iend giving the first and last frequency step to be simulated (not the frequency in Hz). For example, four parallel instances could be started with the command:

NumCalc -istart 1 -iend 25 & NumCalc -istart 26 -iend 50 & NumCalc -istart 51 -iend 75 & NumCalc -istart 76 -iend 100

The results would be saved as in the example above in the folder be.out and the names of the output files in this case would be NC1-25.out, NC26-50.out, NC51-75.out, and NC76-100.out.

Optimized multiple instance use (introduced in Mesh2HRTF 1.0.0)

The function manage_numcalc (cf. Mesh2HRTF API available only in Python) or the script manage_numcalc_script.py on the repository folder NumCalc can be used to parallelize NumCalc in a close to optimal manner. The NumCalc manager monitors available resources (available threads, CPU, RAM) and starts a new NumCalc instance whenever possible.

Additional command line arguments (introduced in Mesh2HRTF 1.x)

  • -adapt_fmmlength adapt the truncation parameter of the multipole expansion to the radii of the clusters. This experimental feature can resolve convergence issues of NumCalc but was not yet formally evaluated.
  • -estimate_ram estimates required RAM per frequency step. The estimated values in GB are written to Memory.txt. This is used by the NumCalc manager and the estimates can be read with the function read_ram_etimates from the Mesh2HRTF API
  • -nitermax controls the maximum number of iterations done for each frequency. For example, NumCalc -nitermax 10 allows maximally 10 iterations. This should usually not be required.
  • -check_normals checks if all face normals are pointing to the same domain. They must point outwards for computing HRTFs, because this is an exterior problem.
  • >NumCalc.txt creates an additional log file, in this case calles NumCalc.txt.
  • 2>NumCalcErr.txt creates an additional error log file and can be combined with the above. For example, NumCalc >NumCalc.txt 2>NumCalcErr.txt

Structure of the input and output files

Structure of NC.inp

Nodes and Elements

Output File Structure

Clone this wiki locally