Force Casas >> More as one possible

About the development of the FEM module/workbench.

Moderator: bernd

Post Reply
Nanayaw
Posts: 90
Joined: Thu Feb 14, 2019 3:04 pm

Force Casas >> More as one possible

Post by Nanayaw »

Hello All

I searched if there is a way to place more force cases at one static simulation like

1. 200n (simulation with the same fixed places and force places)
2. 400n (simulation with the same fixed places and force places)
3. 600n (simulation with the same fixed places and force places)

and then this tree will done after each othe, but I can't find a way.

If it's realy not possible at the moment then I suggest it for implementation

Greetings

Nanayaw
thschrader
Veteran
Posts: 3129
Joined: Sat May 20, 2017 12:06 pm
Location: Germany

Re: Force Casas >> More as one possible

Post by thschrader »

You can define as much loads as you want.
But you can not define different loadcombinations.

For instance:
I have 4 loadcases, each safety-factor=1,0
G: selfweight structure
Eis: ice-loading
W60: 60% wind loading
W100: 100% wind loading

And 2 loadcombinations:
G+Eis+60% Wind (including safety-factors gamma-f)
G+100% Wind…

Each loadcombination is a separate FEM-run, this wont work with FC-FEM input.
But maybe there is a command to advice calculix after writing the inp.

Hope I understood you right.
loadcombination.JPG
loadcombination.JPG (28.96 KiB) Viewed 2120 times
Nanayaw
Posts: 90
Joined: Thu Feb 14, 2019 3:04 pm

Re: Force Casas >> More as one possible

Post by Nanayaw »

Hello All

I found a solution and modified a bit it works so far, the only thing I didn't finished is the adding the used force to the reuslt name
if somebody know it from the mind then let me know or add it to the code.

Code: Select all

# The Analysis have to pre-prepared
# >> Material selected
# >> Fixed Constrain set
# >> Force Constrain set
# >> Mesh generated

from PySide import QtGui
import FemGui
from femtools import ccxtools

# Create the forces to make a multiple analysis with
force = QtGui.QInputDialog.getDouble(None, "Input", "Enter your start force:")[0] # Starting Force
fstep = QtGui.QInputDialog.getDouble(None, "Input", "Enter force step value:")[0]  # Force Step 
rng = QtGui.QInputDialog.getInt(None, "Input", "Enter amount of force steps:")[0] 
forces = []
for f in range(rng):
    forces.append(force)
    force+=fstep

FemGui.setActiveAnalysis(FreeCAD.ActiveDocument.Analysis)
fea = ccxtools.FemToolsCcx()
fea.update_objects()
fea.check_prerequisites()
fea.reset_all()
fea.update_objects()

# Run analysis multiple times
for force in forces:
    obj1 = App.ActiveDocument.getObjectsByLabel('ConstraintForce')[0]
    obj1.Force = force
    App.ActiveDocument.recompute()
    print (obj1.Force)
    fea.write_inp_file()
    fea.ccx_run()
    fea.load_results()
    App.ActiveDocument.recompute()
Thanks and Greetings

Nanayaw
Nanayaw
Posts: 90
Joined: Thu Feb 14, 2019 3:04 pm

Static Analysis >> Multible Force Cases

Post by Nanayaw »

Hello All

I modified the code now with renaming the results (label) with the used force and add some input dialogs

If somebody will modify again with additional features or optimizations then please share it with us. :idea: :lol: :lol:

The Analysis have to pre-prepared
>> Material selected
>> Fixed Constrain set
>> Force Constrain set
>> Mesh generated
NOTE:
1. There are only 10 force cases supported
2. There is only one time step supported
3. The analysis time will be much longer acc. additional simulations

This is an example of 10 load cases with step value of 10
Image

The time step was set by the macro to 1
Image

Code: Select all

#+-----------------------------------------------------------------------------------------------------+
#|                    Macro to run multible static FEM analysis with different forces                  |
#+-----------------------------------------------------------------------------------------------------+
#| The Analysis have to pre-prepared                                                                   |
#|  >> Material selected                                                                               |
#|  >> Fixed Constrain set                                                                             |
#|  >> Force Constrain set                                                                             |
#|  >> Mesh generated                                                                                  |
#+-----------------------------------------------------------------------------------------------------+
#|  NOTE:                                                                                              |
#|  1. There are only 10 force cases supported                               |
#|  2. There are only one time step supported                                                          |
#+-----------------------------------------------------------------------------------------------------+
from PySide import QtCore, QtGui
import FemGui
from femtools import ccxtools

def mainFC():

   cnt = 0
   val1 = 0
   val2 = 0
   # Input boxes 

   rng = QtGui.QInputDialog.getInt(None, "Input", "Enter amount of force steps >> only 10 are possible:")[0]
   if (rng > 10):
     Msgb = QtGui.QMessageBox(QtGui.QMessageBox.Information, 'Information Message:', 'Only 10 force cases are allowed, action abort')
     Msgb.setWindowModality(QtCore.Qt.ApplicationModal)
     Msgb.exec_()
     return  
   else:
     force = QtGui.QInputDialog.getInt(None, "Input", "Enter your start force:")[0] 
     fstep = QtGui.QInputDialog.getInt(None, "Input", "Enter force step value:")[0]  
     tmstp = QtGui.QInputDialog.getDouble(None, "Input", "Enter time step >> only one could set:")[0] 

     # Create the forces to make a multiple analysis with
     forces = []
     for f in range(rng):
         forces.append(force)
         force+=fstep

     FemGui.setActiveAnalysis(FreeCAD.ActiveDocument.Analysis)
     fea = ccxtools.FemToolsCcx()
     fea.update_objects()
     fea.check_prerequisites()
     fea.reset_all()
     fea.update_objects()

     # Run analysis multiple times
     for force in forces:
         obj1 = App.ActiveDocument.getObjectsByLabel('ConstraintForce')[0]
         obj1.Force = force
         App.ActiveDocument.recompute()
         fea.write_inp_file()
         fea.ccx_run()
         fea.load_results()
         App.ActiveDocument.getObject('SolverCcxTools').TimeEnd = tmstp
         App.ActiveDocument.getObject('SolverCcxTools').TimeInitialStep = tmstp
         App.ActiveDocument.recompute()

         if (cnt ==0 and val1 ==0):
           obj2 = App.ActiveDocument.getObjectsByLabel('CCX_Results')[0]
           obj2.Label = 'CCX_Results_' + str(force)
           val1 =1 
           cnt =cnt+1
           App.ActiveDocument.recompute()
         elif (cnt ==1 and val1==1):
           obj3 = App.ActiveDocument.getObjectsByLabel('CCX_Results00' + str(cnt))[0]
           obj3.Label = 'CCX_Results_' + str(force)
           cnt =cnt+1
           App.ActiveDocument.recompute()
         elif (cnt > 1 and val1==1 and cnt < 10):
           obj4 = App.ActiveDocument.getObjectsByLabel('CCX_Results00' + str(cnt))[0]
           obj4.Label = 'CCX_Results_' + str(force)
           cnt =cnt+1
           val2 = 1
           App.ActiveDocument.recompute()
         elif (cnt == 10 and val2==1 and rng ==10):
           obj5 = App.ActiveDocument.getObjectsByLabel('CCX_Results00' + str(cnt))[0]
           obj5.Label = 'CCX_Results_' + str(force)
           cnt =cnt+1
           App.ActiveDocument.recompute()

     diag = QtGui.QMessageBox(QtGui.QMessageBox.Information, 'Information Message:', 'Analysis finished')
     diag.setWindowModality(QtCore.Qt.ApplicationModal)
     diag.exec_()

mainFC()
Greetings

Nanayaw
Attachments
FEM_Static_Multible_Force_Cases.FCMacro
(4.06 KiB) Downloaded 47 times
Nanayaw
Posts: 90
Joined: Thu Feb 14, 2019 3:04 pm

Re: Force Casas >> More as one possible

Post by Nanayaw »

Hello All

here I made an Icon for that macro it is the same as constraint force but with the word Multi

It could add as follow

Image

Image

Image

Create a folder where you like to place the icon then do following

Image

Image

Image

Image

Image

Here the result in a custom menubar at FEM WB
after restart FreeCAD

Image

Greetings

Nanayaw
Attachments
FEM_MultiConstraintForce.svg
(18.83 KiB) Downloaded 50 times
Nanayaw
Posts: 90
Joined: Thu Feb 14, 2019 3:04 pm

Re: Force Casas >> More as one possible

Post by Nanayaw »

Hello All

here an update of the multi force case
>> Add an message box after start macro

Greetings

Nanayaw
Attachments
FEM_Static_Multible_Force_Cases.FCMacro
(4.57 KiB) Downloaded 44 times
RatonLaveur
Posts: 991
Joined: Wed Mar 27, 2019 10:45 am

Re: Force Casas >> More as one possible

Post by RatonLaveur »

One of the Elmer tutorials nonGui deals with modifying the case during a simulation, I've never tried so i cannot support, but it would necessitate a transient sim and enough timesteps between changes to allow steady state.

Essentially in the same sim you'd see self weight, increasing wind...then ice buildup
Nanayaw
Posts: 90
Joined: Thu Feb 14, 2019 3:04 pm

Re: Force Casas >> More as one possible

Post by Nanayaw »

Hello Raton Leveur

at the moment I did not have experiance with elmer.
This macro is specially made to get different force cases done with one
static analysis.
If you need another values for multible cases use, then we could
try to modify the macro for your needs.

Greetings

Nanayaw
Nanayaw
Posts: 90
Joined: Thu Feb 14, 2019 3:04 pm

Re: Force Casas >> More as one possible

Post by Nanayaw »

Hello All

I made a update at the macro not in function only at msg box text and add msg box
so that it will be more self explaining.

Greetings

Nanayaw
Attachments
FEM_Static_Multible_Force_Cases_Update_1_.FCMacro
(5.75 KiB) Downloaded 39 times
Nanayaw
Posts: 90
Joined: Thu Feb 14, 2019 3:04 pm

Re: Force Casas >> More as one possible

Post by Nanayaw »

Hello All

is it possible to get the von mieses max stress by phyton after simulation finished???
The reason is if it will be possible then the macro could modified that if the stress is
at the level of break then the futher analsis will not be done.

Thanks and Greetings

Nanayaw
Post Reply