From 05115446c5f800575ef445dcb2646997fc345961 Mon Sep 17 00:00:00 2001 From: J Dark Date: Fri, 15 Jul 2022 10:00:03 +0000 Subject: [PATCH 1/6] temporary fix for class --- FESTIM/temperature/temperature_from_xdmf.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/FESTIM/temperature/temperature_from_xdmf.py b/FESTIM/temperature/temperature_from_xdmf.py index 2cb514b21..98219819d 100644 --- a/FESTIM/temperature/temperature_from_xdmf.py +++ b/FESTIM/temperature/temperature_from_xdmf.py @@ -40,3 +40,6 @@ def create_functions(self, mesh): self.T_n = f.Function(V, name="T_n") self.T_n.assign(self.T) + + def update(self, t): + pass From 3e67ec6be16e3337cd87e50c2aaeea8805fab849 Mon Sep 17 00:00:00 2001 From: J Dark Date: Fri, 15 Jul 2022 10:11:43 +0000 Subject: [PATCH 2/6] new test --- Tests/unit/test_temperature.py | 42 ++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/Tests/unit/test_temperature.py b/Tests/unit/test_temperature.py index 9e7d13212..2019fd70d 100644 --- a/Tests/unit/test_temperature.py +++ b/Tests/unit/test_temperature.py @@ -3,6 +3,7 @@ from ufl.core.multiindex import Index from pathlib import Path import pytest +import numpy as np def test_formulation_heat_transfer_2_ids_per_mat(): @@ -136,3 +137,44 @@ def test_temperature_from_xdmf_label_checker(tmpdir): # read file with wrong label specified with pytest.raises(ValueError): FESTIM.TemperatureFromXDMF(filename=str(Path(T_file)), label="coucou") + + +def test_temperature_from_xdmf_transient_case(tmpdir): + """Test that the TemperatureFromXdmf class works in a transient + h transport case""" + # create temperature field xdmf + my_model = FESTIM.Simulation(log_level=20) + my_model.mesh = FESTIM.MeshFromVertices(vertices=np.linspace(0, 1, num=100)) + my_model.materials = FESTIM.Materials( + [ + FESTIM.Material( + id=1, + D_0=1, + E_D=1, + ), + ] + ) + my_model.T = FESTIM.Temperature(value=300) + my_model.settings = FESTIM.Settings( + transient=False, + absolute_tolerance=1e12, + relative_tolerance=1e-08, + ) + my_model.initialise() + T = my_model.T.T + T_file = tmpdir.join("T.xdmf") + fenics.XDMFFile(str(Path(T_file))).write_checkpoint( + T, "T", 0, fenics.XDMFFile.Encoding.HDF5, append=False + ) + + # run transient simulation with TemperatureFromXDMF class + my_model.T = FESTIM.TemperatureFromXDMF(filename=str(Path(T_file)), label="T") + my_model.dt = FESTIM.Stepsize(initial_value=1) + my_model.settings = FESTIM.Settings( + transient=True, + final_time=10, + absolute_tolerance=1e12, + relative_tolerance=1e-08, + ) + my_model.initialise() + my_model.run() From e70fd2f8017cfec560a6a690f722ad245fb14226 Mon Sep 17 00:00:00 2001 From: James Dark <65899899+jhdark@users.noreply.github.com> Date: Fri, 15 Jul 2022 12:33:06 +0200 Subject: [PATCH 3/6] Update Tests/unit/test_temperature.py MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Rémi Delaporte-Mathurin <40028739+RemDelaporteMathurin@users.noreply.github.com> --- Tests/unit/test_temperature.py | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/Tests/unit/test_temperature.py b/Tests/unit/test_temperature.py index 2019fd70d..97b891b4d 100644 --- a/Tests/unit/test_temperature.py +++ b/Tests/unit/test_temperature.py @@ -170,11 +170,7 @@ def test_temperature_from_xdmf_transient_case(tmpdir): # run transient simulation with TemperatureFromXDMF class my_model.T = FESTIM.TemperatureFromXDMF(filename=str(Path(T_file)), label="T") my_model.dt = FESTIM.Stepsize(initial_value=1) - my_model.settings = FESTIM.Settings( - transient=True, - final_time=10, - absolute_tolerance=1e12, - relative_tolerance=1e-08, - ) + my_model.settings.transient = True + my_model.settings.final_time = 10 my_model.initialise() my_model.run() From 4cd7bd128e1e0c2a7000d7cc1af367485364c3b7 Mon Sep 17 00:00:00 2001 From: J Dark Date: Fri, 15 Jul 2022 10:34:41 +0000 Subject: [PATCH 4/6] materials def in one line --- Tests/unit/test_temperature.py | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/Tests/unit/test_temperature.py b/Tests/unit/test_temperature.py index 2019fd70d..ef381b112 100644 --- a/Tests/unit/test_temperature.py +++ b/Tests/unit/test_temperature.py @@ -145,15 +145,7 @@ def test_temperature_from_xdmf_transient_case(tmpdir): # create temperature field xdmf my_model = FESTIM.Simulation(log_level=20) my_model.mesh = FESTIM.MeshFromVertices(vertices=np.linspace(0, 1, num=100)) - my_model.materials = FESTIM.Materials( - [ - FESTIM.Material( - id=1, - D_0=1, - E_D=1, - ), - ] - ) + my_model.materials = FESTIM.Materials([FESTIM.Material(1, 1, 1)]) my_model.T = FESTIM.Temperature(value=300) my_model.settings = FESTIM.Settings( transient=False, From a16aad4bb5f90f48b3f0c86a2634df35e8732951 Mon Sep 17 00:00:00 2001 From: J Dark Date: Fri, 15 Jul 2022 10:38:45 +0000 Subject: [PATCH 5/6] added comments to update function --- FESTIM/temperature/temperature_from_xdmf.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/FESTIM/temperature/temperature_from_xdmf.py b/FESTIM/temperature/temperature_from_xdmf.py index 98219819d..843d9561f 100644 --- a/FESTIM/temperature/temperature_from_xdmf.py +++ b/FESTIM/temperature/temperature_from_xdmf.py @@ -42,4 +42,10 @@ def create_functions(self, mesh): self.T_n.assign(self.T) def update(self, t): + """Allows for the use of this class in transient h transport cases, + refer to issue #499 + + Args: + t (float): the time + """ pass From 11edf64a718ad2e92e3ba6f6ecef8fc2bcc0457b Mon Sep 17 00:00:00 2001 From: James Dark <65899899+jhdark@users.noreply.github.com> Date: Fri, 15 Jul 2022 13:45:17 +0200 Subject: [PATCH 6/6] Update FESTIM/temperature/temperature_from_xdmf.py MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Rémi Delaporte-Mathurin <40028739+RemDelaporteMathurin@users.noreply.github.com> --- FESTIM/temperature/temperature_from_xdmf.py | 3 --- 1 file changed, 3 deletions(-) diff --git a/FESTIM/temperature/temperature_from_xdmf.py b/FESTIM/temperature/temperature_from_xdmf.py index 843d9561f..265358ab4 100644 --- a/FESTIM/temperature/temperature_from_xdmf.py +++ b/FESTIM/temperature/temperature_from_xdmf.py @@ -44,8 +44,5 @@ def create_functions(self, mesh): def update(self, t): """Allows for the use of this class in transient h transport cases, refer to issue #499 - - Args: - t (float): the time """ pass