Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Robin boundary conditions for ParticleFlux #752

Merged
merged 6 commits into from
May 1, 2024

Conversation

RemDelaporteMathurin
Copy link
Collaborator

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?

  • Bugfix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Code refactoring
  • Documentation Update (if none of the other choices apply)
  • New tests

Checklist

  • Black formatted
  • Unit tests pass locally with my changes
  • I have added tests that prove my fix is effective or that my feature works
  • I have added necessary documentation (if appropriate)

@RemDelaporteMathurin RemDelaporteMathurin added enhancement New feature or request fenicsx Issue that is related to the fenicsx support labels Apr 12, 2024
@RemDelaporteMathurin RemDelaporteMathurin linked an issue Apr 12, 2024 that may be closed by this pull request
Copy link

codecov bot commented Apr 18, 2024

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).

❗ 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 ⚠️
Additional details and impacted files
@@             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     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@RemDelaporteMathurin RemDelaporteMathurin mentioned this pull request Apr 18, 2024
12 tasks
@RemDelaporteMathurin RemDelaporteMathurin marked this pull request as ready for review April 29, 2024 17:12
Copy link
Collaborator

@jhdark jhdark left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a general comment on the create_value_fenics,, otherwise looks good

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it worth adding some extra logic in here to make sure 1. A species object is given 2. the arguments are unique and users don't give t, x or T 3. The species given is mobile.

Not sure if this is overkill or not

I gave a partial example of this in #746

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would hold this off for now as it's applicable to all paticle fluxes

@RemDelaporteMathurin RemDelaporteMathurin merged commit 0b02ffa into festim-dev:fenicsx May 1, 2024
5 checks passed
@RemDelaporteMathurin RemDelaporteMathurin deleted the robin branch May 1, 2024 12:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request fenicsx Issue that is related to the fenicsx support
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Robin BC for H transport
2 participants