How to speed up response from RFEM #220
-
Hello all, I am attaching 2 scripts with a simple rfem6 file. those scripts does following things: node_reactions: Now I have some questions:
So for the first 2 questions: is it possible to make the process smoother (or faster)? or maybe I am doing something fundamentally wrong, so any help would be much appreciated.
Although my questions are very specific, my intention is to get a grasp of the logic. I have some experience with both python and rfem but this is the first time i use an API. Thanks in advance! create_loads: from RFEM.initModel import *
from RFEM.LoadCasesAndCombinations.loadCase import *
from RFEM.Loads.membersetload import *
Model(False, "beams.rf6")
# Create Load Cases
n_cases = 135
case_names = ["NL1-P" + str(i) for i in range(1, n_cases + 1)]
increment = 0.100
distance_a = 0
distance_b = 0.620
distance_c = 1.480
force = 184000
for i, name in enumerate(case_names):
LoadCase(i + 1, name, [False])
MemberSetLoad.Force(1, i+1, '1', MemberSetLoadDistribution.LOAD_DISTRIBUTION_CONCENTRATED_2x2,
MemberSetLoadDirection.LOAD_DIRECTION_LOCAL_Z,
load_parameter=[False, False, False, force, distance_a, distance_b, distance_c])
distance_a += increment node_reactions: from RFEM.enums import *
from RFEM.Loads.membersetload import *
from RFEM.Results.resultTables import ResultTables
Model(False, "beams.rf6")
n_cases = 135
case_names = ["NL1-P" + str(i) for i in range(1, n_cases + 1)]
Output_Joints = [19, 45, 52, 61, 60, 67]
for j in Output_Joints:
for i, name in enumerate(case_names):
result_table = ResultTables.NodesSupportForces(CaseObjectType.E_OBJECT_TYPE_LOAD_CASE, i+1, 61)
N = result_table[0]["support_force_p_z"]
M = result_table[0]["support_moment_m_y"]
print(name, N, M)```
|
Beta Was this translation helpful? Give feedback.
Replies: 4 comments 3 replies
This comment has been minimized.
This comment has been minimized.
-
Hi @BurakYyurt , I just made slight changes and improved the performance of your script. Load ApplicationFor the creation of load, please use Model class with True, with this you can avoid connection for every loop and therefore you'll gain some time. Also please add begin and finish modification this will help to improve connection time. Your script was taking 595 sec (which is not efficient at all), with the script below you can execute same operation in 18 sec. from RFEM.initModel import Model
from RFEM.LoadCasesAndCombinations.loadCase import LoadCase
from RFEM.Loads.membersetload import MemberSetLoad
from RFEM.enums import MemberSetLoadDistribution, MemberSetLoadDirection
import time
start = time.time()
Model(True, "beams.rf6")
Model.clientModel.service.begin_modification()
# Create Load Cases
n_cases = 135
case_names = ["NL1-P" + str(i) for i in range(1, n_cases + 1)]
increment = 0.100
distance_a = 0
distance_b = 0.620
distance_c = 1.480
force = 184000
for i, name in enumerate(case_names):
LoadCase(i + 1, name, [False])
MemberSetLoad.Force(1, i+1, '1', MemberSetLoadDistribution.LOAD_DISTRIBUTION_CONCENTRATED_2x2,
MemberSetLoadDirection.LOAD_DIRECTION_LOCAL_Z,
load_parameter=[False, False, False, force, distance_a, distance_b, distance_c])
distance_a += increment
Model.clientModel.service.finish_modification()
end = time.time()
print(f"Total time is {end-start} seconds.") Reading ResultsAlso, same solution applies to reading results for the support nodes. The code below took 32 seconds for me, which I believe acceptable for reading 810 result points. But there can be still a way to improve this which is in the ResultTables class. If you pass the object_no=0, it will read all of the nodes. I don't precisely know how you want to parse these results, therefore I couldn't create an example for it. Please try this, and let us know if you have any questions. from RFEM.enums import *
from RFEM.Loads.membersetload import *
from RFEM.Results.resultTables import ResultTables
import time
start = time.time()
Model(True, "beams.rf6")
Model.clientModel.service.begin_modification()
n_cases = 135
case_names = ["NL1-P" + str(i) for i in range(1, n_cases + 1)]
Output_Joints = [19, 45, 52, 61, 60, 67]
for j in Output_Joints:
for i, name in enumerate(case_names):
result_table = ResultTables.NodesSupportForces(CaseObjectType.E_OBJECT_TYPE_LOAD_CASE, i+1, 61)
N = result_table[0]["support_force_p_z"]
M = result_table[0]["support_moment_m_y"]
print(name, N, M)
Model.clientModel.service.finish_modification()
end = time.time()
print(f"Total time is {end-start} seconds") |
Beta Was this translation helpful? Give feedback.
-
Hi @BurakYyurt, |
Beta Was this translation helpful? Give feedback.
-
Using RFEM running in command line called RFEM6Server is also good option to speed things up. See our wiki |
Beta Was this translation helpful? Give feedback.
Hi @BurakYyurt ,
I just made slight changes and improved the performance of your script.
Load Application
For the creation of load, please use Model class with True, with this you can avoid connection for every loop and therefore you'll gain some time. Also please add begin and finish modification this will help to improve connection time.
Your script was taking 595 sec (which is not efficient at all), with the script below you can execute same operation in 18 sec.