# EigenValue, vectors and block matrices

**URL:** https://community.freefem.org/t/eigenvalue-vectors-and-block-matrices/3960
**Category:** General Discussion
**Created:** [June 6, 2025, 4:17pm UTC](https://community.freefem.org/t/eigenvalue-vectors-and-block-matrices/3960 "2025-06-06T16:17:09Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![ross](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.freefem.org/ross/32/3620_2.png) [@ross](https://community.freefem.org/u/ross)
#### Post date: [June 6, 2025, 4:17pm UTC](https://community.freefem.org/t/eigenvalue-vectors-and-block-matrices/3960/1 "2025-06-06T16:17:09Z")

</div>

I’m solving a simple 2D neutron diffusion problem, with delayed neutron precursors (DNPs). In steady-state, the equations look like this:

 ![problem_neutro](https://canada1.discourse-cdn.com/flex030/uploads/freefem/original/2X/7/79dc955603f64fd90bd013a1d7b4923a81cafc51.png)  
We see clearly that, since we’re in steady-state, we could plug (DNP) into (N) and obtain a standalone neutron diffusion equation.  
So I tested 3 ways of solving this problem:

1. The simplest way, which is to plug (DNP) into (N) and solve for \phi only;
2. Assembling a single big matrix, for (N) and (DNP) at the same time;
3. Building block matrices and then assembling big matrices.

All three of these methods give the same eigenvalue keff, but only 1. and 2. give the (correct) eigenvector \phi, while 3. gives a very different output:

 ![neutro_1](https://canada1.discourse-cdn.com/flex030/uploads/freefem/original/2X/c/cda2a3809a2fa1aa14ec1892550b1e2d1c3ea64c.png)  
 ![neutro_2](https://canada1.discourse-cdn.com/flex030/uploads/freefem/original/2X/5/5ab3d05933dae1bb3014c9a654ad19f854d44b2e.png)  
 ![neutro_3](https://canada1.discourse-cdn.com/flex030/uploads/freefem/original/2X/4/489a8f882e0dea184b0fe955ebbb9a716c197478.jpeg)

In the future, I think method 3. is the way to go for more complicated problems, so I’d like to get it working. Maybe I should manipulate the eigenvectors differently?

Here are the three scripts.  
[neutro\_1.edp](https://community.freefem.org/uploads/short-url/otpGfJsDfXa8E0PjlnaR7Qj1c4G.edp) (1.6 KB)  
[neutro\_2.edp](https://community.freefem.org/uploads/short-url/5DUyDLuzFqQTdIkNbsxcVBCUgsV.edp) (2.2 KB)  
[neutro\_3.edp](https://community.freefem.org/uploads/short-url/jGfN6rAMN7rd4rxHonsljwGUQlf.edp) (2.5 KB)

---

<div class="post-metadata">

### Author: ![fb77](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.freefem.org/fb77/32/3796_2.png) [@fb77](https://community.freefem.org/u/fb77)
#### Post date: [June 9, 2025, 1:06pm UTC](https://community.freefem.org/t/eigenvalue-vectors-and-block-matrices/3960/2 "2025-06-09T13:06:02Z")

</div>

Dear Ruggero,  
With the block matrix definition, the ordering of the dofs is not the same as in the  
product space definition `fespace PHICh(Th, [P2, P2]);`  
In the latter the dof are interlaced, whereas in the block matrix the dofs are listed one block after the other.  
Therefore you have to do some reordering in order to have the right interpretation.

```auto
fespace PHIh(Th, P2);
fespace Ch(Th, P2);
PHIh bphi;
Ch bc;
for (int nn=0;nn<nev;++nn) {
 [bphi[],bc[]]=eVphi[nn][];
 [eVphi[nn],eVc[nn]]=[bphi,bc];
}

```

full code  
[neutro\_3.edp](https://community.freefem.org/uploads/short-url/F5O3oXaN2ypwbDVHjWilVk8F5y.edp) (2.7 KB)

---

<div class="post-metadata">

### Author: ![ross](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.freefem.org/ross/32/3620_2.png) [@ross](https://community.freefem.org/u/ross)
#### Post date: [June 10, 2025, 10:04am UTC](https://community.freefem.org/t/eigenvalue-vectors-and-block-matrices/3960/3 "2025-06-10T10:04:42Z")

</div>

Dear François,

Super, got it! Thanks a lot 😃

Ruggero
