Skip to content

Commit

Permalink
Allowed classes to accept non-Parameter Distributions
Browse files Browse the repository at this point in the history
  • Loading branch information
the-sean-c committed Nov 4, 2023
1 parent eca5784 commit 5d06c09
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 4 deletions.
15 changes: 13 additions & 2 deletions src/geotech/load.py → src/geotech/loads.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def __init__(self):
pass

@abstractmethod
def sample(self, x: float, y: float, elevations: float):
def sample_vertical_pressure(self, x: float, y: float, elevations: float):
pass

@abstractmethod
Expand All @@ -37,7 +37,18 @@ def __init__(
self.x_load = x_load # m
self.y_load = y_load # m

def sample(self, x: float, y: float, elevations: np.array):
for attr_name, attr_value in self.__dict__.items():
if not isinstance(attr_value, ParameterDistribution):
attr_value = Constant(attr_value)

def sample_vertical_pressure(
self, x: float, y: float, elevations: np.array
) -> np.array:
"""Calculate the vertical pressure at a given point per Boussinesq
Returns:
vertical pressure in kPa
"""
x_load = self.x_load.sample()
y_load = self.y_load.sample()
elevation_load = self.elevation_load.sample()
Expand Down
5 changes: 3 additions & 2 deletions src/geotech/settlement.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,14 @@
import numpy as np

from geotech.config import Config
from geotech.soil import SoilProfile
from geotech.loads import Load
from geotech.soils import SoilProfile

logger = logging.getLogger(__name__)
config = Config()


def calculate_settlements(profile: SoilProfile, load: float, time: float) -> np.ndarray:
def calculate_settlements(profile: SoilProfile, load: Load, time: float) -> np.ndarray:
"""Calculate the settlements for a soil profile.
Parameters
Expand Down
11 changes: 11 additions & 0 deletions src/geotech/soil.py → src/geotech/soils.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,10 @@ def __init__(
self.water_table_elevation = water_table_elevation # m
self.gradient = gradient # m/m

for attr_name, attr_value in self.__dict__.items():
if not isinstance(attr_value, ParameterDistribution):
attr_value = Constant(attr_value)

def sample(self, elevation):
water_table_elevation = self.water_table_elevation.sample()
hydrostatic = (water_table_elevation - elevation) * self.water_unit_weight
Expand Down Expand Up @@ -112,6 +116,10 @@ def __init__(
self.recompression_index = recompression_index # m2/kN
self.initial_void_ratio = initial_void_ratio # unitless

for attr_name, attr_value in self.__dict__.items():
if not isinstance(attr_value, ParameterDistribution):
attr_value = Constant(attr_value)

def is_wet(self, groundwater_depth):
return self.elevation_top >= groundwater_depth

Expand All @@ -134,6 +142,9 @@ def __init__(
self.layers = layers
self.porewater_pressure = pore_water_pressure

if not isinstance(self.porewater_pressure, ParameterDistribution):
self.porewater_pressure = Constant(self.porewater_pressure)

def add_layer(self, layer: SoilLayer):
self.layers.append(layer)
self.layers.sort(key=lambda x: x.elevation_top, reverse=True)
Expand Down
12 changes: 12 additions & 0 deletions tests/test_settlement.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
from geotech.config import Config
from geotech.loads import PointLoad
from geotech.soils import SoilLayer, SoilProfile, WaterTable

layer1 = SoilLayer("A", 100, 90, 20, 18, 0, 35, 0.33, 0.03, 1)
layer2 = SoilLayer("B", 90, 80, 20, 18, 0, 35, 0.33, 0.03, 1)

pwp = WaterTable(0, 0.0)

profile = SoilProfile([layer1, layer2], pwp)

load = PointLoad(100, 100, 0, 0)

0 comments on commit 5d06c09

Please sign in to comment.