flownet icon indicating copy to clipboard operation
flownet copied to clipboard

Error message when determining the convex hull

Open tayloris opened this issue 5 years ago • 5 comments

The following error message (1) has something to do with flownet not being able to determine the convex hull in a particular case. Flownet needs at least 5 wells for the algorithm to be able to work. The connections need to define a 3D volume.

The model I'm working with has exactly the same depth for all wells.

A temporal solution to do a test is to change the perforation strategy from bottom_point to multiple that would mean each connected block in the Eclipse model with getting a connection in FlowNet.

This may be not what you want in the long run, but it is a simple test to see if you get further.

(1) Error message:

(venv) manuel@manuel:~/repos/projects/DataDrivenModels/flownet$ flownet ahm tests/configs/egg_parameters.yml egg_output_folder 
Adding flow nodes:  0%Traceback (most recent call last):
  File "/home/manuel/repos/projects/DataDrivenModels/flownet/venv/bin/flownet", line 11, in <module>
    load_entry_point('flownet', 'console_scripts', 'flownet')()
  File "/home/manuel/repos/projects/DataDrivenModels/flownet/src/flownet/_command_line.py", line 206, in main
    args.func(args)
  File "/home/manuel/repos/projects/DataDrivenModels/flownet/src/flownet/_command_line.py", line 67, in flownet_ahm
    run_flownet_history_mathing(config, args)
  File "/home/manuel/repos/projects/DataDrivenModels/flownet/src/flownet/ahm/_run_ahm.py", line 162, in run_flownet_history_mathing
    df_connections: pd.DataFrame = create_connections(df_coordinates, config)
  File "/home/manuel/repos/projects/DataDrivenModels/flownet/src/flownet/network_model/_generate_connections.py", line 451, in create_connections
    starts, ends = _generate_connections(df_coordinates, configuration)
  File "/home/manuel/repos/projects/DataDrivenModels/flownet/src/flownet/network_model/_generate_connections.py", line 125, in _generate_connections
    random_seed=configuration.flownet.random_seed,
  File "/home/manuel/repos/projects/DataDrivenModels/flownet/src/flownet/network_model/_mitchell.py", line 88, in mitchell_best_candidate_modified_3d
    hull = Delaunay(np.column_stack([x, y, z]))
  File "qhull.pyx", line 1839, in scipy.spatial.qhull.Delaunay.__init__
  File "qhull.pyx", line 357, in scipy.spatial.qhull._Qhull.__init__
scipy.spatial.qhull.QhullError: QH6154 Qhull precision error: Initial simplex is flat (facet 1 is coplanar with the interior point)

While executing:  | qhull d Qc Qbb Q12 Qt Qz
Options selected for Qhull 2019.1.r 2019/06/21:
  run-id 1237336110  delaunay  Qcoplanar-keep  Qbbound-last  Q12-allow-wide
  Qtriangulate  Qz-infinity-point  _pre-merge  _zero-centrum  Qinterior-keep
  Pgood  _max-width 4.4e+02  Error-roundoff 8.1e-12  _one-merge 7.3e-11
  Visible-distance 4.9e-11  U-max-coplanar 4.9e-11  Width-outside 9.7e-11
  _wide-facet 2.9e-10  _maxoutside 9.7e-11

precision problems (corrected unless 'Q0' or an error)
      9 zero divisors during gaussian elimination

The input to qhull appears to be less than 4 dimensional, or a
computation has overflowed.

Qhull could not construct a clearly convex simplex from points:
- p5(v5):    60    68 4e+03     0
- p6(v4): 2.5e+02    12 4e+03 1.2e+02
- p0(v3):    36 4.5e+02 4e+03 4.3e+02
- p7(v2): 4.5e+02    44 4e+03 4.3e+02
- p2(v1):    12 2.8e+02 4e+03 1.5e+02

The center point is coplanar with a facet, or a vertex is coplanar
with a neighboring facet.  The maximum round off error for
computing distances is 8.1e-12.  The center point, facets and distances
to the center point are as follows:

center point    162.4    170.4     4026    223.6

facet p6 p0 p7 p2 distance=    0
facet p5 p0 p7 p2 distance=    0
facet p5 p6 p7 p2 distance=    0
facet p5 p6 p0 p2 distance=    0
facet p5 p6 p0 p7 distance=    0

These points either have a maximum or minimum x-coordinate, or
they maximize the determinant for k coordinates.  Trial points
are first selected from points that maximize a coordinate.

The min and max coordinates for each dimension are:
  0:        12       452  difference=  440
  1:        12       452  difference=  440
  2:      4026      4026  difference=    0
  3:         0      4026  difference= 4026

If the input should be full dimensional, you have several options that
may determine an initial simplex:
  - use 'QJ'  to joggle the input and make it full dimensional
  - use 'QbB' to scale the points to the unit cube
  - use 'QR0' to randomly rotate the input for different maximum points
  - use 'Qs'  to search all points for the initial simplex
  - use 'En'  to specify a maximum roundoff error less than 8.1e-12.
  - trace execution with 'T3' to see the determinant for each point.

If the input is lower dimensional:
  - use 'QJ' to joggle the input and make it full dimensional
  - use 'Qbk:0Bk:0' to delete coordinate k from the input.  You should
    pick the coordinate with the least range.  The hull will have the
    correct topology.
  - determine the flat containing the points, rotate the points
    into a coordinate plane, and delete the other coordinates.
  - add one or more points to make the input full dimensional.

tayloris avatar Mar 29 '20 15:03 tayloris

I think Delauney should be called with qhull_option='QJ Pp' inside the mitchells best candidate algorithm. That will joggle the input points slightly so you get to 3D.

olelod avatar Mar 30 '20 08:03 olelod

I think Delauney should be called with qhull_option='QJ Pp' inside the mitchells best candidate algorithm. That will joggle the input points slightly so you get to 3D.

That could definitely be something to try!

wouterjdb avatar Apr 04 '20 14:04 wouterjdb

@tayloris How did you solve this issue in the end?

wouterjdb avatar Jul 12 '20 07:07 wouterjdb

I change the depths of the wells to avoid co-planar triangulations. The option of qhull_option='QJ Pp' solve the problem, but you get further errors due to the co-planar triangulation that I haven't solved properly. So the easiest way to get egg model working was changing the depths.

tayloris avatar Jul 13 '20 06:07 tayloris

Are we now talking about minimal changes? If we would simply add a minimal random depth differences (centimetres) to wells with the exact same depth, would that solve the problem? That should be simple to add.

wouterjdb avatar Jul 13 '20 10:07 wouterjdb