festim-dev / FESTIM

Coupled hydrogen/tritium transport and heat transfer modelling using FEniCS
https://festim.readthedocs.io/en/stable/
Apache License 2.0
92 stars 24 forks source link

[BUG] `Simulation.exports` should always be a list #833

Closed RemDelaporteMathurin closed 3 months ago

RemDelaporteMathurin commented 3 months ago

Describe the bug FESTIM expects a list for the exports attribute of Simulation.

However, no error is raised when users give something else.

To Reproduce

Run on main:

import numpy as np
import festim as F

my_model = F.Simulation()
my_model.mesh = F.MeshFromVertices(vertices=np.linspace(0, 1, num=100))
my_model.materials = F.Material(id=1, D_0=1, E_D=0, Q=2)
my_model.T = F.Temperature(value=700 + 1000 * F.x)
my_model.settings = F.Settings(
    absolute_tolerance=1e-10, relative_tolerance=1e-10, transient=False, soret=True
)

flux_left = F.SurfaceFlux(field=0, surface=1)
flux_right = F.SurfaceFlux(field=0, surface=2)
my_model.exports = F.DerivedQuantities([flux_left, flux_right])

my_model.initialise()
my_model.run()

print(flux_left.data)
print(flux_right.data)

Produces an empty list for data of derived quantities (they are just ignored).

Defining initial values
Defining variational problem
Defining source terms
Defining boundary conditions
Solving steady state problem...
Solved problem in 0.00 s
[]
[]

Expected behavior Either the exports setter should convert the user input to a list, or an error should be raised