Skip to content

Commit

Permalink
Add a test case for integral constraint
Browse files Browse the repository at this point in the history
  • Loading branch information
raback committed Nov 1, 2024
1 parent 67fa4c9 commit 2a7d2a3
Show file tree
Hide file tree
Showing 5 changed files with 230 additions and 0 deletions.
8 changes: 8 additions & 0 deletions fem/tests/FluxIntegralBCInduction/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
INCLUDE(test_macros)
INCLUDE_DIRECTORIES(${CMAKE_BINARY_DIR}/fem/src)

CONFIGURE_FILE( case.sif case.sif COPYONLY)

file(COPY ELMERSOLVER_STARTINFO indmesh.grd DESTINATION "${CMAKE_CURRENT_BINARY_DIR}/")

ADD_ELMER_TEST(FluxIntegralBCInduction LABELS quick)
1 change: 1 addition & 0 deletions fem/tests/FluxIntegralBCInduction/ELMERSOLVER_STARTINFO
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
case.sif
185 changes: 185 additions & 0 deletions fem/tests/FluxIntegralBCInduction/case.sif
Original file line number Diff line number Diff line change
@@ -0,0 +1,185 @@
!---------------------------------------------------------------------
! Solves a axially symmetric magnetodynamics equation such that the net
! surface current generated on the surface of the conducting piece vanishes.
! This involves sort of Robin BC where the "external potential" is unknown and
! is found such that the net integral of the surface currents vanish.
!
! This test case was done in collaboration with Roland Ernst in 2023
! and saved to a test case later.
!
! P.R. / 1.11.2024
!--------------------------------------------------------------------

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

$chr="a"

Simulation
Max Output Level = 7
Coordinate System = Axi Symmetric
Coordinate Mapping(3) = 1 2 3
Simulation Type = Steady state
Steady State Max Iterations = 1
Output Intervals(1) = 1
Angular Frequency = 62800.0
Post File = case-$chr$.vtu
ascii output = true
! Mesh Levels = 3
End

Constants
Permittivity of Vacuum = 8.85418781e-12
Permeability of Vacuum = 1.25663706e-6
$i0=6.0e7
$elcond=1.0e6
End

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

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

Solver 1
Equation = MgDyn2DHarmonic
Procedure = "MagnetoDynamics2D" "MagnetoDynamics2DHarmonic"
Variable = Potential[Potential Re:1 Potential Im:1]
Exec Solver = Always
Nonlinear System Max Iterations = 1

Linear System Solver = Direct !Iterative
Linear System Direct Method = MUMPS

Linear System Scaling = False
Optimize Bandwidth = False

Calculate Loads = True
Apply Integral BCs = True
End

Solver 2
Equation = MgDynPost
Procedure = "MagnetoDynamics" "MagnetoDynamicsCalcFields"

Calculate Magnetic Field Strength = True
Calculate Electric Field = True
Calculate Nodal Heating = True
Calculate Current Density = True

Calculate Nodal Fields = True
Calculate Elemental Fields = False

Optimize Bandwidth = False
Linear System Scaling = False

Linear System Solver = Direct
Linear System Direct Method = umfpack

ctest 1 = Real -1.0
ctest 2 = Real -1.0
End


Solver 3
Exec Solver = never !after all
Equation = "SaveLine"
Procedure = "SaveData" "SaveLine"
FileName = f$chr$.dat

Polyline Coordinates(2,2) = 0.0 0.0 0.05 0.0
Polyline Divisions(1) = 100
End

Solver 4
Equation = "SaveScalars"
Procedure = "SaveData" "SaveScalars"
Filename = g.dat
Variable 1 = potential re
Operator 1 = "boundary int"
Variable 2 = potential re
Operator 2 = "boundary int"
Variable 3 = potential loads 1
Operator 3 = "boundary sum"
Variable 4 = potential loads 2
Operator 4 = "boundary sum"

Variable 5 = Surface current re 3
Operator 5 = "boundary int"
Variable 6 = Surface current im 3
Operator 6 = "boundary int"
Variable 7 = Surface current re 3
Operator 7 = "boundary min"
Variable 8 = Surface current re 3
Operator 8 = "boundary max"

Variable 9 = Lagrange Multiplier MgDyn2DHarmonic 1
Variable 10 = Lagrange Multiplier MgDyn2DHarmonic 2

Show Norm Index = 3
File Append = True
End


Equation 1
Name = "Equation 1_EM"
Active Solvers(2) = 2 1
End

Material 1
Name = "Air (room temperature)"
Relative Permittivity = 1.00059
Electric Conductivity = 0
Relative Permeability = 1.00000037
End

Material 2
Name = "Copper (generic) cold_ crucible"
Electric Conductivity = 59.59e6
Relative Permeability = 0.999994
End

Body Force 1
Name = "BodyForce 1"
Current Density = $i0
End

Boundary Condition 1
Target Boundaries = 1
Name = "BC Outside"
! Infinity BC = True
Potential Re = Real 0
Potential Re = Real 0
End

Boundary Condition 2
Target Boundaries = 2
Name = "BC CC_surf"
Layer Electric Conductivity = Real 6.0e7
Layer Relative Permeability = Real 1

! fixit re = real $1.0/(2*pi)
! fixit im = real 0.0

Flux Integral BC = Logical True
Save Scalars = True
End

Solver 1 :: Reference Norm = 1.85168787E-04

! This should by construction be zero.
Solver 4 :: Reference Norm = 0.0
Solver 4 :: Reference Norm Absolute = Logical True
32 changes: 32 additions & 0 deletions fem/tests/FluxIntegralBCInduction/indmesh.grd
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
##### ElmerGrid input file for structured grid generation ######
Version = 210903
Coordinate System = Cartesian 2D
Subcell Divisions in 2D = 6 5
Subcell Limits 1 = 0 0 0.01 0.02 0.03 0.031 0.05
Subcell Limits 2 = -0.04 -0.02 -0.015 0.015 0.02 0.04
Material Structure in 2D
4 2 2 2 2 2
4 2 2 2 1 2
4 2 3 2 1 2
4 2 2 2 1 2
4 2 2 2 2 2
End
Materials Interval = 1 2
Boundary Definitions
# type out int
1 0 2 1
2 3 2 1
3 1 2 1
4 4 2 1
End
Numbering = Horizontal
Element Degree = 1
Element Innernodes = False
Triangles = False
Surface Elements = 10000
Coordinate Ratios = 1
Minimum Element Divisions = 3 3
Element Ratios 1 = 1 1 1 1 1 5
Element Ratios 2 = 0.2 1 1 1 5
Element Densities 1 = 1 1 1 1 1 1
Element Densities 2 = 1 1 1 1 1
4 changes: 4 additions & 0 deletions fem/tests/FluxIntegralBCInduction/runtest.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
include(test_macros)
execute_process(COMMAND ${ELMERGRID_BIN} 1 2 indmesh)

RUN_ELMER_TEST()

0 comments on commit 2a7d2a3

Please sign in to comment.