Skip to main content

RFEM

VIKTOR's RFEM integration requires a specific RFEM worker which can be downloaded here.

Analyzing an RFEM model in VIKTOR can be done using the RFEMAnalysis class (worker required). The RFEM model is defined by:

  • input .rfx file which has to be created manually
  • list of actions which are to be performed sequentially

Creating the actions

The following actions can be defined:

Please click on the actions above to navigate to their reference for more detail on the meaning of each action.

from viktor.external.rfem import EnergyOptimizationAction, CopyNodalLoadAction, WriteResultsAction

# SLS
sls_cases = [1, 2, 3]
sls_optimization = EnergyOptimizationAction(sls_cases, goal=10000, accuracy=0.1) # goal = 10 kNm, accuracy = 10 cm

# ALS
als_cases = [4, 5, 6]
als_optimization = EnergyOptimizationAction(als_cases, goal=15000, accuracy=0.1) # goal = 15 kNm, accuracy = 10 cm

# ULS
uls_cases = [7, 8, 9]
uls_creation = CopyNodalLoadAction(list(zip(sls_cases, uls_cases)), factor=1.5) # ULS = SLS x 1.5

# Write action
write_result_action = WriteResultsAction(sls_cases + als_cases + uls_cases) # or can be left empty = all cases

actions = [sls_optimization, als_optimization, uls_creation, write_result_action]

Running an RFEM analysis

The model can be fed to the RFEMAnalysis as follows:

from viktor.external.rfem import RFEMAnalysis

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

# Run the analysis and obtain the results.
analysis = RFEMAnalysis(input_file, actions=actions)
analysis.execute(timeout=300)
model = analysis.get_model()
result_lc1 = analysis.get_result(load_case=1)
result_lc2 = analysis.get_result(load_case=2)

Testing

New in v13.5.0

mock_RFEMAnalysis decorator for easier testing of RFEMAnalysis

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

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

import unittest

from viktor import File
from viktor.testing import mock_RFEMAnalysis

from app.my_entity_type.controller import MyEntityTypeController

class TestMyEntityTypeController(unittest.TestCase):

@mock_RFEMAnalysis(
get_model=File.from_path('test_file.rfx'),
get_result={
1: File.from_path('test_file.json'), # <load_case>: <File>
...
},
)
def test_rfem_analysis(self):
MyEntityTypeController().rfem_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).