Result Smoothing: Stress-Strain Calculation via API

Good day,

Since I am unable to access results determined by the result smoothing "constant in mesh elements" via the static analysis API, I am now trying this using the Stress-Strain Calculation addon.

Here you can define in the global addon settings which result smoothing settings should be used for the addon, which I set to "constant in mesh elements" according to the nonlinear material:

dlubal_example.rf6 (1.0 MB)

My initial hope was with the following API code:

from dlubal.api import RFEM

from dlubal.api import common

from openpyxl import load_workbook

import math

import pandas

============================================

Settings

============================================

API_KEY = "non of your business"

Select a free load case number in the model

lc_start = 1007

co_start = 1

def show_Weld_stresses(RFEM_app, lc_no):

results: common.Table  = rfem_app.get_results(

       results_type=rfem.results.ResultsType.STATIC_ANALYSIS_SURFACES_BASIC_STRESSES_MESH_NODES,

    ).data

results_lc = results[

    (results["loading"] == f"CO{lc_no}") #

    #(results["element_no"].isin([6885])) &

    #(results["tag"] == f"middle")

]

#cols = [

#    "loading",

#    "surface_no",

#    "mesh_node_no",

#    "element_no",

#    "sigma_x",

#    "sigma_y",

#    "tau_xy",

#    "tau_xz",

#    "tau_yz"

#]

#print("\nResults:\n", results_lc[cols].to_string())

results_analysis: common.Table = rfem_app.get_results(

       results_type=rfem.results.ResultsType.STRESS_STRAIN_ANALYSIS_SURFACES_STRAINS_BY_SURFACE,

).data

#results_lc_analysis = results_analysis[

#    (results_analysis["loading"] == f"CO{lc_no}") &

#    (results_analysis["element_no"].isin([6885])) 

#]



#print("\nResults:\n", results_lc_analysis)

print("\nResults:\n", results_analysis)

def rechne_kombination(RFEM_app):

    rfem_app.calculate_all(

            skip_warnings=True

        )

def main():

lc_counter = co_start

with rfem.Application(api_key_value=API_KEY) as rfem_app:

    info = rfem_app.get_application_info()

    print(f'Version: {info.name}')

    

    rfem_app.get_active_model()     #loads the manual opened model into the here written script

    while lc_counter < 3:

         rechne_kombination(rfem_app=rfem_app)

         show_Weld_stresses(rfem_app=rfem_app,lc_no=lc_counter)

         lc_counter += 1

if name == "main":

main()

To obtain the strains according to the result smoothing "constant in mesh elements".

Because these were manually set in the opened model beforehand via GUI in the global addon settings.

If I now run the above code, I get the following results:

If I check whether these actually correspond to the constant smoothing, unfortunately it does not seem to be the case, if I am not mistaken, because let's look at the first row of the results:

image

For element 5 in load combination 1, at the bottom layer, I would need a comparison strain according to Mises of 0.000626 (0.626 per mille).

Unfortunately, it looks like that graphically for the constant mesh smoothing a result of 0.61 per mille occurs at element 5:

The tabular output of the static analysis results of the comparison strain according to Mises of load combination 1 also corresponds to these 0.61:

If, on the other hand, I set the result smoothing for static analysis to continuous in surface sets or in surfaces, I get a comparison strain of 0.63 per mille, which matches those of the Stress-Strain results addon => although it is explicitly set in the Global Settings to use the smoothing constant in mesh elements.

Here are the results of the static analysis for the calculation settings: continuous in surface sets or in surfaces:

It therefore seems that the Stress-Strain Calculation addon itself, even with global settings to other result smoothing within the API, always outputs the results based on the setting continuous in surface sets or in surfaces.

Therefore the questions:

  1. Am I correct with my statements/assumptions here? Or am I making a mistake?

  2. Is it possible to explicitly define the global settings of the Stress-Strain Calculation addon within the API instead of first in the GUI? And if yes, how?

Hi DeflectionPerfection,

can you send the py file for that? Thanks.

Best regards
Robert Milrath

Danke für die Rückmeldung,

Die Datei befindet sich Anhang,

damit Sie bei dir läuft muss natürlich der API-key angepasst werden, diesen habe ich als String-Variable in Zeile 11 des Codes hinterlegt (so Ansicht in Visual Studio Code):slight_smile:

konstanteNetzglättung_schweißtester copy.py (2,1 KB)

Über eine Rückmeldung wäre ich sehr erfreut.

Mit freundlichen Grüßen,

Nick Böttcher

Hi DeflectionPerfection,

Thank you very much for the example. I have taken a closer look at the matter.

Regarding question 1:
The table provided by the API did not take the smoothing into account. I have forwarded this accordingly to the developers.

Regarding question 2:
You can access the global settings for the stress-strain calculation as follows (one setting as an example):

from dlubal.api import RFEM, common
from google.protobuf.json_format import MessageToJson

with RFEM.Application(port=9000) as RFEM_app:
# Get global settings tree table for Stress Analysis add-on (active model)
design_settings_tree: RFEM.GlobalSettingsTreeTable = RFEM_app.get_design_settings(
addon=RFEM.DesignAddons.STRESS_ANALYSIS
)
print(f"stress_strain_analysis_global_settings_tree_table")
print(f"RFEM.DesignAddons.STRESS_ANALYSIS:\n{MessageToJson(design_settings_tree)}")
# breakpoint()

# *************************************************************************
key='calculate_surfaces_stress_in'
common.set_values_by_key(
    tree=design_settings_tree,
    key=key,
    values=[1]  # 0: in mesh node, 1: in grid point
)

# *************************************************************************
# Set specific value from the global settings
rfem_app.set_design_settings(
    addon=rfem.DesignAddons.STRESS_ANALYSIS,
    global_settings_tree_table=design_settings_tree
)

How to access the corresponding settings is demonstrated in a similar manner in Webinar | Concrete Design with the Dlubal API using the example of concrete design.

Best regards
Robert Milrath