Skip to content

Adding Acoustic Frequency Response to "A Gallery finite element solvers" #230

@bayswiss

Description

@bayswiss

Dozens of people have been asking why none of my tutorials are available here, so I am working on adding an acoustic frequency response solver example to Chapter 2, if it’s welcome.
Of course, both the matematical derivations and the code will be included, following the same style of other tutorials.

I understand that both .ipynb and .py files are required, and the code needs to work in parallel with mpirun.

Before proceeding further, I’d like to confirm if my approach is acceptable:

I often use 'frequency parallelism,' where the frequency loop is computed as follows:

def frequency_loop(nf):

    # solver setup

    # solver.solve

    return p_values #returns pressure at a microphone location

# frequecy axis definition:
f_axis = np.arange(5,200,1)
nf = range(0,len(f_axis))

from multiprocessing import Pool
n_proc = 4
pool = Pool(n_proc)  
p_mic = pool.map(frequency_loop,nf) # pressure spectrum
pool.close()
pool.join()

Here, each process works on a frequency across the entire mesh. This approach requires more RAM but scales perfectly.

That said, I believe it’s a bad idea to mix multiprocessing.Pool with mpirun, so if you agree, I will make the frequency loop a simple for loop:

# frequecy axis definition:
f_axis = np.arange(5,200,1)

p_mic = np.zeros((len(f_axis),1),dtype=complex)

for nf in range(0,len(frequency_axis):

    # solver setup

    # solver.solve

    p_mic[nf] = # code for evaluating pressure at mic

This way, the chapter will remain consistent with the rest of the tutorials. Perhaps at the end of it, I can add a link to a repository showcasing the multiprocessing.Pool alternative.

If you approve this approach, I will add the scripts before Christmas.

Best regards,
Antonio

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions