Skip to content

Commit a9795b4

Browse files
authored
Merge pull request #255 from OpenSEMBA/231-Unclear-porgram-flow-when-compiling-with-MTLN
231 Fix ambiguity in wire/multiwire in compilations with or without MTLN
2 parents 19f2841 + 65c658b commit a9795b4

File tree

60 files changed

+244
-1081
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

60 files changed

+244
-1081
lines changed

doc/smbjson.md

Lines changed: 10 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ The following entries are shared by several FDTD-JSON objects and have a common
5151

5252
+ `type` followed by a string, indicates the type of JSON object that. Some examples of types are `planewave` for `sources` objects, and `polyline` for `elements`.
5353
+ `id` is a unique integer identifier for objects that belong to a list and which can be referenced by other objects. For instance, an element in the `elements` list must contain a `id` which can be referenced by a source in `sources` through its list of `elementIds`.
54-
+ `[name]` is an optional entry which is used to make the FDTD-JSON input human-readable, helping to identify inputs and outputs. Leading and trailing blank spaces are removed. Blank spaces are substituted by underscroes. The following characters are reserved and can't be used in a `name`: `@`.
54+
+ `[name]` is an optional entry which is used to make the FDTD-JSON input human-readable, helping to identify inputs and outputs. Leading and trailing blank spaces are removed. Blank spaces are substituted by underscores. The following characters are reserved and can't be used in a `name`: `@`.
5555

5656
### `<general>`
5757

@@ -60,9 +60,9 @@ This object must always be present and contains general information regarding th
6060
+ `<timeStep>`: A real number indicating the time step used by the solver, in seconds.
6161
+ `<numberOfSteps>`: An integer for the number of steps which the solver will iterate.
6262

63-
Addtionally, it may contain the following optional entry:
63+
Additionally, it may contain the following optional entry:
6464

65-
+ `<mtlnProblem>` : A bool indicating whether the problem is a pure MTLN problem and will solved using only the MTLN solver. If it is not present, its default value is `false`
65+
+ `<mtlnProblem>` : A boolean indicating whether the problem is a pure MTLN problem and will solved using only the MTLN solver. If it is not present, its default value is `false`
6666
+ `<additionalArguments>` : A string with flags. Keep in mind that flags passed by console have higher priority.
6767

6868
**Example:**
@@ -78,7 +78,7 @@ Addtionally, it may contain the following optional entry:
7878
### `[boundary]`
7979
This specifies the boundaries which will be used to terminate the computational domain.
8080
If `boundary` is not present it defaults to a `mur` absorbing condition in all bounds.
81-
The entries within `boundary` are objects labelled with the place where they will be applied:
81+
The entries within `boundary` are objects labeled with the place where they will be applied:
8282

8383
+ `all`, or
8484
+ `xLower`, `xUpper`, `yLower`, `yUpper`, `zLower` `zUpper`.
@@ -359,7 +359,7 @@ A `thinSlot` represents a gap between two conductive surfaces. Therefore it must
359359

360360
### `wire`
361361

362-
A `wire`, or *thin wire*, represents an electrically conducting wire-like structure with a radius much smaller than the surrounding cell sizes.
362+
A `wire`, or *thin wire*, represents an electrically conducting wire-like structure with a radius much smaller than the surrounding cell sizes. Materials of type `wire` can only be defined if the compilation flag for MTLN was OFF, i.e. `SEMBA_FDTD_ENABLE_MTLN = OFF`. Otherwise, the program execution will fail at runtime.
363363
These structures are solved by an algorithm similar to the one described in:
364364

365365
```
@@ -387,29 +387,14 @@ Materials of this type must contain:
387387
}
388388
```
389389

390-
A single wire might be surrounded by a dielectric material. In that case, the radius and the relative permittivity of the material are needed.
391-
392-
**Example:**
393-
394-
```json
395-
{
396-
"name": "WireWithDielectric",
397-
"id": 2,
398-
"type": "wire",
399-
"radius": 0.0001,
400-
"resistancePerMeter": 22.9e-3,
401-
"dielectric" : {"radius": 0.001, "relativePermittivity" : 3}
402-
}
403-
```
404-
If the `dielectric` field is present but any of `radius` or `relativePermittivity` is absent, the parsing of the dielectric will fail.
405390

406391
### `shieldedMultiwire`
407392

408393
A `shieldedMultiwire`, models $N+1$ electrical wires inside a bundled. The voltages and currents on these wires are solved by a multiconductor transmission lines (MTLN) solver described in:
409394

410395
Paul, C. R. (2007). Analysis of multiconductor transmission lines. John Wiley & Sons.
411396

412-
`shieldedMultiwire` materials are assumed to be contained within a `wire` or another `shieldedMultiwire` which is the external domain and is used as voltage reference.
397+
`shieldedMultiwire` materials are assumed to be contained within an `unshieldedMultiwire` or another `shieldedMultiwire` which is the external domain and is used as voltage reference. Materials of type `shieldedMultiwire` and `unshieldedMultiwre` can only be defined if the compilation flag for MTLN was ON, i.e. `SEMBA_FDTD_ENABLE_MTLN = ON`. Otherwise, the program execution will fail at runtime.
413398
They must contain the following entries:
414399

415400
+ `<inductancePerMeter>` and `<capacitancePerMeter>` which must be matrices with a size $N \times N$. If the number of wires is equal to $1$, this property must be a $1 \times 1$ matrix, e.g `[[1e-7]]`
@@ -449,7 +434,7 @@ They must contain the following entries:
449434

450435
A `unshieldedMultiwire`, models a bundle of $N$ electrical wires. The charges and currents on these wires are solved using the model described in:
451436

452-
Berenger, J. P. A Multiwire formalism for the FDTD Method. IEEE Transactions on Electromagnetic Compatability. August, 2000.
437+
Berenger, J. P. A Multiwire formalism for the FDTD Method. IEEE Transactions on Electromagnetic Compatibility. August, 2000.
453438

454439
They must contain the following entries:
455440

@@ -534,8 +519,7 @@ As with the rest of terminations, SPICE terminations have to be equivalents to 2
534519

535520
### `connector`
536521

537-
The `connector` represents the physical connection of a bundle to a structure. `connector` assigns properties to the initial or last segment of a `wire`, a `shieldedMultiwire` or an `unshieldedMultiwire`.
538-
This `wire` can be either a single wire or the outermost conductor of a `cable` bundle. The `connector` can have the following properties:
522+
The `connector` represents the physical connection of a bundle to a structure. `connector` assigns properties to the initial or last segment of a `wire`, a `shieldedMultiwire` or an `unshieldedMultiwire`. The `connector` can have the following properties:
539523

540524
+ `[resistances]`, an array of real numbers which will be converted to resistances per unit length and will replace the resistancePerMeter of that segment.
541525
+ `[transferImpedancesPerMeter]`, an array of [transferImpedancePerMeter], as described in the [shieldedMultiwire](#shieldedMultiwire) section.
@@ -689,7 +673,7 @@ In this example `elementId` points to a volume element, therefore `direction` mu
689673
}
690674
```
691675

692-
One important aspect to keep in mind when working with `bulkCurrent` with `electric field type` is its natural offset. This arises from the fact that to measure the electric current it is necessary to calculate the closed path integral of the magnetic field, then, the electric current is defined on the **dual mesh** of the inserted gridi.e., the mesh corresponding to the magnetic field. The **dual mesh** is constructed by placing a point at the center of each cell in the original (primal) mesh and connecting these points.
676+
One important aspect to keep in mind when working with `bulkCurrent` with `electric field type` is its natural offset. This arises from the fact that to measure the electric current it is necessary to calculate the closed path integral of the magnetic field, then, the electric current is defined on the **dual mesh** of the inserted grid -- i.e., the mesh corresponding to the magnetic field. The **dual mesh** is constructed by placing a point at the center of each cell in the original (primal) mesh and connecting these points.
693677

694678
Because of this, the code internally shifts the `bulkCurrent` you define to align with the dual mesh, causing a **half-cell offset**. In the case of surfaces, the coordinates **perpendicular** to the current flowing through the surface experience a **negative offset**, as shown in the figure below:
695679

@@ -719,7 +703,7 @@ A `line` probe computes the electric field line integral along a given `polyline
719703

720704
#### `farField`
721705

722-
Probes of type `farField` perform a near to far field transformation of the electric and magnetic vector fields and are typically located in the scattered field region which is defined by a total/scatterd field excitation, e.g. [a planewave](#planewave).
706+
Probes of type `farField` perform a near to far field transformation of the electric and magnetic vector fields and are typically located in the scattered field region which is defined by a total/scattered field excitation, e.g. [a planewave](#planewave).
723707
They must be defined with a single `cell` element which must contain a single `interval` defining a cuboid.
724708
The direction of the radiated field $\hat{r}(\theta, \phi)$ is defined with `<theta>` and `<phi>`, which must contain `<initial>`, `<final>`, and `<step>`, expressed in degrees.
725709
The `domain` of a `farField` probe can only be of type `frequency`.

src_json_parser/smbjson.F90

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -183,12 +183,13 @@ function readProblemDescription(this) result (res)
183183
res%conformalRegs = this%readConformalRegions()
184184

185185
! Thin elements
186+
#ifdef CompileWithMTLN
187+
res%mtln = this%readMTLN()
188+
#else
186189
res%tWires = this%readThinWires()
190+
#endif
187191
res%tSlots = this%readThinSlots()
188192

189-
#ifdef CompileWithMTLN
190-
res%mtln = this%readMTLN()
191-
#endif
192193

193194

194195
end function
@@ -1868,10 +1869,17 @@ function buildBaseThinSlotComponent(cs) result(res)
18681869
function readThinWires(this) result (res)
18691870
class(parser_t) :: this
18701871
type(ThinWires) :: res
1871-
type(materialAssociation_t), dimension(:), allocatable :: mAs
1872+
type(materialAssociation_t), dimension(:), allocatable :: mAs, mwires
18721873
integer :: i, j
18731874
logical :: found
18741875

1876+
mwires = this%getMaterialAssociations([ &
1877+
J_MAT_TYPE_SHIELDED_MULTIWIRE//' ',&
1878+
J_MAT_TYPE_UNSHIELDED_MULTIWIRE ])
1879+
if (size(mwires) /= 0) then
1880+
call WarnErrReport('ERROR: shieldedMultiwires and unshieldedMultiwires can only be defined if compiled with MTLN', .true.)
1881+
end if
1882+
18751883
mAs = this%getMaterialAssociations([J_MAT_TYPE_WIRE])
18761884

18771885
! Pre-allocates thin wires.
@@ -2510,21 +2518,25 @@ function readMTLN(this) result (mtln_res)
25102518
class(parser_t) :: this
25112519
type(mtln_t) :: mtln_res
25122520
type(fhash_tbl_t) :: elemIdToPosition, elemIdToCable, connIdToConnector
2513-
type(materialAssociation_t), dimension(:), allocatable :: wires, multiwires, cables
2521+
type(materialAssociation_t), dimension(:), allocatable :: wires, cables
25142522
class(cable_t), pointer :: ptr, read_cable
25152523
integer :: i
25162524

2525+
wires = this%getMaterialAssociations([J_MAT_TYPE_WIRE])
2526+
if (size(wires) /=0 ) then
2527+
call WarnErrReport("ERROR: material type 'wire' is not allowed if compiled with MTLN", .true.)
2528+
end if
25172529

25182530
cables = this%getMaterialAssociations([ &
25192531
J_MAT_TYPE_SHIELDED_MULTIWIRE//' ',&
25202532
J_MAT_TYPE_UNSHIELDED_MULTIWIRE ])
25212533
! spaces are needed to make strings have same length.
25222534
! Why? Because of FORTRAN! It only accepts fixed length strings for arrays.
25232535

2536+
25242537
mtln_res%connectors => readConnectors()
25252538
call addConnIdToConnectorMap(connIdToConnector, mtln_res%connectors)
25262539
if (size(cables) == 0) then
2527-
mtln_res%has_multiwires = .false.
25282540
mtln_res%time_step = 0
25292541
mtln_res%number_of_steps = 0
25302542
allocate(mtln_res%cables(0))
@@ -2533,7 +2545,6 @@ function readMTLN(this) result (mtln_res)
25332545
return
25342546
end if
25352547

2536-
mtln_res%has_multiwires = .true.
25372548
mtln_res%time_step = this%getRealAt(this%root, J_GENERAL//'.'//J_GEN_TIME_STEP)
25382549
mtln_res%number_of_steps = this%getRealAt(this%root, J_GENERAL//'.'//J_GEN_NUMBER_OF_STEPS)
25392550

@@ -2699,8 +2710,8 @@ function buildNetworks() result(res)
26992710

27002711
allocate(aux_nodes(0))
27012712
allocate(networks_coordinates(0))
2702-
cables = [ this%getMaterialAssociations([J_MAT_TYPE_WIRE]), &
2703-
this%getMaterialAssociations([J_MAT_TYPE_UNSHIELDED_MULTIWIRE]), &
2713+
! cables = [ this%getMaterialAssociations([J_MAT_TYPE_WIRE]), &
2714+
cables = [this%getMaterialAssociations([J_MAT_TYPE_UNSHIELDED_MULTIWIRE]), &
27042715
this%getMaterialAssociations([J_MAT_TYPE_SHIELDED_MULTIWIRE]) ]
27052716
do i = 1, size(cables)
27062717
elemIds = cables(i)%elementIds

src_json_parser/smbjson_labels.F90

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@ module smbjson_labels_mod
4949
character (len=*), parameter :: J_MAT_WIRE_REF_INDUCTANCE = "__referenceInductancePerMeter"
5050
character (len=*), parameter :: J_MAT_WIRE_DIELECTRIC = "dielectric"
5151
character (len=*), parameter :: J_MAT_WIRE_DIELECTRIC_RADIUS = "radius"
52-
character (len=*), parameter :: J_MAT_WIRE_DIELECTRIC_PERMITTIVITY = "relativePermittivity"
5352

5453
character (len=*), parameter :: J_MAT_LUMPED_MODEL = "model"
5554
character (len=*), parameter :: J_MAT_LUMPED_MODEL_RESISTOR = "resistor"

src_main_pub/fdetypes.F90

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -676,7 +676,7 @@ module FDETYPES
676676
fieldtotl,finishedwithsuccess, &
677677
permitscaling,mtlnberenger,niapapostprocess, &
678678
stochastic, verbose, dontwritevtk, &
679-
use_mtln_wires, resume_fromold, vtkindex,createh5bin,wirecrank,fatalerror
679+
resume_fromold, vtkindex,createh5bin,wirecrank,fatalerror
680680
#ifdef CompileWithConformal
681681
logical :: input_conformal_flag
682682
#endif

src_main_pub/interpreta_switches.F90

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,6 @@ module interpreta_switches_m
8888
noconformalmapvtk, &
8989
createh5filefromsinglebin, &
9090
creditosyaprinteados, &
91-
use_mtln_wires, &
9291
read_command_line
9392

9493
integer(kind=4) :: &
@@ -696,8 +695,6 @@ subroutine interpreta(l, statuse)
696695
l%forceresampled = .true.
697696
l%opcionespararesumeo = trim(adjustl(l%opcionespararesumeo))//' '//trim(adjustl(l%chain))
698697

699-
case ('-mtlnwires')
700-
l%use_mtln_wires = .true.
701698
CASE ('-wirethickness')
702699
i = i + 1
703700
CALL getcommandargument(l%chaininput, i, f, l%length, statuse, binaryPath)
@@ -1488,7 +1485,6 @@ subroutine print_help(l)
14881485
CALL print11 (l%layoutnumber, '-wiresflavor {new/Slanted.or.experimental.or.slanted/transition/semistructured l%precision} : model for the wires ')
14891486
#endif
14901487
CALL print11(l%layoutnumber, '& (default '//trim(adjustl(l%wiresflavor))//') ')
1491-
CALL print11(l%layoutnumber, '-mtlnwires : Use mtln solver to advance wires currents ')
14921488
CALL print11(l%layoutnumber, '-notaparrabos : Do not remove extra double tails at the end of the wires ')
14931489
CALL print11(l%layoutnumber, '& only available for the native format. ')
14941490
CALL print11(l%layoutnumber, '-intrawiresimplify : Disable strict interpretation of .NFDE topology. ')
@@ -1965,7 +1961,6 @@ subroutine default_flags(l)
19651961
l%facesNF2FF%ab = .true.
19661962
l%facesNF2FF%ar = .true.
19671963
!defaults
1968-
l%use_mtln_wires = .false.
19691964
l%read_command_line = .true.
19701965
l%hay_slanted_wires = .false.
19711966
l%forcing = .FALSE.

src_main_pub/observation.F90

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4034,6 +4034,7 @@ subroutine FlushMTLNObservationFiles(nEntradaRoot, mtlnProblem)
40344034
#endif
40354035

40364036
mtln_solver => GetSolverPtr()
4037+
if (.not. allocated(mtln_solver%bundles)) return
40374038
unit = 2000
40384039
do i = 1, size(mtln_solver%bundles)
40394040
do j = 1, size(mtln_solver%bundles(i)%probes)
@@ -4047,7 +4048,7 @@ subroutine FlushMTLNObservationFiles(nEntradaRoot, mtlnProblem)
40474048
buffer = buffer//" "//"conductor_"//trim(adjustl(temp))
40484049
end do
40494050
write (unit, *) trim(buffer)
4050-
do k = 1, size(mtln_solver%bundles(i)%probes(j)%t)
4051+
do k = 1, mtln_solver%number_of_steps + 1
40514052
buffer = ""
40524053
write (temp, *) mtln_solver%bundles(i)%probes(j)%t(k)
40534054
buffer = buffer//trim(temp)

src_main_pub/semba_fdtd.F90

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -646,6 +646,10 @@ subroutine semba_init(this, input_flags)
646646
CALL print11 (this%l%layoutnumber, '---> Conformal thin-gap solver: '//trim(adjustl(dubuf)))
647647
write(dubuf,*) this%l%run_with_dmma
648648
CALL print11 (this%l%layoutnumber, '---> DMMA thin-gap solver: '//trim(adjustl(dubuf)))
649+
#ifdef CompileWithMTLN
650+
write(dubuf,'(a)') 'MTLN wires'
651+
CALL print11 (this%l%layoutnumber, '---> Wire model: '//trim(adjustl(dubuf)))
652+
#else
649653
write(dubuf,'(a)') this%l%wiresflavor
650654
CALL print11 (this%l%layoutnumber, '---> Wire model: '//trim(adjustl(dubuf)))
651655
write(dubuf,'(a)') this%l%inductance_model
@@ -664,10 +668,11 @@ subroutine semba_init(this, input_flags)
664668
CALL print11 (this%l%layoutnumber, '---> Thin-wire double-tails removed: '//trim(adjustl(dubuf)))
665669
write(dubuf,*) this%l%fieldtotl
666670
CALL print11 (this%l%layoutnumber, '---> Thin-wire -this%l%fieldtotl experimental switch: '//trim(adjustl(dubuf)))
671+
667672
WRITE (dubuf,*) SEPARADOR // SEPARADOR // SEPARADOR
668673
CALL print11 (this%l%layoutnumber, dubuf)
674+
#endif
669675
endif
670-
671676
IF (this%l%layoutnumber == 0) THEN
672677
call erasesignalingfiles(this%l%simu_devia)
673678
endif

0 commit comments

Comments
 (0)