Skip to content

Commit

Permalink
FEM: Make sure .inp doesn't contain force values that crash ccx
Browse files Browse the repository at this point in the history
ccx crashes when a force has too many digits like this:
FemConstraintForce,2,1.5966711853290134e-18
but it's OK with that format:
FemConstraintForce,2,1.5966711853e-18

An example of ccx error:
*ERROR reading *CLOAD. Card image:
FEMCONSTRAINTFORCE,3,1.5966711853290134E-18

This commits adds formatting to make sure the numbers are within ccx
limits.

Signed-off-by: Przemo Firszt <przemo@firszt.eu>
  • Loading branch information
PrzemoF authored and wwmayer committed Apr 23, 2015
1 parent 13b8d32 commit 957f723
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/Mod/Fem/MechanicalAnalysis.py
Expand Up @@ -543,9 +543,12 @@ def write_calculix_input_file(self):
vec = ForceObject['Object'].DirectionVector
inpfile.write('*CLOAD\n')
inpfile.write('** force: ' + str(ForceObject['NodeLoad']) + ' N, direction: ' + str(vec) + '\n')
inpfile.write(ForceObject['Object'].Name + ',1,' + repr(vec.x * ForceObject['NodeLoad']) + '\n')
inpfile.write(ForceObject['Object'].Name + ',2,' + repr(vec.y * ForceObject['NodeLoad']) + '\n')
inpfile.write(ForceObject['Object'].Name + ',3,' + repr(vec.z * ForceObject['NodeLoad']) + '\n\n')
v1 = "{:.15}".format(repr(vec.x * ForceObject['NodeLoad']))
v2 = "{:.15}".format(repr(vec.y * ForceObject['NodeLoad']))
v3 = "{:.15}".format(repr(vec.z * ForceObject['NodeLoad']))
inpfile.write(ForceObject['Object'].Name + ',1,' + v1 + '\n')
inpfile.write(ForceObject['Object'].Name + ',2,' + v2 + '\n')
inpfile.write(ForceObject['Object'].Name + ',3,' + v3 + '\n\n')

# write outputs, both are needed by FreeCAD
inpfile.write('\n** outputs --> frd file\n')
Expand Down

0 comments on commit 957f723

Please sign in to comment.