Skip to content

DerivedQuantities for fenicsx#735

Merged
RemDelaporteMathurin merged 22 commits into
festim-dev:fenicsxfrom
JonathanGSDUFOUR:Add_Quant(Issue638)
Jul 3, 2024
Merged

DerivedQuantities for fenicsx#735
RemDelaporteMathurin merged 22 commits into
festim-dev:fenicsxfrom
JonathanGSDUFOUR:Add_Quant(Issue638)

Conversation

@JonathanGSDUFOUR
Copy link
Copy Markdown
Contributor

@JonathanGSDUFOUR JonathanGSDUFOUR commented Apr 4, 2024

Proposed changes

A first look into what I have for now in trying to work on Issue #638 .

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

@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 4, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 98.95%. Comparing base (2f9f966) to head (dcccfc5).
Report is 49 commits behind head on fenicsx.

Additional details and impacted files
@@             Coverage Diff             @@
##           fenicsx     #735      +/-   ##
===========================================
+ Coverage    98.90%   98.95%   +0.05%     
===========================================
  Files           28       35       +7     
  Lines         1550     1631      +81     
===========================================
+ Hits          1533     1614      +81     
  Misses          17       17              

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

@RemDelaporteMathurin
Copy link
Copy Markdown
Collaborator

@JonathanGSDUFOUR glad to see progress on this! Have you tried testing your implementation on an example?

@JonathanGSDUFOUR
Copy link
Copy Markdown
Contributor Author

@JonathanGSDUFOUR glad to see progress on this! Have you tried testing your implementation on an example?

Not yet, but it's a good next step indeed

@RemDelaporteMathurin RemDelaporteMathurin added the fenicsx Issue that is related to the fenicsx support label Apr 4, 2024
Comment thread festim/exports/average_surface.py Outdated
Comment thread festim/exports/average_volume.py Outdated
Comment thread festim/exports/surface_flux.py Outdated
@JonathanGSDUFOUR
Copy link
Copy Markdown
Contributor Author

Would it be better to test each quantity separately or can we test them all in one case ?

@RemDelaporteMathurin
Copy link
Copy Markdown
Collaborator

Would it be better to test each quantity separately or can we test them all in one case ?

We want to test each quantity ensuring it computes the expected value.
A way to do it would be to create a function, store it as the species.solution and then check that the value computed by the derived quantity is the expected one.

@JonathanGSDUFOUR JonathanGSDUFOUR deleted the Add_Quant(Issue638) branch May 30, 2024 10:10
@JonathanGSDUFOUR JonathanGSDUFOUR restored the Add_Quant(Issue638) branch May 30, 2024 12:10
@RemDelaporteMathurin
Copy link
Copy Markdown
Collaborator

@JonathanGSDUFOUR I don't know if you are aware but:

  • the tests don't pass with your changes. You can run the tests locally with python -m pytest .
  • there are a couple of unadressed comments

@JonathanGSDUFOUR
Copy link
Copy Markdown
Contributor Author

@JonathanGSDUFOUR I don't know if you are aware but:

  • the tests don't pass with your changes. You can run the tests locally with python -m pytest .
  • there are a couple of unadressed comments

Yeah I currently have an issue with the version of dolfinx on my environment so the test don't run correctly, so I'm a bit blind on that, I wanted to share some of the new additions on the PR.
I will go back to the comment next

@RemDelaporteMathurin
Copy link
Copy Markdown
Collaborator

I currently have an issue with the version of dolfinx on my environment

What's the issue?

@JonathanGSDUFOUR
Copy link
Copy Markdown
Contributor Author

I currently have an issue with the version of dolfinx on my environment

What's the issue?

I had the latest version of dolfinx in my conda env (0.8.0) but it's solved now (I have one with 0.7.3 that runs the test correctly)

@RemDelaporteMathurin
Copy link
Copy Markdown
Collaborator

@JonathanGSDUFOUR tests pass yay 🎉

Copy link
Copy Markdown
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.

This is looking very good!

  • Not for this PR but I think it would be good to raise an issue to remind ourselves to write tests for the surface classes in 2D since MaximumSurface MinimumSurface AverageSurface and TotalSurface all give the exact same value in 1D.
  • To test that MinimumVolume and MaximumVolume compute the right value in the right subdomain, could we write tests for a multi-material problem? I guess I have the same concerns about other classes

Comment thread festim/exports/average_volume.py Outdated
Comment thread test/test_surface_quantity.py Outdated
Comment thread festim/exports/average_surface.py Outdated
Comment thread festim/exports/surface_flux.py Outdated
Comment thread festim/exports/surface_quantity.py Outdated
value, bool
):
raise TypeError("surface should be an int or F.SurfaceSubdomain1D")
if not isinstance(value, (int, F.SurfaceSubdomain)) or isinstance(value, bool):
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Can you remind me where we have the type check for bool here @jhdark ?

Comment thread test/test_average_surface.py
Comment thread test/test_average_surface.py Outdated
Comment thread test/test_derived_quantities.py
Comment thread test/test_surface_quantity.py Outdated
@RemDelaporteMathurin RemDelaporteMathurin marked this pull request as ready for review June 11, 2024 15:19
@RemDelaporteMathurin RemDelaporteMathurin changed the title First look to the addition of derived quantities, Issue 638 DerivedQuantities for fenicsx Jun 12, 2024
@RemDelaporteMathurin RemDelaporteMathurin linked an issue Jun 12, 2024 that may be closed by this pull request
20 tasks
Comment thread festim/hydrogen_transport_problem.py Outdated
Comment on lines 790 to 794
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

You can simplify this to:

Suggested change
if (
isinstance(export, F.SurfaceFlux)
or isinstance(export, F.TotalSurface)
or isinstance(export, F.AverageSurface)
):
if isinstance(export, (F.SurfaceFlux, F.TotalSurface, F.AverageSurface)):

Comment thread festim/hydrogen_transport_problem.py Outdated
Comment on lines 807 to 808
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Same comment as above

Copy link
Copy Markdown
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.

hey @JonathanGSDUFOUR this is good to go! Just two small refactoring comments and we can merge 🎉

Copy link
Copy Markdown
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.

This is all good to go @JonathanGSDUFOUR ! Thanks for this effort! 🎉

@RemDelaporteMathurin RemDelaporteMathurin merged commit 4e2afe8 into festim-dev:fenicsx Jul 3, 2024
@JonathanGSDUFOUR JonathanGSDUFOUR deleted the Add_Quant(Issue638) branch July 3, 2024 09:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

fenicsx Issue that is related to the fenicsx support

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Additional derived quantities

2 participants