gem / oq-engine

OpenQuake Engine: a software for Seismic Hazard and Risk Analysis
https://github.com/gem/oq-engine/#openquake-engine
GNU Affero General Public License v3.0
382 stars 277 forks source link

Could magnitude-dependent `pointsource_distance` be reinstated? #7614

Closed g-weatherill closed 2 years ago

g-weatherill commented 2 years ago

Between versions 3.10 and 3.11 of the engine the magnitude-dependent pointsource_distance option was removed (https://github.com/gem/oq-engine/pull/7106). It is not clear why this feature was not seen as worth keeping, as it is a particularly intuitive and smart way of applying point-source distances; collapsing the point sources for smaller events at closer distances while keeping the full distribution of rupture orientations and depths for the largest earthquakes at longer distances.

This is unfortunate, as recent work that I had done in implementing seismic hazard models for France and Germany into OpenQuake had benefited from this feature, to the extent that this had even been documented in a report compiled for the Sigma 2 project. I am enclosing the relevant pages of the report in which the justification of the magnitude-dependent pointsource_distance is given, along with the calibrated set of magnitude-dependent distances and the comparison output seismic hazard curves.

France_OQ_Implementation_SIGMA2_Report_PSdist_expl.pdf

For site-specific calculations using the PSHA model of Drouet et al. (2020), I was getting an approximately 75 % reduction in calculation time using the magnitude-dependent pointsource_distance, which is not a trivial reduction. The reductions were also seen for the regional scale calculations too, though as I hadn't been able to run the larger scale calculations at all without the magnitude-dependent point-source distances I don't have a clearer benchmark for the reduction.

Of course, users have the option of reverting back to the previous OQ < 3.11 versions if they want to benefit from this feature. In doing so, however, they would of course lose the benefit of all of the developments in improving the efficiency of the GMPE library seen in the more recent versions. Ideally, it would be nice to be able to benefit from both!

micheles commented 2 years ago

First, let me notice that the pull request that you are referring to is tagged engine 3.12, the long term release 3.11 is not affected at all (on purpose, the stable release is stable). Secondly, you should keep in mind that optimizations like the pointsource_distance or the ps_grid_spacing are implementation details subject to change, meaning that from one release to another the precision or the performance (or both) can vary significantly; actually it has varied greatly for every release in the last two years. Thirdly, the pointsource_distance or the ps_grid_spacing feature can disappear at any moment without warning. Indeed, I was actively working towards removing completely the pointsource_distance for the next release but I was not able to do so by keeping a good performance. Fourthly, since engine 3.13 the magnitude-dependent pointsource distance is back, just not visible to the user. The line in question if the following: https://github.com/gem/oq-engine/blob/engine-3.13/openquake/hazardlib/contexts.py#L520 i.e. psdist = self.pointsource_distance + src.get_radius(rup), where the radius of the rupture depends on the magnitude and it is a good quantity to use when deciding if finite size effects can be removed. The reason why I want to hide from the user such details is that it is extremely easy to get things wrong, i.e. good speed but terrible precision or good precision but terrible speed.

g-weatherill commented 2 years ago

Thanks @michele for the clarification. From what I see in the code then it looks like the explanation of the parameter here is perhaps a little out of sync with respect to the current operation (the NB part at least): https://docs.openquake.org/oq-engine/advanced/common-mistakes.html#pointsource-distance. As I understand it currently the rupture collapsing distance is the pointsource_distance plus half of the maximum of the rupture's diagonal surface projection.

micheles commented 2 years ago

Exactly. The issue was that for large magnitude ruptures we were not considering the rupture radius and then collapsing too much, causing large differences with respect to the noncollapsed results.