Skip to content

Tests of integration and advection problems with periodic boundary conditions - #3

Merged
mrhardman merged 5 commits into
mainfrom
periodic-integration-test
May 6, 2026
Merged

Tests of integration and advection problems with periodic boundary conditions#3
mrhardman merged 5 commits into
mainfrom
periodic-integration-test

Conversation

@mrhardman

Copy link
Copy Markdown
Collaborator

Test the solution of simple problems in 1D with periodic boundary conditions.

  • Simple advection of the field $F(x)$ with
$$\frac{\partial F}{\partial t} + v \frac{\partial F}{\partial x} = 0,$$

implemented using backward Euler and second-order backward Euler time differencing.

  • Poisson's equation in 1D
$$\frac{\partial^2 \phi}{\partial x^2} = f.$$

Dirichlet boundary conditions are implemented in 1D to use with integration operators in 1D. In this implementation, we need to set the value of the periodic function in two places, i.e., https://github.com/moment-kinetics/FiniteElementAssembly.jl/blob/2c08db02561cc7002d021a5c44532069ff291db2/test/PeriodicBcTests.jl#L80-L86

It would be possible to implement integration with periodic boundary conditions differently, but this would require a new type PeriodicDirichletBC <: AbstractBoundaryCondition. A future implementation could set the first row of the 1D matrix to be

(1, 0, 0, ..., 0, -1)

and set the last row to be

(0, 0, ...., 0, 0, 1)

so that the above code would be modified to

    # form the weak RHS
    mul!(weak_rhs,mass_matrix,f)
    # impose the Dirichlet BC to fix the constants A and B
    weak_rhs[1] = 0.0
    weak_rhs[end] = exact_phi[end]
    # solve the system
    ldiv!(phi, lu_Laplacian, weak_rhs)

In this modified version, there is clearly only one available constant to set when integrating ODEs with periodic boundary conditions. However, we still require the same number of lines of code, and the need for an additional boundary condition type means that we defer the implementation of the feature this way to a future PR where it is explicitly required.

@mrhardman
mrhardman merged commit d8228ca into main May 6, 2026
1 check passed
@mrhardman
mrhardman deleted the periodic-integration-test branch May 6, 2026 15:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant