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

Export average surface temperature #949

Open
wants to merge 70 commits into
base: fenicsx
Choose a base branch
from

Conversation

kaelyndunnell
Copy link
Contributor

Proposed changes

Adds export for average surface temperature.

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

If this is a relatively large or complex change, kick off the discussion by explaining why you chose the solution you did and what alternatives you considered, etc...

Copy link

codecov bot commented Feb 26, 2025

Codecov Report

Attention: Patch coverage is 93.33333% with 2 lines in your changes missing coverage. Please review.

Project coverage is 95.98%. Comparing base (96d62ff) to head (e531a88).
Report is 48 commits behind head on fenicsx.

Files with missing lines Patch % Lines
src/festim/hydrogen_transport_problem.py 71.42% 2 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           fenicsx     #949      +/-   ##
===========================================
- Coverage    96.02%   95.98%   -0.04%     
===========================================
  Files           45       46       +1     
  Lines         2439     2517      +78     
===========================================
+ Hits          2342     2416      +74     
- Misses          97      101       +4     

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

Copy link
Collaborator

@RemDelaporteMathurin RemDelaporteMathurin left a comment

Choose a reason for hiding this comment

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

Hi @kaelyndunnell thanks for this, this is very much needed!

However I think it should be implemented differently:

  • It doesn't make sense to ask users to provide temperature_field as an argument of SurfaceTemperature since they don't have access to the fenics object (fem.Constant or fem.Temperature) before calling initialise and since exports are defined before calling initialise. Instead, I believe the class should not have this argument at all, and temperature_field is set as an attribute only inside HTransportProblem
for export in self.exports:
    if isinstance(export, SurfaceTemperature):
        export.temperature_field = self.temperature_fenics
  • SurfaceTemperature shares a lot of functionality with SurfaceQuantity: it should inherit from it
  • I'm thinking by looking at this we should revisit the design of these quantities @JonathanGSDUFOUR , I'll open an issue to describe my idea but here's the rough pitch
class SurfaceQuantity:
    def __init__(self, surface, filename):
        self.surface = surface
        self.filename = filename

        self.field = None   # this is no longer a user argument but only an attribute
     
    ...

class AverageSurfaceConcentration(SurfaceQuantity):
    def __init__(self, species, surface, filename):
        self.species = species
        super.__init__(surface, filename)

Inside HTransportProblem

def initialise_exports(self):
    for export in self.exports:
        if not hasattr(export, "species"):  # appropriate fenics functions are already stored in F.Species objects
            export.field = self.temperature_fenics 

Comment on lines 831 to 838
elif isinstance(export, exports.SurfaceTemperature):
export.compute(self.ds) # compute surface temp

export.t.append(float(self.t)) # update export time

# if filename given write export data to file
if export.filename is not None:
export.write(t=float(self.t))
Copy link
Collaborator

Choose a reason for hiding this comment

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

These lines are not tested. That's because by design, it's impossible to use SurfaceTemperature in combination with HTransportProblem

@RemDelaporteMathurin RemDelaporteMathurin added enhancement New feature or request fenicsx Issue that is related to the fenicsx support labels Feb 26, 2025
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.

2 participants