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:
- Create the 'empty' model, applying the desired settings.
- Extend the model with the desired objects (material, layers, pl-lines, loads, verticals, calculation times, etc.).
- Let VIKTOR generate the input file for you.
- Run the D-Settlement analysis (worker required) with the input file mentioned above.
- 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.
import viktor as vkt
# Create the model with misc. default parameters.
model = vkt.dsettlement.Model1D(
vkt.dsettlement.CalculationModel.NEN_KOPPEJAN, vkt.dsettlement.ConsolidationModel.TERZAGHI
)
# Create material(s).
model.create_material("my_mat", 21.0, 19.0, color=vkt.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 = vkt.dsettlement.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 = vkt.dsettlement.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.
import viktor as vkt
# Initialize the settings for vertical drains.
vertical_drain = vkt.dsettlement.VerticalDrain(
vkt.dsettlement.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 = vkt.dsettlement.Model2D(
vkt.dsettlement.CalculationModel.NEN_KOPPEJAN, vkt.dsettlement.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 = vkt.dsettlement.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 = vkt.dsettlement.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:
parser = vkt.dsettlement.OutputFileParser(sld_file)
vertical_results = parser.vertical_results
residual_times = parser.residual_times
Testing
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).