festim-dev / FESTIM

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

Robin boundary conditions for ParticleFlux #752

Closed RemDelaporteMathurin closed 5 months ago

RemDelaporteMathurin commented 5 months ago

Proposed changes

This closes #749.

Uage:

import festim as F
import numpy as np
import ufl

my_model = F.HydrogenTransportProblem()
my_model.mesh = F.Mesh1D(vertices=np.linspace(0, 1, 1000))
my_mat = F.Material(name="mat", D_0=1, E_D=0)
vol = F.VolumeSubdomain1D(id=1, borders=[0, 1], material=my_mat)
left = F.SurfaceSubdomain1D(id=1, x=0)
right = F.SurfaceSubdomain1D(id=2, x=1)

my_model.subdomains = [vol, left, right]

H = F.Species("H")
D = F.Species("D")
my_model.species = [H, D]

my_model.temperature = 500

recomb_flux = F.SurfaceReactionBC(
    reactant=[H, H],
    gas_pressure=0,
)

my_model.boundary_conditions = [
    F.DirichletBC(subdomain=left, value=10, species=H),
    F.ParticleFluxBC(
        subdomain=right,
        value=lambda c1, T: -0.01 * ufl.exp(-0 / F.k_B / T) * c1**2,
        species=H,
        species_dependent_value={"c1": H},
    ),
]

my_model.exports = [F.XDMFExport("test.xdmf", H)]

my_model.settings = F.Settings(atol=1e-10, rtol=1e-10, final_time=10, transient=True)

my_model.settings.stepsize = 0.1

my_model.initialise()
my_model.run()

Merge #750 before this.

Types of changes

What types of changes does your code introduce to FESTIM?

Checklist

codecov[bot] commented 5 months ago

Codecov Report

Attention: Patch coverage is 95.45455% with 1 lines in your changes are missing coverage. Please review.

Project coverage is 98.31%. Comparing base (f57b263) to head (d47c76e).

:exclamation: Current head d47c76e differs from pull request most recent head 1e9c502. Consider uploading reports for the commit 1e9c502 to get more accurate results

Files Patch % Lines
festim/boundary_conditions/flux_bc.py 95.45% 1 Missing :warning:
Additional details and impacted files ```diff @@ Coverage Diff @@ ## fenicsx #752 +/- ## =========================================== - Coverage 98.42% 98.31% -0.11% =========================================== Files 28 28 Lines 1519 1540 +21 =========================================== + Hits 1495 1514 +19 - Misses 24 26 +2 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.