Skip to main content

D-Geo Stability

Analyzing a D-Geo Stability model in VIKTOR can be done using the DGeoStabilityAnalysis class (worker required).

GEOLIB

The GEOLIB replaces VIKTOR's D-Series bindings for input file generation. These bindings won't be removed for now, but there won't follow any updates anymore.

Add integration to app config​

To make the worker integration available through the interface, add the following to your viktor.config.toml:

worker_integrations = [
"dgeostability",
]

For personal use, install and enable the worker with VIKTOR Desktop. Instructions on how to install an organization worker can be found here.

App code​

No binding is provided by VIKTOR for this module, which means that the input file has to be generated manually:

import viktor as vkt

# Generate the input STI file.
input_file = ...

# Run the analysis and obtain the output file.
analysis = vkt.dgeostability.DGeoStabilityAnalysis(input_file)
analysis.execute(timeout=10)
output_file = analysis.get_output_file()

Testing​

New in v13.5.0

mock_DGeoStabilityAnalysis decorator for easier testing of DGeoStabilityAnalysis

DGeoStabilityAnalysis.execute needs to be mocked within the context of (automated) testing.

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

import unittest

from viktor import File
from viktor.testing import mock_DGeoStabilityAnalysis

from app.my_entity_type.controller import MyEntityTypeController

class TestMyEntityTypeController(unittest.TestCase):

@mock_DGeoStabilityAnalysis(get_output_file={
'.sto': File.from_path('test_output.sto'),
})
def test_dgeostability_analysis(self):
MyEntityTypeController().dgeostability_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 object (with empty content) is returned each time the corresponding method is called (endlessly).