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

Surface reactions #753

Merged

Conversation

RemDelaporteMathurin
Copy link
Collaborator

@RemDelaporteMathurin RemDelaporteMathurin commented Apr 12, 2024

Proposed changes

This PR fixes #727
Needs to be merged after #752

Also some refactoring. Got rid of HTransportProblem.create_flux_value_fenics and merged it with define_boundary_conditions (which breaks some of the tests). I happy to not do this here and keep it for another PR.

Todo:

  • Write tests
  • Write example and usage

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)

Further comments

@jhdark I chose not to make this a special case of the very generic class ParticleFluxBC (ie using a lambda function for value) to keep a simple implementation.

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

codecov bot commented Apr 18, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 97.75%. Comparing base (ef8d875) to head (9203ac7).
Report is 27 commits behind head on fenicsx.

Additional details and impacted files
@@             Coverage Diff             @@
##           fenicsx     #753      +/-   ##
===========================================
+ Coverage    97.70%   97.75%   +0.05%     
===========================================
  Files           43       44       +1     
  Lines         2048     2098      +50     
===========================================
+ Hits          2001     2051      +50     
  Misses          47       47              

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

Comment on lines 519 to 523
all_bcs = self.boundary_conditions.copy()
for bc in self.boundary_conditions:
if isinstance(bc, F.SurfaceReactionBC):
all_bcs += bc.flux_bcs
all_bcs.remove(bc)
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@jhdark here all_bcs could be a property I just don't want to modify self.boundary_conditions

@RemDelaporteMathurin RemDelaporteMathurin marked this pull request as ready for review May 28, 2024 14:17
@RemDelaporteMathurin
Copy link
Collaborator Author

@KulaginVladimir would you like to give this a look?

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.

Think this can be merged after pulling from the fenicsx branch. Although will likely have to revisit after chemical potential integration anyhow

@RemDelaporteMathurin
Copy link
Collaborator Author

@jhdark I finally rebased with fenicsx. It will need adapting for the mixed domain approach for sure but right now works with HTransportProblem with one material. I'll merge this after the CI has finished

Comment on lines +8 to +21
# TODO add this to the festim package
class FluxFromSurfaceReaction(F.SurfaceFlux):
def __init__(self, reaction: F.SurfaceReactionBC):
super().__init__(
F.Species(), # just a dummy species here
reaction.subdomain,
)
self.reaction = reaction.flux_bcs[0]

def compute(self, ds):
self.value = fem.assemble_scalar(
fem.form(self.reaction.value_fenics * ds(self.surface.id))
)
self.data.append(self.value)
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

We should add this as a FESTIM feature

@RemDelaporteMathurin RemDelaporteMathurin merged commit 2930d8d into festim-dev:fenicsx Nov 1, 2024
8 checks passed
@RemDelaporteMathurin RemDelaporteMathurin deleted the surface-reactions branch November 1, 2024 18:53
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.

Recombination/Dissociation flux BCs
2 participants