BC for connecting bodies. VectorHelmholtz

Numerical methods and mathematical models of Elmer
robnil
Posts: 19
Joined: 13 Apr 2023, 11:05
Antispam: Yes

BC for connecting bodies. VectorHelmholtz

Post by robnil »

Hi, warnign for basic question.

I have a case where I want to simulate how the EM waves changes dependent on a material in a pipe. As such I have a metal cylinder (cavity) with a plastic pipe running through it. It is the material in the pipe that I want to change. The waves are excited by an antenna (half-torus) inside the cavity, but outside the pipe.

My problem is that I can't figure out how the BC's should be set on the surfaces connecting the cavity to the pipe, and the pipe to the material. The things I tried typically results in the fields of the pipe and material is zero, such that the waves does not propgate through the pipe nor material.

I have connected the surfaces through the Mesh -> unify surfaces function.

I've tried;
* not setting the boundaries to anything,
* setting it to zero,
* setting the E field to |E| field,
* setting Electric Robin Coefficient = $-beta and
* Magnetic boundary to 2*beta*|E|

but it all results in zero-fields except in the cavity outside of the pipe.

A crude mesh is attached, and here is the code:

Code: Select all

! Dielectric materials (articles or sites):
! MCC: 
!    [1]. Complex Dielectric Properties of Microcrystalline Cellulose, 
!                 Anhydrous Lactose, and ?-Lactose Monohydrate Powders Using a Microwave-based Open-reflection Resonator Sensor
! Water:
! 

$ beta = 50

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

Simulation
  Max Output Level = 5

  Coordinate System = Cartesian
  Coordinate Mapping(3) = 1 2 3
  Coordinate Scaling = 0.001

  ! Simulation Type = Steady state
  Simulation Type = Scanning
  Timestep intervals = 1  !9

  Steady State Max Iterations = 1
  Output Intervals = 1
  Timestepping Method = BDF
  BDF Order = 1
  Solver Input File = case.sif
  Post File = case.vtu
Output File = "caseres.result"
! Save only the internal E field in Hcurl space
  Output Variable 1 = E re
  Output Variable 2 = E im
  Output Global Variables = True
  Binary Output = False
!  Restart File = "caseresold.result"
  Restart Position = 0
!  Restart Before Initial Conditions = Logical False
!  Initialize Dirichlet Condition = Logical True
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) = 2
  Name = "Pipe"
  Equation = 1
  Material = 2 ! 1
End

Body 2
  Target Bodies(1) = 3
  Name = "Flow"
  Equation = 1
  Material = 2 !3
End

Body 3
  Target Bodies(1) = 1
  Name = "Cyllinder"
  Equation = 1
  Material = 2
End

Solver 3
  Equation = Result Output
  Output File Name = case
  Binary Output = False
  Procedure = "ResultOutputSolve" "ResultOutputSolver"
  Output Format = Vtu
  Exec Solver = After Timestep
End

Solver 2

  Equation = Vector Helmholtz Post Process
  Procedure = "VectorHelmholtz" "VectorHelmholtzCalcFields"

  Calculate Div of Poynting Vector = True
  Calculate Poynting Vector = True
  Calculate Energy Functional = True
  Calculate Electric Field = True
  Calculate Magnetic Field Strength = True
  Calculate Magnetic Flux Density = True
  Field Variable = E

  Exec Solver = Always

  Stabilize = True
  Bubbles = False
  Lumped Mass Matrix = False
  Optimize Bandwidth = True
  Steady State Convergence Tolerance = 1.0e-8
  
  Nonlinear System Convergence Tolerance = 1.0e-8
  Nonlinear System Max Iterations = 50
  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 = BiCGStabl
  Linear System Max Iterations = 500
  Linear System Convergence Tolerance = 1.0e-10
  BiCGstabl polynomial degree = 8
  Linear System Preconditioning = vanka
  Linear System ILUT Tolerance = 1.0e-3
  Linear System Abort Not Converged = False
  Linear System Residual Output = 10
  Linear System Precondition Recompute = 1
End

Solver 1

  Equation = Vector Helmholtz Equation
  Variable = E[E re:1 E im:1]

  Use Piola Transform = True
  Apply Mortar BCs = True
  Edge Basis = True
  Mortar BCs Additive = True

! This is to store the E field in Hcurl space, required for restart.
  Variable Output = Logical True
  Linear System Preconditioning Damp Coefficient im = 1.0
  Procedure = "VectorHelmholtz" "VectorHelmholtzSolver"

  Exec Solver = Always
  Stabilize = True
  Bubbles = False
  Lumped Mass Matrix = False
  Optimize Bandwidth = True
  Steady State Convergence Tolerance = 1.0e-9

  Nonlinear System Convergence Tolerance = 1.0e-9
  Nonlinear System Max Iterations = 20
  Nonlinear System Newton After Iterations = 3
  Nonlinear System Newton After Tolerance = 1.0e-3
  Nonlinear System Relaxation Factor = 1.0
  Nonlinear System Convergence Measure = Solution

  Linear System Solver = Iterative
  Linear System Iterative Method = BiCGStabl
  Linear System Max Iterations = 5000
  Linear System Convergence Tolerance = 1.0e-9
  BiCGstabl polynomial degree = 10
  Linear System Preconditioning = vanka
  Linear System ILUT Tolerance = 1.0e-3
  Linear System Abort Not Converged = False
  Linear System Residual Output = 10
  Linear System Precondition Recompute = 1
End

$ fs = 0.5e9 ! 1.0e9 1.5e9 2.05e9 2.5e9 3.0e9 3.5e9 4.0e9 4.5e9

Equation 1
  Name = "Equation 1"
  Angular Frequency = Variable time; Real MATC "2 * pi * fs(tx - 1)"
$ FeedingCoilRi = 0.001
$ FeedingWireR = 0.0003
$ CableAxisX = 0
$ CableAxisY = 0
$ mu0=4*pi*1e-7
$ epsilon0 = 8.854e-12
$ epsilonPTFERe = 2.03
$ c0 = 1/sqrt(epsilonPTFERe*epsilon0*mu0)
  Active Solvers(3) = 3 2 1
End

Material 1
  Name = "Pipe(Plastic)"
  Electric Conductivity  = 0.00001
  Relative Permittivity im = Real 0.000812
  Relative Reluctivity im = Real 0
  Relative Permittivity = Real 2.2
  Relative Reluctivity = Real 1
End

Material 2
  Name = "Air"
  ! Electric Conductivity  = 0.001
  Relative Permittivity = Real 1.006
  Relative Permittivity im = Real 5e-7
End

Material 3
  Name = "MCC"
  Electric Conductivity  = 0.00001
  ! article [1], fig 4 (max density)
  Relative Permittivity = Real 1.85
  Relative Permittivity im = Real 0.118
End

Material 4
  Name = "Water"
  Electric Conductivity = 0.05 
  Relative Permittivity = Real 86
  Relative Permittivity im = Real 0
End

Boundary Condition 1
  Target Boundaries(2) = 6 10
  Name = "Pipe"
  Electric Robin Coefficient im = $-beta
  Magnetic Boundary Load im = Variable E; Real MATC "-2*beta*sqrt(tx(0)^2 + tx(1)^2 + tx(2)^2 + tx(3)^2 + tx(4)^2 + tx(5)^2)"

!  E im {e} = 0
!  E re {e} = 0

!  E im {e} = Variable E; Real MATC "sqrt(tx(0)^2 + tx(1)^2 + tx(2)^2 + tx(3)^2 + tx(4)^2 + tx(5)^2)"
!  E re {e} = Variable E; Real MATC "sqrt(tx(0)^2 + tx(1)^2 + tx(2)^2 + tx(3)^2 + tx(4)^2 + tx(5)^2)"
  
!  E im {f} = Variable E; Real MATC "sqrt(tx(0)^2 + tx(1)^2 + tx(2)^2 + tx(3)^2 + tx(4)^2 + tx(5)^2)"
!  E re {f} = Variable E; Real MATC "sqrt(tx(0)^2 + tx(1)^2 + tx(2)^2 + tx(3)^2 + tx(4)^2 + tx(5)^2)"
End

Boundary Condition 2
  Target Boundaries(3) = 1 2 3
  Name = "Cylinder Walls"
  E im {e} = 0
  E re {e} = 0
End

Boundary Condition 3
  Target Boundaries(2) = 4 5
  Name = "H-probe"

 ! imaginary equal zero 
  E im {e} = Real 0
  E im {f} = Real 0
 ! z axis equal zero
  E re {e} 3 = Real 0
  E re {f} 3 = Real 0
  
 ! Non zero components
 ! Field scales as 1/r to ensure the same potential over the loop of 1V

  E re {f} 1 = Variable Coordinate; Real MATC "(tx(1) - CableAxisY)/((tx(0) - CableAxisX)^2+(tx(1) - CableAxisY)^2)/(2*pi)"
  E re {f} 2 = Variable Coordinate; Real MATC "-(tx(0) - CableAxisX)/((tx(0) - CableAxisX)^2+(tx(1) - CableAxisY)^2)/(2*pi)"
  
  E re {e} 1 = Variable Coordinate; Real MATC "(tx(1) - CableAxisY)/((tx(0) - CableAxisX)^2+(tx(1) - CableAxisY)^2)/(2*pi)" 
  E re {e} 2 = Variable Coordinate; Real MATC "-(tx(0) - CableAxisX)/((tx(0) - CableAxisX)^2+(tx(1) - CableAxisY)^2)/(2*pi)"
End
All best wishes, and most appriciated help
Robin
Attachments
ElmerCyl.PNG
ElmerCyl.PNG (76.23 KiB) Viewed 679 times
CylinderPipe_antenna.msh
(190.17 KiB) Downloaded 26 times
kevinarden
Posts: 2312
Joined: 25 Jan 2019, 01:28
Antispam: Yes

Re: BC for connecting bodies. VectorHelmholtz

Post by kevinarden »

Between the bodies there are no boundary conditions required, nor boundary elements, if the bodies share nodes at their interfaces. Elmer handles the communication of data (i.e transfer of energy or lack thereof) via the shared nodes.
In cases where the nodes do not align or are not shared for other reasons, then there are mortar boundary conditions to handle the interface between the bodies.
Elmer will except boundary elements and BC conditions on the internal boundaries if they are needed for some reason, although the normal condition would be to allowed the shared nodes to handle it.
kevinarden
Posts: 2312
Joined: 25 Jan 2019, 01:28
Antispam: Yes

Re: BC for connecting bodies. VectorHelmholtz

Post by kevinarden »

Took a look at the mesh file and although it appears the bodies are sharing nodes, they are coincident nodes. In gmsh this can be avoided by doing coherence to merge coincident points prior to meshing.
You could leave coincident nodes if you needed to for some reason but then you would have to use mortar boundary conditions for the internal boundaries, each body would have its own boundary surface, and you would have to define the mortar condition between the two.

In most cases it is just easier to eliminate the coincident nodes to ensure the elements share nodes at the boundary.
robnil
Posts: 19
Joined: 13 Apr 2023, 11:05
Antispam: Yes

Re: BC for connecting bodies. VectorHelmholtz

Post by robnil »

Hi, thanks for the quick reply :)

Would using the 'unify surfaces' option in under the 'mesh' section in the GUI solve the coincident nodes? I tried this prior (and now) to asking and still can't get any good results... If so, I think this sif should solve it:

Code: Select all

$ beta = 50

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

Simulation
  Max Output Level = 5

  Coordinate System = Cartesian
  Coordinate Mapping(3) = 1 2 3
  Coordinate Scaling = 0.001

  ! Simulation Type = Steady state
  Simulation Type = Scanning
  Timestep intervals = 1  !9

  Steady State Max Iterations = 1
  Output Intervals = 1
  Timestepping Method = BDF
  BDF Order = 1
  Solver Input File = case.sif
  Post File = case.vtu
Output File = "caseres.result"
! Save only the internal E field in Hcurl space
  Output Variable 1 = E re
  Output Variable 2 = E im
  Output Global Variables = True
  Binary Output = False
!  Restart File = "caseresold.result"
  Restart Position = 0
!  Restart Before Initial Conditions = Logical False
!  Initialize Dirichlet Condition = Logical True
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) = 2
  Name = "Pipe"
  Equation = 1
  Material = 1
End

Body 2
  Target Bodies(1) = 3
  Name = "Flow"
  Equation = 1
  Material = 1
End

Body 3
  Target Bodies(1) = 1
  Name = "Cyllinder"
  Equation = 1
  Material = 1
End

Solver 3
  Equation = Result Output
  Output File Name = case
  Binary Output = False
  Procedure = "ResultOutputSolve" "ResultOutputSolver"
  Output Format = Vtu
  Exec Solver = After Timestep
End

Solver 2

  Equation = Vector Helmholtz Post Process
  Procedure = "VectorHelmholtz" "VectorHelmholtzCalcFields"

  Calculate Div of Poynting Vector = True
  Calculate Poynting Vector = True
  Calculate Energy Functional = True
  Calculate Electric Field = True
  Calculate Magnetic Field Strength = True
  Calculate Magnetic Flux Density = True
  Field Variable = E

  Exec Solver = Always

  Stabilize = True
  Bubbles = False
  Lumped Mass Matrix = False
  Optimize Bandwidth = True
  Steady State Convergence Tolerance = 1.0e-8
  
  Nonlinear System Convergence Tolerance = 1.0e-8
  Nonlinear System Max Iterations = 50
  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 = BiCGStabl
  Linear System Max Iterations = 500
  Linear System Convergence Tolerance = 1.0e-10
  BiCGstabl polynomial degree = 8
  Linear System Preconditioning = vanka
  Linear System ILUT Tolerance = 1.0e-3
  Linear System Abort Not Converged = False
  Linear System Residual Output = 10
  Linear System Precondition Recompute = 1
End

Solver 1

  Equation = Vector Helmholtz Equation
  Variable = E[E re:1 E im:1]

  Use Piola Transform = True

! This is to store the E field in Hcurl space, required for restart.
  Variable Output = Logical True
  Linear System Preconditioning Damp Coefficient im = 1.0
  Procedure = "VectorHelmholtz" "VectorHelmholtzSolver"

  Exec Solver = Always
  Stabilize = True
  Bubbles = False
  Lumped Mass Matrix = False
  Optimize Bandwidth = True
  Steady State Convergence Tolerance = 1.0e-9

  Nonlinear System Convergence Tolerance = 1.0e-9
  Nonlinear System Max Iterations = 20
  Nonlinear System Newton After Iterations = 3
  Nonlinear System Newton After Tolerance = 1.0e-3
  Nonlinear System Relaxation Factor = 1.0
  Nonlinear System Convergence Measure = Solution

  Linear System Solver = Iterative
  Linear System Iterative Method = BiCGStabl
  Linear System Max Iterations = 5000
  Linear System Convergence Tolerance = 1.0e-9
  BiCGstabl polynomial degree = 10
  Linear System Preconditioning = vanka
  Linear System ILUT Tolerance = 1.0e-3
  Linear System Abort Not Converged = False
  Linear System Residual Output = 10
  Linear System Precondition Recompute = 1
End

$ fs = 0.5e9 1.0e9 1.5e9 2.05e9 2.5e9 3.0e9 3.5e9 4.0e9 4.5e9

Equation 1
  Name = "Equation 1"
  Angular Frequency = Variable time; Real MATC "2 * pi * fs(tx - 1)"
$ FeedingCoilRi = 0.001
$ FeedingWireR = 0.0003
$ CableAxisX = 0
$ CableAxisY = 0
$ mu0=4*pi*1e-7
$ epsilon0 = 8.854e-12
$ epsilonPTFERe = 2.03
$ c0 = 1/sqrt(epsilonPTFERe*epsilon0*mu0)
  Active Solvers(3) = 3 2 1
End

Material 1
  Name = "Air"
  ! Electric Conductivity  = 0.001
  Relative Permittivity = Real 1.006
  Relative Permittivity im = Real 5e-7
End


Boundary Condition 1
  Target Boundaries(3) = 1 2 3
  Name = "Cylinder Walls"
  E im {e} = 0
  E re {e} = 0
End

Boundary Condition 2
  Target Boundaries(2) = 4 5
  Name = "H-probe"

 ! imaginary equal zero 
  E im {e} = Real 0
  E im {f} = Real 0
 ! z axis equal zero
  E re {e} 3 = Real 0
  E re {f} 3 = Real 0
  
 ! Non zero components
 ! Field scales as 1/r to ensure the same potential over the loop of 1V

  E re {f} 1 = Variable Coordinate; Real MATC "(tx(1) - CableAxisY)/((tx(0) - CableAxisX)^2+(tx(1) - CableAxisY)^2)/(2*pi)"
  E re {f} 2 = Variable Coordinate; Real MATC "-(tx(0) - CableAxisX)/((tx(0) - CableAxisX)^2+(tx(1) - CableAxisY)^2)/(2*pi)"
  
  E re {e} 1 = Variable Coordinate; Real MATC "(tx(1) - CableAxisY)/((tx(0) - CableAxisX)^2+(tx(1) - CableAxisY)^2)/(2*pi)" 
  E re {e} 2 = Variable Coordinate; Real MATC "-(tx(0) - CableAxisX)/((tx(0) - CableAxisX)^2+(tx(1) - CableAxisY)^2)/(2*pi)"
End
But still got something like this,
issue.PNG
issue.PNG (21.92 KiB) Viewed 661 times
Rich_B
Posts: 423
Joined: 24 Aug 2009, 20:18

Re: BC for connecting bodies. VectorHelmholtz

Post by Rich_B »

Hello,

Unify surfaces in Elmergui will join boundaries, not bodies.

You can try merging the nodes. In Elmergui, click on 'Mesh', 'Configure', then in the box near the bottom labeled 'elmergrid' and 'String', add this to the existing entry:
-merge 1.0e-5
Change the value of 1.0e-5 to whatever minimum value you need to merge nodes that are that close or closer.

Then click on 'Mesh', 'Remesh', which should then apply the merge command to the mesh.

Let us know how this works for you.

Thanks, Rich.
kevinarden
Posts: 2312
Joined: 25 Jan 2019, 01:28
Antispam: Yes

Re: BC for connecting bodies. VectorHelmholtz

Post by kevinarden »

Correct you must merge coincident nodes, this is a meshing function, either in your mesher, or as Rich pointed out Elmer has an option to merge coincident nodes.
Rich_B
Posts: 423
Joined: 24 Aug 2009, 20:18

Re: BC for connecting bodies. VectorHelmholtz

Post by Rich_B »

One more note, Elmersolver can check to see if you have a single conforming mesh. In Elmergui, click on 'Model' and 'Setup'. Look for the box labeled 'Desired Mesh Pieces'. In your case, you are expecting to have a single conforming mesh, so enter a value of '1'. Elmersolver will check the mesh and then halt if the actual number of mesh pieces is not equal to the desired number of pieces. So instead of proceeding with a solution that won't give proper results due to having two or more non-conforming bodies, Elmersolver will halt and tell you why in the solver log.

Rich.
Rich_B
Posts: 423
Joined: 24 Aug 2009, 20:18

Re: BC for connecting bodies. VectorHelmholtz

Post by Rich_B »

Using your posted mesh, here is the result of adding desired mesh pieces = 1:
CalculateMeshPieces: Number of separate pieces in mesh is 3
ERROR:: CalculateMeshPieces: Number of pieces differ from the requested 1

STOP 1
Then, adding the merge command and remeshing, here is the result:
CalculateMeshPieces: Number of separate pieces in mesh is 1
CalculateMeshPieces: Number of pieces agree with the requested 1
Rich.
robnil
Posts: 19
Joined: 13 Apr 2023, 11:05
Antispam: Yes

Re: BC for connecting bodies. VectorHelmholtz

Post by robnil »

Hi, thank you, atleast I understand what I need to do now!

Following Rich reccomendations works just as he says! the waves transmigates somewhat between the bodies now :D

But setting all body-materials to air, I would expect them to behave kind of like as there is only one body, but there is still some 'block' between the bodies. Here is what I have now,
issue.PNG
issue.PNG (52.17 KiB) Viewed 632 times
Best,
Robin
kevinarden
Posts: 2312
Joined: 25 Jan 2019, 01:28
Antispam: Yes

Re: BC for connecting bodies. VectorHelmholtz

Post by kevinarden »

perhaps post the sif file
Post Reply