API

Nmrc.IncidentType
Incident

Some parameters related to the incident field.

Parameters

  • k: the wave number
  • θ: the incident field
  • α: α = k * sin(θ)
  • β: β = k * cos(θ)
source
Nmrc.IncidentMethod
Incident(k::Float64, θ::Float64)

Define the incident field with the wavenumber k and the incident field θ.

source
Nmrc.PMLType
PML

Information on PML layer and coordinate transformation.

source
Nmrc.allocate_matricesMethod
allocate_matrices(dof::DofHandler, cst::ConstraintHandler)

Allocate the complex-valued stiffness matrices.

source
Nmrc.allocate_stiff_matrixMethod
allocate_stiff_matrix(dofhandler::DofHandler, csthandler::ConstraintHandler, dofs)

Create a sparse pattern for the stiffness matrix. We need to add extra entries due to the DtN map by hand.

source
Nmrc.apply_all_bds!Method
apply_all_bds!(K::Union{SparseMatrixCSC, Symmetric}, ch::ConstraintHandler)
apply_all_bds!(KK::Union{SparseMatrixCSC, Symmetric}, f::AbstractVector, ch::ConstraintHandler, applyzero::Bool = false)

Impose the periodic boundary condition and the Dirichlet boundary condition on the matrices.

source
Nmrc.assemble_AMethod
assemble_A(cv::CellValues, dh::DofHandler, A::SparseMatrixCSC, inc::Incident)
source
Nmrc.assemble_A0Method
assemble_A0(cv::CellValues, dh::DofHandler, A₀::SparseMatrixCSC, medium::Function, k)

Assemble the zero order term $\mathbf{A}_{0}$ in the Nonlinear eigenvalue problem.

$A_{0}(u, v) = \int \nabla u \cdot \nabla \bar{v} - k^{2}n(x_{1}, x_{2}) u \bar{v} d x.$

Argument

  • cv: CellValues
  • dh: DofHandler
  • A₀: an empty sparse pattern preallocated for A₀
  • medium: refractive index function which describes the properties of the medium
  • k: the wavenumber

See also assemble_A1, assemble_A2.

source
Nmrc.assemble_A1Method
assemble_A1(cv::CellValues, dh::DofHandler, A₁::SparseMatrixCSC)

Assemble the first order term $\mathbf{A}_{1}$ in the Nonlinear eigenvalue problem.

$A_{1}(u, v) = -\int 2i \partial_{1} u \bar{v} d x.$

See also assemble_A0, assemble_A2.

source
Nmrc.assemble_A2Method
assemble_A2(cv::CellValues, dh::DofHandler, A₂::SparseMatrixCSC)

Assemble the second order term in the Nonlinear eigenvalue problem.

$A_{2}(u, v) = \int u \bar{v} d x.$

See also assemble_A0, assemble_A1.

source
Nmrc.assemble_loadMethod
assemble_load(fv::FacetValues, dh::DofHandler, facetset, f, inc::Incident, height)

Assemble the load vector due to the incident field.

source
Nmrc.assemble_pml_A0Method
assemble_pml_A0(cv::CellValues, dh::DofHandler, A₀::SparseMatrixCSC, medium::Function, p::PML, k)

Assemble the zero order term in the quadratic eigenvalue problem constructed by PML-FEM.

\[A_{0}(u, v) = \int s(x_{2}) \frac{\partial u}{\partial x_{1}} \frac{\partial \bar{v}}{\partial x_{1}} + \frac{1}{s(x_{2})} \frac{\partial u}{\partial x_{2}} \frac{\partial \bar{v}}{\partial x_{2}} - k^{2} n(x_{1}, x_{2}) s(x_{2}) u \bar{v} dx.\]

Arguments

  • cv: CellValues
  • dh: DofHandler
  • A₀: Sparse matix preallocated for A₀
  • medium: the refractive index
  • p: the information about PML, see PML
  • k: the wavenumber

See also assemble_pml_A1, assemble_pml_A2.

source
Nmrc.assemble_pml_A1Method
assemble_pml_A1(cv::CellValues, dh::DofHandler, A₁::SparseMatrixCSC, p::PML)

Assemble the first order term in the quadratic eigenvalue problem constructed by PML-FEM.

\[A_{1}(u, v) = -\int 2i s(x_{2}) \frac{\partial u}{\partial x_{1}} \bar{v} dx.\]

Arguments

  • cv: CellValues
  • dh: DofHandler
  • A₁: Sparse matix preallocated for A₁
  • p: the information about PML, see PML

See also assemble_pml_A0, assemble_pml_A2.

source
Nmrc.assemble_pml_A2Method
assemble_pml_A2(cv::CellValues, dh::DofHandler, A₂::SparseMatrixCSC, p::PML)

Assemble the second order term in the quadratic eigenvalue problem from the PML-FEM method.

\[A_{2}(u, v) = \int s(x_{2}) u \bar{v} dx.\]

Arguments

  • cv: CellValues
  • dh: DofHandler
  • A₂: Sparse matix preallocated for A₂
  • p: the information about PML, see PML

See also assemble_pml_A0, assemble_pml_A1.

source
Nmrc.assemble_tbcMethod
assemble_tbc(fv::FacetValues, dh::DofHandler, inc::Incident, facetset, F, N, dofsDtN; period = 2π)

Assemble the TBC matrix.

source
Nmrc.beta_nMethod
beta_n(k, α, n)

Compute $\beta_{n}$ for complex $\alpha$. We need this function when we construct nonlinear eigenvalue problems. Please note that we take the negative imaginary axis as the branch cut for square root. So we use csqrt_negimag instead of the default square root in Julia. See also csqrt_negimag.

source
Nmrc.beta_nMethod
beta_n(inc::Incident, n; period = 2π)

Compute the $βₙ$.

source
Nmrc.compute_coef!Method
compute_coef!(Θ::SparseVector, fv::FacetValues, dh::DofHandler, facetset, n; period = 2π)

Compute $\Theta^{n}$ on the facetset. Actually the computation of the TBC matrix reduces to the computation of the vector $\Theta^{n}$.

source
Nmrc.compute_rayleigh_nMethod
compute_rayleigh_n(fv::FacetValues, dh::DofHandler, facetset, u, n)

Compute the $n$-th order Rayleigh coefficient for the solution $u$. Be careful that we need to compute the Rayleigh coefficients for scattered solutions.

\[u_{n} = \int_{\text{boundary}} u e^{-inx_{1}} ds.\]

source
Nmrc.compute_scalingMethod
compute_scaling(A₀::M, A₁::M, A₂::M; scaling=:nothing::Symbol) where {T,M<:AbstractMatrix{T}}

TBW

source
Nmrc.csqrt_negimagMethod
csqrt_negimag(z::Complex{T}) where T<:AbstractFloat

Square root for complex numbers which takes the negative imaginary axis as the branch cut. Note that sqrt for complex number in julia takes the negative real axis as the default branch cut.

source
Nmrc.dofs_on_dtnMethod
dofs_on_dtn(dh::DofHandler, field::Symbol, facetset)

Extract the global indices of Dofs associated to the artificial boundary.

source
Nmrc.integral_nuv̄Method
integral_nuv̄(cv::CellValues, dh::DofHandler, n::Function, u, v)

Compute the integral

\[\int n(x_{1}, x_{2}) u v dx, \]

where $n(x_{1}, x_{2})$ is a function defined in our computational domain (normally, the refraction index). See also integral_uv̄ and integral_∂₁uv̄.

source
Nmrc.integral_uvMethod
integral_uv(cv::CellValues, dh::DofHandler, u, v)

Compute the integral

\[\int u v dx, \]

where $u$ and $v$ are vectors indexed by degrees of freedom. Normally, they are results obtained by FEM.

source
Nmrc.integral_∂₁uvMethod
integral_∂₁uv(cv::CellValues, dh::DofHandler, u, v)

Compute the integral

\[\int \frac{\partial u}{\partial x_{1}} v dx,\]

where $u$ and $v$ are vectors indexed by degrees of freedom. Normally, they are results obtained by FEM.

source
Nmrc.periodic_cellMethod
periodic_cell(;lc=0.5, period=2π, height=2.0)

Generate a mesh for the periodic cell.

Arguments

  • lc: the mesh size near points
  • period: the period of the periodic cell
  • height: the height of the periodic cell

Points

 4 ------------ 3
 |              |
 |              |
 1 ------------ 2

Lines

 . ---- l3 ---- .
 l4             l2
 . ---- l1 ---- .
source
Nmrc.setup_bcsMethod
setup_bcs(dh::DofHandler; period=2π)

Set the periodic boundary condition ("left" and "right") and Dirichelt boundary condition ("bottom").

Arguments

  • dh: DofHandler
  • period: the period of the periodic cell, see periodic_cell
source
Nmrc.setup_bdcsMethod
setup_bdcs(dof::DofHandler, d)

Set the periodic boundary condition ("left" and "right") and Dirichelt boundary condition ("bottom" and "top").

source
Nmrc.setup_fevsMethod
setup_fevs(ip)

Define quadrature rules on Reference triangle and setup FE values.

source
Nmrc.setup_gridMethod
setup_grid(;d=2π, ĥ=1.5, δ=2.0, lc=0.5, lp=0.5, vtk=false)

Generate a mesh by julia interface for Gmsh and read the .msh file by FerriteGmsh.

Arguments

  • d: the period of the periodic layer
  • : the start of the PML layer
  • δ: the height of the PML layer
  • lc: mesh size near the periodic layer
  • lp: mesh size in the PML layer
  • vtk: write .vtk file, default is false

Points

 5 ------------- 4
 |               |
 6               3
 |               |
 1 ------------- 2

Lines

 . ----- l4 ----- . 
 l5               l3
 .                .
 l6               l2 
 . ----- l1 ----- .

Misc

  • We can generate a *.vtk file by replace the do end block with gmsh.write(*.vtk)
source
Nmrc.setup_valsMethod
setup_vals(ip)

Set up CellValues and FacetValues by using interpolation ip. Here we need to define FacetValues because the load vector and the TBC matrix contains integral on the boundary.

source
Nmrc.sub_preserve_structureMethod
sub_preserve_structure(A::SparseMatrixCSC, B::SparseMatrixCSC)

Subtract two sparse matrix without changing the sparse pattern. A and B should have the same sparse pattern.

source