How to set initial temperature distribution from XDMF?

Hello, everyone! Assume, I have a FESTIM model that solves a time-dependent problem (heat transfer + diffusion). I export profiles of temperature, solute concentration, trapped concentration on the last timestep with:

XDMF = [F.XDMFExport(
        field="solute",
        filename=results_folder + "/mobile.xdmf",
        checkpoint=True,
        mode="last",
        ), 
        F.XDMFExport(
        field="1",
        filename=results_folder + "/trapped.xdmf",
        checkpoint=True,
        mode="last",
        ),
        F.XDMFExport(
        field="T",
        filename=results_folder + "/T.xdmf",
        checkpoint=True, 
        mode="last",
        )]

I can successfully set initial conditions for trapped and solute concentrations, but not really understand how to do it for the heat transfer problem. The use of:

my_model.initial_conditions = [
    F.InitialCondition(field="T", value = './results1/T.xdmf', label = 'temperature', time_step=0)
]

Throws an error.

Hi @VVKulagin

This looks correct to me.

Could you provide the full error message?

Hi @remidm. The output message is:

Defining variational problem heat transfers
Defining initial values
Traceback (most recent call last):
  File "/home/vvkulagin/FESTIM/TEST/test.py", line 278, in <module>
    my_model.initialise()
  File "/home/vvkulagin/anaconda3/envs/festim-env/lib/python3.12/site-packages/festim/generic_simulation.py", line 270, in initialise
    self.h_transport_problem.initialise(self.mesh, self.materials, self.dt)
  File "/home/vvkulagin/anaconda3/envs/festim-env/lib/python3.12/site-packages/festim/h_transport_problem.py", line 64, in initialise
    self.initialise_concentrations()
  File "/home/vvkulagin/anaconda3/envs/festim-env/lib/python3.12/site-packages/festim/h_transport_problem.py", line 141, in initialise_concentrations
    component = field_to_component[ini.field]
                ~~~~~~~~~~~~~~~~~~^^^^^^^^^^^
KeyError: 'T'

Having a look at the code, it seems that this (initial conditions for temperature from XDMF) is not possible at the moment.

This is the code for the initialisation of temperature:

It doesn’t account for XDMF files (yet!).

Looking at TemperatureFromXDMF I think it shouldn’t be too hard to adapt:

Feel free to open an issue on the Github repo!

Thanks for reporting

This issue has been solved. New modification allows to set the initial condition for the Heat Transfer Problem from XDMF:

my_temp = F.HeatTransferProblem(
    ...,
    initial_value=F.InitialCondition("T", "filename.xdmf", "label", timestep=-1)
)
1 Like