Skip to content

Commit

Permalink
Merge branch 'feature.multiple.time.dependent.coils' into 'master.dev'
Browse files Browse the repository at this point in the history
Allow more than 1 time-dependent coil in superB and consider different amplitude and phase

See merge request piclas/piclas!618
  • Loading branch information
scopplestone committed Mar 7, 2022
2 parents caf5855 + 69db4ca commit 61c112d
Show file tree
Hide file tree
Showing 12 changed files with 189 additions and 21 deletions.
23 changes: 12 additions & 11 deletions REGGIE.md
Original file line number Diff line number Diff line change
Expand Up @@ -253,17 +253,18 @@ Testing of different tracking routines with DSMC: [Link to build](regressionchec

Testing of different SuperB examples (via piclas or standalone superB binary), which generate a 3D magnetic field distribution to be used in piclas: [Link to build](regressioncheck/NIG_SuperB/builds.ini).

| r **No.** | **Case** | **CMAKE-CONFIG** | **Feature** | **Execution** | **Comparing** | **Readme** |
| :-------: | :------------------------: | :------------------------------------------: | :--------------------------------------------------------------------------------------: | :-----------------------------------: | :--------------------------------------------------------------: | :-----------------------------------------------------------------------------: |
| 1 | LinearConductor | PICLAS_BUILD_POSTI=ON, POSTI_BUILD_SUPERB=ON | straight conducting line | piclas, superB binaries (single-core) | convergence test with number of segments of the linear conductor | [Link](regressioncheck/NIG_SuperB/LinearConductor/readme.md) |
| 2 | CircularCoil | - | circular shaped coil | - | reference solution h5diff | [Link](regressioncheck/NIG_SuperB/CircularCoil/readme.md) |
| 3 | CircularCoilTimeDependent | - | circular shaped coil, time-dependent current (sin function) | nProcs=1,4 | - | [Link](~/piclas/regressioncheck/NIG_SuperB/CircularCoilTimeDependent/readme.md) |
| 4 | RectangularCoil | - | rectangular shaped coil | - | reference solution h5diff | [Link](regressioncheck/NIG_SuperB/RectangularCoil/readme.md) |
| 5 | SphericalMagnet | - | spherically shaped hard magnet | - | convergence test with number of nodes of the spherical magnet | [Link](regressioncheck/NIG_SuperB/SphericalMagnet/readme.md) |
| 6 | CubicMagnet | - | cubic shaped hard magnet | - | magnetic field reference solution h5diff | [Link](regressioncheck/NIG_SuperB/CubicMagnet/readme.md) |
| 7 | CylindricalMagnet | - | cylindrically shaped hard magnet | - | magnetic field reference solution h5diff | [Link](regressioncheck/NIG_SuperB/CylindricalMagnet/readme.md) |
| 8 | HollowCylinderMagnet | - | hollow cylinder hard magnet, placed outside of simulation domain | - | magnetic field reference solution h5diff | [Link](regressioncheck/NIG_SuperB/HollowCylinderMagnet/readme.md) |
| 9 | HollowCylinderMagnetCurved | - | hollow cylinder hard magnet (analytic solution along z-axis available), curvilinear grid | - | magnetic field reference solution h5diff | [Link](regressioncheck/NIG_SuperB/HollowCylinderMagnetCurved/readme.md) |
| **No.** | **Case** | **CMAKE-CONFIG** | **Feature** | **Execution** | **Comparing** | **Readme** |
| :-------: | :------------------------: | :------------------------------------------: | :--------------------------------------------------------------------------------------: | :-----------------------------------: | :--------------------------------------------------------------: | :----------------------------------------------------------------------------------: |
| 1 | LinearConductor | PICLAS_BUILD_POSTI=ON, POSTI_BUILD_SUPERB=ON | straight conducting line | piclas, superB binaries (single-core) | convergence test with number of segments of the linear conductor | [Link](regressioncheck/NIG_SuperB/LinearConductor/readme.md) |
| 2 | CircularCoil | - | circular shaped coil | - | reference solution h5diff | [Link](regressioncheck/NIG_SuperB/CircularCoil/readme.md) |
| 3 | CircularCoilTimeDependent | - | circular shaped coil, time-dependent current (sin function) | nProcs=1,4 | - | [Link](~/piclas/regressioncheck/NIG_SuperB/CircularCoilTimeDependent/readme.md) |
| 4 | CircularCoilTimeDependentMuli | - | three circular shaped coils, time-dependent current (sin function) | nProcs=1,4 | - | [Link](~/piclas/regressioncheck/NIG_SuperB/CircularCoilTimeDependentMuli/readme.md) |
| 5 | RectangularCoil | - | rectangular shaped coil | - | reference solution h5diff | [Link](regressioncheck/NIG_SuperB/RectangularCoil/readme.md) |
| 6 | SphericalMagnet | - | spherically shaped hard magnet | - | convergence test with number of nodes of the spherical magnet | [Link](regressioncheck/NIG_SuperB/SphericalMagnet/readme.md) |
| 7 | CubicMagnet | - | cubic shaped hard magnet | - | magnetic field reference solution h5diff | [Link](regressioncheck/NIG_SuperB/CubicMagnet/readme.md) |
| 8 | CylindricalMagnet | - | cylindrically shaped hard magnet | - | magnetic field reference solution h5diff | [Link](regressioncheck/NIG_SuperB/CylindricalMagnet/readme.md) |
| 9 | HollowCylinderMagnet | - | hollow cylinder hard magnet, placed outside of simulation domain | - | magnetic field reference solution h5diff | [Link](regressioncheck/NIG_SuperB/HollowCylinderMagnet/readme.md) |
| 10 | HollowCylinderMagnetCurved | - | hollow cylinder hard magnet (analytic solution along z-axis available), curvilinear grid | - | magnetic field reference solution h5diff | [Link](regressioncheck/NIG_SuperB/HollowCylinderMagnetCurved/readme.md) |

### NIG_PIC_poisson_Leapfrog

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -185,9 +185,9 @@ It should be noted that the base point defines the start of the first segment as
cross-sections, where it is the middle point of the cross-section.

### Time-dependent Magnetic Coils
A time-dependent magnet field can be created by a time-varying electric current running through a coil.
Note that more than one time-dependent magnetic coil cannot be defined in the parameter file as this is not implemented yet.
However, one time-dependent coil can be combined with an arbitrary number of permanent magnets and coils (with a constant current).
A time-dependent magnetic field can be created by a time-varying electric current running through a coil.
Time-dependent coils can be combined with an arbitrary number of permanent magnets and coils (with a constant current).
Currently, all time-dependent coils must use the same frequency but can have different phases.
The time-dependent settings are required in addition to the ones used for a standard coil

Coil1-TimeDepCoil = T
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
! hdf5 diff
!h5diff_file = SuperB_CircularCoil_BGField.h5
!h5diff_reference_file = SuperB_CircularCoil_BGField_reference.h5
!5diff_data_set = DG_Solution\sBGField ! data set name in h5diff_file and h5diff_reference_file
!h5diff_tolerance_value = 1.0e-5
!h5diff_tolerance_type = relative
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
MPI=1,4
Binary file not shown.
38 changes: 38 additions & 0 deletions regressioncheck/NIG_SuperB/CircularCoilTimeDependentMulti/hopr.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
!===========================================================================================================================
DEFVAR = (REAL): minus_x = 0.0
DEFVAR = (REAL): plus_x = 1.0

DEFVAR = (REAL): minus_y = 0.0
DEFVAR = (REAL): plus_y = 1.0

DEFVAR = (REAL): minus_z = 0.0
DEFVAR = (REAL): plus_z = 1.0
!===========================================================================================================================
ProjectName = cube
Debugvisu = T
DebugVisuLevel = 2
NVisu = 1
Mode = 1

Corner = (/minus_x,minus_y,minus_z ,, plus_x,minus_y,minus_z ,, plus_x,plus_y,minus_z ,, minus_x,plus_y,minus_z ,, minus_x,minus_y,plus_z ,, plus_x,minus_y,plus_z ,, plus_x,plus_y,plus_z ,, minus_x,plus_y,plus_z /)
nElems = (/3,3,3/)
elemtype = 108

BCIndex = (/6 ,4 ,1 ,3 ,2 ,5/)
! = (/z-,y-,x+,y+,x-,z+/)
nZones = 1

! BCs
nUserDefinedBoundaries = 6
BoundaryName = BC_Xplus
BoundaryType = (/4,0,0,0/)
BoundaryName = BC_Xminus
BoundaryType = (/4,0,0,0/)
BoundaryName = BC_Yplus
BoundaryType = (/4,0,0,0/)
BoundaryName = BC_Yminus
BoundaryType = (/4,0,0,0/)
BoundaryName = BC_Zplus
BoundaryType = (/4,0,0,0/)
BoundaryName = BC_Zminus
BoundaryType = (/4,0,0,0/)
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
! =============================================================================== !
! EQUATION (linearscalaradvection)
! =============================================================================== !
IniExactFunc = 0
! =============================================================================== !
! DISCRETIZATION
! =============================================================================== !
N = 3 ! Polynomial degree
!NVisu = 1
!NAnalyze = 1 ! Number of analyze points
! =============================================================================== !
! MESH
! =============================================================================== !
MeshFile = cube_mesh.h5
useCurveds = F
TrackingMethod = triatracking
! =============================================================================== !
! OUTPUT / VISUALIZATION
! =============================================================================== !
ProjectName = SuperB_CircularCoil
IterDisplayStep = 1
Part-AnalyzeStep = 1
! =============================================================================== !
! LOAD BALANCE
! =============================================================================== !
DoLoadBalance = T
DoInitialAutoRestart = T
LoadBalanceMaxSteps = 1
Load-DeviationThreshold = 1E-9
! =============================================================================== !
! CALCULATION
! =============================================================================== !
tend = 1.0E-8
Analyze_dt = 1.0E-8
CFLscale = 0.2 ! Scaling of theoretical CFL number
! =============================================================================== !
! SuperB
! =============================================================================== !
PIC-BG-Field = T

PIC-CalcBField-OutputVTK = T ! output the magnet or coil geometries for visualization

NumOfCoils = 3

! --- Coil 1
Coil1-Type = circle
Coil1-BasePoint = (/0.5,0.5,0.0/)
Coil1-LengthVector = (/0.,0.,0.2/)
Coil1-Current = 1.e6
Coil1-Radius = 0.9
Coil1-LoopNum = 10
Coil1-PointsPerLoop = 20
Coil1-AxisVec1 = (/0.,0.,1.0/)
Coil1-TimeDepCoil = T
Coil1-CurrentFrequency = 1e8
Coil1-CurrentPhase = 0.

! --- Coil 2
Coil2-Type = circle
Coil2-BasePoint = (/0.5,0.5,0.4/)
Coil2-LengthVector = (/0.,0.,0.2/)
Coil2-Current = 1.e6
Coil2-Radius = 0.9
Coil2-LoopNum = 10
Coil2-PointsPerLoop = 20
Coil2-AxisVec1 = (/0.,0.,1.0/)
Coil2-TimeDepCoil = T
Coil2-CurrentFrequency = 1e8
Coil2-CurrentPhase = 2.0943951023932 ! 120°

! --- Coil 3
Coil3-Type = circle
Coil3-BasePoint = (/0.5,0.5,0.8/)
Coil3-LengthVector = (/0.,0.,0.2/)
Coil3-Current = 1.e6
Coil3-Radius = 0.9
Coil3-LoopNum = 10
Coil3-PointsPerLoop = 20
Coil3-AxisVec1 = (/0.,0.,1.0/)
Coil3-TimeDepCoil = T
Coil3-CurrentFrequency = 1e8
Coil3-CurrentPhase = 4.18879020478639 ! 240°

nTimePoints = 31
! =============================================================================== !
! PARTICLES
! =============================================================================== !
Part-maxParticleNumber = 1
Part-nSpecies = 1
Part-nBounds = 6
Part-Boundary1-SourceName = BC_Xplus
Part-Boundary1-Condition = symmetric
Part-Boundary2-SourceName = BC_Xminus
Part-Boundary2-Condition = symmetric
Part-Boundary3-SourceName = BC_Yplus
Part-Boundary3-Condition = symmetric
Part-Boundary4-SourceName = BC_Yminus
Part-Boundary4-Condition = symmetric
Part-Boundary5-SourceName = BC_Zplus
Part-Boundary5-Condition = symmetric
Part-Boundary6-SourceName = BC_Zminus
Part-Boundary6-Condition = symmetric
Part-FIBGMdeltas = (/0.1,0.1,0.1/)
Part-Species1-ChargeIC = 0.
Part-Species1-MassIC = 1.
Part-Species1-MacroParticleFactor = 1.
! =============================================================================== !
! DSMC
! =============================================================================== !
ManualTimeStep= 1.0E-9
Particles-HaloEpsVelo = 2.0E+03
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# SuperB: Circular coils (time-dependent)
- Magnetic field of a three circular coils with a current of 1e6 A that changes in time with a sin function
- The three different coils must have the same frequency but have different phases in this example (shifted by 120 and 240 degrees)
- Output of DG_Solution field to SuperB_CircularCoil_BGField.h5 with additional dimension that accounts for temporal change
- When running this reggie with piclas and MPI=4, the field is created and the read-in when the automatic load balance is performed
after the first time step
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions regressioncheck/NIG_SuperB/builds.ini
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
! --------------
! WARNING:
! This file is currently not used for the regression test
! The default built binaries in the first gitlab-ci stage are used with -DLIBS_BUILD_HDF5 =OFF -DPICLAS_BUILD_POSTI=ON -DPOSTI_BUILD_SUPERB=ON
! The default built binaries in the first gitlab-ci stage are used with -DLIBS_BUILD_HDF5=OFF -DPICLAS_BUILD_POSTI=ON -DPOSTI_BUILD_SUPERB=ON
! --------------

! relative binary path in build directory
Expand All @@ -13,7 +13,7 @@ LIBS_BUILD_HDF5 = OFF
PICLAS_POLYNOMIAL_DEGREE = N
PICLAS_EQNSYSNAME = maxwell
PICLAS_TIMEDISCMETHOD = RK3
LIBS_USE_MPI = ON
LIBS_USE_MPI = ON
PICLAS_NODETYPE = GAUSS

PICLAS_BUILD_POSTI = ON
Expand Down
14 changes: 10 additions & 4 deletions src/posti/superB/superB_init.f90
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ SUBROUTINE InitializeSuperB()
! LOCAL VARIABLES
INTEGER :: iMagnet, iCoil, iSegment, NbrOfTimeDepCoils
CHARACTER(LEN=32) :: hilf,hilf2
REAL :: FrequencyTmp
!===================================================================================================================================

! Get logical for calculating the error norms L2 and LInf of magnetic field
Expand Down Expand Up @@ -215,8 +216,9 @@ SUBROUTINE InitializeSuperB()
END IF

! Get the number of coils/conductors
NumOfCoils = GETINT('NumOfCoils','0')
NumOfCoils = GETINT('NumOfCoils','0')
NbrOfTimeDepCoils = 0. ! Initialize
FrequencyTmp = 0. ! Initialize
ALLOCATE(CoilInfo(NumOfCoils))
ALLOCATE(TimeDepCoil(NumOfCoils))
ALLOCATE(CurrentInfo(NumOfCoils))
Expand Down Expand Up @@ -298,9 +300,13 @@ SUBROUTINE InitializeSuperB()
TimeDepCoil(iCoil) = GETLOGICAL('Coil'//TRIM(hilf)//'-TimeDepCoil')
IF(TimeDepCoil(iCoil)) THEN
NbrOfTimeDepCoils = NbrOfTimeDepCoils + 1
IF(NbrOfTimeDepCoils.GT.1) CALL abort(__STAMP__,'More than one time-dependent magnetic coil not imeplemented!')
CurrentInfo(iCoil)%CurrentFreq = GETREAL('Coil'//TRIM(hilf)//'-CurrentFrequency')
CurrentInfo(iCoil)%CurrentPhase = GETREAL('Coil'//TRIM(hilf)//'-CurrentPhase')
! Check that all time-dependent coils use the same frequency
IF((NbrOfTimeDepCoils.GT.1).AND.(.NOT.ALMOSTEQUALRELATIVE(CurrentInfo(iCoil)%CurrentFreq,FrequencyTmp,1e-5)))THEN
CALL abort(__STAMP__,'All time-dependent coils must have the same frequency!')
END IF
FrequencyTmp = CurrentInfo(iCoil)%CurrentFreq
END IF
CoilInfo(iCoil)%Current = GETREAL('Coil'//TRIM(hilf)//'-Current')
END DO
Expand All @@ -309,8 +315,8 @@ SUBROUTINE InitializeSuperB()
! Discretisation in time
UseTimeDepCoil=.FALSE.
IF (ANY(TimeDepCoil)) THEN
UseTimeDepCoil=.TRUE.
nTimePoints = GETINT('nTimePoints')
UseTimeDepCoil = .TRUE.
nTimePoints = GETINT('nTimePoints')
IF(nTimePoints.LT.2) CALL abort(__STAMP__,'nTimePoints cannot be smaller than 2')
END IF

Expand Down
1 change: 0 additions & 1 deletion src/posti/superB/superB_permMag.f90
Original file line number Diff line number Diff line change
Expand Up @@ -653,7 +653,6 @@ SUBROUTINE CalculateCylindricMagneticPotential(iMagnet)
DO I = -1, 2
ASSOCIATE( idx1 => 2*MAX(I,0), & ! gives 0, 0, 2, 4
idx2 => 2*MIN(I+2,3) ) ! gives 2, 4, 6, 6
WRITE (*,*) "idx1,idx2 =", idx1,idx2
WRITE(1112,'(I0)',ADVANCE="NO") 4*nNodes+2
DO iPoint=0,2*nNodes-1
WRITE(1112,'(1X,I0)',ADVANCE="NO") idx1*nNodes + iPoint
Expand Down

0 comments on commit 61c112d

Please sign in to comment.