Skip to content

Conversation

@mloubout
Copy link
Contributor

Needed for accurate elastic simulations

On top of #2455

@mloubout mloubout added the API api (symbolics, types, ...) label Sep 11, 2024
@codecov
Copy link

codecov bot commented Sep 11, 2024

Codecov Report

Attention: Patch coverage is 75.00000% with 18 lines in your changes missing coverage. Please review.

Project coverage is 87.06%. Comparing base (42398c4) to head (829ba37).
Report is 4 commits behind head on master.

Files with missing lines Patch % Lines
examples/seismic/acoustic/acoustic_example.py 50.00% 2 Missing ⚠️
examples/seismic/elastic/elastic_example.py 66.66% 2 Missing ⚠️
examples/seismic/model.py 71.42% 2 Missing ⚠️
examples/seismic/self_adjoint/test_utils.py 50.00% 2 Missing ⚠️
...amples/seismic/self_adjoint/test_wavesolver_iso.py 50.00% 2 Missing ⚠️
examples/seismic/test_seismic_utils.py 50.00% 2 Missing ⚠️
examples/seismic/tti/tti_example.py 50.00% 2 Missing ⚠️
...les/seismic/viscoacoustic/viscoacoustic_example.py 50.00% 2 Missing ⚠️
...mples/seismic/viscoelastic/viscoelastic_example.py 60.00% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #2456      +/-   ##
==========================================
- Coverage   87.08%   87.06%   -0.03%     
==========================================
  Files         238      238              
  Lines       45118    45171      +53     
  Branches     8408     8417       +9     
==========================================
+ Hits        39291    39326      +35     
- Misses       5094     5112      +18     
  Partials      733      733              

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

@review-notebook-app
Copy link

Check out this pull request on  ReviewNB

See visual diffs & provide feedback on Jupyter Notebooks.


Powered by ReviewNB


# Averaging mode for off the grid evaluation
self._avg_mode = kwargs.get('avg_mode', 'arithmetic')
assert self._avg_mode in ['arithmetic', 'harmonic'], "Accepted avg_mode " \
Copy link
Contributor

Choose a reason for hiding this comment

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

this shouldn't be an assert, but rather a raise ValueError

# Apply interpolation from inner most dim
for d, i in self._grid_map.items():
retval = retval.diff(d, 0, fd_order=2, x0={d: i})
retval = retval.diff(d, deriv_order=0, fd_order=2, x0={d: i}).evaluate
Copy link
Contributor

Choose a reason for hiding this comment

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

Always a bit wary of these premature evaluations

# Evaluate. Since we used `self.function` it will be on the grid when evaluate
# is called again within FD
return retval.evaluate
return retval.evaluate.expand()
Copy link
Contributor

Choose a reason for hiding this comment

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

why the need to expand ?

also, not that we're calling .evaluate multiple times here -- above in the for d, i in self._grid_map loop at each iteration, and then again here.

THere's something weird about this

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Without exapnd you get horrible stuff like 05*(0.5*(0.5 ... instead of 0.125.

This is a trivial square/cube averaging that should be a plain expression anything else is just messing up with the compiler for no reason

import pytest
try:
import pytest
except:
Copy link
Contributor

Choose a reason for hiding this comment

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

nitpicking: All these imports should be except ImportError

Copy link
Contributor

Choose a reason for hiding this comment

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

I thought we needed exactly the opposite?..e.g. pass

Copy link
Contributor

Choose a reason for hiding this comment

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

???


# Base function
retval = self.function
retval = 1 / self.function if self._avg_mode == 'harmonic' else self.function
Copy link
Contributor

Choose a reason for hiding this comment

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

nitpicking: for homogeneity with the rest of the codebase, it should be

if cond:
     <then part>
else:
     <else part>

even if it's a trivial code fragment. But again, nitpicking...

if self._avg_mode == 'harmonic':
retval = 1 / retval

# Evaluate. Since we used `self.function` it will be on the grid when evaluate
Copy link
Contributor

Choose a reason for hiding this comment

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

does this comment still apply?

@mloubout mloubout force-pushed the avg-mode branch 3 times, most recently from e599547 to 1f13559 Compare September 12, 2024 13:29
@FabioLuporini FabioLuporini merged commit cec0542 into master Sep 12, 2024
@FabioLuporini FabioLuporini deleted the avg-mode branch September 12, 2024 15:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

API api (symbolics, types, ...)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants