2d simulation of acoustic wave propagation

Numerical methods and mathematical models of Elmer
panosvar
Posts: 74
Joined: 29 Oct 2019, 16:02
Antispam: Yes

2d simulation of acoustic wave propagation

Post by panosvar »

Hi,

I want to run a simulation of acoustic waves produced by two arrays of transducers facing each other (check 'transducers.PNG'), in 2d. So, basically I have one array of transducers on bottom facing an array on top, each array consists of 16 transducers and each transducer can produce a specific acoustic wave. Geometry and mesh is created with a python script in Salome, then converted from .unv to the right elmer format. I have assigned different boundaries ("edges" in 2d) and bodies to correctly perform the simulation. The idea is that for each boundary (i.e. in 'boundary.PNG' the boundary that produces the corresponding acoustic wave for the transducer on bottom left highlighted in red, each transducer is represented by a square of proper dimensions and gaps in between the transducers) I assign a different boundary condition. So, there are 32 boundary conditions in total, that are generated by a python script that writes the .sif file (for obvious reasons). Each transducer produces the same wave (in amplitude and frequency) with a phase delay. Below you can find a code snippet:

Code: Select all

$ phases(0:31) = 3.4739563 1.28130899 4.92668337 1.79103825 4.38841548 0.10363855 1.46155566 2.1485715 2.1485715 1.46155566 0.10363855 4.38841548 1.79103825 4.92668337 1.28130899 3.4739563 3.4739563 1.28130899 4.92668337 1.79103825 4.38841548 0.10363855 1.46155566 2.1485715 2.1485715 1.46155566 0.10363855 4.38841548 1.79103825 4.92668337 1.28130899 3.4739563

Boundary Condition 1
	Target Boundaries(1) = 2
	Name = "TD1"
	Plane Wave BC = True
$ p0 = 1.0
$ k = 1.0
	Pressure Wave 1 = Variable Coordinate
		Real MATC "p0*cos(k*tx(1) + phases(0))"
	Pressure Wave 2 =  Variable Coordinate
		Real MATC "p0*sin(k*tx(1) + phases(0))"
	Wave Impedance 1 = $c0 * rho0
End

Boundary Condition 2
	Target Boundaries(1) = 3
	Name = "TD2"
	Plane Wave BC = True
$ p0 = 1.0
$ k = 1.0
	Pressure Wave 1 = Variable Coordinate
		Real MATC "p0*cos(k*tx(1) + phases(1))"
	Pressure Wave 2 =  Variable Coordinate
		Real MATC "p0*sin(k*tx(1) + phases(1))"
	Wave Impedance 1 = $c0 * rho0
End

... and so on
The axis that the wave needs to propagate is y, thus I've only used x(1) from variable coordinate. Also, I've added the phases inside real and imaginary parts of pressure wave (cos and sine). Finally, I've assigned Wave Impedance 1 to $c0 * rho0 for all transducers of the bottom array, so the wave propagates from bottom to top, and in contrast I've assigned a negative impedance of the same value for all transducers of the top array (the wave propagates in the opposite direction). However, I've encountered the following problems:

1) Obviously, it doesn't work at all, even though that the simulation is already tested in Matlab & Comsol and it works fine.
2) I only get 'pressure wave' instead of 'pressure wave 1' and 'pressure wave 2' in ParaView. You can find the whole .sif file below.
Attachments
test.sif
(13.12 KiB) Downloaded 310 times
transducers.PNG
(108.8 KiB) Not downloaded yet
boundary.PNG
(110.86 KiB) Not downloaded yet
kevinarden
Posts: 2310
Joined: 25 Jan 2019, 01:28
Antispam: Yes

Re: 2d simulation of acoustic wave propagation

Post by kevinarden »

You may want to review this posting

viewtopic.php?f=3&t=4916&start=50
mika
Posts: 236
Joined: 15 Sep 2009, 07:44

Re: 2d simulation of acoustic wave propagation

Post by mika »

Hi,

If a boundary source is defined by using a Dirichlet condition (the real and imaginary parts of the pressure specified), neither the keyword "Wave Impedance i" nor the keyword "Plane Wave BC" should be used on the same boundary condition definition, since "Wave Impedance i" or "Plane Wave BC" provides an alternate for the Dirichlet condition. Thus your transducer BCs seem to be contradictory. Moreover, if one has "Plane Wave BC = True", the user-defined value of "Wave Impedance i" will have no effect, since in this case the Helmholtz solver generates inbuilt default values for the parameters "Wave Impedance i" by setting Z=c. The effect of "Plane Wave BC" seems to be an undocumented option in the context of the Helmholtz solver, so the documentation needs an update.

I also observed that the section Boundary Condition 3 is defined twice in the sif file.

So I'd try to change BCs given in the sif file to avoid contradictory definitions.

-- Mika
panosvar
Posts: 74
Joined: 29 Oct 2019, 16:02
Antispam: Yes

Re: 2d simulation of acoustic wave propagation

Post by panosvar »

Hi Mika,

Thanks for the reply. Apart from what you mentioned (which I corrected), do you think that the direction of the wave (as I described) is correctly defined by setting k to +- 1 (for upwards and downwards direction correspondingly)? Also, could you please explain me two more things:

1) Why do I get only pressure wave instead of pressure wave 1 and pressure wave 2 on my vtu file?
2) Is this the correct way to add phase delay to the pressure waves: Real MATC "p0*cos(k*tx(2) + phase)"?
mika
Posts: 236
Joined: 15 Sep 2009, 07:44

Re: 2d simulation of acoustic wave propagation

Post by mika »

1) I believe the vtu file nevertheless contains component-wise data. Did you select a component which is displayed in Paraview (with the correspondence X = 1, Y = 2)?

2) The time-domain interpretation of your sources seems to be that each transducer produces a source p0 cos(w t + phi) with phi = k y + phases(i). I'm not sure what is the purpose of the dependence on the y-coordinate.

-- Mika
panosvar
Posts: 74
Joined: 29 Oct 2019, 16:02
Antispam: Yes

Re: 2d simulation of acoustic wave propagation

Post by panosvar »

1) I only get one variable named "pressure wave" in ParaView for some reason, in other Elmer projects I played with in the past which were in 3d I didn't come up with any issue like this
2) I put the y coordinate because that's the axis on which the wave is propagating. I don't quite get why do I need to put the term w*t though. I still want to solve it in the frequency domain, I don't really need timesteps. It's only that I need each transducer to produce the same wave with a different phase.
Last edited by panosvar on 13 Jan 2020, 14:33, edited 1 time in total.
panosvar
Posts: 74
Joined: 29 Oct 2019, 16:02
Antispam: Yes

Re: 2d simulation of acoustic wave propagation

Post by panosvar »

This is the way I've assigned boundaries and bodies in Salome:

For bodies:
- the air between transducers is specified as a face in Salome
- the transducers are specified as a group of faces in Salome

For boundaries:
- one side (bottom side of transducer for transducers on top & top side of transducer for transducers on bottom) of each transducer is specified as edge in Salome, as we'll need it later to assign a boundary condition for each of these for wave propagation
- whole right & left side of the structure is specified as group of edges (that's basically air as in reality)

However, what I've noticed in Elmer is that in 2d, faces are not only assigned as bodies but as boundaries as well. So, in my case I have i.e. the air between the transducers both as a body and as a boundary, specifically named both as 'body 2' and 'boundary 2'. Of course, that's a problem indeed, as the boundary condition for the top side of the 1st transducer of the bottom array is also named 'boundary 2'. Same happens with my group of transducers (group of faces in Salome): it's assigned both as 'body 1' and as 'boundary 1', and 'boundary 1' is also the name of the sides (edges) of the whole structure.

To sum it up, I thought that in 2d you should specify faces in Salome to get bodies in Elmer and edges to get boundaries, as in 3d you assign solids in Salome to get bodies in Elmer and faces to get boundaries. The way I'm doing it right now obviously causes some overlapping, so that some parts are both specified as bodies and boundaries. If that's not the case, please confirm.

EDIT: This seems not to be the case after all. I've explored several 2d examples in ElmerGUI tutorials, and this happens as well, so definitely this is not an issue.
mika
Posts: 236
Joined: 15 Sep 2009, 07:44

Re: 2d simulation of acoustic wave propagation

Post by mika »

1) Unfortunately I cannot reproduce your problem about the missing components with any example I have available.

2) Due to my limited ability to think directly in terms of complex variables I just wanted to recover the problem that should be solved if it were specified as in your sif file and treated in the time domain (making the actual analysis in the frequency domain is of course OK).

If the axes were directed as your figures made it natural to think, then the sources would be at lines y = constant and the dependence on y in the evaluation of the BCs would be very simple. Its effect could be included by modifying the constant values of the phases array and then omitting the terms k*y.

-- Mika
panosvar
Posts: 74
Joined: 29 Oct 2019, 16:02
Antispam: Yes

Re: 2d simulation of acoustic wave propagation

Post by panosvar »

Hi mika,

Thanks for following the thread and answering whenever you can. To make it more simple, I've provided a .rar with the necessary files to run the project. I'd like you to perform a very simple task, if that's possible, that could confirm that at least I'm not making any obvious and stupid mistake. Let's suppose that we only want to propagate a wave of pressure 1 on Target Boundary 9, from bottom to top, which is supposed to be the 8th transducer (from left to right) of the bottom array. Running this in Comsol produced the field attached in the picture below ('transducer9.jpg'). However, what I'm taking from Elmer is totally non sense. EDIT: I've also attached a picture with the axis for you to understand better on which axis the wave should propagate.

Thanks for your time,
Panos
Attachments
vectors.PNG
vectors.PNG (55.19 KiB) Viewed 5213 times
transducer9.png
(111.7 KiB) Not downloaded yet
example.rar
(334.81 KiB) Downloaded 280 times
kevinarden
Posts: 2310
Joined: 25 Jan 2019, 01:28
Antispam: Yes

Re: 2d simulation of acoustic wave propagation

Post by kevinarden »

Not close to a converged solution.

1000 0.1088E+03
WARNING:: IterSolve: Numerical Error: Too many iterations were needed.

Doesn't converge over 10000 Hz, probably need a finer mesh in Elmer
Post Reply