Custom derived quantity#1138
Conversation
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #1138 +/- ##
==========================================
- Coverage 94.93% 94.72% -0.21%
==========================================
Files 44 46 +2
Lines 3434 3508 +74
==========================================
+ Hits 3260 3323 +63
- Misses 174 185 +11 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
jhdark
left a comment
There was a problem hiding this comment.
Looks good to me, is it worth adding some testing too to make sure things break when trying to define an volume/surface quantity without giving a title/compute functions? Although this isnt FESTIM functionality just the python abstract class.
| .. math:: | ||
|
|
||
| q = -D\,\nabla c \cdot n | ||
|
|
||
| and FESTIM will assemble | ||
|
|
||
| .. math:: | ||
|
|
||
| Q = \int_{\Gamma} q\,\mathrm{d}\Gamma | ||
|
|
||
| over the selected surface subdomain. | ||
|
|
||
| The expression returned by ``expr`` is treated as an integrand and assembled over | ||
| the chosen subdomain. | ||
|
|
||
| .. math:: | ||
|
|
||
| Q = \int_{\Omega} q\,\mathrm{d}\Omega |
There was a problem hiding this comment.
These math blocks render on the docs page, but not with the VSC hover/tooltip function. Maybe this is fine? Otherwise, we could just have the equations in Unicode?
There was a problem hiding this comment.
I think we have this in other places too. I didn't know they don't render on the VSC (pylance?) tooltip. That can be a separate issue that we fix (or not) globally
| self, | ||
| expr: Callable, | ||
| subdomain: SurfaceSubdomain | VolumeSubdomain, | ||
| title: str = "Custom Quantity", |
There was a problem hiding this comment.
Maybe we could make this a required arg instead? happy either way
There was a problem hiding this comment.
I personally never use titles for derived quantities (even the ones given by default), don't know about the others. That's also because I pretty much never write derived quantities to csv.
For users using derived quantities like me, i would find it a bit constraining to have to add a title even if you never use it. The only downside of having this default title is that if a user exports two custom quantities to a csv then they would both be written as "Custom Quantity" in the header.
Two solutions:
- raise a warning if two quantities have the same name (i'd do it in another PR)
- dynamically add an index to the title if there are several (ie. "Custom Quantity_1", "Custom Quantity_2")
What do you think?
There was a problem hiding this comment.
Tbf, you can give different filenames per quantity too, so maybe not an issue, think its an issue you'd run into once and then change. Dynamic naming would be better, but only if this rare scenario happens, and it would add more logic. Let's just leave it and see what issues we run into, if any
Description
Summary
This PR adds
festim.exports.CustomQuantitywhich allows users to compute any derived quantity on a volume or surface subdomain.Other changes:
VolumeQuantityandSurfaceQuantitynow both inherit fromDerivedQuantity(all three are abstract classes)write()andfilename()MaximumVolume(and friends)kwargs["D"]was updated when the temperature was time dependentUsage
Related Issues
Fixes #1130
Motivation and Context
Type of Change
Testing
pytest)Code Quality Checklist
ruff format .)ruff check .)Documentation
Breaking Changes
Screenshots/Examples
Additional Notes