# Helmholtz Equation: Storage issue during frequency loop

**URL:** https://fenicsproject.discourse.group/t/helmholtz-equation-storage-issue-during-frequency-loop/15427
**Category:** General
**Created:** [August 2, 2024, 2:15pm UTC](https://fenicsproject.discourse.group/t/helmholtz-equation-storage-issue-during-frequency-loop/15427 "2024-08-02T14:15:53Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![pkontopi](https://avatars.discourse-cdn.com/v4/letter/p/b487fb/32.png) [@pkontopi](https://fenicsproject.discourse.group/u/pkontopi)
#### Post date: [August 2, 2024, 2:15pm UTC](https://fenicsproject.discourse.group/t/helmholtz-equation-storage-issue-during-frequency-loop/15427/1 "2024-08-02T14:15:53Z")

</div>

Hi,

I ran into a strange issue when I tried to store my solutions for a Helmholtz Equation inside an array like this:

```auto
for nf in range(0,len(f_axis)):
    freq = f_axis[nf]

    # Compute solution
    omega.value =f_axis[nf]*2*np.pi
    k0.value = 2*np.pi*f_axis[nf]/c0
    problem.solve()

    with XDMFFile(msh.comm, "solution" + str(f_axis[nf]) + ".xdmf", "w") as xdmf:
        xdmf.write_mesh(msh)
        xdmf.write_function(uh)

    #I want to safe the solution for every single frequency here: 
    all_values.append(uh.x.array.real)

```

If I check the XDMF files in paraview or print the result with print(uh.x.array.real) during the loop, everything works fine but the all\_values array only contains the solution of the last frequency over and over again.

What am I missing here? Is there any other way to do this?

Thanks for any advice!

Best,

Patrick

---

<div class="post-metadata">

### Author: ![nate](https://yyz2.discourse-cdn.com/free1/user_avatar/fenicsproject.discourse.group/nate/32/17_2.png) [@nate](https://fenicsproject.discourse.group/u/nate)
#### Post date: [August 2, 2024, 3:09pm UTC](https://fenicsproject.discourse.group/t/helmholtz-equation-storage-issue-during-frequency-loop/15427/2 "2024-08-02T15:09:47Z")

</div>

You’re simply appending a reference to `uh.x.array.real` in `all_values` every step. If you want a record of data you should copy the values and store them at every step. Consider [numpy.copy — NumPy v2.0 Manual](https://numpy.org/doc/stable/reference/generated/numpy.copy.html).
