Skip to content

Commit

Permalink
merging local master to intrusion merge
Browse files Browse the repository at this point in the history
  • Loading branch information
lachlangrose committed Oct 16, 2022
1 parent f7f65bd commit c27e89b
Show file tree
Hide file tree
Showing 9 changed files with 44 additions and 15 deletions.
4 changes: 4 additions & 0 deletions LoopStructural/interpolators/_discrete_interpolator.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"""
import logging

from time import time
import numpy as np
from scipy.sparse import coo_matrix, bmat, eye
from scipy.sparse import linalg as sla
Expand Down Expand Up @@ -704,6 +705,7 @@ def _solve_cg(self, A, B, precon=None, **kwargs):
cgargs["callback"] = kwargs["callback"]
if precon is not None:
cgargs["M"] = precon(A)
print(cgargs)
return sla.cg(A, B, **cgargs)[0][: self.nx]

def _solve_pyamg(self, A, B, tol=1e-12, x0=None, verb=False, **kwargs):
Expand Down Expand Up @@ -743,6 +745,7 @@ def _solve(self, solver="cg", **kwargs):
True if the interpolation is run
"""
starttime = time()
logger.info("Solving interpolation for {}".format(self.propertyname))
self.c = np.zeros(self.support.n_nodes)
self.c[:] = np.nan
Expand Down Expand Up @@ -799,6 +802,7 @@ def _solve(self, solver="cg", **kwargs):
)
return
self.valid = True
print(f"Solving interpolation: {self.propertyname} took: {time()-starttime}")

def update(self):
"""
Expand Down
2 changes: 0 additions & 2 deletions LoopStructural/interpolators/_p1interpolator.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@


class P1Interpolator(DiscreteInterpolator):
""" """

def __init__(self, mesh):
"""
Piecewise Linear Interpolator
Expand Down
Empty file.
2 changes: 0 additions & 2 deletions LoopStructural/interpolators/piecewiselinear_interpolator.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@


class PiecewiseLinearInterpolator(DiscreteInterpolator):
""" """

def __init__(self, support):
"""
Piecewise Linear Interpolator
Expand Down
5 changes: 4 additions & 1 deletion LoopStructural/modelling/core/geological_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -989,7 +989,6 @@ def create_and_add_folded_foliation(
)
self._add_faults(series_builder)
# series_builder.add_data_to_interpolator(True)
self._add_faults(series_builder)
# build feature

kwargs["tol"] = tol
Expand Down Expand Up @@ -1522,6 +1521,10 @@ def create_and_add_fault(

if tol is None:
tol = self.tol
# divide the tolerance by half of the minor axis, as this is the equivalent of the distance
# of the unit vector
if minor_axis:
tol *= minor_axis / 2

if displacement == 0:
logger.warning(f"{fault_surface_data} displacement is 0")
Expand Down
15 changes: 13 additions & 2 deletions LoopStructural/modelling/features/builders/_fault_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ def __init__(
from LoopStructural.modelling.features.fault import (
FaultSegment,
) # defer import until needed

StructuralFrameBuilder.__init__(
self, interpolator, interpolators, frame=FaultSegment, **kwargs
)
Expand Down Expand Up @@ -151,6 +150,18 @@ def create_data_from_geometry(
fault_tips = np.zeros((2, 3))
fault_depth = np.zeros((2, 3))
data.reset_index(inplace=True)
if not self.fault_major_axis:
logger.warning(f'Fault major axis is not set and cannot be determined from the fault trace. \
This will result in a fault that is represented by a 1 unit major axis. \
If this is not intended add major_axis to fault parameters.')
if not self.fault_intermediate_axis:
logger.warning(f'Fault intermediate axis is not set and cannot be determined from the fault trace. \
This will result in a fault that is represented by a 1 unit intermediate axis. \
If this is not intended add intermediate_axis to fault parameters.')
if not self.fault_minor_axis:
logger.warning(f'Fault minor axis is not set and cannot be determined from the fault trace. \
This will result in a fault that is represented by a 1 unit minor axis. \
If this is not intended add minor_axis to fault parameters.')
if fault_center is not None:
if minor_axis is not None:
fault_edges[0, :] = fault_center[:3] + normal_vector * minor_axis
Expand Down Expand Up @@ -192,7 +203,7 @@ def create_data_from_geometry(
mask = np.logical_and(data["coord"] == 0, ~np.isnan(data["gx"]))
data.loc[mask, ["gx", "gy", "gz"]] /= minor_axis * 0.5
if points == False:
logger.warning(
logger.info(
"Rescaling fault norm constraint length for fault frame"
)
mask = np.logical_and(data["coord"] == 0, ~np.isnan(data["gx"]))
Expand Down
14 changes: 7 additions & 7 deletions LoopStructural/modelling/features/fault/_fault_function.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@ def __init__(self):
self.w = None

def add_cstr(self, x, y):
self.A.append([x ** 3, x ** 2, x, 1.0])
self.A.append([x**3, x**2, x, 1.0])
self.B.append(y)

def add_grad(self, x, g):
self.A.append([3 * x ** 2, 2 * x, 1.0, 0.0])
self.A.append([3 * x**2, 2 * x, 1.0, 0.0])
self.B.append(g)

def add_max(self, max_v):
Expand All @@ -44,16 +44,16 @@ def __call__(self, v):
ATA = A.T @ A
ATB = A.T @ B
self.w = np.linalg.lstsq(ATA, ATB, rcond=None)[0]
eva = self.w[0] * v ** 3 + self.w[1] * v ** 2 + self.w[2] * v + self.w[3]
eva = self.w[0] * v**3 + self.w[1] * v**2 + self.w[2] * v + self.w[3]
eva[v > self.max_v] = (
self.w[0] * self.max_v ** 3
+ self.w[1] * self.max_v ** 2
self.w[0] * self.max_v**3
+ self.w[1] * self.max_v**2
+ self.w[2] * self.max_v
+ self.w[3]
)
eva[v < self.min_v] = (
self.w[0] * self.min_v ** 3
+ self.w[1] * self.min_v ** 2
self.w[0] * self.min_v**3
+ self.w[1] * self.min_v**2
+ self.w[2] * self.min_v
+ self.w[3]
)
Expand Down
2 changes: 1 addition & 1 deletion LoopStructural/modelling/features/fault/_fault_segment.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ def faultfunction(self):
@faultfunction.setter
def faultfunction(self, value):
if callable(value):
self.faultfunction = value
self._faultfunction = value
elif isinstance(value, str) and value == "BaseFault":
self._faultfunction = BaseFault.fault_displacement
else:
Expand Down
15 changes: 15 additions & 0 deletions docker-compose-win.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
version: "3"

services:
structural:
build:
context: ./
dockerfile: DockerfileDev
volumes:
- C:\Users\lachl\OneDrive\Documents\GitHub\LoopStructural:/home/jovyan/LoopStructural
- C:\Users\lachl\OneDrive\Documents\Loop\notebooks:/home/jovyan/notebooks
ports:
- 8888:8888
- 8050:8050
- 8080-8090:8080-8090
# command: jupyter notebook --ip='0.0.0.0' --NotebookApp.token='' --no-browser

0 comments on commit c27e89b

Please sign in to comment.