Skip to main content

D-Settlement

VIKTOR's D-Settlement integration requires a specific D-Settlement worker which can be downloaded here.

A D-Settlement binding has been developed by VIKTOR to simplify the process of creating a D-Settlement model, running an analysis (worker required) and parsing the results. The process consists of the following steps:

  1. Create the 'empty' model, applying the desired settings.
  2. Extend the model with the desired objects (material, layers, pl-lines, loads, verticals, calculation times, etc.).
  3. Let VIKTOR generate the input file for you.
  4. Run the D-Settlement analysis (worker required) with the input file mentioned above.
  5. Obtain and parse the results, and process them as desired.

It is possible to create both a 1D-model and a 2D-model using VIKTOR's D-Settlement binding. The following sections describe how each of these models can be made.

1D-model

The class Model1D represents the 1D-model in D-Settlement. Its geometry is defined by a list of depths versus materials.

from viktor import Color
from viktor.external.dsettlement import Model1D
from viktor.external.dsettlement import CalculationModel
from viktor.external.dsettlement import ConsolidationModel
from viktor.external.dsettlement import Metadata
from viktor.external.dsettlement import DSettlementAnalysis

# Create the model with misc. default parameters.
model = Model1D(CalculationModel.NEN_KOPPEJAN, ConsolidationModel.TERZAGHI)

# Create material(s).
model.create_material("my_mat", 21.0, 19.0, color=Color(0, 0, 0))

# Update the geometry.
model.update_geometry(-1.0, [(1.0, "Loam"), (0.0, "my_mat")], phreatic_level=-3.0)

# Create loads.
model.create_uniform_load("my_load", 0, 0.001, 0.0, 0.0)

# Generate the input file for the model as if it was generated by D-Settlement.
# Metadata can be used (not required) to update data such as created_by, titles, etc.
metadata = Metadata(title_1='Example Model', created_by='VIKTOR')
input_file = model.generate_input_file(metadata)

# Run the analysis with the generated input file (requires worker).
analysis = DSettlementAnalysis(input_file)
analysis.execute(300)

# Obtain the result file.
sld_file = analysis.get_sld_file()

2D-model

The class Model2D represents the 2D-model in D-Settlement. Its geometry can be built-up from layers, consisting of points.

It is possible to create a model using VIKTOR's binding that will result in errors in D-Settlement (e.g. intersecting boundaries). Notice that it is not guaranteed that these errors are captured in the code upon creation of the model, such that the error only shows up during the analysis. It is the responsibility of the developer to build-up a 'valid' model.

from viktor.external.dsettlement import VerticalDrain
from viktor.external.dsettlement import Model2D
from viktor.external.dsettlement import CalculationModel
from viktor.external.dsettlement import ConsolidationModel
from viktor.external.dsettlement import DrainType
from viktor.external.dsettlement import Metadata
from viktor.external.dsettlement import DSettlementAnalysis

# Initialize the settings for vertical drains.
vertical_drain = VerticalDrain(DrainType.SAND_WALL, 5.0, 90.0, 0.0, 2.0, 4.0,
start_of_drainage=2.0, phreatic_level_in_drain=4.0)

# Create the model with a starting bottom boundary, vertical drainage settings and misc. default parameters.
model = Model2D(CalculationModel.NEN_KOPPEJAN, ConsolidationModel.TERZAGHI,
boundary_bottom=[(0.0, 0.0), (100.0, 0.0)], vertical_drain=vertical_drain)

# Create points for defining boundaries and pl-lines.
points_boundary1 = [model.create_point(x, y) for (x, y) in [(0.0, 5.0), (50.0, 5.0), (100.0, 2.5)]]
points_boundary2 = [model.create_point(x, y) for (x, y) in [(0.0, 5.0), (50.0, 5.0), (100.0, 7.5)]]
points_boundary3 = [model.create_point(x, y) for (x, y) in [(0.0, 10.0), (25, 10.0), (75, 10.0), (100.0, 10.0)]]
points_plline1 = [model.create_point(x, y) for (x, y) in [(0.0, 4.0), (100.0, 4.0)]]
points_plline2 = [model.create_point(x, y) for (x, y) in [(0.0, 6.0), (100.0, 6.0)]]

# Create the pl-lines.
plline1 = model.create_pl_line(points_plline1, is_phreatic=True)
plline2 = model.create_pl_line(points_plline2)

# Create the layers.
model.create_layer(points_boundary1, 'Sand', pl_line_top=99, pl_line_bottom=plline2)
model.create_layer(points_boundary2, 'Soft Clay', pl_line_top=99, pl_line_bottom=99)
model.create_layer(points_boundary3, 'Loam', pl_line_top=plline1, pl_line_bottom=99)

# Create verticals.
model.create_vertical(45.0)
model.create_vertical(50.0)
model.create_vertical(55.0)

# Create loads.
model.create_non_uniform_load('load1', [(25, 10.0), (50.0, 12.0), (75, 10.0)])

# Create calculation/residual times.
model.set_calculation_times(1, 4, 2, 5)

# Generate the input file for the model as if it was generated by D-Settlement.
# Metadata can be used (not required) to update data such as created_by, titles, etc.
metadata = Metadata(title_1='Example Model', created_by='VIKTOR')
input_file = model.generate_input_file(metadata)

# Run the analysis with the generated input file (requires worker).
analysis = DSettlementAnalysis(input_file)
analysis.execute(300)

# Obtain the result file.
sld_file = analysis.get_sld_file()

Supported features

Currently, the following 1D-Model features are supported:

  • Defining consolidation and calculation model and various settings.
  • Creating materials (or using the default ones).
  • Defining the geometry.
  • Creating uniform loads.
  • Adding calculation times (residual times).

Currently, the following 2D-Model features are supported:

  • Defining consolidation and calculation model and various settings.
  • Creating materials (or using the default ones).
  • Creating points (for the creation of layers and pl-lines).
  • Creating layers.
  • Creating pl-lines.
  • Creating uniform loads.
  • Creating non-uniform loads.
  • Creating verticals.
  • Adding calculation times (residual times).

Parsing output using OutputFileParser

After running a DSettlementAnalysis, the sld file can be obtained and results can be extracted. The class OutputFileParser makes the parsing more convenient and return Python objects that can be further processed:

from viktor.external.dsettlement import OutputFileParser

parser = OutputFileParser(sld_file)
vertical_results = parser.vertical_results
residual_times = parser.residual_times

Testing

New in v13.5.0

mock_DSettlementAnalysis decorator for easier testing of DSettlementAnalysis

Model1D.generate_input_file, Model2D.generate_input_file and DSettlementAnalysis.execute need to be mocked within the context of (automated) testing.

The viktor.testing module provides the mock_DSettlementAnalysis decorator that facilitate mocking of workers:

import unittest

from viktor import File
from viktor.testing import mock_DSettlementAnalysis

from app.my_entity_type.controller import MyEntityTypeController

class TestMyEntityTypeController(unittest.TestCase):

@mock_DSettlementAnalysis(get_output_file={
'.sld': File.from_path('test_output.sld'),
'.slo': File.from_path('test_output.slo')
})
def test_dsettlement_analysis(self):
MyEntityTypeController().dsettlement_analysis()

For the decorator's input parameters the following holds:

  • If a Sequence type is provided, the next entry is returned for each corresponding method call. When a call is performed on a depleted iterable, an Exception is raised.
  • If a single object is provided, the object is returned each time the corresponding method is called (endlessly).
  • If None is provided (default), a default File/BytesIO/StringIO object (with empty content) is returned each time the corresponding method is called (endlessly).