Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/d serie 2023 2 msl 2289 #138

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
83 changes: 41 additions & 42 deletions geolib/models/dsettlement/dsettlement_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,9 @@ def serialize(self, filename: Union[FilePath, BinaryIO]):
Args:
filename:
"""
self.datastructure.geometry_data.pre_process()
self.datastructure.input_data.geometry_data.pre_process()

serializer = DSettlementInputSerializer(ds=self.datastructure.dict())
serializer = DSettlementInputSerializer(ds=self.datastructure.input_data.dict())
serializer.write(filename)

if isinstance(filename, Path):
Expand All @@ -99,7 +99,7 @@ def serialize(self, filename: Union[FilePath, BinaryIO]):
def add_soil(self, soil_input: Soil_Input) -> None:
"""Soil is converted in the internal structure and added in soil_collection."""
soil_new = soil_input._to_dsettlement()
self.datastructure.soil_collection.add_soil_if_unique(soil_new)
self.datastructure.input_data.soil_collection.add_soil_if_unique(soil_new)

# 1.2.3 Models
def set_model(
Expand Down Expand Up @@ -133,15 +133,15 @@ def set_model(
Returns:
Model
"""
if isinstance(self.datastructure.calculation_options, str):
if isinstance(self.datastructure.input_data.calculation_options, str):
logger.warning("Calculation options are overwritten")
self.datastructure.calculation_options = CalculationOptions()
self.datastructure.input_data.calculation_options = CalculationOptions()

if isinstance(self.datastructure.model, str):
if isinstance(self.datastructure.input_data.model, str):
logger.warning("Model options are overwritten")
self.datastructure.model = Model()
self.datastructure.input_data.model = Model()

model_options = self.datastructure.model
model_options = self.datastructure.input_data.model

model_options.dimension = (
Dimension.TWO_D if is_two_dimensional else Dimension.ONE_D
Expand Down Expand Up @@ -196,45 +196,45 @@ def set_any_calculation_options(self, **kwargs):
Returns:
calculation options
"""
if isinstance(self.datastructure.calculation_options, str):
if isinstance(self.datastructure.input_data.calculation_options, str):
logger.warning("Calculation options are overwritten")
self.datastructure.calculation_options = CalculationOptions()
self.datastructure.input_data.calculation_options = CalculationOptions()

if isinstance(self.datastructure.model, str):
if isinstance(self.datastructure.input_data.model, str):
logger.warning("Model options are overwritten")
self.datastructure.model = Model()
self.datastructure.input_data.model = Model()

calculation_options = self.datastructure.calculation_options.dict()
calculation_options = self.datastructure.input_data.calculation_options.dict()
calculation_options.update(**kwargs)
self.datastructure.calculation_options = CalculationOptions.set_options(
self.datastructure.input_data.calculation_options = CalculationOptions.set_options(
**calculation_options
)

return calculation_options

@property
def accuracy(self):
return self.datastructure.geometry_data.accuracy
def input(self):
return self.datastructure.input_data

@property
def curves(self):
return self.datastructure.geometry_data.curves
return self.datastructure.input_data.geometry_data.curves

@property
def boundaries(self):
return self.datastructure.geometry_data.boundaries
return self.datastructure.input_data.geometry_data.boundaries

@property
def use_probabilistic_defaults_boundaries(self):
return self.datastructure.geometry_data.use_probabilistic_defaults_boundaries
return self.datastructure.input_data.geometry_data.use_probabilistic_defaults_boundaries

@property
def stdv_boundaries(self):
return self.datastructure.geometry_data.stdv_boundaries
return self.datastructure.input_data.geometry_data.stdv_boundaries

@property
def distribution_boundaries(self):
return self.datastructure.geometry_data.distribution_boundaries
return self.datastructure.input_data.geometry_data.distribution_boundaries

def set_probabilistic_data(
self,
Expand Down Expand Up @@ -271,9 +271,9 @@ def set_probabilistic_data(
is_reliability_calculation : set to True if a probabilistic calculation should be performed.

"""
self.datastructure.check_x_in_vertical(point_of_vertical=point_of_vertical)
self.datastructure.probabilistic_data = (
self.datastructure.probabilistic_data.set_probabilistic_data(
self.datastructure.input_data.check_x_in_vertical(point_of_vertical=point_of_vertical)
self.datastructure.input_data.probabilistic_data = (
self.datastructure.input_data.probabilistic_data.set_probabilistic_data(
point_of_vertical=point_of_vertical,
residual_settlement=residual_settlement,
maximum_number_of_samples=maximum_number_of_samples,
Expand All @@ -295,7 +295,7 @@ def add_boundary(
"""Add boundary to model."""
# Divide points into curves and boundary
# Check point uniqueness
tolerance = self.accuracy.accuracy
tolerance = 0.001
points = [
self.points.add_point_if_unique(
DSeriePoint.from_point(point), tolerance=tolerance
Expand All @@ -316,11 +316,11 @@ def add_boundary(
@property
def points(self):
"""Enables easy access to the points in the internal dict-like datastructure. Also enables edit/delete for individual points."""
return self.datastructure.geometry_data.points
return self.datastructure.input_data.geometry_data.points

@property
def headlines(self):
return self.datastructure.geometry_data.piezo_lines
return self.datastructure.input_data.geometry_data.piezo_lines

def add_head_line(self, points: List[Point], is_phreatic=False) -> int:
"""Add head line to model."""
Expand All @@ -335,12 +335,12 @@ def add_head_line(self, points: List[Point], is_phreatic=False) -> int:

piezo_line = self.headlines.create_piezoline(curves)
if is_phreatic:
self.datastructure.geometry_data.phreatic_line.phreatic_line = piezo_line.id
self.datastructure.input_data.geometry_data.phreatic_line.phreatic_line = piezo_line.id
return piezo_line.id

@property
def layers(self):
return self.datastructure.geometry_data.layers
return self.datastructure.input_data.geometry_data.layers

def add_layer(
self,
Expand Down Expand Up @@ -381,7 +381,7 @@ def add_layer(
@property
def other_loads(self):
"""Enables easy access to the other loads in the internal dict-like datastructure."""
return self.datastructure.other_loads
return self.datastructure.input_data.other_loads

def add_other_load(
self,
Expand All @@ -395,13 +395,13 @@ def add_other_load(
internal_other_load = other_load._to_internal(time, point)
if isinstance(self.other_loads, str):
logger.warning("Replacing unparsed OtherLoads!")
self.datastructure.other_loads = OtherLoads()
self.datastructure.input_data.other_loads = OtherLoads()
self.other_loads.add_load(name, internal_other_load)

@property
def non_uniform_loads(self):
"""Enables easy access to the non-uniform loads in the internal dict-like datastructure."""
return self.datastructure.non__uniform_loads
return self.datastructure.input_data.non__uniform_loads

def add_non_uniform_load(
self,
Expand Down Expand Up @@ -437,19 +437,19 @@ def add_non_uniform_load(

if isinstance(self.non_uniform_loads, str):
logger.warning("Replacing unparsed NonUniformLoads!")
self.datastructure.non__uniform_loads = NonUniformLoads()
self.datastructure.input_data.non__uniform_loads = NonUniformLoads()
self.non_uniform_loads.add_load(name, non_uniform_load)

def add_water_load(self, name: str, time: timedelta, phreatic_line_id: int):
"""Create water load for a time in days, based on a phreatic line.

Edit the head lines for each layer with `create layer`.
"""
if isinstance(self.datastructure.water_loads, str):
if isinstance(self.datastructure.input_data.water_loads, str):
logger.warning("Replacing unparsed [WATER LOADS]!")
self.datastructure.water_loads = WaterLoads()
headlines = self.datastructure.get_headlines_for_layers()
self.datastructure.water_loads.add_waterload(
self.datastructure.input_data.water_loads = WaterLoads()
headlines = self.datastructure.input_data.get_headlines_for_layers()
self.datastructure.input_data.water_loads.add_waterload(
name, time.days, phreatic_line_id, headlines
)

Expand All @@ -468,7 +468,7 @@ def set_calculation_times(self, time_steps: List[timedelta]):
residual_times = ResidualTimes(
time_steps=[timestep.days for timestep in time_steps]
)
self.datastructure.residual_times = residual_times
self.datastructure.input_data.residual_times = residual_times

def set_verticals(self, locations: List[Point]) -> None:
"""
Expand All @@ -480,16 +480,15 @@ def set_verticals(self, locations: List[Point]) -> None:
"""
points = [DSeriePoint.from_point(point) for point in locations]
verticals = Verticals(locations=points)
self.datastructure.verticals = verticals
self.datastructure.input_data.verticals = verticals

def set_vertical_drain(self, verticaldrain: VerticalDrain):
if self.datastructure.model.is_vertical_drains:
self.datastructure.vertical_drain = verticaldrain._to_internal()
if self.datastructure.input_data.model.is_vertical_drains:
self.datastructure.input_data.vertical_drain = verticaldrain._to_internal()
else:
raise ValueError(
"If you wish to add a vertical drain then value is_vertical_drains for the model should be True"
)

@property
def output(self) -> Results:
"""Access internal dict-like datastructure of the output.
Expand Down
53 changes: 12 additions & 41 deletions geolib/models/dsettlement/internal.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,9 +101,9 @@ def add_soil_if_unique(self, soil, tolerance=TOLERANCE) -> None:


class Version(DSerieVersion):
soil: int = 1005
geometry: int = 1000
d__settlement: int = 1007
soil: int = 1011
geometry: int = 1002
d__settlement: int = 1011


class Points(DSeriesMatrixTreeStructureCollection):
Expand Down Expand Up @@ -363,18 +363,13 @@ def append_distribution_boundary(self, distribution_boundary: DistributionType):
)


class Accuracy(DSeriesUnmappedNameProperties):
accuracy: confloat(ge=1e-10) = 1e-3


class PhreaticLine(DSeriesUnmappedNameProperties):
phreatic_line: conint(ge=0, lt=99) = 0


class GeometryData(DSeriesStructure):
"""Representation of [GEOMETRY DATA] group."""

accuracy: Accuracy = Accuracy()
points: Points = Points()
curves: Curves = Curves()
boundaries: Boundaries = Boundaries()
Expand All @@ -385,16 +380,7 @@ class GeometryData(DSeriesStructure):
distribution_boundaries: DistributionBoundaries = DistributionBoundaries()
piezo_lines: PiezoLines = PiezoLines()
phreatic_line: PhreaticLine = PhreaticLine()
world_co__ordinates: str = cleandoc(
"""
0.000 - X world 1 -
0.000 - Y world 1 -
0.000 - X world 2 -
0.000 - Y world 2 -
"""
)
layers: Layers = Layers()
layerloads: str = ""

def boundary_area_above_horizontal(self, boundary: Boundary, y: float = 0.0) -> float:
"""Area above horizontal line defined by y-coordinate."""
Expand Down Expand Up @@ -539,8 +525,6 @@ class ResidualTimes(DSeriesNoParseSubStructure):
class Verticals(DSeriesNoParseSubStructure):
"""Representation of [VERTICALS] group."""

# total mesh is default value that is written in sli file but not read
total_mesh: int = 100
locations: List[DSeriePoint] = []


Expand Down Expand Up @@ -823,7 +807,7 @@ def externaltointernalprobabilisticcalculationtype(
return map_values[reliability_type.value]


class DSettlementStructure(DSeriesStructure):
class DSettlementInputStructure(DSeriesStructure):
"""Representation of complete .sli file."""

version: Version = Version()
Expand All @@ -845,15 +829,6 @@ class DSettlementStructure(DSeriesStructure):
0.05
"""
)
pore_pressure_meters: str = ZERO_ITEMS
non__uniform_loads_pore_pressures: str = ZERO_ITEMS
other_loads_pore_pressures: str = ZERO_ITEMS
calculation_options_pore_pressures: str = cleandoc(
"""
1 : Shear stress = TRUE
1 : calculation method of lateral stress ratio (k0) = Nu
"""
)
vertical_drain: Union[VerticalDrain, str] = VerticalDrain()
probabilistic_data: ProbabilisticData = ProbabilisticData()
probabilistic_defaults: str = cleandoc(
Expand Down Expand Up @@ -924,14 +899,6 @@ class DSettlementStructure(DSeriesStructure):
Fit Vertical Number=-1
"""
)
eps: str = cleandoc(
"""
0.00 = Dry unit weight
0.00 = Saturated unit weight
0.00 = Load
0.00 = Height above surface
"""
)
fit: str = ZERO_ITEMS

# Custom validator
Expand Down Expand Up @@ -1014,21 +981,25 @@ class ResidualSettlements(DSerieOldTableStructure):
# TODO LIst[Dict[str, float]] but can be empty which now gives a validation error
residualsettlements: List[Dict[str, float]]

class CalculationSettings(DSeriesStructure):
is_secondary_swelling_used: bool = False

class Results(DSeriesRepeatedGroupedProperties):
"""Representation of [results] group in sld file."""

calculation_settings: Optional[CalculationSettings]
verticals_count: int
vertical: List[Vertical]
residual_settlements: List[ResidualSettlements]
amounts_of_loads: Optional[str]
dissipation_in_layers: Optional[str]
reliability_calculation_results: Optional[str]


class DSettlementOutputStructure(DSeriesStructure):
"""Representation of complete .sld file, inherting
the structure of the .sli file as well."""

results: Results
input_data: DSettlementStructure
input_data: DSettlementInputStructure

class DSettlementStructure(DSeriesStructure):
input_data: DSettlementInputStructure = DSettlementInputStructure()
output_data: Optional[Results] = None
4 changes: 4 additions & 0 deletions geolib/models/dsettlement/internal_soil.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ class SoilInternal(DSeriesUnmappedNameProperties):
soillimitstress: float = 0 # fixed value
soildrained: Bool = Bool.FALSE
soilapasapproximationbycpcs: Bool = Bool.FALSE
soilsecondaryswellingreduced: Bool = Bool.FALSE
soilsecondaryswellingfactor: float = 0.5
soilunloadingstressratio: float = 2.0
soilcv: float = 1e-12
soilpermeabilityver: float = 0.00000001
soilpermeabilityhorfactor: float = 1
Expand Down Expand Up @@ -128,3 +131,4 @@ class SoilInternal(DSeriesUnmappedNameProperties):
soilhorizontalbehaviourtype: HorizontalBehaviourType = HorizontalBehaviourType.Elastic
soilelasticity: float = 1000
soildefaultelasticity: Bool = Bool.TRUE

Loading