Skip to content

Commit

Permalink
Update schema to account for CoordinateSystem, and fix bugs with conf…
Browse files Browse the repository at this point in the history
…ig parsing.
  • Loading branch information
hughcars committed Aug 8, 2023
1 parent 9217fc6 commit 6e8c8fc
Show file tree
Hide file tree
Showing 7 changed files with 80 additions and 31 deletions.
61 changes: 46 additions & 15 deletions docs/src/config/boundaries.md
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,8 @@ accounts for nonzero metal thickness.
{
"Index": <int>,
"Attributes": [<int array>],
"Direction": <string>,
"Direction": <string> or <float array>,
"CoordinateSystem": <string>,
"Excitation": <bool>,
"R": <float>,
"L": <float>,
Expand All @@ -258,8 +259,9 @@ accounts for nonzero metal thickness.
"Elements":
[
{
"Attributes": [<int array>],
"Direction": <string>
"Attributes": <string> or <float array>,
"Direction": <string>,
"CoordinateSystem": <string>
},
...
]
Expand All @@ -276,12 +278,20 @@ with
boundary. If this port is to be a multielement lumped port with more than a single lumped
element, use the `"Elements"` array described below.

`"Direction" [None]` : Direction to define the polarization direction of the port field
mode on this lumped port boundary. Lumped ports must be axis-aligned unless the port is a
coaxial port. The available options are: `"+X"`, `"-X"`, `"+Y"`, `"-Y"`, `"+Z"`, `"-Z"`,
`"+R"`, `"-R"` (`"R"` is for a coaxial lumped port). If this port is to be a multielement
lumped port with more than a single lumped element, use the `"Elements"` array described
below.
`"Direction" [None]` : Direction to define the polarization direction of the
port field mode on this lumped port boundary. Axis aligned lumped ports can be
specified using keywords: `"+X"`, `"-X"`, `"+Y"`, `"-Y"`, `"+Z"`, `"-Z"`, while
coaxial lumped ports can be specified using `"+R"`, `"-R"`. The direction can
alternatively be specified as a normalized array of three values, for example
`[0, 1, 0]`. If a vector direction is specified, the `"CoordinateSystem"` value
specifies the coordinate system it is expressed in. If this port is to be a
multielement lumped port with more than a single lumped element, use the
`"Elements"` array described below.

`"CoordinateSystem" ["Cartesian"]` : Coordinate system used to express the
`"Direction"` vector, the options are `"Cartesian"` and `"Cylindrical"`. If a
keyword argument is used for `"Direction"` this value is ignored, and the
appropriate coordinate system is used instead.

`"Excitation" [false]` : Turns on or off port excitation for this lumped port boundary for
driven or transient simulation types.
Expand Down Expand Up @@ -320,6 +330,11 @@ should not be combined with the `"Direction"` field described above. Each elemen
multielement lumped port can be described by its own unique direction, which is specified
here. The elements of a multielement port add in parallel.

`"Elements"[]["CoordinateSystem"] [None]` : This option is for multielement surface current
boundaries and should not be combined with the `"CoordinateSystem"` field described above. Each
element of a multielement lumped port can be described by its own unique
direction, and corresponding coordinate system.

## `boundaries["WavePort"]`

```json
Expand Down Expand Up @@ -375,12 +390,14 @@ those specified under [`config["Boundaries"]["PEC"]["Attributes"]`]
{
"Index": <int>,
"Attributes": [<int array>],
"Direction": <string>
"Direction": <string> or <float array>,
"CoordinateSystem": <string>,
"Elements":
[
{
"Attributes": [<int array>],
"Direction": <string>
"Direction": <string> or <float array>,
"CoordinateSystem": <string>,
},
...
]
Expand All @@ -404,18 +421,29 @@ boundary. The available options are the same as under
this source is to be a multielement source which distributes the source across more than a
single lumped element, use the `"Elements"` array described below.

`"CoordinateSystem" ["Cartesian"]` : Defines the coordinate system for the source current
direction for this surface current boundary. The available options are the same as under
[`config["Boundaries"]["LumpedPort"]["CoordinateSystem"]`](#boundaries%5B%22LumpedPort%22%5D). If
this source is to be a multielement source which distributes the source across more than a
single lumped element, use the `"Elements"` array described below.

`"Elements"[]["Attributes"] [None]` : This option is for multielement surface current
boundaries should not be combined with the `"Attributes"` field described above. Each
element of a multielement current source can be described by its own unique integer array of
mesh boundary attributes, which are specified here. The elements of a multielement source
add in parallel to give the same total current as a single-element source.

`"Elements"[]["Direction"] [None]` : This option is for multielement surface current
boundaires and should not be combined with the `"Direction"` field described above. Each
boundaries and should not be combined with the `"Direction"` field described above. Each
element of a multielement current source can be described by its own unique direction,
which is specified here. The elements of a multielement source add in parallel to give the
same total current as a single-element source.

`"Elements"[]["CoordinateSystem"] ["Cartesian"]` : This option is for multielement surface current
boundaries and should not be combined with the `"CoordinateSystem"` field described above. Each
element of a multielement current source can be described by its own unique
direction, and corresponding coordinate system.

## `boundaries["Ground"]`

```json
Expand Down Expand Up @@ -516,7 +544,10 @@ postprocessing boundary.

`"Direction" [None]` : Defines the global direction with which to orient the surface
normals with computing the magnetic flux for this inductance postprocessing boundary. The
available options are: `"+X"`, `"-X"`, `"+Y"`, `"-Y"`, `"+Z"`, `"-Z"`.
available options are: `"+X"`, `"-X"`, `"+Y"`, `"-Y"`, `"+Z"`, `"-Z"`. The
direction can alternatively be specified as a normalized array of three values,
for example `[0, 1, 0]`. The true surface normal is used in the calculation,
`"Direction"` is only used to ensure the correct choice of orientation of the normal.

## `boundaries["Postprocessing"]["Dielectric"]`

Expand All @@ -528,7 +559,7 @@ available options are: `"+X"`, `"-X"`, `"+Y"`, `"-Y"`, `"+Z"`, `"-Z"`.
{
"Index": <int>,
"Attributes": [<int array>],
"Side": <string>,
"Side": <string> or <float array>,
"Thickness": <float>,
"Permittivity": <float>,
"PermittivityMA": <float>,
Expand All @@ -539,7 +570,7 @@ available options are: `"+X"`, `"-X"`, `"+Y"`, `"-Y"`, `"+Z"`, `"-Z"`.
[
{
"Attributes": [<int array>],
"Side": <string>
"Side": <string> or <float array>
},
...
]
Expand Down
3 changes: 2 additions & 1 deletion examples/coaxial/coaxial_matched.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@
"Index": 2,
"Attributes": [4],
"R": 50.0, // Ω, perfect matching
"Direction": "+R" // Coaxial lumped port
"Direction": [1,0,0], // Coaxial lumped port
"CoordinateSystem": "Cylindrical"
}
]
},
Expand Down
6 changes: 4 additions & 2 deletions examples/cpw/cpw_lumped_uniform.json
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,8 @@
[
{
"Attributes": [4],
"Direction": [0,1,0]
"Direction": [0,1,0],
"CoordinateSystem": "Cartesian"
},
{
"Attributes": [8],
Expand All @@ -98,7 +99,8 @@
},
{
"Attributes": [9],
"Direction": [0,-1,0]
"Direction": [0,-1,0],
"CoordinateSystem": "Cartesian"
}
]
},
Expand Down
6 changes: 4 additions & 2 deletions examples/rings/rings.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,14 @@
{
"Index": 1,
"Attributes": [4], // Inner ring
"Direction": [-0.5, 0.8660254037844386, 0.0] // "+Y" rotated pi/6 around (0,0,1)
"Direction": [-0.5, 0.8660254037844386, 0.0], // "+Y" rotated pi/6 around (0,0,1)
"CoordinateSystem": "Cartesian"
},
{
"Index": 2,
"Attributes": [5], // Outer ring
"Direction": [-0.5, 0.8660254037844386, 0.0] // "+Y" rotated pi/6 around (0,0,1)
"Direction": [-0.5, 0.8660254037844386, 0.0], // "+Y" rotated pi/6 around (0,0,1)
"CoordinateSystem": "Cartesian"
}
],
"Postprocessing": // Inductance from flux instead of energy
Expand Down
4 changes: 1 addition & 3 deletions palace/fem/lumpedelement.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -141,9 +141,7 @@ class CoaxialElementData : public LumpedElementData
sign(direction[0] > 0),
bounding_ball(mesh::GetBoundingBall(*fespace.GetParMesh(), marker, true))
{
MFEM_VERIFY(std::abs(bounding_ball.planar_normal[0]) == 0 &&
std::abs(bounding_ball.planar_normal[1]) == 0 &&
std::abs(bounding_ball.planar_normal[2]) == 0,
MFEM_VERIFY(bounding_ball.planar_normal.norm() > 0,
"Boundary elements must be coplanar to define a coaxial port.");

double A = GetArea(fespace);
Expand Down
14 changes: 11 additions & 3 deletions palace/utils/configfile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -699,13 +699,14 @@ void ImpedanceBoundaryData::SetUp(json &boundaries)
}
}

namespace
{

NLOHMANN_JSON_SERIALIZE_ENUM(CoordinateSystem,
{{CoordinateSystem::CARTESIAN, "Cartesian"},
{CoordinateSystem::CYLINDRICAL, "Cylindrical"}})

namespace
{

// Helper function for extracting a DataNode from a json, if the is_port
// value is set to true, will extract the normal vector from either the provided
// keyword argument or from a specified 3 vector. In extracting the normal
Expand All @@ -729,7 +730,7 @@ auto ParseDataNode(json &j, const std::string &key_word, bool is_port = true)
}
catch (json::exception)
{
MFEM_VERIFY(!is_port, "A port requires the direction be specified");
MFEM_VERIFY(!is_port, "A port requires " << key_word << " be specified");
return node;
}
}
Expand Down Expand Up @@ -880,6 +881,7 @@ void LumpedPortBoundaryData::SetUp(json &boundaries)
// Cleanup
elem.erase("Attributes");
elem.erase("Direction");
elem.erase("CoordinateSystem");
MFEM_VERIFY(elem.empty(),
"Found an unsupported configuration file keyword under \"LumpedPort\" "
"or \"Terminal\" boundary element!\n"
Expand Down Expand Up @@ -913,6 +915,7 @@ void LumpedPortBoundaryData::SetUp(json &boundaries)
p.erase("Excitation");
p.erase("Attributes");
p.erase("Direction");
p.erase("CoordinateSystem");
p.erase("Elements");
MFEM_VERIFY(p.empty(), "Found an unsupported configuration file keyword under "
"\"LumpedPort\" or \"Terminal\"!\n"
Expand Down Expand Up @@ -1009,6 +1012,7 @@ void SurfaceCurrentBoundaryData::SetUp(json &boundaries)
// Cleanup
elem.erase("Attributes");
elem.erase("Direction");
elem.erase("CoordinateSystem");
MFEM_VERIFY(elem.empty(), "Found an unsupported configuration file keyword "
"under \"SurfaceCurrent\" boundary element!\n"
<< elem.dump(2));
Expand All @@ -1028,6 +1032,7 @@ void SurfaceCurrentBoundaryData::SetUp(json &boundaries)
s.erase("Attributes");
s.erase("Direction");
s.erase("Elements");
s.erase("CoordinateSystem");
MFEM_VERIFY(
s.empty(),
"Found an unsupported configuration file keyword under \"SurfaceCurrent\"!\n"
Expand Down Expand Up @@ -1095,6 +1100,7 @@ void InductancePostData::SetUp(json &postpro)
i.erase("Index");
i.erase("Attributes");
i.erase("Direction");
i.erase("CoordinateSystem");
MFEM_VERIFY(i.empty(),
"Found an unsupported configuration file keyword under \"Inductance\"!\n"
<< i.dump(2));
Expand Down Expand Up @@ -1170,6 +1176,7 @@ void InterfaceDielectricPostData::SetUp(json &postpro)
// Cleanup
e.erase("Attributes");
e.erase("Side");
e.erase("CoordinateSystem");
MFEM_VERIFY(e.empty(), "Found an unsupported configuration file keyword "
"under \"Dielectric\" boundary element!\n"
<< e.dump(2));
Expand Down Expand Up @@ -1200,6 +1207,7 @@ void InterfaceDielectricPostData::SetUp(json &postpro)
d.erase("Thickness");
d.erase("Attributes");
d.erase("Side");
d.erase("CoordinateSystem");
MFEM_VERIFY(d.empty(),
"Found an unsupported configuration file keyword under \"Dielectric\"!\n"
<< d.dump(2));
Expand Down
17 changes: 12 additions & 5 deletions scripts/schema/config/boundaries.json
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@
"items": { "type": "integer"}
},
"Direction": { "$ref": "#/$defs/Direction" },
"CoordinateSystem": { "type": "string", "enum": ["Cartesian", "Cylindrical"] },
"R": { "type": "number" },
"L": { "type": "number" },
"C": { "type": "number" },
Expand All @@ -142,7 +143,8 @@
"additionalItems": false,
"items": { "type": "integer"}
},
"Direction": { "$ref": "#/$defs/Direction" }
"Direction": { "$ref": "#/$defs/Direction" },
"CoordinateSystem": { "type": "string", "enum": ["Cartesian", "Cylindrical"] },
}
}
}
Expand Down Expand Up @@ -207,6 +209,7 @@
"items": { "type": "integer"}
},
"Direction": { "$ref": "#/$defs/Direction" },
"CoordinateSystem": { "type": "string", "enum": ["Cartesian", "Cylindrical"] },
"Elements":
{
"type": "array",
Expand All @@ -224,7 +227,8 @@
"additionalItems": false,
"items": { "type": "integer"}
},
"Direction": { "$ref": "#/$defs/Direction" }
"Direction": { "$ref": "#/$defs/Direction" },
"CoordinateSystem": { "type": "string", "enum": ["Cartesian", "Cylindrical"] },
}
}
}
Expand Down Expand Up @@ -328,7 +332,8 @@
"additionalItems": false,
"items": { "type": "integer"}
},
"Direction": { "$ref": "#/$defs/Direction" }
"Direction": { "$ref": "#/$defs/Direction" },
"CoordinateSystem": { "type": "string", "enum": ["Cartesian", "Cylindrical"] }
}
}
},
Expand All @@ -350,7 +355,8 @@
"additionalItems": false,
"items": { "type": "integer"}
},
"Side": { "type": "string" },
"Side": { "$ref": "#/$defs/Direction" },
"CoordinateSystem": { "type": "string", "enum": ["Cartesian", "Cylindrical"] },
"Permittivity": { "type": "number" },
"PermittivityMA": { "type": "number" },
"PermittivityMS": { "type": "number" },
Expand All @@ -374,7 +380,8 @@
"additionalItems": false,
"items": { "type": "integer"}
},
"Side": { "type": "string" }
"Side": { "$ref": "#/$defs/Direction" },
"CoordinateSystem": { "type": "string", "enum": ["Cartesian", "Cylindrical"] }
}
}
}
Expand Down

0 comments on commit 6e8c8fc

Please sign in to comment.