Acoustics – Basic Postprocessing With ElmerSolver & Paraview
Re: Acoustics – Basic Postprocessing With ElmerSolver & Paraview
Hi,
thanks for taking the time to write all this stuff down for the community. I cannot comment on the contents, but if I ever do acoustics simulation with Elmer, I will certainly work through this thread...
Two remarks:
1. I use Linux Mint 17.3 at home and had no problem installing Elmer from launchpad.
2. To use the Fluxsolver in ElmerGUI, just move the fluxsolver.xml file from $ELMER_HOME/share/ElmerGUI/edf-extra to $ELMER_HOME/share/ElmerGUI/edf. However, you might be able to use only one instance of Fluxsolver that way. Beware that once the sif file has been edited by hand, you cannot return to ElmerGUI without losing the changes since ElmerGUI overwrites the sif file when the project is saved.
Matthias
thanks for taking the time to write all this stuff down for the community. I cannot comment on the contents, but if I ever do acoustics simulation with Elmer, I will certainly work through this thread...
Two remarks:
1. I use Linux Mint 17.3 at home and had no problem installing Elmer from launchpad.
2. To use the Fluxsolver in ElmerGUI, just move the fluxsolver.xml file from $ELMER_HOME/share/ElmerGUI/edf-extra to $ELMER_HOME/share/ElmerGUI/edf. However, you might be able to use only one instance of Fluxsolver that way. Beware that once the sif file has been edited by hand, you cannot return to ElmerGUI without losing the changes since ElmerGUI overwrites the sif file when the project is saved.
Matthias
Re: Acoustics – Basic Postprocessing With ElmerSolver & Paraview
After two steps forward, here is the one step back:
During night of 6th January I was able to successfully run the FluxSolver as described in my previous post using
Cv = Real MATC "1/(Density * Angular Frequency)"
in the Material 1 section. The results were good as well.
Then around middle of the night, or early next morning I have allowed the “Ubuntu Software” to install an “OS update”. Later on when trying to run the same project with the same sif file that was backed up last time, the solver stopped with an error message:
But the Density is definitely declared right above the MATC formula:
When I try to declare Density at the top of the sif file with a MATC instruction:
$ Density = 1.205
then it stops with this error message:
Right… apparently, we have to declare Angular frequency as well at the top:
$ Angular Frequency = 2155
The error message this time is:
The MATC routine treats “Angular Frequency” as two separate parameters, because there is a space between them. At the same time ElmerSolver treats it as a single parameter. If I appease MATC by declaring:
$ Angular_Frequency = 2155
At the top without a space in the name, then I also must change the name in the formula to:
Cv = Real MATC "1/(Density * Angular_Frequency)"
Now the FluxSolver runs without error messages and produces correct results. The only problem now is that it uses “Angular_Frequency” declared at the top of the sif file, and not the “Angular Frequency” given in Equation 1 which is used by the HelmholtzSolver. These are completely two different parameters, one is used by MATC and the other used by the main solver.
This can not possibly be the correct way of using the software… What if I want to run a parametric sweep using Angular Frequency as the swept parameter? Do I have to change both “Angular Frequency” and “Angular_Frequency” in each cycle separately? This is really confusing.
Here is the sif file in its present state (the project folder and files can be downloaded from the attachments of my original posts series near the top of this thread):
I was thinking about uninstalling the latest Ubuntu updates to get back to the state where Elmer was working as expected. But that can’t be the right solution, because sooner or later it will have to be updated anyway. So then what am I doing wrong? How is this supposed to work as designed?
If anybody knows the solutions, or has some idea what could be wrong, please comment.
Regards,
Zoltan
During night of 6th January I was able to successfully run the FluxSolver as described in my previous post using
Cv = Real MATC "1/(Density * Angular Frequency)"
in the Material 1 section. The results were good as well.
Then around middle of the night, or early next morning I have allowed the “Ubuntu Software” to install an “OS update”. Later on when trying to run the same project with the same sif file that was backed up last time, the solver stopped with an error message:
Code: Select all
FluxSolver: -------------------------------------
FluxSolver: Computing the flux and/or gradient
FluxSolver: -------------------------------------
Solver input file error: MATC ERROR: Undeclared identifier: [Density].
...offending input line: 1/(Density * Angular Frequency)
Code: Select all
Material 1
Name = "Air (room temperature)"
Viscosity = 1.983e-5
Heat expansion Coefficient = 3.43e-3
Heat Conductivity = 3.85e-4
Relative Permittivity = 1.00059
Sound speed = 343.0
Heat Capacity = 1005.0
Density = 1.205
Cv = Real MATC "1/(Density * Angular Frequency)"
!Cv = Real 3.85e-4
End
$ Density = 1.205
then it stops with this error message:
Code: Select all
Solver input file error: MATC ERROR: Undeclared identifier: [Angular].
...offending input line: 1/(Density * Angular Frequency)
$ Angular Frequency = 2155
The error message this time is:
Code: Select all
Solver input file error: MATC ERROR: Undeclared identifier: [Frequency].
...offending input line: 1/(Density * Angular Frequency)
$ Angular_Frequency = 2155
At the top without a space in the name, then I also must change the name in the formula to:
Cv = Real MATC "1/(Density * Angular_Frequency)"
Now the FluxSolver runs without error messages and produces correct results. The only problem now is that it uses “Angular_Frequency” declared at the top of the sif file, and not the “Angular Frequency” given in Equation 1 which is used by the HelmholtzSolver. These are completely two different parameters, one is used by MATC and the other used by the main solver.
This can not possibly be the correct way of using the software… What if I want to run a parametric sweep using Angular Frequency as the swept parameter? Do I have to change both “Angular Frequency” and “Angular_Frequency” in each cycle separately? This is really confusing.
Here is the sif file in its present state (the project folder and files can be downloaded from the attachments of my original posts series near the top of this thread):
Code: Select all
$ Density = 1.205
$ Angular_Frequency = 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 = 2155
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 = 3.85e-4
Relative Permittivity = 1.00059
Sound speed = 343.0
Heat Capacity = 1005.0
Density = 1.205
Cv = Real MATC "1/(Density * Angular_Frequency)"
!Cv = Real 3.85e-4
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
If anybody knows the solutions, or has some idea what could be wrong, please comment.
Regards,
Zoltan
Re: Acoustics – Basic Postprocessing With ElmerSolver & Paraview
Hi Matthias,
Thank you for sharing useful information.
I will delete Ubuntu and install Linux Mint later; this time your version of 17.3 and see if Elmer can be installed correctly from Launchpad on my computer as well. But right now I am lost in figuring out how to use Elmer for acoustics (this is the primary purpose) and it is wiser to keep the present installation until the major confusion is dispelled.
Excellent tip about moving the fluxsolver.xml, thanks. It would be a nice feature for simple use. Unfortunately, since we will have to implement manual modifications in the sif file (see my last post), as long as a two way synchronizing link is not established between the GUI and sif file, it is wiser not to move the flux solver. It would be indeed great though, to have a GUI that would contain all Elmer features, and we could avoid the manual editing of the sif file.
Zoltan
Thank you for sharing useful information.
I will delete Ubuntu and install Linux Mint later; this time your version of 17.3 and see if Elmer can be installed correctly from Launchpad on my computer as well. But right now I am lost in figuring out how to use Elmer for acoustics (this is the primary purpose) and it is wiser to keep the present installation until the major confusion is dispelled.
Excellent tip about moving the fluxsolver.xml, thanks. It would be a nice feature for simple use. Unfortunately, since we will have to implement manual modifications in the sif file (see my last post), as long as a two way synchronizing link is not established between the GUI and sif file, it is wiser not to move the flux solver. It would be indeed great though, to have a GUI that would contain all Elmer features, and we could avoid the manual editing of the sif file.
Zoltan
Re: Acoustics – Basic Postprocessing With ElmerSolver & Paraview
That would be very practical indeed. Actually there is work on a solution for that: The Elmer plugin for Salomé can already reload sif files it writes (see viewtopic.php?f=9&t=4482). But it doesn't implement more sif features than ElmerGUI. I am just starting to work on improving that functionality, with the goal to make it available also outside Salomé. But don't expect something useable anytime soon...Z.Losonc wrote:Unfortunately, since we will have to implement manual modifications in the sif file (see my last post), as long as a two way synchronizing link is not established between the GUI and sif file, it is wiser not to move the flux solver. It would be indeed great though, to have a GUI that would contain all Elmer features, and we could avoid the manual editing of the sif file.
Zoltan
Matthias
Re: Acoustics – Basic Postprocessing With ElmerSolver & Paraview
Great project! If you understand all the different solvers and modules and how to use them, then indeed the next step is to embed them in an up-to-date, all-inclusive GUI. I am still at the very start of figuring out how to use the acoustics related solvers manually implemented in sif file. There is very little practical explanation available about this subject at this time, therefore progress is slow; but we are getting there…mzenker wrote:That would be very practical indeed. Actually there is work on a solution for that: The Elmer plugin for Salomé can already reload sif files it writes (see viewtopic.php?f=9&t=4482). But it doesn't implement more sif features than ElmerGUI. I am just starting to work on improving that functionality, with the goal to make it available also outside Salomé. But don't expect something useable anytime soon...
Wish you success with the GUI project, as soon as possible.
Zoltan
Re: Acoustics – Basic Postprocessing With ElmerSolver & Paraview
This post is a clarification of my earlier confusion concerning the MATC calculation of the “Flux Coefficient” in FluxSolver.
Found the source of confusion mentioned in my post dated 08 Jan 2018, 13:56.
During my experimentations with FluxSolver the expression:
Cv = 3.85e-4
was first used in section “Material 1” to define the “Flux Coefficient” for the FluxSolver. This way we can use:
Flux Coefficient = String "Cv"
instead of the default:
Flux Coefficient = String "Heat Conductivity"
This worked flawlessly. But it would be much better if the program would calculate this value from the formula 1/(Density * Angular Frequency), instead of the user calculating it manually. So, the next step was to try if this could be accomplished by simply replacing the
Cv = 3.85e-4
with this line using a MATC expression to perform the calculation:
Cv = Real MATC "1/(Density * Angular Frequency)"
It was late night, and me being tired, forgot to disable the line that supposed to be replaced (by starting the line with a “!” character), and just added the MATC line to the Material 1 section like this:
With this setup the solver ran nicely, and did not complain about not recognizing neither “Density” nor “Angular Frequency”. The results were also correct. Therefore, I have concluded that this method of calculating the Flux Coefficient with a MATC expression worked correctly. Then installed some Ubuntu updates and went to sleep.
Next day when attempted to run the solver again with the same sif file, but with a disabled
! Cv = Real 3.85e-4
line, it stopped with an error message:
Then following the debugging procedure described in my earlier post I have succeeded in running the solver while using the MATC expression, but was dissatisfied with the fact that “Angular Frequency” defined in the “Equation 1” section was now a completely different parameter from the “Angular_Frequency” declared at the sif file's top, which was used by the MATC expression. I was logically expecting that the MATC should be able to use the parameters and variables specified anywhere in the sif file (which apparently doesn't work that way). Then wondered, how was I able to run the solver the previous night without such error messages. Suspected, that perhaps the Ubuntu updates messed up the Elmer installation, or similar.
Finally to resolve this confusion I have deleted Ubuntu, and installed Linux Mint 17.3 Xfce 64bit, and the latest elmerfem-csc_8.3-0ppa0-201801021617~07f4b35~ubuntu14.04.1_amd64.deb published on 2018-01-02 from Launchpad. Re-run the sif file, but the solver behaved the same way as before, so finally I have realized that the Ubuntu update did not cause the mystery. After a bit of experimentation it became clear that originally the solver didn't complain about the Density etc. only because both these lines were left enabled simultaneously:
Cv = Real MATC "1/(Density * Angular Frequency)"
Cv = Real 3.85e-4
It looks like in such cases when different values are assigned to the same parameter, only the last instruction is executed, therefore the errors in the first instruction were not even examined/recognized by Elmer. Since the last instruction gave a correct 3.85e-4 value to Cv, the results were also correct, and this made me think that the value was calculated by the MATC expression (which was not true).
In order to clear the fog, and show a clean presentation of how the “Flux Coefficient” can be calculated with a MATC expression and used in the FluxSolver a summary will be written in the next post below.
Zoltan
Found the source of confusion mentioned in my post dated 08 Jan 2018, 13:56.
During my experimentations with FluxSolver the expression:
Cv = 3.85e-4
was first used in section “Material 1” to define the “Flux Coefficient” for the FluxSolver. This way we can use:
Flux Coefficient = String "Cv"
instead of the default:
Flux Coefficient = String "Heat Conductivity"
This worked flawlessly. But it would be much better if the program would calculate this value from the formula 1/(Density * Angular Frequency), instead of the user calculating it manually. So, the next step was to try if this could be accomplished by simply replacing the
Cv = 3.85e-4
with this line using a MATC expression to perform the calculation:
Cv = Real MATC "1/(Density * Angular Frequency)"
It was late night, and me being tired, forgot to disable the line that supposed to be replaced (by starting the line with a “!” character), and just added the MATC line to the Material 1 section like this:
Code: Select all
Material 1
Name = "Air (room temperature)"
Viscosity = 1.983e-5
Heat expansion Coefficient = 3.43e-3
Heat Conductivity = 3.85e-4
Relative Permittivity = 1.00059
Sound speed = 343.0
Heat Capacity = 1005.0
Density = 1.205
Cv = Real MATC "1/(Density * Angular Frequency)"
Cv = Real 3.85e-4
End
Next day when attempted to run the solver again with the same sif file, but with a disabled
! Cv = Real 3.85e-4
line, it stopped with an error message:
Code: Select all
FluxSolver: -------------------------------------
FluxSolver: Computing the flux and/or gradient
FluxSolver: -------------------------------------
Solver input file error: MATC ERROR: Undeclared identifier: [Density].
...offending input line: 1/(Density * Angular Frequency)
Finally to resolve this confusion I have deleted Ubuntu, and installed Linux Mint 17.3 Xfce 64bit, and the latest elmerfem-csc_8.3-0ppa0-201801021617~07f4b35~ubuntu14.04.1_amd64.deb published on 2018-01-02 from Launchpad. Re-run the sif file, but the solver behaved the same way as before, so finally I have realized that the Ubuntu update did not cause the mystery. After a bit of experimentation it became clear that originally the solver didn't complain about the Density etc. only because both these lines were left enabled simultaneously:
Cv = Real MATC "1/(Density * Angular Frequency)"
Cv = Real 3.85e-4
It looks like in such cases when different values are assigned to the same parameter, only the last instruction is executed, therefore the errors in the first instruction were not even examined/recognized by Elmer. Since the last instruction gave a correct 3.85e-4 value to Cv, the results were also correct, and this made me think that the value was calculated by the MATC expression (which was not true).
In order to clear the fog, and show a clean presentation of how the “Flux Coefficient” can be calculated with a MATC expression and used in the FluxSolver a summary will be written in the next post below.
Zoltan
Last edited by Z.Losonc on 11 Jan 2018, 16:20, edited 1 time in total.
Re: Acoustics – Basic Postprocessing With ElmerSolver & Paraview
This post presents a way to use an arbitrary parameter name Cv as “Flux Coefficient” in FluxSolver and assign a value to it using a MATC expression.
Apparently, MATC can not use parameters defined in sif file sections, but all parameters and variables we want to use in MATC must be first declared at the top of the sif file, outside any section with a special MATC syntax like f. ex. This:
$ x = 1.2
Our formula needs two parameters (no space is allowed in the names in MATC), so let's declare them at the top of the sif file like this:
$ Density_M = 1.205
$ Angular_Frequency_M = 2155
(Note that this form “$ Density_M = Real 1.205” won't work).
Next, in the “Material 1” section we can declare an arbitrary parameter for Flux Coefficient and calculate its value with a MATC expression:
Cv = Real MATC "1/(Density_M * Angular_Frequency_M)"
Now the Cv can be used in the FluxSolver sections as:
Flux Coefficient = String "Cv"
If we run the solver now, it will finish without errors and produce correct results. But the results will be correct only if we assign identical, correct values to both Denisty_M and Density; the same is valid for Angular_Frequency_M and Angular Frequency. In order to avoid the need of assigning the same value to several parameters at two different places in the sif file, we can replace this line in “Equation 1” section:
Angular Frequency = 2155
With this one:
Angular Frequency = Real MATC "Angular_Frequency_M"
Also replace this line in “Material 1” section:
Density = 1.205
with this one:
Density = Real MATC "Density_M"
This way we have to specify the values of Density and Angular Frequency at only one place in the sif file, namely at the top. This setup can be also easily adapted to parametric sweeps that will be discussed in another post. The sif file at this point looks like this:
Zoltan
Apparently, MATC can not use parameters defined in sif file sections, but all parameters and variables we want to use in MATC must be first declared at the top of the sif file, outside any section with a special MATC syntax like f. ex. This:
$ x = 1.2
Our formula needs two parameters (no space is allowed in the names in MATC), so let's declare them at the top of the sif file like this:
$ Density_M = 1.205
$ Angular_Frequency_M = 2155
(Note that this form “$ Density_M = Real 1.205” won't work).
Next, in the “Material 1” section we can declare an arbitrary parameter for Flux Coefficient and calculate its value with a MATC expression:
Cv = Real MATC "1/(Density_M * Angular_Frequency_M)"
Now the Cv can be used in the FluxSolver sections as:
Flux Coefficient = String "Cv"
If we run the solver now, it will finish without errors and produce correct results. But the results will be correct only if we assign identical, correct values to both Denisty_M and Density; the same is valid for Angular_Frequency_M and Angular Frequency. In order to avoid the need of assigning the same value to several parameters at two different places in the sif file, we can replace this line in “Equation 1” section:
Angular Frequency = 2155
With this one:
Angular Frequency = Real MATC "Angular_Frequency_M"
Also replace this line in “Material 1” section:
Density = 1.205
with this one:
Density = Real MATC "Density_M"
This way we have to specify the values of Density and Angular Frequency at only one place in the sif file, namely at the top. This setup can be also easily adapted to parametric sweeps that will be discussed in another post. The sif file at this point looks like this:
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 = Real MATC "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 = Real MATC "Density_M"
Cv = Real MATC "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
-
- Site Admin
- Posts: 4812
- Joined: 22 Aug 2009, 11:57
- Antispam: Yes
- Location: Espoo, Finland
- Contact:
Re: Acoustics – Basic Postprocessing With ElmerSolver & Paraview
Hi
To clarify a little: matc parses the expressions and evaluates them. There are two operation modes:
$expression
MATC "expression"
The difference here is that the 1st one is evaluated only once when the command file is read. Hence it is handy mainly in that it allows higher abstraction level for the comand file just as demonstrated by Zoltan.
The second one involving "MATC" evaluates the expressions always when the parameter is requested. This is quite expensive since it involves some back-and-forth parsing. However, it can be very poweful. For example, setting in Simulation section:
would compute solution with frequencies 10, 20, ..., 10240 Hz. (tx is always the name of the "Variable" passed on to the expression, here the pseudotime in scanning mode).
Unless there is some variable involved "MATC" does not offer any advantage over "$" but is more costly.
-Peter
To clarify a little: matc parses the expressions and evaluates them. There are two operation modes:
$expression
MATC "expression"
The difference here is that the 1st one is evaluated only once when the command file is read. Hence it is handy mainly in that it allows higher abstraction level for the comand file just as demonstrated by Zoltan.
The second one involving "MATC" evaluates the expressions always when the parameter is requested. This is quite expensive since it involves some back-and-forth parsing. However, it can be very poweful. For example, setting in Simulation section:
Code: Select all
Simulation Type = scanning
Timestep Intervals = 11
Frequency = Variable "time"
Real MATC "10*2^(tx-1)"
Unless there is some variable involved "MATC" does not offer any advantage over "$" but is more costly.
-Peter
Re: Acoustics – Basic Postprocessing With ElmerSolver & Paraview
Hi Peter,
Thank you for helping us understand Elmer.
Your explanation, and especially the sentence:
$ expression
MATC "expression"
supposed to have basically equal functionality, and they are interchangeable, if the expressions need to be evaluated only once, when the sif file is being read by Elmer. With other words, the only difference being, that the first form is executed only once, while the second form is executed every time the variable is used. In our simple example then we could replace these lines:
with these, using the simpler $ form, because we don't need to evaluate them more than once:
I did just that, and it didn't work that way. The simple $ form of MATC expression is not accepted and executed inside the sections. For example running Elmer with this sif file:
will result in an error message:
In this case we could say that the reason for the error message is that we are using a parameter name “Angular Frequency” in the MATC expression that contains a forbidden space. But even if we circumvent this obvious syntax error by replacing this line temporarily (for the sake of testing) with the line that is surely correct:
Angular Frequency = 2155
the results will be still wrong, since the intended $ expressions are not evaluated correctly inside the sections.
It looks like the simple "$" form can be used only outside of sections, and it is evaluated only once, when Elmer reads the sif file. Inside the sections only the MATC form is accepted and executed, and it is evaluated every time the variable is used.
Your code sample using Scanning simulation type is very useful for parametric sweeps; thanks. I will expand on it in more detail for beginners (like me) in another post. I know that it is possible to preform a parametric sweep when the swept parameter is the frequency, or any other simple parameter (like Density etc.) specified within the sif file. It is also possible therefore to sweep boundary condition parameters that don't change the geometry.
But I don't know whether it is possible to perform a parametric sweep, when the size of at least one geometric entity is swept. This would require reconstructing the geometry, and the mesh as well for each parameter value, and then perform the simulation using the new mesh. Would this be too complicated? How? Is there a practical example that we could use as a template staring point?
Regards,
Zoltan
Thank you for helping us understand Elmer.
Your explanation, and especially the sentence:
creates an impression that the two forms of MATC expressions:Unless there is some variable involved "MATC" does not offer any advantage over "$" but is more costly.
$ expression
MATC "expression"
supposed to have basically equal functionality, and they are interchangeable, if the expressions need to be evaluated only once, when the sif file is being read by Elmer. With other words, the only difference being, that the first form is executed only once, while the second form is executed every time the variable is used. In our simple example then we could replace these lines:
Code: Select all
Angular Frequency = Real MATC "Angular_Frequency_M"
Density = Real MATC "Density_M"
Cv = Real MATC "1/(Density_M * Angular_Frequency_M)"
Code: Select all
$ Angular Frequency = Angular_Frequency_M
$ Density = Density_M
$ Cv = 1/(Density_M * Angular_Frequency_M)
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 = 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
Code: Select all
SingleSolver: Solver Equation string is: helmholtz equation
ERROR:: HelmholtzSolver: Could not fugure out Frquency!
Angular Frequency = 2155
the results will be still wrong, since the intended $ expressions are not evaluated correctly inside the sections.
It looks like the simple "$" form can be used only outside of sections, and it is evaluated only once, when Elmer reads the sif file. Inside the sections only the MATC form is accepted and executed, and it is evaluated every time the variable is used.
Your code sample using Scanning simulation type is very useful for parametric sweeps; thanks. I will expand on it in more detail for beginners (like me) in another post. I know that it is possible to preform a parametric sweep when the swept parameter is the frequency, or any other simple parameter (like Density etc.) specified within the sif file. It is also possible therefore to sweep boundary condition parameters that don't change the geometry.
But I don't know whether it is possible to perform a parametric sweep, when the size of at least one geometric entity is swept. This would require reconstructing the geometry, and the mesh as well for each parameter value, and then perform the simulation using the new mesh. Would this be too complicated? How? Is there a practical example that we could use as a template staring point?
Regards,
Zoltan
-
- Site Admin
- Posts: 4812
- Joined: 22 Aug 2009, 11:57
- Antispam: Yes
- Location: Espoo, Finland
- Contact:
Re: Acoustics – Basic Postprocessing With ElmerSolver & Paraview
Hi
The proper syntax would be
The last one needs the type "Real" since I guess its a new keyword not in the database.
Looping over geometric entities requires an auxiliary solver that can stretch the mesh. Stretching of course offers limited range but has the advantage of providing more or less smooth results (as opposed to remeshing). There are two solvers that can be used 1) RigidMeshMapper and 2) MeshUpdate. So the logic would be to parametrisize the mesh deformation and then loop over this parameter. The name for 1) is a little misleading. It can handle stretching as well where as 2) mimics elastic deformations. I would think there are useful examples among the tests on these.
-Peter
The proper syntax would be
Code: Select all
Angular Frequency = $Angular_Frequency_M
Density = $Density_M
Cv = Real $1/(Density_M * Angular_Frequency_M)
Looping over geometric entities requires an auxiliary solver that can stretch the mesh. Stretching of course offers limited range but has the advantage of providing more or less smooth results (as opposed to remeshing). There are two solvers that can be used 1) RigidMeshMapper and 2) MeshUpdate. So the logic would be to parametrisize the mesh deformation and then loop over this parameter. The name for 1) is a little misleading. It can handle stretching as well where as 2) mimics elastic deformations. I would think there are useful examples among the tests on these.
-Peter