## Simple Pipe Acoustics - the very basics

Numerical methods and mathematical models of Elmer
Takala
Posts: 183
Joined: 23 Aug 2009, 23:59

### Re: Simple Pipe Acoustics - the very basics

JoeD wrote:Thanks Peter for confirming my conclusions that the solver gives wrong results.

Now that we are sure about this fact, the next step would be to contact the people who coded the solver and ask them to kindly fix the bug. I don't know who needs to be contacted. Perhaps if you Peter know them, could you please convey our humble requests to give this issue some attention?

I was thinking about taking a look at the source code myself and try to fix it, but I am not familiar with the programming language and it would take too much time and effort to learn it just for this case. It is much more economical and productive if the people who wrote the code could do the debugging (with much less effort).

If this issue gets resolved then I can create several test cases/tutorials, compare the results with commercial software, and publish the projects to help other beginners as well. There is very little documentation and few published projects in Elmer acoustics. I could contribute in this regard, but only if the programmers get the solver to work properly.

Joe

What you are missing here is that a wave has a time and place. If you concentrate only on the time variable, then you should choose a point where you inspect the amplitude. Generally, the resultant of the two pressure
components should be 70.71 as you have set. And additionally at the *boundary* you set the amplitude explicitly to 70.71 (re) and 0 (im), it should be so. However in some other point in space the amplitude can be a mix of
the two components but the resultant needs to equate to the set value. Just remember that you have only explicitly set the amplitude at the boundary! You can also check that wherever the p1 amplitude is 70.71 then p2 needs
to be zero and vice versa.

I hope this helps,

Eelis

JoeD
Posts: 10
Joined: 30 Jun 2017, 10:47
Antispam: Yes

### Re: Simple Pipe Acoustics - the very basics

Takala wrote: “Peter did not confirm your statement.”
OK then, I might have misunderstood his last post. But this is easy to clarify by simply asking a pointed question. Peter, did you recognize and acknowledge that my explanations are correct, and the solution of this project given by the Elmer solver is wrong?
Takala wrote: “Your results are correct.”
Apparently you still don’t get it… I have meticulously proven that the results are incorrect! Please read my previous posts again and again until you understand it.
Takala wrote: “What you are missing here is that a wave has a time and place.”
How did you come to this conclusion? Did you read my previous posts? It looks like you didn’t; or if you did, then you have not understood the math and explanations I have demonstrated. The wave does not “have a time and a place”. The wave has different local properties at different points in space and time. The equation (9.3) in the ElemerModelsManual.pdf

p(t)=Re(P*exp(i*om*t)=Re(P)*cos(om*t) – Im(P)*sin(om*t)

describes exactly how to calculate the instantaneous pressure at a specific point in space at a specific time using the solution provided by the Elmer solver. The solver gives only the value P, which is a complex number. This complex number describes the wave at a specific point in space in frequency domain. In fact if we want to be very specific, then instead of P we supposed to write P(x,y,z) in 3D space (or P(x,y) in 2D, or P(x) in 1D), because the complex value of P depends on where it is measured or calculated.

In this project I was attempting to model the propagation of a harmonic acoustic wave of 100 Pa amplitude through a simple tube. It was ambiguous whether the incoming wave at the input should be given as an amplitude, or as an effective value, because this is not specified in the manual. In commercial software this is always amplitude, and the derived results are also amplitudes, because this makes most sense. But doing so in Elmer leads to wrong solution, so out of good will I have had to try both options, and both options lead to wrong results. But the closest solution to the expected value is obtained when the input is defined using the effective value of the pressure peff= 100 /sqrt(2) Pa=70.71 Pa as:
pressure Wave 1 (real part): 70.71068
pressure Wave 2 (imag part): 0

This value is defined at the input at coordinate point x=0. If we assume that this value is the effective value, then the amplitude must be 100 Pa. Since pressure Wave 2 (imag part)=0 that means that at point x=0 and at time t=0 the instantaneous pressure amplitude must be 100 Pa.

The pressure in the solution at the same point at the same time must be the same if there are no reflections (or at least approximately the same, if there are small reflections) within the tube. Since the output boundary condition is chosen to be a matched boundary, having the same impedance as the characteristic impedance of the tube (supposed to be rho*c, but Elmer awkwardly requires this to be only c):
real part of impedance: 343
imag part of impedance: 0
there should not be any reflections in the solution.

Therefore again, the complex pressure amplitude at the point x=0 in the solution must be equal with the defined input pressure amplitude at x=0 which is 100 Pa; or if we deal with effective values, then the effective magnitude of the pressure in the solution must be 70.71 Pa, the same as the input effective value. This requirement is satisfied by the Elmer solution only if we (again awkwardly) assume that the result represents amplitudes and not effective values. But even with this assumption, this is still not a sufficient condition to make the solution accurate.

The other requirement is that the phase of the complex pressure must be also identical with the input wave in this case, which is zero. Or the same requirement expressed in time domain demands that at time t=0 at point x=0 the instantaneous pressure must be 100 Pa. This is the requirement that the Elmer solution does not fulfil!

In my previous posts I have proven and explained in detail that there is only one accurate solution that satisfies this condition of equivalence, namely when at point x=0 the effective value of
pressure Wave 1 (real part)[at point x=0]: 70.71068
pressure Wave 2 (imag part)[at point x=0]: 0

Or more consistently expressed as amplitudes:
pressure Wave 1 (real part)[at point x=0]: 100
pressure Wave 2 (imag part)[at point x=0]: 0

Please note that “pressure Wave 2 (imag part)” MUST be zero! But instead of this only possible accurate solution Elmer provides a wrong solution with these values:
pressure Wave 1 (real part)[at point x=0]: =70.71
pressure Wave 2 (imag part)[at point x=0]: =70.6308

Now the confusion gets squared here again, because if we have defined the input wave using its effective value, then we would logically expect the Elmer solution to be also given as effective values. But if these are effective values and we want to calculate the instantaneous pressure in time domain, then first we must convert these effective values back to amplitudes, which would be:
pressure Wave 1 amplitude (real part)[at point x=0]: ~100
pressure Wave 2 amplitude (imag part)[at point x=0]: ~100

Why does this lead to confusion? Because the time domain amplitude of this wave would be p_amp=sqrt(100^2+100^2)= 141.42 Pa, which is obviously wrong.

Therefore, the complex pressure components of the Elemer solution can not possibly be effective values, but must be amplitudes. If this is so, then the user is utterly confused, because when setting up the project effective values are demanded to define input waves, but apparently the output values of the solution are not effective values, but rather amplitudes!

Now out of good will we gulp down this inconsistency, and let’s assume that the solution is meant to represent complex amplitudes. In that case the time domain amplitude of the pressure would be p_amp=sqrt(70.71 ^2+70.6308^2)= 99.94, Pa which is close enough to the expected 100 Pa. So far so good, but even in this case the solution is still wrong! Why? Because the phase angle of the complex pressure is not zero as it supposed to be (it must be identical with the phase angle of the input wave), but it is -45 degrees instead.

In time domain this means that the instantaneous pressure at time t=0 at point x=0 is
p(t)=Re(P*exp(i*om*t)=Re(P)*cos(om*t) – Im(P)*sin(om*t)
p(0)=Re(P)*cos(om*t) = Re(P)= 70.71 Pa,
which is incorrect, because the input pressure at t=0 at x=0, p(0,0)=100 Pa, and in the absence of reflections, the instantaneous pressure of the Elmer solution must be the same!
Takala wrote: “If you concentrate only on the time variable, then you should choose a point where you inspect the amplitude.”
I have chosen the point of x=0 in my previous explanations (and above as well), which you should have already realized if you would really be interested in being constructive.
Takala wrote: “Generally, the resultant of the two pressure components should be 70.71 as you have set. And additionally at the *boundary* you set the amplitude explicitly to 70.71 (re) and 0 (im), it should be so.”
It should be so, but as demonstrated, it is NOT so, which makes the solution wrong.
Takala wrote: “However in some other point in space the amplitude can be a mix of the two components but the resultant needs to equate to the set value. Just remember that you have only explicitly set the amplitude at the boundary!”
There is no “however” here! I have explicitly and exclusively examined the pressure at one single specific point of x=0 in order to make my arguments as simple as possible. If the solution would be correct at this trivial point then we could take a step further and check the validity of the results at other points as well. But as long as the solution is wrong even at this point, it is totally meaningless to talk about pressures at other points.
Takala wrote: “You can also check that wherever the p1 amplitude is 70.71 then p2 needs to be zero and vice versa.”
I have already shown several times (and you can also see it for yourself if you would really care), that the imaginary part of the solution p2 is NOT zero! This makes the solution wrong! Why is it so difficult to understand so trivially simple things?

To summarize the problems, inconsistencies, awkwardness, and errors again:
1) The input waves supposed to be defined as pressure amplitudes (not as effective values, because this leads to confusion as this case demonstrates).
2) The impedance of boundaries supposed to be given as properly defined in acoustics as rho*c and not as c only (source of confusion again)
3) The output result of the Elmer solver supposed to be consistent with the definition of the input pressures, namely they should be amplitudes as well (and not effective values).
4) Both the real and imaginary parts of the complex pressure of the solution must be correct, not only the real part (or only the imaginary part). In time domain this requirement means that both the pressure amplitude AND also its phase angle must be correct (not only the amplitude).

Did you write the code of the Helholz Solver?

Joe

raback
Posts: 3670
Joined: 22 Aug 2009, 11:57
Antispam: Yes
Location: Espoo, Finland
Contact:

### Re: Simple Pipe Acoustics - the very basics

Hi Joe,

The results of the code are correct. The solution is for the complex amplitude of the ansatz. I hope this explains the confusion. We don't use any effective quantities. If such would be used they should also be defined in the documentation. With the impedance condition there is no fully real solution for the amplitude except the trivial one.

Now the small discrepancy of the amplitude is to be expected. This is the discretization error. The easiest way to improve it is to use higher order elements. Finite element will still need ~20 elements for each wave and hence the standard method is not ideal for large number of waves.

The documentation includes the list of authors. I'm familiar with the code and have done some modications to it.

-Peter

JoeD
Posts: 10
Joined: 30 Jun 2017, 10:47
Antispam: Yes

### Re: Simple Pipe Acoustics - the very basics

Peter, if you still maintain your claim that the solution is correct, then please explain to me in minute detail exactly how do you calculate the instantaneous pressure amplitude at x=0, t=0 at the input from the Elmer solver results, where the input amplitude must be 100 Pa!

Please, no irrelevant BS gobbledygook, like “discretizition error”, and “small discrepancy”. The error I am talking about is HUGE (about 30% in this case), not just a minor discrepancy. This error makes the solution totally useless for scientific purposes.

It looks like I will have to take this case to other CFD forums where objective answer could be gained from unbiased experts.

Joe

raback
Posts: 3670
Joined: 22 Aug 2009, 11:57
Antispam: Yes
Location: Espoo, Finland
Contact:

### Re: Simple Pipe Acoustics - the very basics

Hi

Your input P is (70.71,0) Pa. Thus both the Re and Im components of amplitude will be in [-70,71,70.71]. You can get the total amplitude of the pressure wave from sqrt(P1^1+P2^2). I compute that and it was in range [70.71,70.7564]. it should be constant so this is the "discretization error". I don't see why I should get 100 Pa when you feed the system with amplitude of 70.71 Pa.

Attached is the pressure plot from the case.

This is an open source code and and this service is provided pro bono. For me this means that I usually take only a few minutes to comment a case which may result to compromized quality of answers. Also I've also chosen a minimalistic style borderlining rudeness.

-Peter
Attachments Pressure curve
PressureCurve.png (21.34 KiB) Viewed 2183 times

JoeD
Posts: 10
Joined: 30 Jun 2017, 10:47
Antispam: Yes

### Re: Simple Pipe Acoustics - the very basics

raback wrote: “We don't use any effective quantities.”

Why didn’t you tell me this right after my first post few months ago? If you would have done that, then this discussion could have been limited to the clarification of a much simpler confusion.
raback wrote: “If such would be used they should also be defined in the documentation.”
The documentation does not contain many things that one would expect to read there. Like for example the explicit warning that the impedance boundary condition should be given as speed of sound c only, instead of its normal definition of z=rho*c.

Now that you have finally declared that the software doesn’t uses effective values, it means that they must be amplitudes. Right? If this is so, then the results given by the solver make even less sense.

At the outset I have assumed that the solver deals with amplitudes (as you have just claimed, and as all other professional solvers do), but the solution was totally nonsensical with this assumption. A detached user would have just simply ditched Elemer for good at this point, but I was very eager to make it work right, therefore I have attempted all possible interpretations of input values and results. This is the only reason why I have examined whether the solution could be interpreted as being correct if we assume that the pressure values are effective values (instead of being amplitudes) or not.
raback wrote: “With the impedance condition there is no fully real solution for the amplitude except the trivial one.”
If the output impedance is real, which means purely resistive (dissipative) only, like in the case of a perfectly matched output of a wave guide that I was using, then why “is there no fully real solution”?

The only way that the given Elmer solution can be correct is if there are significant reflections within the tube. If this would be the case, then the reflected wave could shift the phase of the resultant wave, and also change its amplitude at the input. But I have made my intent very clear in my first post, that there should not be any reflections within the tube. In any professional acoustic FEM solver this is simply achieved by terminating the tube output with a perfectly matched purely resistive impedance boundary. This impedance should be chosen as z=rho*c. In COMSOL for example this works like charm! No confusion, no reflections, only correct solution, which says that there is no significant reactive (imaginary part) pressure present at the input (in perfect harmony with the declared incoming wave).

Let’s not obfuscate the truth again by preaching about “discretization errors”. A couple of percent error caused by the inherent inaccuracy of numerical methods is not considered to make a significant difference in this case. We are talking here about big errors, which are definitely not the results of a low resolution mesh. No matter how much you refine your mesh, this error will still remain!

Are there any significant reflections within the tube (according to the solution), which could change the local pressure at the input by superposition?
raback wrote: “Your input P is (70.71,0) Pa.”
That is correct.
raback wrote: “Thus both the Re and Im components of amplitude will be in [-70,71,70.71].”
Stop right there! Why do you think that the solution at the point x=0 should have a real component of -70.71 and an imaginary component of 70.71 if there are no reflections? This boggles my mind! On the other hand if there are reflections, then why didn’t you warn me about that already months ago, and explained how to eliminate such reflections in Elmer?
raback wrote: “You can get the total amplitude of the pressure wave from sqrt(P1^1+P2^2). I compute that and it was in range [70.71,70.7564]. it should be constant so this is the "discretization error".”
I’m sorry to say, but this is again just an obvious obfuscation. If you expect a value to be 70.71 and the solver gives you 70.7564 instead, then that is an insignificant error (less than 0.1% in this case) that includes the discretization errors, and numerical errors as well. Why are you diverting the attention onto such irrelevant and insignificant things that have nothing to do with the huge errors I am discussing? What is the huge error? Well, for example to get the value of pressure Wave 2 (imag part)[at point x=0]: =70.6308, instead of the expected correct value of zero!

So you are saying that you have used an input P value of (70.71,0) Pa. The magnitude or the absolute value of this complex pressure is sqrt(P1^1+P2^2)=sqrt(70.71^2+0^2)= sqrt(70.71^2)= 70.71 Pa. This is the pressure amplitude that we are expecting to see at x=0 in the solution as well, if there are no significant reflections. Now let’s see what your solution says about this amplitude:

Your solver gave the solution at x=0 Re(P)=70.71, Im(P)=70.7564. This should ring an alarm bell right away, because the Im(P) supposed to be zero, or close to it, but definitely not anywhere near 70.7564! Let’s calculate the magnitude of this complex pressure: sqrt(P1^1+P2^2)=sqrt(70.71^2+70.7564^2)= 100.03 Pa. Now how is that a correct solution?

You feed the tube with a wave of 70.71 Pa amplitude at x=0, but by some miracle your solver insists that the pressure amplitude there at x=0 must be 100.03 Pa instead! Could that make any sense? Of course it could, if some part of the outgoing wave at the output would be reflected by the output boundary and this reflected wave propagating back to the input would superpose over the input wave. In that case the resultant local pressure amplitude could become greater than the input wave and the 100.03 Pa could be correct. But here we are again forced to re-examine the issue whether there are any reflected waves in this setup or not; and if there are, then why have they not been prevented by the purely dissipative real impedance at the output. If there are reflected waves present, then exactly what kind of boundary condition are we supposed to define for Elmer to eliminate such gross reflections?

On the other hand, if there are no reflections in this setup (as there shouldn’t be any) then the solution of 100.03 Pa instead the expected 70.71 Pa makes absolutely no sense, and the solution is definitely wrong!
raback wrote: “I don't see why I should get 100 Pa when you feed the system with amplitude of 70.71 Pa.”
I have already explained this in great detail in several of my previous posts, and even in this one above. This expectation is valid only for the hypothetical case when we interpret the pressure values to be effective values instead of simple amplitudes. Now that you have declared that this interpretation is incorrect in this solver, then this is not valid anymore (just forget it).

Instead of that, here is what we should expect now (assuming that the pressures are complex amplitudes):
We feed the tube with a plane wave of (70.71,0) Pa which has a magnitude of 70.71 Pa. In the absence of reflection we expect the solution to give the same value at the same point in space.
But the solution gives a complex pressure at x=0 of [70.71,70.7564], which has got a magnitude of 100.03 Pa which is about 40% greater than the expected value of 70.71 Pa! This huge error is not the result of numerical errors, and it can not be swept under the rag! This inconsistency and confusion must be resolved before using the solver for any serious applications!
raback wrote: “Attached is the pressure plot from the case.”
Your pressure plot only visually displays your complex pressure of [70.71,70.7564], and since this complex number makes no sense compared to the expected value, so the plot is also totally meaningless.
raback wrote: “This is an open source code and and this service is provided pro bono. For me this means that I usually take only a few minutes to comment a case which may result to compromized quality of answers. Also I've also chosen a minimalistic style borderlining rudeness.”
I am also posting in this thread pro bono, nobody is paying me for doing so. Doing something for free does not give one the license to obfuscate the truth, confuse people, and sweep bugs under the rag. It is better not to respond at all, than to give useless, nonsensical, and obfuscating responses. It is not the quality and the length of the answers that matters, but the usefulness of the answers. A short answer in few sentences can be fully satisfying if it resolves a problem.

If you can not resolve a problem, or you are motivated not to resolve a problem, then is much better if you frankly say it in a single sentence, or just simply don’t respond at all. That will make people ditch Elmer and use another one like OpenFoam, and they will not waste their time and effort on explaining trivially simple thing to people who just don’t seem to get it… The rudeness is not in the minimalistic style, but rather in the unwillingness or inability to understand extremely detailed explanations, and now wanting to find solutions to the presented problems. Bringing up strawman arguments like a politician, and just repeating that “the solutions is correct” without explaining why do you think it is correct, against all the contrary evidence I have presented.

Joe

mzenker
Posts: 1988
Joined: 07 Dec 2009, 11:49
Location: Germany

### Re: Simple Pipe Acoustics - the very basics

Hi Joe,

I must say that I don't like the increasingly arrogant and and aggressive tone of your posts. Elmer is a very powerful FEM solver suite you get for free, plus a forum where you normally get help within a day. If you are not satisfied with that, feel free to go to COMSOL or ANSYS where you get commercial support. But you pay for it, and you are not guaranteed to get better results at the end.

BTW, when Peter writes “Thus both the Re and Im components of amplitude will be in [-70,71,70.71]", he means that both components are contained in the interval [-70,71,70.71]. This is common mathematical notation.

Now to your problem: I have run the case you attached to your first post. If that is the one you are referring to all the time, then your problem seems to be simply that you think Elmer is calculating Pressure Wave 2 = Im(P)=70.7564 Pa at x=0. But as far as I see it, that is not true. Peter's plot shows that Elmer calculates Pressure Wave 2 = 0 at x=0, just as you expect (the green curve). I have also got the same result. I don't know how you find Pressure Wave 2 to be 70.7564 Pa at x=0. Perhaps you can explain that (after having re-run your case to be sure), and we might come to find the cause for all the misunderstandings and confusion.
BTW, from your sif file it seems that you use ElmerPost as postprocessor, which is still functional, but somehow outdated. You can alternatively use ParaView which is far more modern and powerful. For that, you have to change the extension of the output file from .ep to .vtu, re-run the case and open the vtu file with ParaView.
If you refer to another case than the one you attached to your first post, i.e. if the sif file giving you Im(P)!=0 at x=0 differs from the first one, then you should post it if you still want help in tracking down the problem.

I hope this helps. If not, then so be it.

Matthias

JoeD
Posts: 10
Joined: 30 Jun 2017, 10:47
Antispam: Yes

### Re: Simple Pipe Acoustics - the very basics

Hi Matthias,

I have rerun the solver and loaded the solution into Paraview. You were right, the solution is indeed correct even on my laptop now. Previously I have been able to view the solution only in ElmerGUI Postprocessor (Postprocessor VTK…) (which might have contributed to my confusion), because I didn’t have Paraview at the time.

I got stuck with this issue and started this thread about 5 months ago, and to be honest, I cant remember anymore why did I think at that time, that the Pressure Wave 2 = Im(P)= 70.6308 Pa at x=0. It is indeed zero. It is meaningless for me to find any excuses for my mistake, so I just simply say that it was my fault, sorry.

If I have offended anyone on this thread, please accept my sincere apologies!

I would like to express my gratitude as well to all who contributed, especially to Matthias who actually understood my problem, and offered to help track down the problem and fix it. This is the kind of support that is highly efficient and valued. Thanks to Peter as well for putting up with me.

I will attempt to repay to the Elmer community for the support received here by preparing a couple of acoustics tutorials, or reference cases that might help other Elmer newbies like me, and upload them to this forum. If there are any suggestions what setup would be most beneficial for this purpose, please let me know. This case can be closed now.

Best regards,
Joe

mzenker
Posts: 1988
Joined: 07 Dec 2009, 11:49
Location: Germany

### Re: Simple Pipe Acoustics - the very basics

I am glad that the problem is found at last and the case could be settled... Matthias

Posts: 30
Joined: 02 Oct 2019, 22:18
Antispam: Yes
Location: Florida, USA

### Re: Simple Pipe Acoustics - the very basics

Hello all,
As background, I am the real rooky here at ELMER, trying to get up to speed and learn how to use it for primarily solving pipe acoustic problems.
I just loaded the project file C V T - P posted by "JoeD" back in 2017, and received an error message in the project log file pasted below.
I am very confident that my ignorance on how to run that example is on full display.
The short version is that I launched ELMER, then opened the project from the posted files by JoeD, then pressed the Run button.
Any help will be greatly appreciated!

ELMER SOLVER (v 8.4) STARTED AT: 2019/10/17 10:40:26
ParCommInit: Initialize #PEs: 1
MAIN:
MAIN: =============================================================
MAIN: ElmerSolver finite element software, Welcome!
MAIN: This program is free software licensed under (L)GPL
MAIN: Copyright 1st April 1995 - , CSC - IT Center for Science Ltd.
MAIN: Version: 8.4 (Rev: 1d03d4f5, Compiled: 2019-09-30)
MAIN: Running one task without MPI parallelization.
MAIN: =============================================================

MAIN:
MAIN:
MAIN: -------------------------------------

LoadMesh: Elapsed REAL time: 0.1070 (s)
MAIN: -------------------------------------