The propagation of waves in periodic media is governed by the eigenvalue problem
$$L u = \omega^2 u$$
where $L$ is a linear operator that is periodic with a period defined by the unit cell of the periodic medium. The eigenfunctions satisfy the Bloch form:
$$u(x) = \hat{u}(x) e^{-i k \cdot x}$$
where $k$ is the wavevector and $\hat{u}(x)$ is periodic on the unit cell (i.e. $\hat{u}(x) = \hat{u}(x + a)$, where $a$ is a basis vector of the unit cell). Note that the eigenfunction $u(x)$ is Floquet-periodic on the unit cell, i.e. the solution on one boundary is related to the solution on the opposite boundary by $u(x) = u(x + a) e^{i k \cdot a}$. A common solution technique uses the finite element method to seek solutions $u(x)$ subject to Floquet periodic boundary conditions. For example, one might consider the unit square subject to the boundary conditions
$$u(x=1) = u(x=0) e^{-i k_1}$$
where $k_1$ is the x-component of the wavenumber. This can be represented as a multi-point constraint with slave dofs located at $x=1$, master dofs located at $x=0$, and a (complex-valued) scale of $e^{-i k_1}$.
Issue
It appears that complex-valued scales are not fully implemented in dolfinx_mpc. Consider the following MWE, heavily adapted from demo_periodic_gep.py, which attempts to apply a periodic constraint with a complex-valued scale. A warning is issued suggesting that an implicit conversion from complex to real takes place, i.e. that the imaginary part of the scale is ignored. It appears that this error arises at the cpp wrapper layer, as create_periodic_constraint_topological takes a double scale, rather than a PetscScalar scale.
WARNING:py.warnings:/usr/local/lib/python3.10/dist-packages/dolfinx_mpc/multipointconstraint.py:110: ComplexWarning: Casting complex values to real discards the imaginary part
mpc_data = dolfinx_mpc.cpp.mpc.create_periodic_constraint_topological(
It looks like there is an intention to support this, but perhaps it was never finished? mpc_data stores coefficients using the PETSc scalar type, but all of the call signatures in PeriodicConstraint accept only reals.
Motivation
The propagation of waves in periodic media is governed by the eigenvalue problem $$L u = \omega^2 u$$ where $L$ is a linear operator that is periodic with a period defined by the unit cell of the periodic medium. The eigenfunctions satisfy the Bloch form: $$u(x) = \hat{u}(x) e^{-i k \cdot x}$$ where $k$ is the wavevector and $\hat{u}(x)$ is periodic on the unit cell (i.e. $\hat{u}(x) = \hat{u}(x + a)$, where $a$ is a basis vector of the unit cell). Note that the eigenfunction $u(x)$ is Floquet-periodic on the unit cell, i.e. the solution on one boundary is related to the solution on the opposite boundary by $u(x) = u(x + a) e^{i k \cdot a}$. A common solution technique uses the finite element method to seek solutions $u(x)$ subject to Floquet periodic boundary conditions. For example, one might consider the unit square subject to the boundary conditions $$u(x=1) = u(x=0) e^{-i k_1}$$ where $k_1$ is the x-component of the wavenumber. This can be represented as a multi-point constraint with slave dofs located at $x=1$, master dofs located at $x=0$, and a (complex-valued)
scale
of $e^{-i k_1}$.Issue
It appears that complex-valued
scale
s are not fully implemented indolfinx_mpc
. Consider the following MWE, heavily adapted from demo_periodic_gep.py, which attempts to apply a periodic constraint with a complex-valuedscale
. A warning is issued suggesting that an implicit conversion from complex to real takes place, i.e. that the imaginary part of thescale
is ignored. It appears that this error arises at the cpp wrapper layer, ascreate_periodic_constraint_topological
takes adouble scale
, rather than aPetscScalar scale
.It looks like there is an intention to support this, but perhaps it was never finished?
mpc_data
stores coefficients using the PETSc scalar type, but all of the call signatures inPeriodicConstraint
accept only reals.MWE
Environment
The above was run in a complex-only Docker container that I built from the following recipe:
Library versions:
1dd043332314a1633f3bdc32bb15ce31e498d892
fd773880195b39327f652a47a892d89f7ef200cc
c007abd0753fb7a5a1f6c14ef6ff81b099666043
66f5adfc2d4e4c32e1e50a7ac472337b591ccb28
1a1520862e5ef2f05c0790a2ea94d2b231d01ff1