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)"
```

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));\
}
```

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
```

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
```

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
```

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

Zoltan