Skip to content

Fem: Add cylindrical shell example #99

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: femexamples
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/Mod/Fem/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ SET(FemExamples_SRCS
femexamples/equation_electrostatics_capacitance_two_balls.py
femexamples/equation_electrostatics_electricforce_elmer_nongui6.py
femexamples/frequency_beamsimple.py
femexamples/frequency_cylindricalshell.py
femexamples/manager.py
femexamples/material_multiple_bendingbeam_fiveboxes.py
femexamples/material_multiple_bendingbeam_fivefaces.py
Expand Down Expand Up @@ -115,6 +116,7 @@ SET(FemExampleMeshes_SRCS
femexamples/meshes/mesh_constraint_tie_tetra10.py
femexamples/meshes/mesh_contact_box_halfcylinder_tetra10.py
femexamples/meshes/mesh_contact_tube_tube_tria3.py
femexamples/meshes/mesh_cylindricalshell_quad4.py
femexamples/meshes/mesh_eigenvalue_of_elastic_beam_tetra10.py
femexamples/meshes/mesh_electricforce_elmer_nongui6_tetra10.py
femexamples/meshes/mesh_flexural_buckling.py
Expand Down
166 changes: 166 additions & 0 deletions src/Mod/Fem/femexamples/frequency_cylindricalshell.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,166 @@
# ***************************************************************************
# * Copyright (c) 2022 Bernd Hahnebach <bernd@bimstatik.org> *
# * *
# * This file is part of the FreeCAD CAx development system. *
# * *
# * This program is free software; you can redistribute it and/or modify *
# * it under the terms of the GNU Lesser General Public License (LGPL) *
# * as published by the Free Software Foundation; either version 2 of *
# * the License, or (at your option) any later version. *
# * for detail see the LICENCE text file. *
# * *
# * This program is distributed in the hope that it will be useful, *
# * but WITHOUT ANY WARRANTY; without even the implied warranty of *
# * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
# * GNU Library General Public License for more details. *
# * *
# * You should have received a copy of the GNU Library General Public *
# * License along with this program; if not, write to the Free Software *
# * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 *
# * USA *
# * *
# ***************************************************************************

import FreeCAD

import Draft

import Fem
import ObjectsFem

from . import manager
from .manager import get_meshname
from .manager import init_doc


def get_information():
return {
"name": "Frequency Analysis Cylindrical Shell",
"meshtype": "face",
"meshelement": "Quad4",
"constraints": ["fixed"],
"solvers": ["calculix", "ccxtools"],
"material": "solid",
"equation": "frequency",
}


def get_explanation(header=""):
return (
header
+ """

To run the example from Python console use:
from femexamples.frequency_cylindrical_shell import setup
setup()


See forum topic post:
https://forum.freecadweb.org/viewtopic.php?f=18&t=65382#p564156
frequency analysis for cylindrical shell

"""
)


def setup(doc=None, solvertype="ccxtools"):

# init FreeCAD document
if doc is None:
doc = init_doc()

# explanation object
# just keep the following line and change text string in get_explanation method
manager.add_explanation_obj(
doc, get_explanation(manager.get_header(get_information()))
)

# geometric object
# create cylinder
cyl_obj = doc.addObject("Part::Cylinder", "Cylinder")
cyl_obj.Radius = 5000
cyl_obj.Height = 5000
doc.recompute()
if FreeCAD.GuiUp:
cyl_obj.ViewObject.Document.activeView().viewAxonometric()
cyl_obj.ViewObject.Document.activeView().fitAll()

# create cylindrical shell
Draft.downgrade(cyl_obj, delete=True)
doc.removeObject("Face001")
doc.removeObject("Face002")
doc.recompute()

# analysis
analysis = ObjectsFem.makeAnalysis(doc, "Analysis")

# solver
if solvertype == "calculix":
solver_obj = ObjectsFem.makeSolverCalculix(doc, "SolverCalculiX")
elif solvertype == "ccxtools":
solver_obj = ObjectsFem.makeSolverCalculixCcxTools(doc, "CalculiXccxTools")
solver_obj.WorkingDir = u""
else:
FreeCAD.Console.PrintWarning(
"Not known or not supported solver type: {}. "
"No solver object was created.\n".format(solvertype)
)
if solvertype == "calculix" or solvertype == "ccxtools":
solver_obj.SplitInputWriter = False
solver_obj.AnalysisType = "frequency"
solver_obj.GeometricalNonlinearity = "linear"
solver_obj.ThermoMechSteadyState = False
solver_obj.MatrixSolverType = "default"
solver_obj.IterationsControlParameterTimeUse = False
solver_obj.EigenmodesCount = 10
solver_obj.EigenmodeHighLimit = 1000000.0
solver_obj.EigenmodeLowLimit = 0.01
analysis.addObject(solver_obj)

# material
material_obj = analysis.addObject(
ObjectsFem.makeMaterialSolid(doc, "MechanicalMaterial")
)[0]
mat = material_obj.Material
mat["Name"] = "Steel-Generic"
mat["YoungsModulus"] = "210 GPa"
mat["PoissonRatio"] = "0.30"
mat["Density"] = "7900 kg/m^3"
material_obj.Material = mat
analysis.addObject(material_obj)

# constraint displacement xyz
con_disp_xyz = ObjectsFem.makeConstraintDisplacement(doc, "Fix_Z")
con_disp_xyz.References = [(doc.Face, "Edge2")]
con_disp_xyz.xFix = False
con_disp_xyz.xFree = True
con_disp_xyz.xDisplacement = 0.0
con_disp_xyz.yFix = False
con_disp_xyz.yFree = True
con_disp_xyz.yDisplacement = 0.0
con_disp_xyz.zFix = True
con_disp_xyz.zFree = False
con_disp_xyz.zDisplacement = 0.0
analysis.addObject(con_disp_xyz)

# add thickness
geo_thickness = ObjectsFem.makeElementGeometry2D(doc, 10)
analysis.addObject(geo_thickness)

# mesh
from .meshes.mesh_cylindricalshell_quad4 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.Part = doc.Face
femmesh_obj.SecondOrderLinear = False
femmesh_obj.CharacteristicLengthMax = "250.0 mm"

doc.recompute()
return doc
Loading