Acoustics – Basic Postprocessing With ElmerSolver & Paraview

Numerical methods and mathematical models of Elmer
Z.Losonc
Posts: 40
Joined: 21 Dec 2017, 16:05
Antispam: Yes

Re: Acoustics – Basic Postprocessing With ElmerSolver & Paraview

Hi,

Thank you Peter for revealing this “special” syntax of MATC expression. There is nothing written about this in the MATCManual.pdf, and (unless analysing the source code) I would have perhaps never used this form. More accurately, I would have never used this form again, because I have attempted to use it already on the top of the sif file, outside of sections a while ago, and it did not work. In our example this form on the top of the sif file:

Density_M = \$ 1.205

stops the solver with the error message:

“ERROR:: Model Input: Unknown input field in header section: density_m”

The alternate form of:

Density_M = Real \$ 1.205

Doesn't work either. This experience lead me to conclude that this syntax that you have presented was incorrect, and the \$ sign must be always at the beginning of the instruction (which was a wrong conclusion). Without detailed explanations I am having hard time to grasp the logic of Elmer. I hope that you continue to reveal the occult (hidden) rules and techniques of practical Elmer implementation.

To summarize my present understanding of MATC syntax:

When using the short \$ form of expression:
- the \$ sign must be at the beginning of the expression when it is outside of sections like this:
\$ Density_M = 1.205
and the variable type (Real, Int, etc.) may not be used (“\$ Density_M = Real 1.205” won't work).
- within the sections the \$ sign must come after the = mark like this:
Density = \$ Density_M
in this case the variable type may (or in some cases must) also be used:
Density = Real \$ Density_M
- this short \$ form of expression will get evaluated only once, when the sif file is being read by Elmer. Therefore, if an expression needs to be evaluated only once, we can save processor time by using this economical short form instead of the MATC form.

When using the long MATC form of expression:
- this form may not be used outside of sections. Therefore this form at the top of the sif file would not work:
Density_M = Real MATC "1.205" neither this:
\$ Density_M = Real MATC "1.205"
- inside the sections the keyword MATC must come always after the = sign, and may be (or sometimes must be) preceded with the variable type specifier.
- the mathematical expression must be between two “ marks, and after the keyword MATC:
Cv = Real MATC "1/(Density_M * Angular_Frequency_M)"
- this expression form will be evaluated (only if and) every time when the parameter it was assigned to (Cv in this case) is called/used somewhere during the computation. If it is never called, then the expression will never get evaluated; and if it contains errors, these errors will never get reported.
- this feature of being re-evaluated every time the parameter is used consumes more processor time, but it enables us to change its value during the simulation, which can be useful f. ex. during parametric sweeps.
- here is an example (from FEM-CurvedFlowinaPipe.pdf) how to specify a variable, and assign a value to it with a MATC expression:

Code: Select all

Material 1
Name = "Water (room temperature)"
Viscosity = Variable Temperature
Real MATC "mu0 * relativevisc(tx)"
In this form the tx represents the parameter Temperature as an argument of the function relativevisc. The function can be defined as:

Code: Select all

\$ mu0 = 1.788e-3
\$ function relativevisc(T){\
a = -1.704;\
b = -5.306;\
c = 7.003;\
z = 273.15/T;\
_relativevisc = exp(a + b * z + c *(z^2));\
}
If there is something wrong with these explanations (or need to be extended), please let me know. Based on the simpler \$ form of MATC expressions, here is an alternative sif for our sample project that works as well:

Code: Select all

\$ Density_M = 1.205
\$ Angular_Frequency_M = 2155

Header
CHECK KEYWORDS Warn
Mesh DB "." "."
Include Path ""
Results Directory ""
End

Simulation
Max Output Level = 10
Coordinate System = Cartesian
Coordinate Mapping(3) = 1 2 3
Simulation Type = Steady state
Steady State Max Iterations = 1
Output Intervals = 1
Timestepping Method = BDF
BDF Order = 1
Solver Input File = tube.sif
Post File = tube.ep
End

Constants
Gravity(4) = 0 -1 0 9.82
Stefan Boltzmann = 5.67e-08
Permittivity of Vacuum = 8.8542e-12
Boltzmann Constant = 1.3807e-23
Unit Charge = 1.602e-19
End

Body 1
Target Bodies(1) = 1
Name = "Body Property 1"
Equation = 1
Material = 1
Initial condition = 1
End

Solver 1
Equation = Helmholtz Equation
Procedure = "HelmholtzSolve" "HelmholtzSolver"
Variable = -dofs 2 Pressure Wave
Stabilize = True
Bubbles = False
Lumped Mass Matrix = False
Optimize Bandwidth = True
Steady State Convergence Tolerance = 1.0e-5
Nonlinear System Convergence Tolerance = 1.0e-8
Nonlinear System Max Iterations = 20
Nonlinear System Newton After Iterations = 3
Nonlinear System Newton After Tolerance = 1.0e-3
Nonlinear System Relaxation Factor = 1
Linear System Solver = Direct
Linear System Direct Method = Banded
End

Solver 2
Equation = "flux compute 1"
Procedure = "FluxSolver" "FluxSolver"
Calculate Flux = Logical True
Target Variable = String "Pressure Wave 2"
Flux Coefficient = String "Cv"
Linear System Solver = Direct
Linear System Direct Method = Banded
End

Solver 3
Equation = "flux compute 2"
Procedure = "FluxSolver" "FluxSolver"
Calculate Flux = Logical True
Target Variable = String "Pressure Wave 1"
Flux Coefficient = String "Cv"
Linear System Solver = Direct
Linear System Direct Method = Banded
End

Solver 4
Equation = Result Output
Procedure = "ResultOutputSolve" "ResultOutputSolver"
Save Geometry Ids = False
Output File Name = tube
Output Format = Vtu
Scalar Field 2 = Pressure wave 2
Scalar Field 1 = Pressure wave 1
Vector Field 1 = Pressure wave 2 flux
Vector Field 2 = Pressure wave 1 flux
End

Equation 1
Name = "Helmholtz"
Angular Frequency =  \$ Angular_Frequency_M
Active Solvers(4) = 1 2 3 4
End

Material 1
Name = "Air (room temperature)"
Viscosity = 1.983e-5
Heat expansion Coefficient = 3.43e-3
Heat Conductivity = 0.0257
Relative Permittivity = 1.00059
Sound speed = 343.0
Heat Capacity = 1005.0
Density = \$ Density_M
Cv = Real \$ 1/(Density_M * Angular_Frequency_M)
End

Initial Condition 1
Name = "InitialCondition 1"
Pressure Wave 1 = 0
Pressure Wave 2 = 0
End

Boundary Condition 1
Target Boundaries(1) = 6
Name = "In"
Pressure Wave 2 = 0
Pressure Wave 1 = 100
End

Boundary Condition 2
Target Boundaries(4) = 2 3 4 5
Name = "Walls"
Wave Flux 1 = 0
Wave Flux 2 = 0
End

Boundary Condition 3
Target Boundaries(1) = 1
Name = "Out"
Wave impedance 1 = 343
Wave impedance 2 = 0
End
Good to know that Elmer can do parametric sweeps when the dimensions of the geometry are swept. I will study the recommended RigidMeshMapper and MeshUpdate later, when the more basic features are understood.

In my earlier post dated 06 Jan 2018, 03:37 I have discussed that the default iterative solver of the FluxSolver, which can be found in the ElmerModelsManual.pdf did not work for me:

Code: Select all

Solver 3
Exec Solver = after all
Equation = "flux compute"
Procedure = "FluxSolver" "FluxSolver"
Calculate Flux = Logical True
Flux Variable = String Temperature
Flux Coefficient = String "Heat Conductivity"
Linear System Solver = "Iterative"
Linear System Iterative Method = "cg"
Linear System Preconditioning = ILU0
Linear System Residual Output = 10
Linear System Max Iterations = Integer 500
Linear System Convergence Tolerance = 1.0e-10
End
Is there a fix for this problem?

The alternative BiCGStab did produce correct results, but with warnings in the log file about convergence not being reached:

Code: Select all

Stabilize = True
Bubbles = False
Lumped Mass Matrix = False
Optimize Bandwidth = True
Steady State Convergence Tolerance = 1.0e-5
Nonlinear System Convergence Tolerance = 1.0e-7
Nonlinear System Max Iterations = 20
Nonlinear System Newton After Iterations = 3
Nonlinear System Newton After Tolerance = 1.0e-3
Nonlinear System Relaxation Factor = 1
Linear System Solver = Iterative
Linear System Iterative Method = BiCGStab
Linear System Max Iterations = 500
Linear System Convergence Tolerance = 1.0e-10
BiCGstabl polynomial degree = 2
Linear System Preconditioning = Diagonal
Linear System ILUT Tolerance = 1.0e-3
Linear System Abort Not Converged = False
Linear System Residual Output = 1
Linear System Precondition Recompute = 1
This problem looks very similar to the one reported by adamo in this thread viewtopic.php?f=3&t=4930&start=0. It looks like the solver residua are too small, and the solver can not handle it. Is there a way to overcome these problems?

Which iterative solver would be the best to use in FluxSolver for acoustic simulations?

Zoltan

Z.Losonc
Posts: 40
Joined: 21 Dec 2017, 16:05
Antispam: Yes

Re: Acoustics – Basic Postprocessing With ElmerSolver & Paraview

Hi,

The questions in this post are primarily to the Elmer team, but if anybody else also knows the correct answers, then please comment.

The next step in post-processing acoustic simulations with ElmerSolver would be to calculate the acoustic (sound) Intensity (RMS), which can be calculated from the variables we have derived so far using the equation:

I = (pressure wave 1 * pressure wave 2 flux - pressure wave 2 * pressure wave 1 flux)/2

The MATC does not seem to be able to use the parameters and variables (used by and) computed by other solvers, therefore the intensity can't be calculated using MATC. Is this correct?

Is there any other way to compute sound intensity in ElmerSolver?

By the way, the post processor can't be launched from the ElmerGUI. Was this deliberately disabled in Elmer 8.3, or just an installation error?

Zoltan

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

Re: Acoustics – Basic Postprocessing With ElmerSolver & Paraview

Hi,

it is recommended to use ParaView as postprocessor. It has many features allowing you to calculate whatever you want provided that it can be done using the results calculated by Elmer.
The Elmer postprocessors are not under active development any more AFAIK.
To use ParaView, simply replace the .ep extension of the output file by .vtu in the simulation section (Model->Setup in ElmerGUI).
You can also calculate things in Elmer using the SaveScalars solver, see models manual.

HTH,

Matthias

Z.Losonc
Posts: 40
Joined: 21 Dec 2017, 16:05
Antispam: Yes

Re: Acoustics – Basic Postprocessing With ElmerSolver & Paraview

Hi,

I am using Paraview, as it has been already discussed in this thread, and the vtu file is written in every sif I posted. I don't mind if the Elmer Postprocessor is not included in the installation; it is just useful to know whether it was deliberately left out from the installation binary, or it can't be started due to an error. If it was deliberately removed, then it would be more user friendly to remove the starting button and menu option from ElmerGUI as well.

The Elmer VTK is very useful though for having a quick look at the results when experimenting with different settings in the sif file. Please don't remove that from ElmerGUI, not even if Paraview is better for post processing.

As described earlier, the computing of acoustic velocity in Elmer (instead of doing it in Paraview) is necessary at this time (due to Paraview filter bug), and we have done that successfully. The computation of acoustic intensity on the other hand, can be done in Paraview. The only reason I am trying to do it in Elmer is to learn whether it can be done at all, or not; and what are the exact capabilities of Elmer. We were discussing the practical usage of MATC, and it would make sense to see if MATC is able to multiply a vector field computed by the FluxSolver with a scalar filed, which is the output of the main Helmholtz solver. I was reading the manuals, and read all acoustic related threads in this forum, but could not find anything about this.

There is a way to calculate a scalar field (f. ex. the absolute pressure in dB) from the variables of the main solver like this:

Code: Select all

Body 1
…
Body Force = 1
End

Body Force 1
! This is p_abs in dB
Press_dB = Variable Pressure Wave 1, Pressure Wave 2
Real MATC "20*log(((sqrt(tx(0)^2+tx(1)^2))/sqrt(2)))"
End

Solver 1
Equation = Helmholtz Equation
Procedure = "HelmholtzSolve" "HelmholtzSolver"
...
Nonlinear Update Exported Variables = Logical True
Update Exported Variables = Logical True
Exported Variable 1 = Press_dB
End

Solver 4
Equation = Result Output
Procedure = "ResultOutputSolve" "ResultOutputSolver"
...
Scalar Field 3 = "Press_dB"
End
See: viewtopic.php?f=4&t=2120&p=6288&hilit=a ... 8c15#p6288

But this worked for me only as long as the result is a scalar field. If the result supposed to be a vector field computed from another vector field, I could not get it to work. But there might be some hidden syntax, or trick that we are not aware of, and perhaps the Elmer developers would be kind enough to share such knowledge with us… If it is not possible do such computation, no problem. Just please, let us know explicitly what we can do, and what we can't do in Elmer.

The SaveScalars solver may be used to compute derived quantities and save scalar values to an external file. But in our case, we have to compute and save vector values (not scalar values) to the output file, therefore this won't help, as far as I can tell.

Zoltan