Skip to main content

AxisVM

An AxisVM binding has been developed by VIKTOR to simplify the process of creating and analyzing an AxisVM model. VIKTOR's AxisVM integration requires a specific AxisVM worker which can be downloaded here.

note

This binding was tested in AxisVM version 5. We cannot guarantee that the binding in combination with the worker will function properly with other versions of AxisVM.

Creating a Model

An AxisVM model is made by starting off with an empty model and creating/modifying objects via their respective interfaces. The following Model interfaces are available:

Below is an example of a model, representing a cantilever beam bending under its own weight:

from viktor.external.axisvm import Model
from viktor.external.axisvm import Material

model = Model() # Initialize the empty model.
material = model.materials.add_from_catalog('C12/15', Material.DesignCode.EURO_CODE)
cross_section = model.cross_sections.create_rectangular(0.01, 0.01)
n1 = model.nodes.create(0, 0, 0)
n2 = model.nodes.create(1, 0, 0)
beam = model.lines.create(n1, n2).define_as_beam(material, cross_section)
model.node_supports.create_relative_to_member(n1, stiffness_x=1e10, stiffness_y=1e10, stiffness_z=1e10,
stiffness_xx=1e10, stiffness_yy=1e10, stiffness_zz=1e10)
load_case = model.load_cases.create()
model.loads.create_beam_self_weight(load_case, beam)
model.results.nodal_displacements([n2])

Running an AxisVM analysis

The model can be fed to the AxisVMAnalysis as follows:

from viktor.external.axisvm import AxisVMAnalysis

# Run the analysis and obtain the results, model (.axs) and/or result file (.axe).
analysis = AxisVMAnalysis(model, return_results=True, return_model=True)
analysis.execute(timeout=25) # make a conservative estimation of the time needed to finish
results = analysis.get_results() # obtain the results in a dict
model_file = analysis.get_model_file() # obtain the model file (.axs)
result_file = analysis.get_result_file() # obtain the result file (.axe)

If return_results is set to True, an analysis will be performed and the following methods become available:

If return_model=True, the model file will also become available:

Testing

New in v13.5.0

mock_AxisVMAnalysis decorator for easier testing of AxisVMAnalysis

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

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

import unittest

from viktor import File
from viktor.testing import mock_AxisVMAnalysis

from app.my_entity_type.controller import MyEntityTypeController

class TestMyEntityTypeController(unittest.TestCase):

@mock_AxisVMAnalysis(
get_results={"Forces": ...},
get_model_file=File.from_path('test_file.axs'),
get_result_file=File.from_path('test_file.axe'),
)
def test_axis_vm_analysis(self):
MyEntityTypeController().axis_vm_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).