precice / micro-manager

A manager tool to facilitate two-scale coupling in multi-physics simulations using preCICE.
GNU Lesser General Public License v3.0
15 stars 9 forks source link

Interpolation of micro simulation output data #92

Open tjwsch opened 3 months ago

tjwsch commented 3 months ago

While working on #85 to handle crashing micro simulations, it came up that if a simulation crashes during the first iteration it is difficult to replace that simulation. It cannot be replaced with previous data and with no data available, it is also impossible to say, what other simulation is similar to this. In my opinion, it is necessary to use interpolation or extrapolation to continue a run if this kind of crash occurs. This could also be used if a simulation crash occurs in a later iteration.

Another potential use case for interpolation in the micro-manager is providing an alternative to adaptivity.

I've been looking at readily available interpolation tools in Python. For three-dimensional irregular grid points, I only found scipy's datagrid but it cannot handle extrapolation, which the micro would run into as soon as a corner simulation crashes.

Does it make sense to include interpolation into the micro-manager?

Is there an interpolation function available in Python that could be used? Or is it necessary to implement this tailored to the requirements of the micro-manager? How sophisticated should this be? One of the simplest implementations would be to take the mean value of neighboring micro simulations.

IshaanDesai commented 3 months ago

I did a quick search and scipy.interpolate.griddata indeed seems like the best option. Let us worry about extrapolation later, as this is quite literally a corner case. It absolutely makes sense to include interpolation functionality in the Micro Manager. This functionality should be implemented in a modular way because it will most certainly be used in the association step of the adaptivity.

tjwsch commented 3 months ago

The relevance of the corner case should not be underestimated as keeping the interpolation local could lead to many said cases in a parallel execution.

IshaanDesai commented 3 months ago

The relevance of the corner case should not be underestimated as keeping the interpolation local could lead to many said cases in a parallel execution.

Let us worry about extrapolation when we hit the problem. I can imagine that for simulations at macro vertices on boundaries or edges, partial interpolation is done and some value is generated. We can try to estimate if this value is good enough after testing the installation.

uekerman commented 3 months ago

Does interpolation in the geometric space really make sense? I guess only if we assume that micro simulations are similar if they are close together in the geometry. I could imagine that interpolation in the parameter space could be a better fit here. Inverse distance weighting could be a simple solution then.

tjwsch commented 3 months ago

We discussed using inverse distance weighting and implemented it in #85 but so far it is done based on spatial distances. I also thought about this and for the snapshot computation I concluded that it makes sense to base the interpolation on the parameter space, but I did not extend that thought to the coupled case. I also think basing the interpolation on the parameter space rather than spatial information could be a better fit.

uekerman commented 3 months ago

For the snapshot computation, the simple alternative is to only report on crashing cases. I am not sure if interpolation is what users want here, but I don't really know. Could be something to ask Felix Fritzen about.