From 2c993334ce98d3ff13b4e19192f66009cc06d3a9 Mon Sep 17 00:00:00 2001 From: David Wells Date: Sun, 6 Jul 2025 21:29:29 -0400 Subject: [PATCH] step-36: update the output. --- examples/step-36/doc/results.dox | 61 ++++++++++++++++---------------- 1 file changed, 31 insertions(+), 30 deletions(-) diff --git a/examples/step-36/doc/results.dox b/examples/step-36/doc/results.dox index 4e883ca09d..5242714392 100644 --- a/examples/step-36/doc/results.dox +++ b/examples/step-36/doc/results.dox @@ -17,10 +17,10 @@ $m,n\in{\mathbb N^+}$. Eigenfunctions are sines and cosines with $m$ and $n$ periods in $x$ and $y$ directions. This matches the output our program generates: @code -examples/\step-36> make run -============================ Running \step-36 +step-36$ ./step-36 Number of active cells: 1024 Number of degrees of freedom: 1089 + Spurious eigenvalues are all in the interval [1536,1536] Solver converged in 67 iterations. Eigenvalue 0 : 4.93877 @@ -29,7 +29,9 @@ examples/\step-36> make run Eigenvalue 3 : 19.8027 Eigenvalue 4 : 24.837 - Job done. @endcode These eigenvalues are exactly the ones that + Job done. +@endcode +These eigenvalues are exactly the ones that correspond to pairs $(m,n)=(1,1)$, $(1,2)$ and $(2,1)$, $(2,2)$, and $(3,1)$. A visualization of the corresponding eigenfunctions would look like this: @@ -83,8 +85,7 @@ set Potential = if (x^2 + y^2 < 0.75^2, if (x*y > 0, -100, -5), 0) If in addition we also increase the mesh refinement by one level, we get the following results: @code -examples/\step-36> make run -============================ Running \step-36 +step-36$ ./step-36 Number of active cells: 4096 Number of degrees of freedom: 4225 @@ -198,51 +199,51 @@ ARPACK allows complex eigenvalues, so we will also need Secondly, we switch back to the deal.II matrix and vector definitions in the main class: @code - SparsityPattern sparsity_pattern; - SparseMatrix stiffness_matrix, mass_matrix; - std::vector > eigenfunctions; - std::vector> eigenvalues; + SparsityPattern sparsity_pattern; + SparseMatrix stiffness_matrix, mass_matrix; + std::vector> eigenfunctions; + std::vector> eigenvalues; @endcode and initialize them as usual in make_grid_and_dofs(): @code - sparsity_pattern.reinit (dof_handler.n_dofs(), - dof_handler.n_dofs(), - dof_handler.max_couplings_between_dofs()); + sparsity_pattern.reinit(dof_handler.n_dofs(), + dof_handler.n_dofs(), + dof_handler.max_couplings_between_dofs()); - DoFTools::make_sparsity_pattern (dof_handler, sparsity_pattern); - constraints.condense (sparsity_pattern); + DoFTools::make_sparsity_pattern(dof_handler, sparsity_pattern); + constraints.condense(sparsity_pattern); sparsity_pattern.compress(); - stiffness_matrix.reinit (sparsity_pattern); - mass_matrix.reinit (sparsity_pattern); + stiffness_matrix.reinit(sparsity_pattern); + mass_matrix.reinit(sparsity_pattern); @endcode For solving the eigenvalue problem with ARPACK, we finally need to modify solve(): @code template - unsigned int EigenvalueProblem::solve () + unsigned int EigenvalueProblem::solve() { - SolverControl solver_control (dof_handler.n_dofs(), 1e-9); + SolverControl solver_control(dof_handler.n_dofs(), 1e-9); SparseDirectUMFPACK inverse; - inverse.initialize (stiffness_matrix); + inverse.initialize(stiffness_matrix); - const unsigned int num_arnoldi_vectors = 2*eigenvalues.size() + 2; + const unsigned int num_arnoldi_vectors = 2 * eigenvalues.size() + 2; ArpackSolver::AdditionalData additional_data(num_arnoldi_vectors); - ArpackSolver eigensolver (solver_control, additional_data); - eigensolver.solve (stiffness_matrix, - mass_matrix, - inverse, - eigenvalues, - eigenfunctions, - eigenvalues.size()); + ArpackSolver eigensolver(solver_control, additional_data); + eigensolver.solve(stiffness_matrix, + mass_matrix, + inverse, + eigenvalues, + eigenfunctions, + eigenvalues.size()); - for (unsigned int i=0; i