| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
|
|
| import FreeCAD |
|
|
| import Fem |
| import ObjectsFem |
|
|
| from . import manager |
| from .manager import get_meshname |
| from .manager import init_doc |
|
|
|
|
| def get_information(): |
| return { |
| "name": "Flexural Buckling", |
| "meshtype": "solid", |
| "meshelement": "Hexa8", |
| "constraints": ["fixed", "force"], |
| "solvers": ["ccxtools"], |
| "material": "solid", |
| "equations": ["buckling"], |
| } |
|
|
|
|
| def get_explanation(header=""): |
| return ( |
| header |
| + """ |
| |
| To run the example from Python console use: |
| from femexamples.ccx_buckling_flexuralbuckling import setup |
| setup() |
| |
| |
| See forum topic post: |
| https://forum.freecad.org/viewtopic.php?f=18&t=20217&start=80#p488666 |
| |
| This example is based on a CalculiX verification example. |
| http://www.feacluster.com/CalculiX/ccx_2.13/doc/ccx/input_deck_viewer.php?input_deck=beam8b.inp |
| |
| """ |
| ) |
|
|
|
|
| def setup(doc=None, solvertype="ccxtools"): |
|
|
| |
| if doc is None: |
| doc = init_doc() |
|
|
| |
| |
| manager.add_explanation_obj(doc, get_explanation(manager.get_header(get_information()))) |
|
|
| |
| geom_obj = doc.addObject("Part::Box", "Beam") |
| geom_obj.Length = 1 |
| geom_obj.Width = 1.5 |
| geom_obj.Height = 8 |
| doc.recompute() |
| if FreeCAD.GuiUp: |
| geom_obj.ViewObject.Document.activeView().viewAxonometric() |
| geom_obj.ViewObject.Document.activeView().fitAll() |
|
|
| |
| analysis = ObjectsFem.makeAnalysis(doc, "Analysis") |
|
|
| |
| if solvertype == "ccxtools": |
| solver_obj = ObjectsFem.makeSolverCalculiXCcxTools(doc, "CalculiXCcxTools") |
| solver_obj.WorkingDir = "" |
| else: |
| FreeCAD.Console.PrintWarning( |
| "Unknown or unsupported solver type: {}. " |
| "No solver object was created.\n".format(solvertype) |
| ) |
| if solvertype == "ccxtools": |
| solver_obj.SplitInputWriter = False |
| solver_obj.AnalysisType = "buckling" |
| solver_obj.BucklingFactors = 10 |
| solver_obj.GeometricalNonlinearity = "linear" |
| solver_obj.ThermoMechSteadyState = False |
| solver_obj.MatrixSolverType = "default" |
| solver_obj.IterationsControlParameterTimeUse = False |
| analysis.addObject(solver_obj) |
|
|
| |
| material_obj = ObjectsFem.makeMaterialSolid(doc, "MechanicalMaterial") |
| mat = material_obj.Material |
| mat["Name"] = "CalculiX-Steel" |
| mat["YoungsModulus"] = "210000 MPa" |
| mat["PoissonRatio"] = "0.30" |
| material_obj.Material = mat |
| analysis.addObject(material_obj) |
|
|
| |
| con_fixed = ObjectsFem.makeConstraintFixed(doc, "ConstraintFixed") |
| con_fixed.References = [(geom_obj, "Face5")] |
| analysis.addObject(con_fixed) |
|
|
| |
| con_force = ObjectsFem.makeConstraintForce(doc, "ConstraintForce") |
| con_force.References = [(geom_obj, "Face6")] |
| con_force.Force = "21 N" |
| con_force.Reversed = True |
| analysis.addObject(con_force) |
|
|
| |
| from .meshes.mesh_flexural_buckling import create_nodes, create_elements |
|
|
| fem_mesh = Fem.FemMesh() |
| control = create_nodes(fem_mesh) |
| if not control: |
| FreeCAD.Console.PrintError("Error on creating nodes.\n") |
| control = create_elements(fem_mesh) |
| if not control: |
| FreeCAD.Console.PrintError("Error on creating elements.\n") |
| femmesh_obj = analysis.addObject(ObjectsFem.makeMeshGmsh(doc, get_meshname()))[0] |
| femmesh_obj.FemMesh = fem_mesh |
| femmesh_obj.Shape = geom_obj |
|
|
| doc.recompute() |
| return doc |
|
|