D-Foundations
VIKTOR's D-Foundations integration requires a specific D-Foundations worker which can be installed using these instructions.
The D-Foundations binding is created to work with D-Foundations version v17. Other versions of D-Foundations might not be able to read the generated input files properly.
A D-Foundations binding has been developed by VIKTOR to simplify the process of creating a D-Foundations model, running an analysis (worker required) and parsing the results. The process consists of the following steps:
- Create the 'empty' model (optionally with default materials), applying the desired settings.
- (Optional) Create material(s). Also possible to only use the default materials.
- Create or import profile(s).
- Create pile type(s).
- Create pile(s).
- Let VIKTOR generate the input file for you.
- Run the D-Foundations analysis (worker required) with the input file.
- Obtain and parse the results, and process them as desired.
Supported model types
D-Foundations supports 4 type of models. The following types are currently (un)supported in the D-Foundations binding:
- Bearing Piles (EC7-NL): supported
- Bearing Piles (EC7-B): not supported
- Tension Piles (EC7-NL): supported
- Shallow Foundations (EC7-NL): not supported
Creating the model (example: Bearing Piles (EC7-NL) model)
The class BearingPilesModel
represents the Bearing Piles
(EC7-NL) model in D-Foundations. The following code shows how a (minimal) bearing piles model can be created in Python
using the binding. The Tension Piles (EC7-NL) model can be created in a similar way, using the
TensionPilesModel
class.
import viktor as vkt
# Create the model with misc. options.
options = vkt.dfoundations.BearingPilesCalculationOptions(
vkt.dfoundations.CalculationType.BEARING_CAPACITY_AT_FIXED_PILE_TIP_LEVEL, False
)
model = vkt.dfoundations.BearingPilesModel(
vkt.dfoundations.ConstructionSequence.CPT_INSTALL_EXCAVATION, options, -5.0
)
# Create material (optional), or use one of the default material names.
model.create_material("my_material", vkt.dfoundations.SoilType.SAND, 19.0, 19.0, 3.0)
# Create profile(s).
layers = [
vkt.dfoundations.ProfileLayer(0.0, "my_material"),
vkt.dfoundations.ProfileLayer(-20.0, "my_material")
]
measurements = [(0.0, 10.0), (-20.0, 20.0)]
model.create_profile('my_profile', layers, 0.0, 0.0, measurements, -5.0, -15.0, 1.0, -10.0, -12.0, -0.11)
# Create pile type(s).
model.create_pile_type(
"my_pile_type",
vkt.dfoundations.RectPile(1.0, 1.0),
vkt.dfoundations.PileType.PREFAB_CONCRETE,
vkt.dfoundations.PileSlipLayer.NONE
)
# Create pile(s).
model.create_pile("my_pile", 0.0, 0.0, -1.0, 1.0, 0.0, 0.0)
# Generate the input file for the model as if it was generated by D-Foundations.
# Metadata can be used (not required) to update data such as titles, company, etc.
metadata = vkt.dfoundations.Metadata(title_1='Example Model', company='VIKTOR')
foi_file = model.generate_input_file(metadata)
# Run the analysis with the generated input file (requires worker).
analysis = vkt.dfoundations.DFoundationsAnalysis(foi_file)
analysis.execute(300)
# Obtain the result file.
fod_file = analysis.get_output_file()
Parsing output using OutputFileParser
After running a DFoundationsAnalysis
, the fod 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.dfoundations.OutputFileParser(fod_file)
# Calculation parameters.
calculation_parameters = parser.calculation_parameters
# Parsed results in the form of a dictionary.
results = parser.results(False) # True (default) for returning pandas DataFrame(s).
# Raw, unparsed results in the form of a string.
# Manual parsing required. Useful, if parser.results is not sufficient.
raw_results = parser.raw_results
Supported D-Foundation versions
Currently, the parser supports the following versions (completely or partially) of D-Foundations:
-
v17:
- Tension Piles model
- Bearing Piles model - Preliminary Design (calculation options only)
-
v19:
- Tension Piles model
- Bearing Piles model - Verification
Testing
mock_DFoundationsAnalysis
decorator for easier testing of DFoundationsAnalysis
BearingPilesModel.generate_input_file
, TensionPilesModel.generate_input_file
and DFoundationsAnalysis.execute
need to be mocked within the context of (automated)
testing.
The viktor.testing
module provides the mock_DFoundationsAnalysis
decorator that facilitate mocking of workers:
import unittest
from viktor import File
from viktor.testing import mock_DFoundationsAnalysis
from app.my_entity_type.controller import MyEntityTypeController
class TestMyEntityTypeController(unittest.TestCase):
@mock_DFoundationsAnalysis(get_output_file={
'.fod': File.from_path('test_output.fod'),
'.fos': File.from_path('test_output.fos'),
})
def test_dfoundations_analysis(self):
MyEntityTypeController().dfoundations_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).