-
Notifications
You must be signed in to change notification settings - Fork 25
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
Total Volume for Cylindrical and Spherical meshes #882
base: main
Are you sure you want to change the base?
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #882 +/- ##
==========================================
- Coverage 99.56% 99.49% -0.07%
==========================================
Files 61 61
Lines 2750 2799 +49
==========================================
+ Hits 2738 2785 +47
- Misses 12 14 +2 ☔ View full report in Codecov by Sentry. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @rekomodo thanks for this contribution it will be much needed!
I made a few comments. The expression for spherical is wrong and needs fixing
class TotalVolumeCylindrical(TotalVolume): | ||
""" | ||
Computes the total value of a field in a given volume | ||
int(f r dx) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
int(f r dx) | |
int(f r dr) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For these new classes you will need to override the export_unit
property.
The units of TotalVolumeCylindrical and TotalVolumeSpherical are always H
(since it's a 3D equivalent).
For TotalVolume
this property is defined here:
FESTIM/festim/exports/derived_quantities/total_volume.py
Lines 38 to 50 in 9dfb219
@property | |
def export_unit(self): | |
# obtain domain dimension | |
try: | |
dim = self.function.function_space().mesh().topology().dim() | |
except AttributeError: | |
dim = self.dx._domain._topological_dimension | |
# TODO we could simply do that all the time | |
# return unit depending on field and dimension of domain | |
if self.field == "T": | |
return f"K m{dim}".replace("1", "") | |
else: | |
return f"H m{dim-3}".replace(" m0", "") |
|
||
@property | ||
def allowed_meshes(self): | ||
return ["spherical"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This line isn't tested. Could we add a simple test that checks that the only allowed mesh is spherical
?
class TotalVolumeSpherical(TotalVolume): | ||
""" | ||
Computes the total value of a field in a given volume | ||
int(f r dx) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
int(f r dx) | |
int(f r**2 dx) |
Btw, this should include the angular coverages too! Same comment for the Cylindrical version
(phi_1 - phi_0) | ||
* (theta_1 - theta_0) | ||
* f.assemble(self.function * self.r**2 * self.dx(self.volume)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
az0, az1 = azimuth_range | ||
th0, th1 = polar_range | ||
|
||
expected_value = f.assemble((az1 - az0) * (th1 - th0) * c * r**2 * dx(volume)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not the expected value, see my comment above
Proposed changes
Implements TotalVolume derived quantities for both Cylindrical and Spherical meshes as per #723 .
Types of changes
What types of changes does your code introduce to FESTIM?
Checklist
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...