Skip to main content

RFEM 5

VIKTOR's RFEM 5 integration requires a specific RFEM worker which can be installed using these instructions.

Analyzing an RFEM 5 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.

import viktor as vkt

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

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

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

# Write action
write_result_action = vkt.rfem.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:

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

# Run the analysis and obtain the results.
analysis = vkt.rfem.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).