FEM: examples, code formating and code improvements
This commit is contained in:
@@ -29,7 +29,7 @@ setup()
|
||||
|
||||
"""
|
||||
|
||||
import FreeCAD
|
||||
# import FreeCAD
|
||||
|
||||
import ObjectsFem
|
||||
|
||||
@@ -38,49 +38,40 @@ from .boxanalysis_static import setup_base
|
||||
mesh_name = "Mesh" # needs to be Mesh to work with unit tests
|
||||
|
||||
|
||||
def init_doc(doc=None):
|
||||
if doc is None:
|
||||
doc = FreeCAD.newDocument()
|
||||
return doc
|
||||
|
||||
|
||||
def get_information():
|
||||
info = {"name": "Box Analysis Frequency",
|
||||
"meshtype": "solid",
|
||||
"meshelement": "Tet10",
|
||||
"constraints": [],
|
||||
"solvers": ["calculix"],
|
||||
"material": "solid",
|
||||
"equation": "frequency"
|
||||
}
|
||||
return info
|
||||
return {
|
||||
"name": "Box Analysis Frequency",
|
||||
"meshtype": "solid",
|
||||
"meshelement": "Tet10",
|
||||
"constraints": [],
|
||||
"solvers": ["calculix"],
|
||||
"material": "solid",
|
||||
"equation": "frequency"
|
||||
}
|
||||
|
||||
|
||||
def setup(doc=None, solvertype="ccxtools"):
|
||||
# setup box frequency, change solver attributes
|
||||
|
||||
# setup box frequency, change solver attributes
|
||||
doc = setup_base(doc, solvertype)
|
||||
analysis = doc.Analysis
|
||||
|
||||
# solver
|
||||
if solvertype == "calculix":
|
||||
solver_object = analysis.addObject(
|
||||
ObjectsFem.makeSolverCalculix(doc, "SolverCalculiX")
|
||||
)[0]
|
||||
solver_obj = ObjectsFem.makeSolverCalculix(doc, "SolverCalculiX")
|
||||
elif solvertype == "ccxtools":
|
||||
solver_object = analysis.addObject(
|
||||
ObjectsFem.makeSolverCalculixCcxTools(doc, "CalculiXccxTools")
|
||||
)[0]
|
||||
solver_object.WorkingDir = u""
|
||||
solver_obj = ObjectsFem.makeSolverCalculixCcxTools(doc, "CalculiXccxTools")
|
||||
solver_obj.WorkingDir = u""
|
||||
if solvertype == "calculix" or solvertype == "ccxtools":
|
||||
solver_object.AnalysisType = "frequency"
|
||||
solver_object.GeometricalNonlinearity = "linear"
|
||||
solver_object.ThermoMechSteadyState = False
|
||||
solver_object.MatrixSolverType = "default"
|
||||
solver_object.IterationsControlParameterTimeUse = False
|
||||
solver_object.EigenmodesCount = 10
|
||||
solver_object.EigenmodeHighLimit = 1000000.0
|
||||
solver_object.EigenmodeLowLimit = 0.01
|
||||
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)
|
||||
|
||||
doc.recompute()
|
||||
return doc
|
||||
|
||||
@@ -44,24 +44,26 @@ def init_doc(doc=None):
|
||||
|
||||
|
||||
def get_information():
|
||||
info = {"name": "Box Analysis Static",
|
||||
"meshtype": "solid",
|
||||
"meshelement": "Tet10",
|
||||
"constraints": ["fixed", "force", "pressure"],
|
||||
"solvers": ["calculix", "elmer"],
|
||||
"material": "solid",
|
||||
"equation": "mechanical"
|
||||
}
|
||||
return info
|
||||
return {
|
||||
"name": "Box Analysis Static",
|
||||
"meshtype": "solid",
|
||||
"meshelement": "Tet10",
|
||||
"constraints": ["fixed", "force", "pressure"],
|
||||
"solvers": ["calculix", "elmer"],
|
||||
"material": "solid",
|
||||
"equation": "mechanical"
|
||||
}
|
||||
|
||||
|
||||
def setup_base(doc=None, solvertype="ccxtools"):
|
||||
# setup box base model
|
||||
|
||||
# init FreeCAD document
|
||||
if doc is None:
|
||||
doc = init_doc()
|
||||
|
||||
# geometry object
|
||||
# geometric objects
|
||||
# object name is important in this base setup method
|
||||
# all module which use this base setup, use the object name to find the object
|
||||
geom_obj = doc.addObject("Part::Box", "Box")
|
||||
geom_obj.Height = geom_obj.Width = geom_obj.Length = 10
|
||||
doc.recompute()
|
||||
@@ -74,19 +76,17 @@ def setup_base(doc=None, solvertype="ccxtools"):
|
||||
analysis = ObjectsFem.makeAnalysis(doc, "Analysis")
|
||||
|
||||
# material
|
||||
material_object = analysis.addObject(
|
||||
ObjectsFem.makeMaterialSolid(doc, "MechanicalMaterial")
|
||||
)[0]
|
||||
mat = material_object.Material
|
||||
material_obj = ObjectsFem.makeMaterialSolid(doc, "MechanicalMaterial")
|
||||
mat = material_obj.Material
|
||||
mat["Name"] = "Steel-Generic"
|
||||
mat["YoungsModulus"] = "200000 MPa"
|
||||
mat["PoissonRatio"] = "0.30"
|
||||
mat["Density"] = "7900 kg/m^3"
|
||||
material_object.Material = mat
|
||||
material_obj.Material = mat
|
||||
analysis.addObject(material_obj)
|
||||
|
||||
# mesh
|
||||
from .meshes.mesh_boxanalysis_tetra10 import create_nodes, create_elements
|
||||
|
||||
fem_mesh = Fem.FemMesh()
|
||||
control = create_nodes(fem_mesh)
|
||||
if not control:
|
||||
@@ -105,62 +105,54 @@ def setup_base(doc=None, solvertype="ccxtools"):
|
||||
|
||||
|
||||
def setup(doc=None, solvertype="ccxtools"):
|
||||
# setup box static, add a fixed, force and a pressure constraint
|
||||
|
||||
# setup box static, add a fixed, force and a pressure constraint
|
||||
doc = setup_base(doc, solvertype)
|
||||
geom_obj = doc.Box
|
||||
analysis = doc.Analysis
|
||||
|
||||
# solver
|
||||
if solvertype == "calculix":
|
||||
solver_object = analysis.addObject(
|
||||
ObjectsFem.makeSolverCalculix(doc, "SolverCalculiX")
|
||||
)[0]
|
||||
solver_obj = ObjectsFem.makeSolverCalculix(doc, "SolverCalculiX")
|
||||
elif solvertype == "ccxtools":
|
||||
solver_object = analysis.addObject(
|
||||
ObjectsFem.makeSolverCalculixCcxTools(doc, "CalculiXccxTools")
|
||||
)[0]
|
||||
solver_object.WorkingDir = u""
|
||||
solver_obj = ObjectsFem.makeSolverCalculixCcxTools(doc, "CalculiXccxTools")
|
||||
solver_obj.WorkingDir = u""
|
||||
elif solvertype == "elmer":
|
||||
solver_object = analysis.addObject(
|
||||
ObjectsFem.makeSolverElmer(doc, "SolverElmer")
|
||||
)[0]
|
||||
ObjectsFem.makeEquationElasticity(doc, solver_object)
|
||||
solver_obj = ObjectsFem.makeSolverElmer(doc, "SolverElmer")
|
||||
ObjectsFem.makeEquationElasticity(doc, solver_obj)
|
||||
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_object.SplitInputWriter = False
|
||||
solver_object.AnalysisType = "static"
|
||||
solver_object.GeometricalNonlinearity = "linear"
|
||||
solver_object.ThermoMechSteadyState = False
|
||||
solver_object.MatrixSolverType = "default"
|
||||
solver_object.IterationsControlParameterTimeUse = False
|
||||
solver_obj.SplitInputWriter = False
|
||||
solver_obj.AnalysisType = "static"
|
||||
solver_obj.GeometricalNonlinearity = "linear"
|
||||
solver_obj.ThermoMechSteadyState = False
|
||||
solver_obj.MatrixSolverType = "default"
|
||||
solver_obj.IterationsControlParameterTimeUse = False
|
||||
analysis.addObject(solver_obj)
|
||||
|
||||
# fixed_constraint
|
||||
fixed_constraint = analysis.addObject(
|
||||
ObjectsFem.makeConstraintFixed(doc, name="FemConstraintFixed")
|
||||
)[0]
|
||||
fixed_constraint.References = [(geom_obj, "Face1")]
|
||||
# constraint fixed
|
||||
con_fixed = ObjectsFem.makeConstraintFixed(doc, "FemConstraintFixed")
|
||||
con_fixed.References = [(geom_obj, "Face1")]
|
||||
analysis.addObject(con_fixed)
|
||||
|
||||
# force_constraint
|
||||
force_constraint = analysis.addObject(
|
||||
ObjectsFem.makeConstraintForce(doc, name="FemConstraintForce")
|
||||
)[0]
|
||||
force_constraint.References = [(geom_obj, "Face6")]
|
||||
force_constraint.Force = 40000.0
|
||||
force_constraint.Direction = (geom_obj, ["Edge5"])
|
||||
force_constraint.Reversed = True
|
||||
# constraint force
|
||||
con_force = ObjectsFem.makeConstraintForce(doc, "FemConstraintForce")
|
||||
con_force.References = [(geom_obj, "Face6")]
|
||||
con_force.Force = 40000.0
|
||||
con_force.Direction = (geom_obj, ["Edge5"])
|
||||
con_force.Reversed = True
|
||||
analysis.addObject(con_force)
|
||||
|
||||
# pressure_constraint
|
||||
pressure_constraint = analysis.addObject(
|
||||
ObjectsFem.makeConstraintPressure(doc, name="FemConstraintPressure")
|
||||
)[0]
|
||||
pressure_constraint.References = [(geom_obj, "Face2")]
|
||||
pressure_constraint.Pressure = 1000.0
|
||||
pressure_constraint.Reversed = False
|
||||
# constraint pressure
|
||||
con_pressure = ObjectsFem.makeConstraintPressure(doc, name="FemConstraintPressure")
|
||||
con_pressure.References = [(geom_obj, "Face2")]
|
||||
con_pressure.Pressure = 1000.0
|
||||
con_pressure.Reversed = False
|
||||
analysis.addObject(con_pressure)
|
||||
|
||||
doc.recompute()
|
||||
return doc
|
||||
|
||||
@@ -30,7 +30,7 @@ setup()
|
||||
"""
|
||||
|
||||
# Forum discussion
|
||||
# https://forum.freecadweb.org/viewtopic.php?f=18&t=20217&start=90
|
||||
# https://forum.freecadweb.org/viewtopic.php?f=18&t=20217&start=80#p488666
|
||||
|
||||
# This example is based on Calculix own verification example.
|
||||
# http://www.feacluster.com/CalculiX/ccx_2.13/doc/ccx/input_deck_viewer.php?input_deck=beam8b.inp
|
||||
@@ -42,26 +42,6 @@ import ObjectsFem
|
||||
|
||||
mesh_name = "Mesh" # needs to be Mesh to work with unit tests
|
||||
|
||||
# Example geometry input
|
||||
example_b = 1.5 # Width
|
||||
example_h = 8 # Height
|
||||
example_l = 1 # Length
|
||||
|
||||
|
||||
def addbox(
|
||||
docxx, height, width, length,
|
||||
x, y, z, box_name):
|
||||
|
||||
box_obj = docxx.addObject("Part::Box", box_name)
|
||||
box_obj.Height = height
|
||||
box_obj.Width = width
|
||||
box_obj.Length = length
|
||||
box_obj.Placement = FreeCAD.Placement(
|
||||
FreeCAD.Vector(x, y, z),
|
||||
FreeCAD.Rotation(0, 0, 0)
|
||||
)
|
||||
return box_obj
|
||||
|
||||
|
||||
def init_doc(doc=None):
|
||||
if doc is None:
|
||||
@@ -70,25 +50,28 @@ def init_doc(doc=None):
|
||||
|
||||
|
||||
def get_information():
|
||||
info = {
|
||||
"name": "Flexural Buckling Analysis",
|
||||
return {
|
||||
"name": "Flexural Buckling",
|
||||
"meshtype": "solid",
|
||||
"meshelement": "Hexa8",
|
||||
"constraints": ["force", "displacement"],
|
||||
"constraints": ["fixed", "force"],
|
||||
"solvers": ["calculix"],
|
||||
"material": "solid",
|
||||
"equation": "mechanical"
|
||||
"equation": "buckling"
|
||||
}
|
||||
return info
|
||||
|
||||
|
||||
def setup_base(doc=None, solvertype="ccxtools"):
|
||||
def setup(doc=None, solvertype="ccxtools"):
|
||||
|
||||
# setup box base model
|
||||
# init FreeCAD document
|
||||
if doc is None:
|
||||
doc = init_doc()
|
||||
|
||||
geom_obj = addbox(doc, example_h, example_b, example_l, 0, 0, 0, "beam")
|
||||
# geometric object
|
||||
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()
|
||||
@@ -97,18 +80,51 @@ def setup_base(doc=None, solvertype="ccxtools"):
|
||||
# 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 = "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
|
||||
material_object = analysis.addObject(ObjectsFem.makeMaterialSolid(doc, "MechanicalMaterial"))[0]
|
||||
mat = material_object.Material
|
||||
material_obj = ObjectsFem.makeMaterialSolid(doc, "MechanicalMaterial")
|
||||
mat = material_obj.Material
|
||||
mat["Name"] = "CalculiX-Steel"
|
||||
mat["YoungsModulus"] = "210000 MPa"
|
||||
mat["PoissonRatio"] = "0.30"
|
||||
mat["Density"] = "7900 kg/m^3"
|
||||
material_object.Material = mat
|
||||
material_obj.Material = mat
|
||||
analysis.addObject(material_obj)
|
||||
|
||||
# constraint fixed
|
||||
# FIXME: wrong obj name, fix unit test as well
|
||||
con_fixed = ObjectsFem.makeConstraintFixed(doc, "FemConstraintDisplacement")
|
||||
con_fixed.References = [(geom_obj, "Face5")]
|
||||
analysis.addObject(con_fixed)
|
||||
|
||||
# constraint force
|
||||
con_force = ObjectsFem.makeConstraintForce(doc, "FemConstraintForce")
|
||||
con_force.References = [(geom_obj, "Face6")]
|
||||
con_force.Force = 21
|
||||
con_force.Reversed = True
|
||||
analysis.addObject(con_force)
|
||||
|
||||
# mesh
|
||||
from .meshes.mesh_flexural_buckling import create_nodes, create_elements
|
||||
|
||||
fem_mesh = Fem.FemMesh()
|
||||
control = create_nodes(fem_mesh)
|
||||
if not control:
|
||||
@@ -118,55 +134,7 @@ def setup_base(doc=None, solvertype="ccxtools"):
|
||||
FreeCAD.Console.PrintError("Error on creating elements.\n")
|
||||
femmesh_obj = analysis.addObject(ObjectsFem.makeMeshGmsh(doc, mesh_name))[0]
|
||||
femmesh_obj.FemMesh = fem_mesh
|
||||
femmesh_obj.Part = doc.beam
|
||||
|
||||
return doc
|
||||
|
||||
|
||||
def setup(doc=None, solvertype="ccxtools"):
|
||||
# setup
|
||||
|
||||
doc = setup_base(doc, solvertype)
|
||||
|
||||
analysis = doc.Analysis
|
||||
|
||||
# solver,
|
||||
if solvertype == "calculix":
|
||||
solver_object = analysis.addObject(
|
||||
ObjectsFem.makeSolverCalculix(doc, "SolverCalculiX")
|
||||
)[0]
|
||||
elif solvertype == "ccxtools":
|
||||
solver_object = analysis.addObject(
|
||||
ObjectsFem.makeSolverCalculixCcxTools(doc, "CalculiXccxTools")
|
||||
)[0]
|
||||
solver_object.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_object.SplitInputWriter = False
|
||||
solver_object.AnalysisType = "buckling"
|
||||
solver_object.BucklingFactors = 10
|
||||
solver_object.GeometricalNonlinearity = "linear"
|
||||
solver_object.ThermoMechSteadyState = False
|
||||
solver_object.MatrixSolverType = "default"
|
||||
solver_object.IterationsControlParameterTimeUse = False
|
||||
|
||||
## displacement constraint
|
||||
displacement_constraint = ObjectsFem.makeConstraintFixed(doc, "FemConstraintDisplacement")
|
||||
displacement_constraint.References = [(doc.beam, "Face5")]
|
||||
analysis.addObject(displacement_constraint)
|
||||
|
||||
## force_constraint
|
||||
force_constraint = ObjectsFem.makeConstraintForce(doc, "FemConstraintForce")
|
||||
force_constraint.References = [(doc.beam, "Face6")]
|
||||
force_constraint.Force = 21
|
||||
force_constraint.Reversed = True
|
||||
analysis.addObject(force_constraint)
|
||||
femmesh_obj.Part = geom_obj
|
||||
|
||||
doc.recompute()
|
||||
|
||||
return doc
|
||||
|
||||
@@ -44,30 +44,30 @@ def init_doc(doc=None):
|
||||
|
||||
|
||||
def get_information():
|
||||
info = {"name": "CCX cantilever face load",
|
||||
"meshtype": "solid",
|
||||
"meshelement": "Tet10",
|
||||
"constraints": ["fixed", "force"],
|
||||
"solvers": ["calculix", "z88", "elmer"],
|
||||
"material": "solid",
|
||||
"equation": "mechanical"
|
||||
}
|
||||
return info
|
||||
return {
|
||||
"name": "CCX cantilever face load",
|
||||
"meshtype": "solid",
|
||||
"meshelement": "Tet10",
|
||||
"constraints": ["fixed", "force"],
|
||||
"solvers": ["calculix", "z88", "elmer"],
|
||||
"material": "solid",
|
||||
"equation": "mechanical"
|
||||
}
|
||||
|
||||
|
||||
def setup_cantileverbase(doc=None, solvertype="ccxtools"):
|
||||
# setup CalculiX cantilever base model
|
||||
|
||||
# init FreeCAD document
|
||||
if doc is None:
|
||||
doc = init_doc()
|
||||
|
||||
# geometry object
|
||||
# name is important because the other method in this module use obj name
|
||||
# geometric object
|
||||
# object name is important in this base setup method
|
||||
# all module which use this base setup, use the object name to find the object
|
||||
geom_obj = doc.addObject("Part::Box", "Box")
|
||||
geom_obj.Height = geom_obj.Width = 1000
|
||||
geom_obj.Length = 8000
|
||||
doc.recompute()
|
||||
|
||||
if FreeCAD.GuiUp:
|
||||
geom_obj.ViewObject.Document.activeView().viewAxonometric()
|
||||
geom_obj.ViewObject.Document.activeView().fitAll()
|
||||
@@ -77,50 +77,43 @@ def setup_cantileverbase(doc=None, solvertype="ccxtools"):
|
||||
|
||||
# solver
|
||||
if solvertype == "calculix":
|
||||
solver_object = analysis.addObject(
|
||||
ObjectsFem.makeSolverCalculix(doc, "SolverCalculiX")
|
||||
)[0]
|
||||
solver_obj = ObjectsFem.makeSolverCalculix(doc, "SolverCalculiX")
|
||||
elif solvertype == "ccxtools":
|
||||
solver_object = analysis.addObject(
|
||||
ObjectsFem.makeSolverCalculixCcxTools(doc, "CalculiXccxTools")
|
||||
)[0]
|
||||
solver_object.WorkingDir = u""
|
||||
solver_obj = ObjectsFem.makeSolverCalculixCcxTools(doc, "CalculiXccxTools")
|
||||
solver_obj.WorkingDir = u""
|
||||
elif solvertype == "elmer":
|
||||
solver_object = analysis.addObject(
|
||||
ObjectsFem.makeSolverElmer(doc, "SolverElmer")
|
||||
)[0]
|
||||
ObjectsFem.makeEquationElasticity(doc, solver_object)
|
||||
solver_obj = ObjectsFem.makeSolverElmer(doc, "SolverElmer")
|
||||
ObjectsFem.makeEquationElasticity(doc, solver_obj)
|
||||
elif solvertype == "z88":
|
||||
analysis.addObject(ObjectsFem.makeSolverZ88(doc, "SolverZ88"))
|
||||
solver_obj = ObjectsFem.makeSolverZ88(doc, "SolverZ88")
|
||||
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_object.SplitInputWriter = False
|
||||
solver_object.AnalysisType = "static"
|
||||
solver_object.GeometricalNonlinearity = "linear"
|
||||
solver_object.ThermoMechSteadyState = False
|
||||
solver_object.MatrixSolverType = "default"
|
||||
solver_object.IterationsControlParameterTimeUse = False
|
||||
solver_obj.SplitInputWriter = False
|
||||
solver_obj.AnalysisType = "static"
|
||||
solver_obj.GeometricalNonlinearity = "linear"
|
||||
solver_obj.ThermoMechSteadyState = False
|
||||
solver_obj.MatrixSolverType = "default"
|
||||
solver_obj.IterationsControlParameterTimeUse = False
|
||||
analysis.addObject(solver_obj)
|
||||
|
||||
# material
|
||||
material_object = analysis.addObject(
|
||||
ObjectsFem.makeMaterialSolid(doc, "FemMaterial")
|
||||
)[0]
|
||||
mat = material_object.Material
|
||||
material_obj = ObjectsFem.makeMaterialSolid(doc, "FemMaterial")
|
||||
mat = material_obj.Material
|
||||
mat["Name"] = "CalculiX-Steel"
|
||||
mat["YoungsModulus"] = "210000 MPa"
|
||||
mat["PoissonRatio"] = "0.30"
|
||||
mat["Density"] = "7900 kg/m^3"
|
||||
material_object.Material = mat
|
||||
material_obj.Material = mat
|
||||
analysis.addObject(material_obj)
|
||||
|
||||
# fixed_constraint
|
||||
fixed_constraint = analysis.addObject(
|
||||
ObjectsFem.makeConstraintFixed(doc, name="ConstraintFixed")
|
||||
)[0]
|
||||
fixed_constraint.References = [(geom_obj, "Face1")]
|
||||
# constraint fixed
|
||||
con_fixed = ObjectsFem.makeConstraintFixed(doc, "ConstraintFixed")
|
||||
con_fixed.References = [(geom_obj, "Face1")]
|
||||
analysis.addObject(con_fixed)
|
||||
|
||||
# mesh
|
||||
from .meshes.mesh_canticcx_tetra10 import create_nodes, create_elements
|
||||
@@ -131,9 +124,7 @@ def setup_cantileverbase(doc=None, solvertype="ccxtools"):
|
||||
control = create_elements(fem_mesh)
|
||||
if not control:
|
||||
FreeCAD.Console.PrintError("Error on creating elements.\n")
|
||||
femmesh_obj = analysis.addObject(
|
||||
ObjectsFem.makeMeshGmsh(doc, mesh_name)
|
||||
)[0]
|
||||
femmesh_obj = analysis.addObject(ObjectsFem.makeMeshGmsh(doc, mesh_name))[0]
|
||||
femmesh_obj.FemMesh = fem_mesh
|
||||
femmesh_obj.Part = geom_obj
|
||||
femmesh_obj.SecondOrderLinear = False
|
||||
@@ -146,15 +137,16 @@ def setup(doc=None, solvertype="ccxtools"):
|
||||
# setup CalculiX cantilever, apply 9 MN on surface of front end face
|
||||
|
||||
doc = setup_cantileverbase(doc, solvertype)
|
||||
analysis = doc.Analysis
|
||||
geom_obj = doc.Box
|
||||
|
||||
# force_constraint
|
||||
force_constraint = doc.Analysis.addObject(
|
||||
ObjectsFem.makeConstraintForce(doc, name="ConstraintForce")
|
||||
)[0]
|
||||
force_constraint.References = [(doc.Box, "Face2")]
|
||||
force_constraint.Force = 9000000.0
|
||||
force_constraint.Direction = (doc.Box, ["Edge5"])
|
||||
force_constraint.Reversed = True
|
||||
# constraint force
|
||||
con_force = ObjectsFem.makeConstraintForce(doc, "ConstraintForce")
|
||||
con_force.References = [(geom_obj, "Face2")]
|
||||
con_force.Force = 9000000.0
|
||||
con_force.Direction = (geom_obj, ["Edge5"])
|
||||
con_force.Reversed = True
|
||||
analysis.addObject(con_force)
|
||||
|
||||
doc.recompute()
|
||||
return doc
|
||||
|
||||
@@ -33,31 +33,26 @@ import FreeCAD
|
||||
|
||||
import Fem
|
||||
|
||||
from . import ccx_cantilever_faceload as faceload
|
||||
from .ccx_cantilever_faceload import setup as setup_with_faceload
|
||||
|
||||
mesh_name = "Mesh" # needs to be Mesh to work with unit tests
|
||||
|
||||
|
||||
def init_doc(doc=None):
|
||||
if doc is None:
|
||||
doc = FreeCAD.newDocument()
|
||||
return doc
|
||||
|
||||
|
||||
def get_information():
|
||||
info = {"name": "CCX cantilever hexa20 face load",
|
||||
"meshtype": "solid",
|
||||
"meshelement": "Hexa20",
|
||||
"constraints": ["fixed", "force"],
|
||||
"solvers": ["calculix", "z88", "elmer"],
|
||||
"material": "solid",
|
||||
"equation": "mechanical"
|
||||
}
|
||||
return info
|
||||
return {
|
||||
"name": "CCX cantilever hexa20 face load",
|
||||
"meshtype": "solid",
|
||||
"meshelement": "Hexa20",
|
||||
"constraints": ["fixed", "force"],
|
||||
"solvers": ["calculix", "z88", "elmer"],
|
||||
"material": "solid",
|
||||
"equation": "mechanical"
|
||||
}
|
||||
|
||||
|
||||
def setup(doc=None, solvertype="ccxtools"):
|
||||
doc = faceload.setup(doc, solvertype)
|
||||
|
||||
doc = setup_with_faceload(doc, solvertype)
|
||||
|
||||
# load the hexa20 mesh
|
||||
from .meshes.mesh_canticcx_hexa20 import create_nodes, create_elements
|
||||
|
||||
@@ -29,7 +29,7 @@ setup()
|
||||
|
||||
"""
|
||||
|
||||
import FreeCAD
|
||||
# import FreeCAD
|
||||
|
||||
import ObjectsFem
|
||||
|
||||
@@ -38,43 +38,37 @@ from .ccx_cantilever_faceload import setup_cantileverbase
|
||||
mesh_name = "Mesh" # needs to be Mesh to work with unit tests
|
||||
|
||||
|
||||
def init_doc(doc=None):
|
||||
if doc is None:
|
||||
doc = FreeCAD.newDocument()
|
||||
return doc
|
||||
|
||||
|
||||
def get_information():
|
||||
info = {"name": "CCX cantilever node load",
|
||||
"meshtype": "solid",
|
||||
"meshelement": "Tet10",
|
||||
"constraints": ["fixed", "force"],
|
||||
"solvers": ["calculix", "z88", "elmer"],
|
||||
"material": "solid",
|
||||
"equation": "mechanical"
|
||||
}
|
||||
return info
|
||||
return {
|
||||
"name": "CCX cantilever node load",
|
||||
"meshtype": "solid",
|
||||
"meshelement": "Tet10",
|
||||
"constraints": ["fixed", "force"],
|
||||
"solvers": ["calculix", "z88", "elmer"],
|
||||
"material": "solid",
|
||||
"equation": "mechanical"
|
||||
}
|
||||
|
||||
|
||||
def setup(doc=None, solvertype="ccxtools"):
|
||||
# setup CalculiX cantilever, apply 9 MN on the 4 nodes of the front end face
|
||||
|
||||
doc = setup_cantileverbase(doc, solvertype)
|
||||
analysis = doc.Analysis
|
||||
geom_obj = doc.Box
|
||||
|
||||
# force_constraint
|
||||
force_constraint = doc.Analysis.addObject(
|
||||
ObjectsFem.makeConstraintForce(doc, name="ConstraintForce")
|
||||
)[0]
|
||||
# should be possible in one tuple too
|
||||
force_constraint.References = [
|
||||
(doc.Box, "Vertex5"),
|
||||
(doc.Box, "Vertex6"),
|
||||
(doc.Box, "Vertex7"),
|
||||
(doc.Box, "Vertex8")
|
||||
# constraint force
|
||||
con_force = ObjectsFem.makeConstraintForce(doc, "ConstraintForce")
|
||||
con_force.References = [
|
||||
(geom_obj, "Vertex5"),
|
||||
(geom_obj, "Vertex6"),
|
||||
(geom_obj, "Vertex7"),
|
||||
(geom_obj, "Vertex8")
|
||||
]
|
||||
force_constraint.Force = 9000000.0
|
||||
force_constraint.Direction = (doc.Box, ["Edge5"])
|
||||
force_constraint.Reversed = True
|
||||
con_force.Force = 9000000.0
|
||||
con_force.Direction = (doc.Box, ["Edge5"])
|
||||
con_force.Reversed = True
|
||||
analysis.addObject(con_force)
|
||||
|
||||
doc.recompute()
|
||||
return doc
|
||||
|
||||
@@ -29,7 +29,7 @@ setup()
|
||||
|
||||
"""
|
||||
|
||||
import FreeCAD
|
||||
# import FreeCAD
|
||||
|
||||
import ObjectsFem
|
||||
|
||||
@@ -38,22 +38,16 @@ from .ccx_cantilever_faceload import setup_cantileverbase
|
||||
mesh_name = "Mesh" # needs to be Mesh to work with unit tests
|
||||
|
||||
|
||||
def init_doc(doc=None):
|
||||
if doc is None:
|
||||
doc = FreeCAD.newDocument()
|
||||
return doc
|
||||
|
||||
|
||||
def get_information():
|
||||
info = {"name": "CCX cantilever prescibed displacement",
|
||||
"meshtype": "solid",
|
||||
"meshelement": "Tet10",
|
||||
"constraints": ["fixed", "displacement"],
|
||||
"solvers": ["calculix", "elmer"],
|
||||
"material": "solid",
|
||||
"equation": "mechanical"
|
||||
}
|
||||
return info
|
||||
return {
|
||||
"name": "CCX cantilever prescibed displacement",
|
||||
"meshtype": "solid",
|
||||
"meshelement": "Tet10",
|
||||
"constraints": ["fixed", "displacement"],
|
||||
"solvers": ["calculix", "elmer"],
|
||||
"material": "solid",
|
||||
"equation": "mechanical"
|
||||
}
|
||||
|
||||
|
||||
def setup(doc=None, solvertype="ccxtools"):
|
||||
@@ -66,15 +60,16 @@ def setup(doc=None, solvertype="ccxtools"):
|
||||
solvertype = "z88_not_valid"
|
||||
|
||||
doc = setup_cantileverbase(doc, solvertype)
|
||||
analysis = doc.Analysis
|
||||
geom_obj = doc.Box
|
||||
|
||||
# displacement_constraint
|
||||
displacement_constraint = doc.Analysis.addObject(
|
||||
ObjectsFem.makeConstraintDisplacement(doc, name="ConstraintDisplacmentPrescribed")
|
||||
)[0]
|
||||
displacement_constraint.References = [(doc.Box, "Face2")]
|
||||
displacement_constraint.zFix = False
|
||||
displacement_constraint.zFree = False
|
||||
displacement_constraint.zDisplacement = -250.0
|
||||
# constraint displacement
|
||||
con_disp = ObjectsFem.makeConstraintDisplacement(doc, name="ConstraintDisplacmentPrescribed")
|
||||
con_disp.References = [(geom_obj, "Face2")]
|
||||
con_disp.zFix = False
|
||||
con_disp.zFree = False
|
||||
con_disp.zDisplacement = -250.0
|
||||
analysis.addObject(con_disp)
|
||||
|
||||
doc.recompute()
|
||||
return doc
|
||||
|
||||
@@ -50,25 +50,25 @@ def init_doc(doc=None):
|
||||
|
||||
|
||||
def get_information():
|
||||
info = {"name": "Constraint Constact Shell Shell",
|
||||
"meshtype": "solid",
|
||||
"meshelement": "Tria3",
|
||||
"constraints": ["fixed", "force", "contact"],
|
||||
"solvers": ["calculix"],
|
||||
"material": "solid",
|
||||
"equation": "mechanical"
|
||||
}
|
||||
return info
|
||||
return {
|
||||
"name": "Constraint Constact Shell Shell",
|
||||
"meshtype": "solid",
|
||||
"meshelement": "Tria3",
|
||||
"constraints": ["fixed", "force", "contact"],
|
||||
"solvers": ["calculix"],
|
||||
"material": "solid",
|
||||
"equation": "mechanical"
|
||||
}
|
||||
|
||||
|
||||
def setup(doc=None, solvertype="ccxtools"):
|
||||
# setup model
|
||||
|
||||
# init FreeCAD document
|
||||
if doc is None:
|
||||
doc = init_doc()
|
||||
|
||||
# geometry objects
|
||||
# TODO turn circle of upper tube to have the line on the other side
|
||||
# geometric objects
|
||||
# TODO: turn circle of upper tube to have the line on the other side
|
||||
# make a boolean fragment of them to be sure there is a mesh point on remesh
|
||||
# but as long as we do not remesh it works without the boolean fragment too
|
||||
|
||||
@@ -130,36 +130,32 @@ def setup(doc=None, solvertype="ccxtools"):
|
||||
|
||||
# solver
|
||||
if solvertype == "calculix":
|
||||
solver_object = analysis.addObject(
|
||||
ObjectsFem.makeSolverCalculix(doc, "SolverCalculiX")
|
||||
)[0]
|
||||
solver_obj = ObjectsFem.makeSolverCalculix(doc, "SolverCalculiX")
|
||||
elif solvertype == "ccxtools":
|
||||
solver_object = analysis.addObject(
|
||||
ObjectsFem.makeSolverCalculixCcxTools(doc, "CalculiXccxTools")
|
||||
)[0]
|
||||
solver_object.WorkingDir = u""
|
||||
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_object.AnalysisType = "static"
|
||||
solver_object.BeamShellResultOutput3D = True
|
||||
solver_object.GeometricalNonlinearity = "linear" # really?
|
||||
solver_obj.AnalysisType = "static"
|
||||
solver_obj.BeamShellResultOutput3D = True
|
||||
solver_obj.GeometricalNonlinearity = "linear" # really?
|
||||
# TODO iterations parameter !!!
|
||||
solver_object.ThermoMechSteadyState = False
|
||||
solver_object.MatrixSolverType = "default"
|
||||
solver_object.IterationsControlParameterTimeUse = False
|
||||
solver_object.SplitInputWriter = False
|
||||
solver_obj.ThermoMechSteadyState = False
|
||||
solver_obj.MatrixSolverType = "default"
|
||||
solver_obj.IterationsControlParameterTimeUse = False
|
||||
solver_obj.SplitInputWriter = False
|
||||
analysis.addObject(solver_obj)
|
||||
|
||||
# shell thickness
|
||||
analysis.addObject(ObjectsFem.makeElementGeometry2D(doc, 0.5, 'ShellThickness'))
|
||||
shell_thick = ObjectsFem.makeElementGeometry2D(doc, 0.5, 'ShellThickness')
|
||||
analysis.addObject(shell_thick)
|
||||
|
||||
# material
|
||||
material_obj = analysis.addObject(
|
||||
ObjectsFem.makeMaterialSolid(doc, "MechanicalMaterial")
|
||||
)[0]
|
||||
material_obj = ObjectsFem.makeMaterialSolid(doc, "MechanicalMaterial")
|
||||
mat = material_obj.Material
|
||||
mat["Name"] = "AlCuMgPb"
|
||||
mat["YoungsModulus"] = "72000 MPa"
|
||||
@@ -167,36 +163,33 @@ def setup(doc=None, solvertype="ccxtools"):
|
||||
material_obj.Material = mat
|
||||
analysis.addObject(material_obj)
|
||||
|
||||
# fixed_constraint
|
||||
fixed_constraint = analysis.addObject(
|
||||
ObjectsFem.makeConstraintFixed(doc, "ConstraintFixed")
|
||||
)[0]
|
||||
fixed_constraint.References = [
|
||||
# constraint fixed
|
||||
con_fixed = ObjectsFem.makeConstraintFixed(doc, "ConstraintFixed")
|
||||
con_fixed.References = [
|
||||
(lower_tube, "Edge2"),
|
||||
(upper_tube, "Edge3"),
|
||||
]
|
||||
analysis.addObject(con_fixed)
|
||||
|
||||
# force_constraint
|
||||
force_constraint = doc.Analysis.addObject(
|
||||
ObjectsFem.makeConstraintForce(doc, name="ConstraintForce")
|
||||
)[0]
|
||||
# constraint force
|
||||
con_force = ObjectsFem.makeConstraintForce(doc, "ConstraintForce")
|
||||
# TODO use point of tube boolean fragment
|
||||
force_constraint.References = [(force_point, "Vertex1")]
|
||||
force_constraint.Force = 5000.0
|
||||
force_constraint.Direction = (load_line, ["Edge1"])
|
||||
force_constraint.Reversed = True
|
||||
con_force.References = [(force_point, "Vertex1")]
|
||||
con_force.Force = 5000.0
|
||||
con_force.Direction = (load_line, ["Edge1"])
|
||||
con_force.Reversed = True
|
||||
analysis.addObject(con_force)
|
||||
|
||||
# contact constraint
|
||||
contact_constraint = doc.Analysis.addObject(
|
||||
ObjectsFem.makeConstraintContact(doc, name="ConstraintContact")
|
||||
)[0]
|
||||
contact_constraint.References = [
|
||||
# constraint contact
|
||||
con_contact = ObjectsFem.makeConstraintContact(doc, "ConstraintContact")
|
||||
con_contact.References = [
|
||||
(lower_tube, "Face1"),
|
||||
(upper_tube, "Face1"),
|
||||
]
|
||||
contact_constraint.Friction = 0.0
|
||||
# contact_constrsh_aint.Slope = "1000000.0 kg/(mm*s^2)" # contact stiffness
|
||||
contact_constraint.Slope = 1000000.0 # should be 1000000.0 kg/(mm*s^2)
|
||||
con_contact.Friction = 0.0
|
||||
# con_contact.Slope = "1000000.0 kg/(mm*s^2)" # contact stiffness
|
||||
con_contact.Slope = 1000000.0 # should be 1000000.0 kg/(mm*s^2)
|
||||
analysis.addObject(con_contact)
|
||||
|
||||
# mesh
|
||||
from .meshes.mesh_contact_tube_tube_tria3 import create_nodes, create_elements
|
||||
@@ -207,9 +200,7 @@ def setup(doc=None, solvertype="ccxtools"):
|
||||
control = create_elements(fem_mesh)
|
||||
if not control:
|
||||
FreeCAD.Console.PrintError("Error on creating elements.\n")
|
||||
femmesh_obj = analysis.addObject(
|
||||
ObjectsFem.makeMeshGmsh(doc, mesh_name)
|
||||
)[0]
|
||||
femmesh_obj = analysis.addObject(ObjectsFem.makeMeshGmsh(doc, mesh_name))[0]
|
||||
femmesh_obj.FemMesh = fem_mesh
|
||||
femmesh_obj.Part = geom_obj
|
||||
femmesh_obj.SecondOrderLinear = False
|
||||
|
||||
@@ -50,24 +50,24 @@ def init_doc(doc=None):
|
||||
|
||||
|
||||
def get_information():
|
||||
info = {"name": "Constraint Contact Solid Solid",
|
||||
"meshtype": "solid",
|
||||
"meshelement": "Tet10",
|
||||
"constraints": ["fixed", "pressure", "contact"],
|
||||
"solvers": ["calculix"],
|
||||
"material": "solid",
|
||||
"equation": "mechanical"
|
||||
}
|
||||
return info
|
||||
return {
|
||||
"name": "Constraint Contact Solid Solid",
|
||||
"meshtype": "solid",
|
||||
"meshelement": "Tet10",
|
||||
"constraints": ["fixed", "pressure", "contact"],
|
||||
"solvers": ["calculix"],
|
||||
"material": "solid",
|
||||
"equation": "mechanical"
|
||||
}
|
||||
|
||||
|
||||
def setup(doc=None, solvertype="ccxtools"):
|
||||
# setup model
|
||||
|
||||
# init FreeCAD document
|
||||
if doc is None:
|
||||
doc = init_doc()
|
||||
|
||||
# geometry objects
|
||||
# geometric objects
|
||||
# bottom box
|
||||
bottom_box_obj = doc.addObject("Part::Box", "BottomBox")
|
||||
bottom_box_obj.Length = 100
|
||||
@@ -111,42 +111,36 @@ def setup(doc=None, solvertype="ccxtools"):
|
||||
|
||||
# solver
|
||||
if solvertype == "calculix":
|
||||
solver_object = analysis.addObject(
|
||||
ObjectsFem.makeSolverCalculix(doc, "SolverCalculiX")
|
||||
)[0]
|
||||
solver_obj = ObjectsFem.makeSolverCalculix(doc, "SolverCalculiX")
|
||||
elif solvertype == "ccxtools":
|
||||
solver_object = analysis.addObject(
|
||||
ObjectsFem.makeSolverCalculixCcxTools(doc, "CalculiXccxTools")
|
||||
)[0]
|
||||
solver_object.WorkingDir = u""
|
||||
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_object.AnalysisType = "static"
|
||||
solver_object.GeometricalNonlinearity = "linear"
|
||||
solver_object.ThermoMechSteadyState = False
|
||||
solver_object.MatrixSolverType = "default"
|
||||
solver_object.IterationsControlParameterTimeUse = False
|
||||
solver_object.SplitInputWriter = False
|
||||
|
||||
solver_obj.AnalysisType = "static"
|
||||
solver_obj.GeometricalNonlinearity = "linear"
|
||||
solver_obj.ThermoMechSteadyState = False
|
||||
solver_obj.MatrixSolverType = "default"
|
||||
solver_obj.IterationsControlParameterTimeUse = False
|
||||
solver_obj.SplitInputWriter = False
|
||||
"""
|
||||
# solver parameter from fandaL, but they are not needed (see forum topic)
|
||||
solver_object.IterationsControlParameterTimeUse = True
|
||||
solver_object.IterationsControlParameterCutb = '0.25,0.5,0.75,0.85,,,1.5,'
|
||||
solver_object.IterationsControlParameterIter = '4,8,9,200,10,400,,200,,'
|
||||
solver_object.IterationsUserDefinedTimeStepLength = True
|
||||
solver_object.TimeInitialStep = 0.1
|
||||
solver_object.TimeEnd = 1.0
|
||||
solver_object.IterationsUserDefinedIncrementations = True # parameter DIRECT
|
||||
solver_obj.IterationsControlParameterTimeUse = True
|
||||
solver_obj.IterationsControlParameterCutb = '0.25,0.5,0.75,0.85,,,1.5,'
|
||||
solver_obj.IterationsControlParameterIter = '4,8,9,200,10,400,,200,,'
|
||||
solver_obj.IterationsUserDefinedTimeStepLength = True
|
||||
solver_obj.TimeInitialStep = 0.1
|
||||
solver_obj.TimeEnd = 1.0
|
||||
solver_obj.IterationsUserDefinedIncrementations = True # parameter DIRECT
|
||||
"""
|
||||
analysis.addObject(solver_obj)
|
||||
|
||||
# material
|
||||
material_obj = analysis.addObject(
|
||||
ObjectsFem.makeMaterialSolid(doc, "MechanicalMaterial")
|
||||
)[0]
|
||||
material_obj = ObjectsFem.makeMaterialSolid(doc, "MechanicalMaterial")
|
||||
mat = material_obj.Material
|
||||
mat["Name"] = "Steel-Generic"
|
||||
mat["YoungsModulus"] = "200000 MPa"
|
||||
@@ -155,34 +149,31 @@ def setup(doc=None, solvertype="ccxtools"):
|
||||
analysis.addObject(material_obj)
|
||||
|
||||
# constraint fixed
|
||||
con_fixed = analysis.addObject(
|
||||
ObjectsFem.makeConstraintFixed(doc, "ConstraintFixed")
|
||||
)[0]
|
||||
con_fixed = ObjectsFem.makeConstraintFixed(doc, "ConstraintFixed")
|
||||
con_fixed.References = [
|
||||
(geom_obj, "Face5"),
|
||||
(geom_obj, "Face6"),
|
||||
(geom_obj, "Face8"),
|
||||
(geom_obj, "Face9"),
|
||||
]
|
||||
analysis.addObject(con_fixed)
|
||||
|
||||
# constraint pressure
|
||||
con_pressure = analysis.addObject(
|
||||
ObjectsFem.makeConstraintPressure(doc, name="ConstraintPressure")
|
||||
)[0]
|
||||
con_pressure = ObjectsFem.makeConstraintPressure(doc, "ConstraintPressure")
|
||||
con_pressure.References = [(geom_obj, "Face10")]
|
||||
con_pressure.Pressure = 100.0 # Pa ? = 100 Mpa ?
|
||||
con_pressure.Reversed = False
|
||||
analysis.addObject(con_pressure)
|
||||
|
||||
# constraint contact
|
||||
con_contact = doc.Analysis.addObject(
|
||||
ObjectsFem.makeConstraintContact(doc, name="ConstraintContact")
|
||||
)[0]
|
||||
con_contact = ObjectsFem.makeConstraintContact(doc, "ConstraintContact")
|
||||
con_contact.References = [
|
||||
(geom_obj, "Face7"), # first seams slave face, TODO proof in writer code!
|
||||
(geom_obj, "Face3"), # second seams master face, TODO proof in writer code!
|
||||
]
|
||||
con_contact.Friction = 0.0
|
||||
con_contact.Slope = 1000000.0 # contact stiffness 1000000.0 kg/(mm*s^2)
|
||||
analysis.addObject(con_contact)
|
||||
|
||||
# mesh
|
||||
from .meshes.mesh_contact_box_halfcylinder_tetra10 import create_nodes, create_elements
|
||||
@@ -193,9 +184,7 @@ def setup(doc=None, solvertype="ccxtools"):
|
||||
control = create_elements(fem_mesh)
|
||||
if not control:
|
||||
FreeCAD.Console.PrintError("Error on creating elements.\n")
|
||||
femmesh_obj = analysis.addObject(
|
||||
ObjectsFem.makeMeshGmsh(doc, mesh_name)
|
||||
)[0]
|
||||
femmesh_obj = analysis.addObject(ObjectsFem.makeMeshGmsh(doc, mesh_name))[0]
|
||||
femmesh_obj.FemMesh = fem_mesh
|
||||
femmesh_obj.Part = geom_obj
|
||||
femmesh_obj.SecondOrderLinear = False
|
||||
|
||||
@@ -56,26 +56,26 @@ def init_doc(doc=None):
|
||||
|
||||
|
||||
def get_information():
|
||||
info = {"name": "Constraint Section Print",
|
||||
"meshtype": "solid",
|
||||
"meshelement": "Tet10",
|
||||
"constraints": ["section_print", "fixed", "pressure"],
|
||||
"solvers": ["calculix"],
|
||||
"material": "solid",
|
||||
"equation": "mechanical"
|
||||
}
|
||||
return info
|
||||
return {
|
||||
"name": "Constraint Section Print",
|
||||
"meshtype": "solid",
|
||||
"meshelement": "Tet10",
|
||||
"constraints": ["section_print", "fixed", "pressure"],
|
||||
"solvers": ["calculix"],
|
||||
"material": "solid",
|
||||
"equation": "mechanical"
|
||||
}
|
||||
|
||||
|
||||
def setup(doc=None, solvertype="ccxtools"):
|
||||
|
||||
# init FreeCAD document
|
||||
if doc is None:
|
||||
doc = init_doc()
|
||||
|
||||
# geometry object
|
||||
|
||||
# geometric objects
|
||||
# the part sketch
|
||||
arc_sketch = doc.addObject('Sketcher::SketchObject', 'Arc_Sketch')
|
||||
arc_sketch = doc.addObject("Sketcher::SketchObject", "Arc_Sketch")
|
||||
arc_sketch.Placement = FreeCAD.Placement(
|
||||
Vector(0, 0, 0),
|
||||
Rotation(0, 0, 0, 1)
|
||||
@@ -103,24 +103,24 @@ def setup(doc=None, solvertype="ccxtools"):
|
||||
# but the best way is to add a constraint is watching
|
||||
# FreeCAD python console while create this one by the Gui
|
||||
conList = [
|
||||
Sketcher.Constraint('Coincident', 0, 3, -1, 1),
|
||||
Sketcher.Constraint('PointOnObject', 0, 2, -1),
|
||||
Sketcher.Constraint('PointOnObject', 0, 1, -1),
|
||||
Sketcher.Constraint('PointOnObject', 1, 2, -1),
|
||||
Sketcher.Constraint('PointOnObject', 1, 1, -1),
|
||||
Sketcher.Constraint('Coincident', 2, 1, 0, 2),
|
||||
Sketcher.Constraint('Coincident', 2, 2, 1, 2),
|
||||
Sketcher.Constraint('Coincident', 3, 1, 1, 1),
|
||||
Sketcher.Constraint('Coincident', 3, 2, 0, 1),
|
||||
Sketcher.Constraint('DistanceX', 2, 2, 2, 1, 58),
|
||||
Sketcher.Constraint('DistanceX', 3, 2, 3, 1, 20),
|
||||
Sketcher.Constraint('Radius', 0, 47),
|
||||
Sketcher.Constraint('Radius', 1, 89)
|
||||
Sketcher.Constraint("Coincident", 0, 3, -1, 1),
|
||||
Sketcher.Constraint("PointOnObject", 0, 2, -1),
|
||||
Sketcher.Constraint("PointOnObject", 0, 1, -1),
|
||||
Sketcher.Constraint("PointOnObject", 1, 2, -1),
|
||||
Sketcher.Constraint("PointOnObject", 1, 1, -1),
|
||||
Sketcher.Constraint("Coincident", 2, 1, 0, 2),
|
||||
Sketcher.Constraint("Coincident", 2, 2, 1, 2),
|
||||
Sketcher.Constraint("Coincident", 3, 1, 1, 1),
|
||||
Sketcher.Constraint("Coincident", 3, 2, 0, 1),
|
||||
Sketcher.Constraint("DistanceX", 2, 2, 2, 1, 58),
|
||||
Sketcher.Constraint("DistanceX", 3, 2, 3, 1, 20),
|
||||
Sketcher.Constraint("Radius", 0, 47),
|
||||
Sketcher.Constraint("Radius", 1, 89)
|
||||
]
|
||||
arc_sketch.addConstraint(conList)
|
||||
|
||||
# the part extrusion
|
||||
extrude_part = doc.addObject('Part::Extrusion', 'ArcExtrude')
|
||||
extrude_part = doc.addObject("Part::Extrusion", "ArcExtrude")
|
||||
extrude_part.Base = arc_sketch
|
||||
extrude_part.DirMode = "Custom"
|
||||
extrude_part.Dir = Vector(0.00, 0.00, 1.00)
|
||||
@@ -134,7 +134,7 @@ def setup(doc=None, solvertype="ccxtools"):
|
||||
extrude_part.TaperAngleRev = 0.00
|
||||
|
||||
# section plane sketch
|
||||
section_sketch = doc.addObject('Sketcher::SketchObject', 'Section_Sketch')
|
||||
section_sketch = doc.addObject("Sketcher::SketchObject", "Section_Sketch")
|
||||
section_sketch.Placement = FreeCAD.Placement(
|
||||
Vector(0.000000, 0.000000, 0.000000),
|
||||
Rotation(0.000000, 0.000000, 0.000000, 1.000000)
|
||||
@@ -147,7 +147,7 @@ def setup(doc=None, solvertype="ccxtools"):
|
||||
# section_sketch.ExternalGeometry = extrude_part
|
||||
|
||||
# section plane extrusion
|
||||
extrude_section_plane = doc.addObject('Part::Extrusion', 'SectionPlaneExtrude')
|
||||
extrude_section_plane = doc.addObject("Part::Extrusion", "SectionPlaneExtrude")
|
||||
extrude_section_plane.Base = section_sketch
|
||||
extrude_section_plane.DirMode = "Custom"
|
||||
extrude_section_plane.Dir = Vector(0.00, 0.00, -1.00)
|
||||
@@ -168,15 +168,15 @@ def setup(doc=None, solvertype="ccxtools"):
|
||||
extrude_part.ViewObject.hide()
|
||||
extrude_section_plane.ViewObject.hide()
|
||||
|
||||
Slice = makeSlice(name='Slice')
|
||||
Slice = makeSlice(name="Slice")
|
||||
Slice.Base = extrude_part
|
||||
Slice.Tools = extrude_section_plane
|
||||
Slice.Mode = 'Split'
|
||||
Slice.Mode = "Split"
|
||||
# Slice.Proxy.execute(Slice)
|
||||
Slice.purgeTouched()
|
||||
|
||||
# compound filter to get the solids of the slice
|
||||
solid_one = makeCompoundFilter(name='SolidOne')
|
||||
solid_one = makeCompoundFilter(name="SolidOne")
|
||||
solid_one.Base = Slice
|
||||
solid_one.FilterType = "specific items"
|
||||
solid_one.items = "0"
|
||||
@@ -185,7 +185,7 @@ def setup(doc=None, solvertype="ccxtools"):
|
||||
if FreeCAD.GuiUp:
|
||||
solid_one.Base.ViewObject.hide()
|
||||
|
||||
solid_two = makeCompoundFilter(name='SolidTwo')
|
||||
solid_two = makeCompoundFilter(name="SolidTwo")
|
||||
solid_two.Base = Slice
|
||||
solid_two.FilterType = "specific items"
|
||||
solid_two.items = "1"
|
||||
@@ -195,9 +195,9 @@ def setup(doc=None, solvertype="ccxtools"):
|
||||
solid_two.Base.ViewObject.hide()
|
||||
|
||||
# CompSolid out of the two solids
|
||||
geom_obj = makeBooleanFragments(name='BooleanFragments')
|
||||
geom_obj = makeBooleanFragments(name="BooleanFragments")
|
||||
geom_obj.Objects = [solid_one, solid_two]
|
||||
geom_obj.Mode = 'CompSolid'
|
||||
geom_obj.Mode = "CompSolid"
|
||||
# geom_obj.Proxy.execute(geom_obj)
|
||||
geom_obj.purgeTouched()
|
||||
if FreeCAD.GuiUp:
|
||||
@@ -215,56 +215,49 @@ def setup(doc=None, solvertype="ccxtools"):
|
||||
|
||||
# solver
|
||||
if solvertype == "calculix":
|
||||
solver_object = analysis.addObject(
|
||||
ObjectsFem.makeSolverCalculix(doc, "SolverCalculiX")
|
||||
)[0]
|
||||
solver_obj = ObjectsFem.makeSolverCalculix(doc, "SolverCalculiX")
|
||||
elif solvertype == "ccxtools":
|
||||
solver_object = analysis.addObject(
|
||||
ObjectsFem.makeSolverCalculixCcxTools(doc, "CalculiXccxTools")
|
||||
)[0]
|
||||
solver_object.WorkingDir = u""
|
||||
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_object.SplitInputWriter = False
|
||||
solver_object.AnalysisType = "static"
|
||||
solver_object.GeometricalNonlinearity = "linear"
|
||||
solver_object.ThermoMechSteadyState = False
|
||||
solver_object.MatrixSolverType = "default"
|
||||
solver_object.IterationsControlParameterTimeUse = False
|
||||
solver_obj.SplitInputWriter = False
|
||||
solver_obj.AnalysisType = "static"
|
||||
solver_obj.GeometricalNonlinearity = "linear"
|
||||
solver_obj.ThermoMechSteadyState = False
|
||||
solver_obj.MatrixSolverType = "default"
|
||||
solver_obj.IterationsControlParameterTimeUse = False
|
||||
analysis.addObject(solver_obj)
|
||||
|
||||
# material
|
||||
material_object = analysis.addObject(
|
||||
ObjectsFem.makeMaterialSolid(doc, "Material")
|
||||
)[0]
|
||||
mat = material_object.Material
|
||||
material_obj = ObjectsFem.makeMaterialSolid(doc, "Material")
|
||||
mat = material_obj.Material
|
||||
mat["Name"] = "CalculiX-Steel"
|
||||
mat["YoungsModulus"] = "210000 MPa"
|
||||
mat["PoissonRatio"] = "0.30"
|
||||
material_object.Material = mat
|
||||
material_obj.Material = mat
|
||||
analysis.addObject(material_obj)
|
||||
|
||||
# constraint fixed
|
||||
fixed_constraint = analysis.addObject(
|
||||
ObjectsFem.makeConstraintFixed(doc, name="ConstraintFixed")
|
||||
)[0]
|
||||
fixed_constraint.References = [(geom_obj, "Face9")]
|
||||
con_fixed = ObjectsFem.makeConstraintFixed(doc, "ConstraintFixed")
|
||||
con_fixed.References = [(geom_obj, "Face9")]
|
||||
analysis.addObject(con_fixed)
|
||||
|
||||
# constraint pressure
|
||||
pressure_constraint = analysis.addObject(
|
||||
ObjectsFem.makeConstraintPressure(doc, name="ConstraintPressure")
|
||||
)[0]
|
||||
pressure_constraint.References = [(geom_obj, "Face1")]
|
||||
pressure_constraint.Pressure = 100.0
|
||||
pressure_constraint.Reversed = False
|
||||
con_pressure = ObjectsFem.makeConstraintPressure(doc, "ConstraintPressure")
|
||||
con_pressure.References = [(geom_obj, "Face1")]
|
||||
con_pressure.Pressure = 100.0
|
||||
con_pressure.Reversed = False
|
||||
analysis.addObject(con_pressure)
|
||||
|
||||
# constraint section print
|
||||
section_constraint = analysis.addObject(
|
||||
ObjectsFem.makeConstraintSectionPrint(doc, name="ConstraintSectionPrint")
|
||||
)[0]
|
||||
section_constraint.References = [(geom_obj, "Face6")]
|
||||
con_sectionpr = ObjectsFem.makeConstraintSectionPrint(doc, "ConstraintSectionPrint")
|
||||
con_sectionpr.References = [(geom_obj, "Face6")]
|
||||
analysis.addObject(con_sectionpr)
|
||||
|
||||
# mesh
|
||||
from .meshes.mesh_section_print_tetra10 import create_nodes, create_elements
|
||||
@@ -275,9 +268,7 @@ def setup(doc=None, solvertype="ccxtools"):
|
||||
control = create_elements(fem_mesh)
|
||||
if not control:
|
||||
FreeCAD.Console.PrintError("Error on creating elements.\n")
|
||||
femmesh_obj = analysis.addObject(
|
||||
ObjectsFem.makeMeshGmsh(doc, mesh_name)
|
||||
)[0]
|
||||
femmesh_obj = analysis.addObject(ObjectsFem.makeMeshGmsh(doc, mesh_name))[0]
|
||||
femmesh_obj.FemMesh = fem_mesh
|
||||
femmesh_obj.Part = geom_obj
|
||||
femmesh_obj.SecondOrderLinear = False
|
||||
|
||||
@@ -49,7 +49,7 @@ def init_doc(doc=None):
|
||||
|
||||
|
||||
def get_information():
|
||||
info = {
|
||||
return {
|
||||
"name": "Constraint Self Weight Cantilever",
|
||||
"meshtype": "solid",
|
||||
"meshelement": "Tet10",
|
||||
@@ -58,22 +58,19 @@ def get_information():
|
||||
"material": "solid",
|
||||
"equation": "mechanical"
|
||||
}
|
||||
return info
|
||||
|
||||
|
||||
def setup(doc=None, solvertype="ccxtools"):
|
||||
# setup self weight cantilever base model
|
||||
|
||||
# init FreeCAD document
|
||||
if doc is None:
|
||||
doc = init_doc()
|
||||
|
||||
# geometry object
|
||||
# name is important because the other method in this module use obj name
|
||||
# geometric object
|
||||
geom_obj = doc.addObject("Part::Box", "Box")
|
||||
geom_obj.Height = geom_obj.Width = 1000
|
||||
geom_obj.Length = 32000
|
||||
doc.recompute()
|
||||
|
||||
if FreeCAD.GuiUp:
|
||||
geom_obj.ViewObject.Document.activeView().viewAxonometric()
|
||||
geom_obj.ViewObject.Document.activeView().fitAll()
|
||||
@@ -83,19 +80,13 @@ def setup(doc=None, solvertype="ccxtools"):
|
||||
|
||||
# solver
|
||||
if solvertype == "calculix":
|
||||
solver_object = analysis.addObject(
|
||||
ObjectsFem.makeSolverCalculix(doc, "SolverCalculiX")
|
||||
)[0]
|
||||
solver_obj = ObjectsFem.makeSolverCalculix(doc, "SolverCalculiX")
|
||||
elif solvertype == "ccxtools":
|
||||
solver_object = analysis.addObject(
|
||||
ObjectsFem.makeSolverCalculixCcxTools(doc, "CalculiXccxTools")
|
||||
)[0]
|
||||
solver_object.WorkingDir = u""
|
||||
solver_obj = ObjectsFem.makeSolverCalculixCcxTools(doc, "CalculiXccxTools")
|
||||
solver_obj.WorkingDir = u""
|
||||
elif solvertype == "elmer":
|
||||
solver_object = analysis.addObject(
|
||||
ObjectsFem.makeSolverElmer(doc, "SolverElmer")
|
||||
)[0]
|
||||
eq_obj = ObjectsFem.makeEquationElasticity(doc, solver_object)
|
||||
solver_obj = ObjectsFem.makeSolverElmer(doc, "SolverElmer")
|
||||
eq_obj = ObjectsFem.makeEquationElasticity(doc, solver_obj)
|
||||
eq_obj.LinearSolverType = "Direct"
|
||||
else:
|
||||
FreeCAD.Console.PrintWarning(
|
||||
@@ -103,35 +94,33 @@ def setup(doc=None, solvertype="ccxtools"):
|
||||
"No solver object was created.\n".format(solvertype)
|
||||
)
|
||||
if solvertype == "calculix" or solvertype == "ccxtools":
|
||||
solver_object.SplitInputWriter = False
|
||||
solver_object.AnalysisType = "static"
|
||||
solver_object.GeometricalNonlinearity = "linear"
|
||||
solver_object.ThermoMechSteadyState = False
|
||||
solver_object.MatrixSolverType = "default"
|
||||
solver_object.IterationsControlParameterTimeUse = False
|
||||
solver_obj.SplitInputWriter = False
|
||||
solver_obj.AnalysisType = "static"
|
||||
solver_obj.GeometricalNonlinearity = "linear"
|
||||
solver_obj.ThermoMechSteadyState = False
|
||||
solver_obj.MatrixSolverType = "default"
|
||||
solver_obj.IterationsControlParameterTimeUse = False
|
||||
analysis.addObject(solver_obj)
|
||||
|
||||
# material
|
||||
material_object = analysis.addObject(
|
||||
ObjectsFem.makeMaterialSolid(doc, "FemMaterial")
|
||||
)[0]
|
||||
mat = material_object.Material
|
||||
material_obj = ObjectsFem.makeMaterialSolid(doc, "FemMaterial")
|
||||
mat = material_obj.Material
|
||||
mat["Name"] = "CalculiX-Steel"
|
||||
mat["YoungsModulus"] = "210000 MPa"
|
||||
mat["PoissonRatio"] = "0.30"
|
||||
mat["Density"] = "7900 kg/m^3"
|
||||
material_object.Material = mat
|
||||
material_obj.Material = mat
|
||||
analysis.addObject(material_obj)
|
||||
|
||||
# fixed_constraint
|
||||
fixed_constraint = analysis.addObject(
|
||||
ObjectsFem.makeConstraintFixed(doc, name="ConstraintFixed")
|
||||
)[0]
|
||||
fixed_constraint.References = [(geom_obj, "Face1")]
|
||||
# constraint fixed
|
||||
con_fixed = ObjectsFem.makeConstraintFixed(doc, "ConstraintFixed")
|
||||
con_fixed.References = [(geom_obj, "Face1")]
|
||||
analysis.addObject(con_fixed)
|
||||
|
||||
# selfweight_constraint
|
||||
selfweight = doc.Analysis.addObject(
|
||||
ObjectsFem.makeConstraintSelfWeight(doc)
|
||||
)[0]
|
||||
selfweight.Gravity_z = -1.00
|
||||
# constraint selfweight
|
||||
con_selfweight = ObjectsFem.makeConstraintSelfWeight(doc, "ConstraintSelfWeight")
|
||||
con_selfweight.Gravity_z = -1.00
|
||||
analysis.addObject(con_selfweight)
|
||||
|
||||
# mesh
|
||||
from .meshes.mesh_selfweight_cantilever_tetra10 import create_nodes, create_elements
|
||||
@@ -142,9 +131,7 @@ def setup(doc=None, solvertype="ccxtools"):
|
||||
control = create_elements(fem_mesh)
|
||||
if not control:
|
||||
FreeCAD.Console.PrintError("Error on creating elements.\n")
|
||||
femmesh_obj = analysis.addObject(
|
||||
ObjectsFem.makeMeshGmsh(doc, mesh_name)
|
||||
)[0]
|
||||
femmesh_obj = analysis.addObject(ObjectsFem.makeMeshGmsh(doc, mesh_name))[0]
|
||||
femmesh_obj.FemMesh = fem_mesh
|
||||
femmesh_obj.Part = geom_obj
|
||||
femmesh_obj.SecondOrderLinear = False
|
||||
|
||||
@@ -50,24 +50,24 @@ def init_doc(doc=None):
|
||||
|
||||
|
||||
def get_information():
|
||||
info = {"name": "Constraint Tie",
|
||||
"meshtype": "solid",
|
||||
"meshelement": "Tet10",
|
||||
"constraints": ["fixed", "force", "tie"],
|
||||
"solvers": ["calculix"],
|
||||
"material": "solid",
|
||||
"equation": "mechanical"
|
||||
}
|
||||
return info
|
||||
return {
|
||||
"name": "Constraint Tie",
|
||||
"meshtype": "solid",
|
||||
"meshelement": "Tet10",
|
||||
"constraints": ["fixed", "force", "tie"],
|
||||
"solvers": ["calculix"],
|
||||
"material": "solid",
|
||||
"equation": "mechanical"
|
||||
}
|
||||
|
||||
|
||||
def setup(doc=None, solvertype="ccxtools"):
|
||||
# setup model
|
||||
|
||||
# init FreeCAD document
|
||||
if doc is None:
|
||||
doc = init_doc()
|
||||
|
||||
# geometry objects
|
||||
# geometric objects
|
||||
# cones cut
|
||||
cone_outer_sh = Part.makeCone(1100, 1235, 1005, Vector(0, 0, 0), Vector(0, 0, 1), 359)
|
||||
cone_inner_sh = Part.makeCone(1050, 1185, 1005, Vector(0, 0, 0), Vector(0, 0, 1), 359)
|
||||
@@ -83,7 +83,7 @@ def setup(doc=None, solvertype="ccxtools"):
|
||||
line_force_obj = doc.addObject("Part::Feature", "Line_Force")
|
||||
line_force_obj.Shape = line_force_sh
|
||||
|
||||
geom_obj = SplitFeatures.makeBooleanFragments(name='BooleanFragments')
|
||||
geom_obj = SplitFeatures.makeBooleanFragments(name="BooleanFragments")
|
||||
geom_obj.Objects = [cone_cut_obj, line_fix_obj, line_force_obj]
|
||||
if FreeCAD.GuiUp:
|
||||
cone_cut_obj.ViewObject.hide()
|
||||
@@ -100,31 +100,26 @@ def setup(doc=None, solvertype="ccxtools"):
|
||||
|
||||
# solver
|
||||
if solvertype == "calculix":
|
||||
solver_object = analysis.addObject(
|
||||
ObjectsFem.makeSolverCalculix(doc, "SolverCalculiX")
|
||||
)[0]
|
||||
solver_obj = ObjectsFem.makeSolverCalculix(doc, "SolverCalculiX")
|
||||
elif solvertype == "ccxtools":
|
||||
solver_object = analysis.addObject(
|
||||
ObjectsFem.makeSolverCalculixCcxTools(doc, "CalculiXccxTools")
|
||||
)[0]
|
||||
solver_object.WorkingDir = u""
|
||||
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_object.AnalysisType = "static"
|
||||
solver_object.GeometricalNonlinearity = "linear"
|
||||
solver_object.ThermoMechSteadyState = False
|
||||
solver_object.MatrixSolverType = "default"
|
||||
solver_object.IterationsControlParameterTimeUse = False
|
||||
solver_object.SplitInputWriter = False
|
||||
solver_obj.AnalysisType = "static"
|
||||
solver_obj.GeometricalNonlinearity = "linear"
|
||||
solver_obj.ThermoMechSteadyState = False
|
||||
solver_obj.MatrixSolverType = "default"
|
||||
solver_obj.IterationsControlParameterTimeUse = False
|
||||
solver_obj.SplitInputWriter = False
|
||||
analysis.addObject(solver_obj)
|
||||
|
||||
# material
|
||||
material_obj = analysis.addObject(
|
||||
ObjectsFem.makeMaterialSolid(doc, "MechanicalMaterial")
|
||||
)[0]
|
||||
material_obj = ObjectsFem.makeMaterialSolid(doc, "MechanicalMaterial")
|
||||
mat = material_obj.Material
|
||||
mat["Name"] = "Calculix-Steel"
|
||||
mat["YoungsModulus"] = "210000 MPa"
|
||||
@@ -133,29 +128,26 @@ def setup(doc=None, solvertype="ccxtools"):
|
||||
analysis.addObject(material_obj)
|
||||
|
||||
# constraint fixed
|
||||
con_fixed = analysis.addObject(
|
||||
ObjectsFem.makeConstraintFixed(doc, "ConstraintFixed")
|
||||
)[0]
|
||||
con_fixed = ObjectsFem.makeConstraintFixed(doc, "ConstraintFixed")
|
||||
con_fixed.References = [(geom_obj, "Edge1")]
|
||||
analysis.addObject(con_fixed)
|
||||
|
||||
# constraint force
|
||||
con_force = doc.Analysis.addObject(
|
||||
ObjectsFem.makeConstraintForce(doc, name="ConstraintForce")
|
||||
)[0]
|
||||
con_force = ObjectsFem.makeConstraintForce(doc, "ConstraintForce")
|
||||
con_force.References = [(geom_obj, "Edge2")]
|
||||
con_force.Force = 10000.0 # 10000 N = 10 kN
|
||||
con_force.Direction = (geom_obj, ["Edge2"])
|
||||
con_force.Reversed = False
|
||||
analysis.addObject(con_force)
|
||||
|
||||
# constraint tie
|
||||
con_tie = doc.Analysis.addObject(
|
||||
ObjectsFem.makeConstraintTie(doc, name="ConstraintTie")
|
||||
)[0]
|
||||
con_tie = ObjectsFem.makeConstraintTie(doc, "ConstraintTie")
|
||||
con_tie.References = [
|
||||
(geom_obj, "Face5"),
|
||||
(geom_obj, "Face7"),
|
||||
]
|
||||
con_tie.Tolerance = 25.0
|
||||
analysis.addObject(con_tie)
|
||||
|
||||
# mesh
|
||||
from .meshes.mesh_constraint_tie_tetra10 import create_nodes, create_elements
|
||||
@@ -166,9 +158,7 @@ def setup(doc=None, solvertype="ccxtools"):
|
||||
control = create_elements(fem_mesh)
|
||||
if not control:
|
||||
FreeCAD.Console.PrintError("Error on creating elements.\n")
|
||||
femmesh_obj = analysis.addObject(
|
||||
ObjectsFem.makeMeshGmsh(doc, mesh_name)
|
||||
)[0]
|
||||
femmesh_obj = analysis.addObject(ObjectsFem.makeMeshGmsh(doc, mesh_name))[0]
|
||||
femmesh_obj.FemMesh = fem_mesh
|
||||
femmesh_obj.Part = geom_obj
|
||||
femmesh_obj.SecondOrderLinear = False
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
# ***************************************************************************
|
||||
# * Copyright (c) 2020 Sudhanshu Dubey <sudhanshu.thethunder@gmail.com> *
|
||||
# * Copyright (c) 2021 Bernd Hahnebach <bernd@bimstatik.org> *
|
||||
# * *
|
||||
# * This file is part of the FreeCAD CAx development system. *
|
||||
# * *
|
||||
@@ -48,24 +49,24 @@ def init_doc(doc=None):
|
||||
|
||||
|
||||
def get_information():
|
||||
info = {"name": "Constraint Transform Beam Hinged",
|
||||
"meshtype": "solid",
|
||||
"meshelement": "Tet10",
|
||||
"constraints": ["pressure", "displacement", "transform"],
|
||||
"solvers": ["calculix"],
|
||||
"material": "solid",
|
||||
"equation": "mechanical"
|
||||
}
|
||||
return info
|
||||
return {
|
||||
"name": "Constraint Transform Beam Hinged",
|
||||
"meshtype": "solid",
|
||||
"meshelement": "Tet10",
|
||||
"constraints": ["pressure", "displacement", "transform"],
|
||||
"solvers": ["calculix"],
|
||||
"material": "solid",
|
||||
"equation": "mechanical"
|
||||
}
|
||||
|
||||
|
||||
def setup(doc=None, solvertype="ccxtools"):
|
||||
# setup cylinder base model
|
||||
|
||||
# init FreeCAD document
|
||||
if doc is None:
|
||||
doc = init_doc()
|
||||
|
||||
# geometry object
|
||||
# geometric object
|
||||
# name is important because the other method in this module use obj name
|
||||
cube = doc.addObject("Part::Box", "Cube")
|
||||
cube.Height = "20 mm"
|
||||
@@ -108,74 +109,64 @@ def setup(doc=None, solvertype="ccxtools"):
|
||||
|
||||
# solver
|
||||
if solvertype == "calculix":
|
||||
solver_object = analysis.addObject(
|
||||
ObjectsFem.makeSolverCalculix(doc, "SolverCalculiX")
|
||||
)[0]
|
||||
solver_obj = ObjectsFem.makeSolverCalculix(doc, "SolverCalculiX")
|
||||
elif solvertype == "ccxtools":
|
||||
solver_object = analysis.addObject(
|
||||
ObjectsFem.makeSolverCalculixCcxTools(doc, "CalculiXccxTools")
|
||||
)[0]
|
||||
solver_object.WorkingDir = u""
|
||||
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_object.SplitInputWriter = False
|
||||
solver_object.AnalysisType = "static"
|
||||
solver_object.GeometricalNonlinearity = "linear"
|
||||
solver_object.ThermoMechSteadyState = False
|
||||
solver_object.MatrixSolverType = "default"
|
||||
solver_object.IterationsControlParameterTimeUse = False
|
||||
solver_obj.SplitInputWriter = False
|
||||
solver_obj.AnalysisType = "static"
|
||||
solver_obj.GeometricalNonlinearity = "linear"
|
||||
solver_obj.ThermoMechSteadyState = False
|
||||
solver_obj.MatrixSolverType = "default"
|
||||
solver_obj.IterationsControlParameterTimeUse = False
|
||||
analysis.addObject(solver_obj)
|
||||
|
||||
# material
|
||||
material_object = analysis.addObject(
|
||||
ObjectsFem.makeMaterialSolid(doc, "FemMaterial")
|
||||
)[0]
|
||||
mat = material_object.Material
|
||||
material_obj = ObjectsFem.makeMaterialSolid(doc, "FemMaterial")
|
||||
mat = material_obj.Material
|
||||
mat["Name"] = "CalculiX-Steel"
|
||||
mat["YoungsModulus"] = "210000 MPa"
|
||||
mat["PoissonRatio"] = "0.30"
|
||||
mat["Density"] = "7900 kg/m^3"
|
||||
mat["ThermalExpansionCoefficient"] = "0.012 mm/m/K"
|
||||
material_object.Material = mat
|
||||
material_obj.Material = mat
|
||||
|
||||
# constraint pressure
|
||||
pressure_constraint = analysis.addObject(
|
||||
ObjectsFem.makeConstraintPressure(doc, name="FemConstraintPressure")
|
||||
)[0]
|
||||
pressure_constraint.References = [(geom_obj, "Face8")]
|
||||
pressure_constraint.Pressure = 10.0
|
||||
pressure_constraint.Reversed = False
|
||||
con_pressure = ObjectsFem.makeConstraintPressure(doc, name="FemConstraintPressure")
|
||||
con_pressure.References = [(geom_obj, "Face8")]
|
||||
con_pressure.Pressure = 10.0
|
||||
con_pressure.Reversed = False
|
||||
analysis.addObject(con_pressure)
|
||||
|
||||
# constraint_displacement
|
||||
displacement_constraint = doc.Analysis.addObject(
|
||||
ObjectsFem.makeConstraintDisplacement(doc, name="FemConstraintDisplacment")
|
||||
)[0]
|
||||
displacement_constraint.References = [(geom_obj, "Face4"), (geom_obj, "Face5")]
|
||||
displacement_constraint.xFree = False
|
||||
displacement_constraint.xFix = True
|
||||
# constraint displacement
|
||||
con_disp = ObjectsFem.makeConstraintDisplacement(doc, name="FemConstraintDisplacment")
|
||||
con_disp.References = [(geom_obj, "Face4"), (geom_obj, "Face5")]
|
||||
con_disp.xFree = False
|
||||
con_disp.xFix = True
|
||||
analysis.addObject(con_disp)
|
||||
|
||||
# constraint_transform_1
|
||||
transform_constraint1 = doc.Analysis.addObject(
|
||||
ObjectsFem.makeConstraintTransform(doc, name="FemConstraintTransform1")
|
||||
)[0]
|
||||
transform_constraint1.References = [(geom_obj, "Face4")]
|
||||
transform_constraint1.TransformType = "Cylindrical"
|
||||
transform_constraint1.X_rot = 0.0
|
||||
transform_constraint1.Y_rot = 0.0
|
||||
transform_constraint1.Z_rot = 0.0
|
||||
# constraints transform
|
||||
con_transform1 = ObjectsFem.makeConstraintTransform(doc, name="FemConstraintTransform1")
|
||||
con_transform1.References = [(geom_obj, "Face4")]
|
||||
con_transform1.TransformType = "Cylindrical"
|
||||
con_transform1.X_rot = 0.0
|
||||
con_transform1.Y_rot = 0.0
|
||||
con_transform1.Z_rot = 0.0
|
||||
analysis.addObject(con_transform1)
|
||||
|
||||
# constraint_transform_2
|
||||
transform_constraint2 = doc.Analysis.addObject(
|
||||
ObjectsFem.makeConstraintTransform(doc, name="FemConstraintTransform2")
|
||||
)[0]
|
||||
transform_constraint2.References = [(geom_obj, "Face5")]
|
||||
transform_constraint2.TransformType = "Cylindrical"
|
||||
transform_constraint2.X_rot = 0.0
|
||||
transform_constraint2.Y_rot = 0.0
|
||||
transform_constraint2.Z_rot = 0.0
|
||||
con_transform2 = ObjectsFem.makeConstraintTransform(doc, name="FemConstraintTransform2")
|
||||
con_transform2.References = [(geom_obj, "Face5")]
|
||||
con_transform2.TransformType = "Cylindrical"
|
||||
con_transform2.X_rot = 0.0
|
||||
con_transform2.Y_rot = 0.0
|
||||
con_transform2.Z_rot = 0.0
|
||||
analysis.addObject(con_transform2)
|
||||
|
||||
# mesh
|
||||
from .meshes.mesh_transform_beam_hinged_tetra10 import create_nodes, create_elements
|
||||
@@ -186,9 +177,7 @@ def setup(doc=None, solvertype="ccxtools"):
|
||||
control = create_elements(fem_mesh)
|
||||
if not control:
|
||||
FreeCAD.Console.PrintError("Error on creating elements.\n")
|
||||
femmesh_obj = analysis.addObject(
|
||||
ObjectsFem.makeMeshGmsh(doc, mesh_name)
|
||||
)[0]
|
||||
femmesh_obj = analysis.addObject(ObjectsFem.makeMeshGmsh(doc, mesh_name))[0]
|
||||
femmesh_obj.FemMesh = fem_mesh
|
||||
femmesh_obj.Part = geom_obj
|
||||
femmesh_obj.SecondOrderLinear = False
|
||||
|
||||
@@ -57,18 +57,17 @@ def get_information():
|
||||
|
||||
|
||||
def setup(doc=None, solvertype="elmer"):
|
||||
# setup model
|
||||
|
||||
# init FreeCAD document
|
||||
if doc is None:
|
||||
doc = init_doc()
|
||||
|
||||
# geometry object
|
||||
# geometric object
|
||||
geom_obj = doc.addObject("Part::Box", "Box")
|
||||
geom_obj.Length = 1000
|
||||
geom_obj.Width = 200
|
||||
geom_obj.Height = 100
|
||||
doc.recompute()
|
||||
|
||||
if FreeCAD.GuiUp:
|
||||
geom_obj.ViewObject.Document.activeView().viewAxonometric()
|
||||
geom_obj.ViewObject.Document.activeView().fitAll()
|
||||
@@ -78,19 +77,13 @@ def setup(doc=None, solvertype="elmer"):
|
||||
|
||||
# solver
|
||||
if solvertype == "calculix":
|
||||
solver_object = analysis.addObject(
|
||||
ObjectsFem.makeSolverCalculix(doc, "SolverCalculiX")
|
||||
)[0]
|
||||
solver_obj = ObjectsFem.makeSolverCalculix(doc, "SolverCalculiX")
|
||||
elif solvertype == "ccxtools":
|
||||
solver_object = analysis.addObject(
|
||||
ObjectsFem.makeSolverCalculixCcxTools(doc, "CalculiXccxTools")
|
||||
)[0]
|
||||
solver_object.WorkingDir = u""
|
||||
solver_obj = ObjectsFem.makeSolverCalculixCcxTools(doc, "CalculiXccxTools")
|
||||
solver_obj.WorkingDir = u""
|
||||
elif solvertype == "elmer":
|
||||
solver_object = analysis.addObject(
|
||||
ObjectsFem.makeSolverElmer(doc, "SolverElmer")
|
||||
)[0]
|
||||
eq_obj = ObjectsFem.makeEquationElasticity(doc, solver_object)
|
||||
solver_obj = ObjectsFem.makeSolverElmer(doc, "SolverElmer")
|
||||
eq_obj = ObjectsFem.makeEquationElasticity(doc, solver_obj)
|
||||
eq_obj.LinearSolverType = "Direct"
|
||||
# direct solver was used in the tutorial, thus used here too
|
||||
# the iterative is much faster and gives the same results
|
||||
@@ -102,39 +95,37 @@ def setup(doc=None, solvertype="elmer"):
|
||||
"No solver object was created.\n".format(solvertype)
|
||||
)
|
||||
if solvertype == "calculix" or solvertype == "ccxtools":
|
||||
solver_object.AnalysisType = "frequency"
|
||||
solver_object.GeometricalNonlinearity = "linear"
|
||||
solver_object.ThermoMechSteadyState = False
|
||||
solver_object.MatrixSolverType = "default"
|
||||
solver_object.IterationsControlParameterTimeUse = False
|
||||
solver_object.EigenmodesCount = 5
|
||||
solver_object.EigenmodeHighLimit = 1000000.0
|
||||
solver_object.EigenmodeLowLimit = 0.01
|
||||
solver_obj.AnalysisType = "frequency"
|
||||
solver_obj.GeometricalNonlinearity = "linear"
|
||||
solver_obj.ThermoMechSteadyState = False
|
||||
solver_obj.MatrixSolverType = "default"
|
||||
solver_obj.IterationsControlParameterTimeUse = False
|
||||
solver_obj.EigenmodesCount = 5
|
||||
solver_obj.EigenmodeHighLimit = 1000000.0
|
||||
solver_obj.EigenmodeLowLimit = 0.01
|
||||
analysis.addObject(solver_obj)
|
||||
|
||||
# material
|
||||
material_object = analysis.addObject(
|
||||
ObjectsFem.makeMaterialSolid(doc, "MechanicalMaterial")
|
||||
)[0]
|
||||
mat = material_object.Material
|
||||
material_obj = ObjectsFem.makeMaterialSolid(doc, "MechanicalMaterial")
|
||||
mat = material_obj.Material
|
||||
mat["Name"] = "Steel-Generic"
|
||||
mat["YoungsModulus"] = "100 GPa"
|
||||
mat["PoissonRatio"] = "0.30"
|
||||
mat["Density"] = "2330 kg/m^3"
|
||||
material_object.Material = mat
|
||||
material_obj.Material = mat
|
||||
analysis.addObject(material_obj)
|
||||
|
||||
# fixed_constraint
|
||||
fixed_constraint = analysis.addObject(
|
||||
ObjectsFem.makeConstraintFixed(doc, name="FemConstraintFixed")
|
||||
)[0]
|
||||
fixed_constraint.References = [
|
||||
# constraint fixed
|
||||
con_fixed = ObjectsFem.makeConstraintFixed(doc, "ConstraintFixed")
|
||||
con_fixed.References = [
|
||||
(geom_obj, "Face1"),
|
||||
(geom_obj, "Face2")
|
||||
]
|
||||
analysis.addObject(con_fixed)
|
||||
|
||||
# mesh
|
||||
from .meshes.mesh_eigenvalue_of_elastic_beam_tetra10 import create_nodes
|
||||
from .meshes.mesh_eigenvalue_of_elastic_beam_tetra10 import create_elements
|
||||
|
||||
fem_mesh = Fem.FemMesh()
|
||||
control = create_nodes(fem_mesh)
|
||||
if not control:
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# ***************************************************************************
|
||||
# * Copyright (c) 2020 Sudhanshu Dubey <sudhanshu.thethunder@gmail.com> *
|
||||
# * Copyright (c) 2021 Bernd Hahnebach <bernd@bimstatik.org> *
|
||||
# * *
|
||||
# * This file is part of the FreeCAD CAx development system. *
|
||||
# * *
|
||||
@@ -26,6 +26,7 @@
|
||||
"""
|
||||
from femexamples.equation_electrostatics_capacitance_two_balls import setup
|
||||
setup()
|
||||
|
||||
"""
|
||||
# Electrostatics equation in FreeCAD FEM-Elmer
|
||||
# https://forum.freecadweb.org/viewtopic.php?f=18&t=41488&start=90#p412047
|
||||
@@ -47,38 +48,37 @@ def init_doc(doc=None):
|
||||
|
||||
|
||||
def get_information():
|
||||
info = {"name": "Electrostatics Capacitance Two Balls",
|
||||
"meshtype": "solid",
|
||||
"meshelement": "Tet10",
|
||||
"constraints": ["electrostatic potential"],
|
||||
"solvers": ["elmer"],
|
||||
"material": "fluid",
|
||||
"equation": "electrostatic"
|
||||
}
|
||||
return info
|
||||
return {
|
||||
"name": "Electrostatics Capacitance Two Balls",
|
||||
"meshtype": "solid",
|
||||
"meshelement": "Tet10",
|
||||
"constraints": ["electrostatic potential"],
|
||||
"solvers": ["elmer"],
|
||||
"material": "fluid",
|
||||
"equation": "electrostatic"
|
||||
}
|
||||
|
||||
|
||||
def setup(doc=None, solvertype="elmer"):
|
||||
# setup base model
|
||||
|
||||
# init FreeCAD document
|
||||
if doc is None:
|
||||
doc = init_doc()
|
||||
|
||||
# geometry object
|
||||
# name is important because the other method in this module use obj name
|
||||
# geometric objects
|
||||
small_sphere1 = doc.addObject("Part::Sphere", "Small_Sphere1")
|
||||
small_sphere1.Placement = FreeCAD.Placement(Vector(-1000, 0, 0), Rotation(Vector(0, 0, 1), 0))
|
||||
small_sphere1.Radius = '500 mm'
|
||||
small_sphere1.Radius = "500 mm"
|
||||
|
||||
small_sphere2 = doc.addObject("Part::Sphere", "Small_Sphere2")
|
||||
small_sphere2.Placement = FreeCAD.Placement(Vector(1000, 0, 0), Rotation(Vector(0, 0, 1), 0))
|
||||
small_sphere2.Radius = '500 mm'
|
||||
small_sphere2.Radius = "500 mm"
|
||||
|
||||
fusion = doc.addObject("Part::MultiFuse", "Fusion")
|
||||
fusion.Shapes = [small_sphere1, small_sphere2]
|
||||
|
||||
large_sphere = doc.addObject("Part::Sphere", "Large_Sphere")
|
||||
large_sphere.Radius = '5000 mm'
|
||||
large_sphere.Radius = "5000 mm"
|
||||
|
||||
geom_obj = doc.addObject("Part::Cut", "Cut")
|
||||
geom_obj.Base = large_sphere
|
||||
@@ -95,8 +95,8 @@ def setup(doc=None, solvertype="elmer"):
|
||||
|
||||
# solver
|
||||
if solvertype == "elmer":
|
||||
solver_object = analysis.addObject(ObjectsFem.makeSolverElmer(doc, "SolverElmer"))[0]
|
||||
eq_electrostatic = ObjectsFem.makeEquationElectrostatic(doc, solver_object)
|
||||
solver_obj = ObjectsFem.makeSolverElmer(doc, "SolverElmer")
|
||||
eq_electrostatic = ObjectsFem.makeEquationElectrostatic(doc, solver_obj)
|
||||
eq_electrostatic.CalculateCapacitanceMatrix = True
|
||||
eq_electrostatic.CalculateElectricEnergy = True
|
||||
eq_electrostatic.CalculateElectricField = True
|
||||
@@ -105,12 +105,11 @@ def setup(doc=None, solvertype="elmer"):
|
||||
"Not known or not supported solver type: {}. "
|
||||
"No solver object was created.\n".format(solvertype)
|
||||
)
|
||||
analysis.addObject(solver_obj)
|
||||
|
||||
# material
|
||||
material_object = analysis.addObject(
|
||||
ObjectsFem.makeMaterialFluid(doc, "FemMaterial")
|
||||
)[0]
|
||||
mat = material_object.Material
|
||||
material_obj = ObjectsFem.makeMaterialFluid(doc, "FemMaterial")
|
||||
mat = material_obj.Material
|
||||
mat["Name"] = "Air-Generic"
|
||||
mat["Density"] = "1.20 kg/m^3"
|
||||
mat["KinematicViscosity"] = "15.11 mm^2/s"
|
||||
@@ -119,32 +118,38 @@ def setup(doc=None, solvertype="elmer"):
|
||||
mat["ThermalExpansionCoefficient"] = "0.0034/K"
|
||||
mat["SpecificHeat"] = "1.00 J/kg/K"
|
||||
mat["RelativePermittivity"] = "1.00"
|
||||
material_object.Material = mat
|
||||
material_obj.Material = mat
|
||||
analysis.addObject(material_obj)
|
||||
|
||||
# 1st potential_constraint
|
||||
constraint_elect_pot0 = analysis.addObject(
|
||||
ObjectsFem.makeConstraintElectrostaticPotential(doc))[0]
|
||||
constraint_elect_pot0.References = [(geom_obj, "Face1")]
|
||||
constraint_elect_pot0.ElectricInfinity = True
|
||||
# constraint potential 1st
|
||||
name_pot1 = "ConstraintElectrostaticPotential001"
|
||||
con_elect_pot1 = ObjectsFem.makeConstraintElectrostaticPotential(doc, name_pot1)
|
||||
con_elect_pot1.References = [(geom_obj, "Face1")]
|
||||
con_elect_pot1.ElectricInfinity = True
|
||||
analysis.addObject(con_elect_pot1)
|
||||
|
||||
# 2nd potential_constraint
|
||||
constraint_elect_pot1 = analysis.addObject(
|
||||
ObjectsFem.makeConstraintElectrostaticPotential(doc))[0]
|
||||
constraint_elect_pot1.References = [(geom_obj, "Face2")]
|
||||
constraint_elect_pot1.CapacitanceBody = 1
|
||||
constraint_elect_pot1.CapacitanceBodyEnabled = True
|
||||
# constraint potential 2nd
|
||||
# TODO: use a better name for the constraint, but unit test needs to be changed
|
||||
name_pot2 = "ConstraintElectrostaticPotential001"
|
||||
con_elect_pot2 = ObjectsFem.makeConstraintElectrostaticPotential(doc, name_pot2)
|
||||
con_elect_pot2.References = [(geom_obj, "Face2")]
|
||||
con_elect_pot2.CapacitanceBody = 1
|
||||
con_elect_pot2.CapacitanceBodyEnabled = True
|
||||
analysis.addObject(con_elect_pot2)
|
||||
|
||||
# 3rd potential_constraint
|
||||
constraint_elect_pot2 = analysis.addObject(
|
||||
ObjectsFem.makeConstraintElectrostaticPotential(doc))[0]
|
||||
constraint_elect_pot2.References = [(geom_obj, "Face3")]
|
||||
constraint_elect_pot2.CapacitanceBody = 2
|
||||
constraint_elect_pot2.CapacitanceBodyEnabled = True
|
||||
# constraint potential 3rd
|
||||
# TODO: use a better name for the constraint, but unit test needs to be changed
|
||||
name_pot3 = "ConstraintElectrostaticPotential002"
|
||||
con_elect_pot3 = ObjectsFem.makeConstraintElectrostaticPotential(doc, name_pot3)
|
||||
con_elect_pot3.References = [(geom_obj, "Face3")]
|
||||
con_elect_pot3.CapacitanceBody = 2
|
||||
con_elect_pot3.CapacitanceBodyEnabled = True
|
||||
analysis.addObject(con_elect_pot3)
|
||||
|
||||
# constant vacuum permittivity
|
||||
const_vaccum_permittivity = analysis.addObject(
|
||||
ObjectsFem.makeConstantVacuumPermittivity(doc))[0]
|
||||
const_vaccum_permittivity.VacuumPermittivity = '1 F/m'
|
||||
const_vacperm = ObjectsFem.makeConstantVacuumPermittivity(doc, "ConstantVacuumPermittivity")
|
||||
const_vacperm.VacuumPermittivity = "1 F/m"
|
||||
analysis.addObject(const_vacperm)
|
||||
|
||||
# mesh
|
||||
from .meshes.mesh_capacitance_two_balls_tetra10 import create_nodes, create_elements
|
||||
@@ -155,16 +160,14 @@ def setup(doc=None, solvertype="elmer"):
|
||||
control = create_elements(fem_mesh)
|
||||
if not control:
|
||||
FreeCAD.Console.PrintError("Error on creating elements.\n")
|
||||
femmesh_obj = analysis.addObject(
|
||||
ObjectsFem.makeMeshGmsh(doc, mesh_name)
|
||||
)[0]
|
||||
femmesh_obj = analysis.addObject(ObjectsFem.makeMeshGmsh(doc, mesh_name))[0]
|
||||
femmesh_obj.FemMesh = fem_mesh
|
||||
femmesh_obj.Part = geom_obj
|
||||
femmesh_obj.SecondOrderLinear = False
|
||||
|
||||
# mesh_region
|
||||
mesh_region = ObjectsFem.makeMeshRegion(doc, femmesh_obj)
|
||||
mesh_region.CharacteristicLength = '300 mm'
|
||||
mesh_region = ObjectsFem.makeMeshRegion(doc, femmesh_obj, name="MeshRegion")
|
||||
mesh_region.CharacteristicLength = "300 mm"
|
||||
mesh_region.References = [(geom_obj, "Face2"), (geom_obj, "Face3")]
|
||||
|
||||
doc.recompute()
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
# ***************************************************************************
|
||||
# * Copyright (c) 2020 Sudhanshu Dubey <sudhanshu.thethunder@gmail.com> *
|
||||
# * Copyright (c) 2021 Bernd Hahnebach <bernd@bimstatik.org> *
|
||||
# * *
|
||||
# * This file is part of the FreeCAD CAx development system. *
|
||||
# * *
|
||||
@@ -25,6 +26,7 @@
|
||||
"""
|
||||
from femexamples.equation_electrostatics_electricforce_elmer_nongui6 import setup
|
||||
setup()
|
||||
|
||||
"""
|
||||
# Electrostatics equation in FreeCAD FEM-Elmer
|
||||
# https://forum.freecadweb.org/viewtopic.php?f=18&t=41488&start=40#p373292
|
||||
@@ -49,29 +51,29 @@ def init_doc(doc=None):
|
||||
|
||||
|
||||
def get_information():
|
||||
info = {"name": "Electrostatics Electricforce - Elmer NonGUI6",
|
||||
"meshtype": "solid",
|
||||
"meshelement": "Tet10",
|
||||
"constraints": ["electrostatic potential"],
|
||||
"solvers": ["elmer"],
|
||||
"material": "fluid",
|
||||
"equation": "electrostatic"
|
||||
}
|
||||
return info
|
||||
return {
|
||||
"name": "Electrostatics Electricforce - Elmer NonGUI6",
|
||||
"meshtype": "solid",
|
||||
"meshelement": "Tet10",
|
||||
"constraints": ["electrostatic potential"],
|
||||
"solvers": ["elmer"],
|
||||
"material": "fluid",
|
||||
"equation": "electrostatic"
|
||||
}
|
||||
|
||||
|
||||
def setup(doc=None, solvertype="elmer"):
|
||||
# setup base model
|
||||
|
||||
# init FreeCAD document
|
||||
if doc is None:
|
||||
doc = init_doc()
|
||||
|
||||
# geometry object
|
||||
# geometric objects
|
||||
# name is important because the other method in this module use obj name
|
||||
geom_obj = doc.addObject('PartDesign::Body', 'Body')
|
||||
base_sketch = geom_obj.newObject('Sketcher::SketchObject', 'Base_Sketch')
|
||||
base_sketch.Support = (doc.getObject('XY_Plane'), [''])
|
||||
base_sketch.MapMode = 'FlatFace'
|
||||
geom_obj = doc.addObject("PartDesign::Body", "Body")
|
||||
base_sketch = geom_obj.newObject("Sketcher::SketchObject", "Base_Sketch")
|
||||
base_sketch.Support = (doc.getObject("XY_Plane"), [""])
|
||||
base_sketch.MapMode = "FlatFace"
|
||||
base_geoList = [
|
||||
Part.LineSegment(Vector(0.000000, 0.000000, 0), Vector(57.407921, 0.000000, 0)),
|
||||
Part.LineSegment(Vector(57.407921, 0.000000, 0), Vector(57.407921, 35.205284, 0)),
|
||||
@@ -79,27 +81,27 @@ def setup(doc=None, solvertype="elmer"):
|
||||
Part.LineSegment(Vector(0.000000, 35.205284, 0), Vector(0.000000, 0.000000, 0))]
|
||||
base_sketch.addGeometry(base_geoList, False)
|
||||
base_conList = [
|
||||
Sketcher.Constraint('Coincident', 0, 2, 1, 1),
|
||||
Sketcher.Constraint('Coincident', 1, 2, 2, 1),
|
||||
Sketcher.Constraint('Coincident', 2, 2, 3, 1),
|
||||
Sketcher.Constraint('Coincident', 3, 2, 0, 1),
|
||||
Sketcher.Constraint('Horizontal', 0),
|
||||
Sketcher.Constraint('Horizontal', 2),
|
||||
Sketcher.Constraint('Vertical', 1),
|
||||
Sketcher.Constraint('Vertical', 3),
|
||||
Sketcher.Constraint('Coincident', 0, 1, -1, 1),
|
||||
Sketcher.Constraint('DistanceY', 1, 1, 1, 2, 35.205284),
|
||||
Sketcher.Constraint('DistanceX', 0, 1, 0, 2, 57.407921)]
|
||||
Sketcher.Constraint("Coincident", 0, 2, 1, 1),
|
||||
Sketcher.Constraint("Coincident", 1, 2, 2, 1),
|
||||
Sketcher.Constraint("Coincident", 2, 2, 3, 1),
|
||||
Sketcher.Constraint("Coincident", 3, 2, 0, 1),
|
||||
Sketcher.Constraint("Horizontal", 0),
|
||||
Sketcher.Constraint("Horizontal", 2),
|
||||
Sketcher.Constraint("Vertical", 1),
|
||||
Sketcher.Constraint("Vertical", 3),
|
||||
Sketcher.Constraint("Coincident", 0, 1, -1, 1),
|
||||
Sketcher.Constraint("DistanceY", 1, 1, 1, 2, 35.205284),
|
||||
Sketcher.Constraint("DistanceX", 0, 1, 0, 2, 57.407921)]
|
||||
base_sketch.addConstraint(base_conList)
|
||||
base_sketch.setDatum(9, Units.Quantity('5000.000000 mm'))
|
||||
base_sketch.setDatum(10, Units.Quantity('5000.000000 mm'))
|
||||
base_sketch.setDatum(9, Units.Quantity("5000.000000 mm"))
|
||||
base_sketch.setDatum(10, Units.Quantity("5000.000000 mm"))
|
||||
|
||||
pad = geom_obj.newObject('PartDesign::Pad', 'Pad')
|
||||
pad = geom_obj.newObject("PartDesign::Pad", "Pad")
|
||||
pad.Profile = base_sketch
|
||||
pad.Length = 7500.0
|
||||
pad.Length2 = 1000.0
|
||||
|
||||
upper_sketch = geom_obj.newObject('Sketcher::SketchObject', 'Upper_Sketch')
|
||||
upper_sketch = geom_obj.newObject("Sketcher::SketchObject", "Upper_Sketch")
|
||||
upper_sketch.Support = None
|
||||
upper_sketch.MapMode = "Deactivated"
|
||||
upper_sketch.Placement = FreeCAD.Placement(Vector(0, 0, 1000), Rotation(Vector(0, 0, 1), 0))
|
||||
@@ -112,31 +114,31 @@ def setup(doc=None, solvertype="elmer"):
|
||||
Part.LineSegment(Vector(0.000000, 1544.678467, 0), Vector(25.560951, 4958.778320, 0))]
|
||||
upper_sketch.addGeometry(upper_geoList, False)
|
||||
upper_conList = [
|
||||
Sketcher.Constraint('Horizontal', 0),
|
||||
Sketcher.Constraint('Coincident', 1, 1, 0, 2),
|
||||
Sketcher.Constraint('PointOnObject', 1, 2, -1),
|
||||
Sketcher.Constraint('Vertical', 1),
|
||||
Sketcher.Constraint('Coincident', 2, 1, 1, 2),
|
||||
Sketcher.Constraint('PointOnObject', 2, 2, -1),
|
||||
Sketcher.Constraint('Coincident', 3, 1, 2, 2),
|
||||
Sketcher.Constraint('Coincident', 4, 1, 3, 2),
|
||||
Sketcher.Constraint('PointOnObject', 4, 2, -2),
|
||||
Sketcher.Constraint('Horizontal', 4),
|
||||
Sketcher.Constraint('Coincident', 5, 1, 4, 2),
|
||||
Sketcher.Constraint('Coincident', 5, 2, 0, 1),
|
||||
Sketcher.Constraint('Vertical', 5),
|
||||
Sketcher.Constraint('Vertical', 3),
|
||||
Sketcher.Constraint('DistanceX', 0, 1, 0, 2, 5037.082520),
|
||||
Sketcher.Constraint('DistanceY', 1, 2, 1, 1, 4958.778320),
|
||||
Sketcher.Constraint('DistanceY', 3, 1, 3, 2, 1544.678467),
|
||||
Sketcher.Constraint('DistanceX', 4, 2, 4, 1, 1309.763672)]
|
||||
Sketcher.Constraint("Horizontal", 0),
|
||||
Sketcher.Constraint("Coincident", 1, 1, 0, 2),
|
||||
Sketcher.Constraint("PointOnObject", 1, 2, -1),
|
||||
Sketcher.Constraint("Vertical", 1),
|
||||
Sketcher.Constraint("Coincident", 2, 1, 1, 2),
|
||||
Sketcher.Constraint("PointOnObject", 2, 2, -1),
|
||||
Sketcher.Constraint("Coincident", 3, 1, 2, 2),
|
||||
Sketcher.Constraint("Coincident", 4, 1, 3, 2),
|
||||
Sketcher.Constraint("PointOnObject", 4, 2, -2),
|
||||
Sketcher.Constraint("Horizontal", 4),
|
||||
Sketcher.Constraint("Coincident", 5, 1, 4, 2),
|
||||
Sketcher.Constraint("Coincident", 5, 2, 0, 1),
|
||||
Sketcher.Constraint("Vertical", 5),
|
||||
Sketcher.Constraint("Vertical", 3),
|
||||
Sketcher.Constraint("DistanceX", 0, 1, 0, 2, 5037.082520),
|
||||
Sketcher.Constraint("DistanceY", 1, 2, 1, 1, 4958.778320),
|
||||
Sketcher.Constraint("DistanceY", 3, 1, 3, 2, 1544.678467),
|
||||
Sketcher.Constraint("DistanceX", 4, 2, 4, 1, 1309.763672)]
|
||||
upper_sketch.addConstraint(upper_conList)
|
||||
upper_sketch.setDatum(14, Units.Quantity('5000.000000 mm'))
|
||||
upper_sketch.setDatum(15, Units.Quantity('5000.000000 mm'))
|
||||
upper_sketch.setDatum(16, Units.Quantity('1500.000000 mm'))
|
||||
upper_sketch.setDatum(17, Units.Quantity('1500.000000 mm'))
|
||||
upper_sketch.setDatum(14, Units.Quantity("5000.000000 mm"))
|
||||
upper_sketch.setDatum(15, Units.Quantity("5000.000000 mm"))
|
||||
upper_sketch.setDatum(16, Units.Quantity("1500.000000 mm"))
|
||||
upper_sketch.setDatum(17, Units.Quantity("1500.000000 mm"))
|
||||
|
||||
pocket = geom_obj.newObject('PartDesign::Pocket', 'Pocket')
|
||||
pocket = geom_obj.newObject("PartDesign::Pocket", "Pocket")
|
||||
pocket.Profile = upper_sketch
|
||||
pocket.Length = 1500.0
|
||||
pocket.Length2 = 100.0
|
||||
@@ -152,20 +154,19 @@ def setup(doc=None, solvertype="elmer"):
|
||||
|
||||
# solver
|
||||
if solvertype == "elmer":
|
||||
solver_object = analysis.addObject(ObjectsFem.makeSolverElmer(doc, "SolverElmer"))[0]
|
||||
ObjectsFem.makeEquationElectrostatic(doc, solver_object)
|
||||
ObjectsFem.makeEquationElectricforce(doc, solver_object)
|
||||
solver_obj = ObjectsFem.makeSolverElmer(doc, "SolverElmer")
|
||||
ObjectsFem.makeEquationElectrostatic(doc, solver_obj)
|
||||
ObjectsFem.makeEquationElectricforce(doc, solver_obj)
|
||||
else:
|
||||
FreeCAD.Console.PrintWarning(
|
||||
"Not known or not supported solver type: {}. "
|
||||
"No solver object was created.\n".format(solvertype)
|
||||
)
|
||||
analysis.addObject(solver_obj)
|
||||
|
||||
# material
|
||||
material_object = analysis.addObject(
|
||||
ObjectsFem.makeMaterialFluid(doc, "FemMaterial")
|
||||
)[0]
|
||||
mat = material_object.Material
|
||||
material_obj = ObjectsFem.makeMaterialFluid(doc, "FemMaterial")
|
||||
mat = material_obj.Material
|
||||
mat["Name"] = "Air-Generic"
|
||||
mat["Density"] = "1.20 kg/m^3"
|
||||
mat["KinematicViscosity"] = "15.11 mm^2/s"
|
||||
@@ -174,30 +175,34 @@ def setup(doc=None, solvertype="elmer"):
|
||||
mat["ThermalExpansionCoefficient"] = "0.0034/K"
|
||||
mat["SpecificHeat"] = "1.00 J/kg/K"
|
||||
mat["RelativePermittivity"] = "1.00"
|
||||
material_object.Material = mat
|
||||
material_obj.Material = mat
|
||||
analysis.addObject(material_obj)
|
||||
|
||||
# 0V_potential_constraint
|
||||
constraint_elect_pot0 = analysis.addObject(
|
||||
ObjectsFem.makeConstraintElectrostaticPotential(doc))[0]
|
||||
constraint_elect_pot0.References = [(geom_obj, "Face2")]
|
||||
constraint_elect_pot0.Potential = 0.00
|
||||
constraint_elect_pot0.CapacitanceBody = 1
|
||||
constraint_elect_pot0.CapacitanceBodyEnabled = True
|
||||
constraint_elect_pot0.PotentialEnabled = True
|
||||
# constraint potential 0V
|
||||
name_pot1 = "ConstraintElectrostaticPotential"
|
||||
con_elect_pot1 = ObjectsFem.makeConstraintElectrostaticPotential(doc, name_pot1)
|
||||
con_elect_pot1.References = [(geom_obj, "Face2")]
|
||||
con_elect_pot1.Potential = 0.00
|
||||
con_elect_pot1.CapacitanceBody = 1
|
||||
con_elect_pot1.CapacitanceBodyEnabled = True
|
||||
con_elect_pot1.PotentialEnabled = True
|
||||
analysis.addObject(con_elect_pot1)
|
||||
|
||||
# 1e6V_potential_constraint
|
||||
constraint_elect_pot1 = analysis.addObject(
|
||||
ObjectsFem.makeConstraintElectrostaticPotential(doc))[0]
|
||||
constraint_elect_pot1.References = [
|
||||
# constraint potential 1e6V
|
||||
# TODO: use a better name for the constraint, but unit test needs to be changed
|
||||
name_pot2 = "ConstraintElectrostaticPotential001"
|
||||
con_elect_pot2 = ObjectsFem.makeConstraintElectrostaticPotential(doc, name_pot2)
|
||||
con_elect_pot2.References = [
|
||||
(geom_obj, "Face4"),
|
||||
(geom_obj, "Face5"),
|
||||
(geom_obj, "Face6"),
|
||||
(geom_obj, "Face11")]
|
||||
constraint_elect_pot1.Potential = 1000000.00
|
||||
constraint_elect_pot1.CapacitanceBody = 2
|
||||
constraint_elect_pot1.CapacitanceBodyEnabled = True
|
||||
constraint_elect_pot1.PotentialEnabled = True
|
||||
constraint_elect_pot1.ElectricForcecalculation = True
|
||||
con_elect_pot2.Potential = 1000000.00
|
||||
con_elect_pot2.CapacitanceBody = 2
|
||||
con_elect_pot2.CapacitanceBodyEnabled = True
|
||||
con_elect_pot2.PotentialEnabled = True
|
||||
con_elect_pot2.ElectricForcecalculation = True
|
||||
analysis.addObject(con_elect_pot2)
|
||||
|
||||
# mesh
|
||||
from .meshes.mesh_electricforce_elmer_nongui6_tetra10 import create_nodes, create_elements
|
||||
@@ -208,16 +213,14 @@ def setup(doc=None, solvertype="elmer"):
|
||||
control = create_elements(fem_mesh)
|
||||
if not control:
|
||||
FreeCAD.Console.PrintError("Error on creating elements.\n")
|
||||
femmesh_obj = analysis.addObject(
|
||||
ObjectsFem.makeMeshGmsh(doc, mesh_name)
|
||||
)[0]
|
||||
femmesh_obj = analysis.addObject(ObjectsFem.makeMeshGmsh(doc, mesh_name))[0]
|
||||
femmesh_obj.FemMesh = fem_mesh
|
||||
femmesh_obj.Part = geom_obj
|
||||
femmesh_obj.SecondOrderLinear = False
|
||||
|
||||
# mesh_region
|
||||
mesh_region = ObjectsFem.makeMeshRegion(doc, femmesh_obj)
|
||||
mesh_region.CharacteristicLength = '300 mm'
|
||||
mesh_region = ObjectsFem.makeMeshRegion(doc, femmesh_obj, name="MeshRegion")
|
||||
mesh_region.CharacteristicLength = "300 mm"
|
||||
mesh_region.References = [
|
||||
(geom_obj, "Face4"),
|
||||
(geom_obj, "Face5"),
|
||||
|
||||
@@ -45,30 +45,29 @@ def init_doc(doc=None):
|
||||
|
||||
|
||||
def get_information():
|
||||
info = {"name": "Frequency Analysis Simple Beam",
|
||||
"meshtype": "solid",
|
||||
"meshelement": "Tet10",
|
||||
"constraints": ["fixed"],
|
||||
"solvers": ["calculix"],
|
||||
"material": "solid",
|
||||
"equation": "frequency"
|
||||
}
|
||||
return info
|
||||
return {
|
||||
"name": "Frequency Analysis Simple Beam",
|
||||
"meshtype": "solid",
|
||||
"meshelement": "Tet10",
|
||||
"constraints": ["fixed"],
|
||||
"solvers": ["calculix"],
|
||||
"material": "solid",
|
||||
"equation": "frequency"
|
||||
}
|
||||
|
||||
|
||||
def setup(doc=None, solvertype="ccxtools"):
|
||||
# setup simple beam frequency
|
||||
|
||||
# init FreeCAD document
|
||||
if doc is None:
|
||||
doc = init_doc()
|
||||
|
||||
# geometry object
|
||||
# geometric object
|
||||
geom_obj = doc.addObject("Part::Box", "Box")
|
||||
geom_obj.Length = 3000
|
||||
geom_obj.Width = 100
|
||||
geom_obj.Height = 50
|
||||
doc.recompute()
|
||||
|
||||
if FreeCAD.GuiUp:
|
||||
geom_obj.ViewObject.Document.activeView().viewAxonometric()
|
||||
geom_obj.ViewObject.Document.activeView().fitAll()
|
||||
@@ -78,74 +77,69 @@ def setup(doc=None, solvertype="ccxtools"):
|
||||
|
||||
# solver
|
||||
if solvertype == "calculix":
|
||||
solver_object = analysis.addObject(
|
||||
ObjectsFem.makeSolverCalculix(doc, "SolverCalculiX")
|
||||
)[0]
|
||||
solver_obj = ObjectsFem.makeSolverCalculix(doc, "SolverCalculiX")
|
||||
elif solvertype == "ccxtools":
|
||||
solver_object = analysis.addObject(
|
||||
ObjectsFem.makeSolverCalculixCcxTools(doc, "CalculiXccxTools")
|
||||
)[0]
|
||||
solver_object.WorkingDir = u""
|
||||
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_object.SplitInputWriter = False
|
||||
solver_object.AnalysisType = "frequency"
|
||||
solver_object.GeometricalNonlinearity = "linear"
|
||||
solver_object.ThermoMechSteadyState = False
|
||||
solver_object.MatrixSolverType = "default"
|
||||
solver_object.IterationsControlParameterTimeUse = False
|
||||
solver_object.EigenmodesCount = 10
|
||||
solver_object.EigenmodeHighLimit = 1000000.0
|
||||
solver_object.EigenmodeLowLimit = 0.01
|
||||
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_object = analysis.addObject(
|
||||
material_obj = analysis.addObject(
|
||||
ObjectsFem.makeMaterialSolid(doc, "MechanicalMaterial")
|
||||
)[0]
|
||||
mat = material_object.Material
|
||||
mat = material_obj.Material
|
||||
mat["Name"] = "Steel-Generic"
|
||||
mat["YoungsModulus"] = "200000 MPa"
|
||||
mat["PoissonRatio"] = "0.30"
|
||||
mat["Density"] = "7900 kg/m^3"
|
||||
material_object.Material = mat
|
||||
material_obj.Material = mat
|
||||
analysis.addObject(material_obj)
|
||||
|
||||
# displacement_constraint 1
|
||||
displacement_constraint = doc.Analysis.addObject(
|
||||
ObjectsFem.makeConstraintDisplacement(doc, name="Fix_XYZ")
|
||||
)[0]
|
||||
displacement_constraint.References = [(doc.Box, "Edge4")]
|
||||
displacement_constraint.xFix = True
|
||||
displacement_constraint.xFree = False
|
||||
displacement_constraint.xDisplacement = 0.0
|
||||
displacement_constraint.yFix = True
|
||||
displacement_constraint.yFree = False
|
||||
displacement_constraint.yDisplacement = 0.0
|
||||
displacement_constraint.zFix = True
|
||||
displacement_constraint.zFree = False
|
||||
displacement_constraint.zDisplacement = 0.0
|
||||
# constraint displacement xyz
|
||||
con_disp_xyz = ObjectsFem.makeConstraintDisplacement(doc, "Fix_XYZ")
|
||||
con_disp_xyz.References = [(doc.Box, "Edge4")]
|
||||
con_disp_xyz.xFix = True
|
||||
con_disp_xyz.xFree = False
|
||||
con_disp_xyz.xDisplacement = 0.0
|
||||
con_disp_xyz.yFix = True
|
||||
con_disp_xyz.yFree = False
|
||||
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)
|
||||
|
||||
# displacement_constraint 2
|
||||
displacement_constraint = doc.Analysis.addObject(
|
||||
ObjectsFem.makeConstraintDisplacement(doc, name="Fix_YZ")
|
||||
)[0]
|
||||
displacement_constraint.References = [(doc.Box, "Edge8")]
|
||||
displacement_constraint.xFix = False
|
||||
displacement_constraint.xFree = True
|
||||
displacement_constraint.xDisplacement = 0.0
|
||||
displacement_constraint.yFix = True
|
||||
displacement_constraint.yFree = False
|
||||
displacement_constraint.yDisplacement = 0.0
|
||||
displacement_constraint.zFix = True
|
||||
displacement_constraint.zFree = False
|
||||
displacement_constraint.zDisplacement = 0.0
|
||||
# constraint displacement yz
|
||||
con_disp_yz = ObjectsFem.makeConstraintDisplacement(doc, "Fix_YZ")
|
||||
con_disp_yz.References = [(doc.Box, "Edge8")]
|
||||
con_disp_yz.xFix = False
|
||||
con_disp_yz.xFree = True
|
||||
con_disp_yz.xDisplacement = 0.0
|
||||
con_disp_yz.yFix = True
|
||||
con_disp_yz.yFree = False
|
||||
con_disp_yz.yDisplacement = 0.0
|
||||
con_disp_yz.zFix = True
|
||||
con_disp_yz.zFree = False
|
||||
con_disp_yz.zDisplacement = 0.0
|
||||
analysis.addObject(con_disp_yz)
|
||||
|
||||
# mesh
|
||||
from .meshes.mesh_beamsimple_tetra10 import create_nodes, create_elements
|
||||
|
||||
fem_mesh = Fem.FemMesh()
|
||||
control = create_nodes(fem_mesh)
|
||||
if not control:
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
# ***************************************************************************
|
||||
# * Copyright (c) 2020 Sudhanshu Dubey <sudhanshu.thethunder@gmail.com> *
|
||||
# * Copyright (c) 2021 Bernd Hahnebach <bernd@bimstatik.org> *
|
||||
# * *
|
||||
# * This file is part of the FreeCAD CAx development system. *
|
||||
# * *
|
||||
@@ -25,6 +26,7 @@
|
||||
"""
|
||||
from femexamples.material_multiple_bendingbeam_fiveboxes import setup
|
||||
setup()
|
||||
|
||||
"""
|
||||
|
||||
import FreeCAD
|
||||
@@ -43,23 +45,24 @@ def init_doc(doc=None):
|
||||
|
||||
|
||||
def get_information():
|
||||
info = {"name": "Multimaterial bending beam 5 boxes",
|
||||
"meshtype": "solid",
|
||||
"meshelement": "Tet10",
|
||||
"constraints": ["fixed", "force"],
|
||||
"solvers": ["calculix"],
|
||||
"material": "solid",
|
||||
"equation": "mechanical"
|
||||
}
|
||||
return info
|
||||
return {
|
||||
"name": "Multimaterial bending beam 5 boxes",
|
||||
"meshtype": "solid",
|
||||
"meshelement": "Tet10",
|
||||
"constraints": ["fixed", "force"],
|
||||
"solvers": ["calculix"],
|
||||
"material": "solid",
|
||||
"equation": "mechanical"
|
||||
}
|
||||
|
||||
|
||||
def setup(doc=None, solvertype="ccxtools"):
|
||||
|
||||
# init FreeCAD document
|
||||
if doc is None:
|
||||
doc = init_doc()
|
||||
|
||||
# geometry object
|
||||
# geometric objects
|
||||
# name is important because the other method in this module use obj name
|
||||
box_obj1 = doc.addObject('Part::Box', 'Box1')
|
||||
box_obj1.Height = 10
|
||||
@@ -112,81 +115,73 @@ def setup(doc=None, solvertype="ccxtools"):
|
||||
|
||||
# solver
|
||||
if solvertype == "calculix":
|
||||
solver_object = analysis.addObject(
|
||||
ObjectsFem.makeSolverCalculix(doc, "SolverCalculiX")
|
||||
)[0]
|
||||
solver_obj = ObjectsFem.makeSolverCalculix(doc, "SolverCalculiX")
|
||||
elif solvertype == "ccxtools":
|
||||
solver_object = analysis.addObject(
|
||||
ObjectsFem.makeSolverCalculixCcxTools(doc, "CalculiXccxTools")
|
||||
)[0]
|
||||
solver_object.WorkingDir = u""
|
||||
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_object.SplitInputWriter = False
|
||||
solver_object.AnalysisType = "static"
|
||||
solver_object.GeometricalNonlinearity = "linear"
|
||||
solver_object.ThermoMechSteadyState = False
|
||||
solver_object.MatrixSolverType = "default"
|
||||
solver_object.IterationsControlParameterTimeUse = False
|
||||
solver_obj.SplitInputWriter = False
|
||||
solver_obj.AnalysisType = "static"
|
||||
solver_obj.GeometricalNonlinearity = "linear"
|
||||
solver_obj.ThermoMechSteadyState = False
|
||||
solver_obj.MatrixSolverType = "default"
|
||||
solver_obj.IterationsControlParameterTimeUse = False
|
||||
analysis.addObject(solver_obj)
|
||||
|
||||
# material
|
||||
# material1
|
||||
material_object1 = analysis.addObject(
|
||||
ObjectsFem.makeMaterialSolid(doc, 'FemMaterial1'))[0]
|
||||
material_object1.References = [(doc.Box3, "Solid1")]
|
||||
mat = material_object1.Material
|
||||
material_obj1 = ObjectsFem.makeMaterialSolid(doc, 'FemMaterial1')
|
||||
material_obj1.References = [(doc.Box3, "Solid1")]
|
||||
mat = material_obj1.Material
|
||||
mat['Name'] = "Concrete-Generic"
|
||||
mat['YoungsModulus'] = "32000 MPa"
|
||||
mat['PoissonRatio'] = "0.17"
|
||||
mat['Density'] = "0 kg/m^3"
|
||||
material_object1.Material = mat
|
||||
material_obj1.Material = mat
|
||||
analysis.addObject(material_obj1)
|
||||
|
||||
# material2
|
||||
material_object2 = analysis.addObject(
|
||||
ObjectsFem.makeMaterialSolid(doc, 'FemMaterial2'))[0]
|
||||
material_object2.References = [(doc.Box2, "Solid1"), (doc.Box4, "Solid1")]
|
||||
mat = material_object2.Material
|
||||
material_obj2 = ObjectsFem.makeMaterialSolid(doc, 'FemMaterial2')
|
||||
material_obj2.References = [(doc.Box2, "Solid1"), (doc.Box4, "Solid1")]
|
||||
mat = material_obj2.Material
|
||||
mat['Name'] = "PLA"
|
||||
mat['YoungsModulus'] = "3640 MPa"
|
||||
mat['PoissonRatio'] = "0.36"
|
||||
mat['Density'] = "0 kg/m^3"
|
||||
material_object2.Material = mat
|
||||
material_obj2.Material = mat
|
||||
analysis.addObject(material_obj2)
|
||||
|
||||
# material3
|
||||
material_object3 = analysis.addObject(
|
||||
ObjectsFem.makeMaterialSolid(doc, 'FemMaterial3'))[0]
|
||||
material_object3.References = []
|
||||
mat = material_object3.Material
|
||||
material_obj3 = ObjectsFem.makeMaterialSolid(doc, 'FemMaterial3')
|
||||
material_obj3.References = []
|
||||
mat = material_obj3.Material
|
||||
mat['Name'] = "Steel-Generic"
|
||||
mat['YoungsModulus'] = "200000 MPa"
|
||||
mat['PoissonRatio'] = "0.30"
|
||||
mat['Density'] = "7900 kg/m^3"
|
||||
material_object3.Material = mat
|
||||
material_obj3.Material = mat
|
||||
analysis.addObject(material_obj3)
|
||||
|
||||
# constraint fixed
|
||||
fixed_constraint = analysis.addObject(
|
||||
ObjectsFem.makeConstraintFixed(doc, name="ConstraintFixed")
|
||||
)[0]
|
||||
fixed_constraint.References = [(doc.Box1, "Face1"), (doc.Box5, "Face2")]
|
||||
con_fixed = ObjectsFem.makeConstraintFixed(doc, "ConstraintFixed")
|
||||
con_fixed.References = [(doc.Box1, "Face1"), (doc.Box5, "Face2")]
|
||||
analysis.addObject(con_fixed)
|
||||
|
||||
# force_constraint
|
||||
force_constraint = analysis.addObject(
|
||||
ObjectsFem.makeConstraintForce(doc, name="ConstraintForce")
|
||||
)[0]
|
||||
force_constraint.References = [
|
||||
# constraint force
|
||||
con_force = ObjectsFem.makeConstraintForce(doc, "ConstraintForce")
|
||||
con_force.References = [
|
||||
(doc.Box1, "Face6"),
|
||||
(doc.Box2, "Face6"),
|
||||
(doc.Box3, "Face6"),
|
||||
(doc.Box4, "Face6"),
|
||||
(doc.Box5, "Face6")
|
||||
]
|
||||
force_constraint.Force = 10000.00
|
||||
force_constraint.Direction = (doc.Box1, ["Edge1"])
|
||||
force_constraint.Reversed = True
|
||||
con_force.Force = 10000.00
|
||||
con_force.Direction = (doc.Box1, ["Edge1"])
|
||||
con_force.Reversed = True
|
||||
analysis.addObject(con_force)
|
||||
|
||||
# mesh
|
||||
from .meshes.mesh_multibodybeam_tetra10 import create_nodes, create_elements
|
||||
@@ -197,9 +192,7 @@ def setup(doc=None, solvertype="ccxtools"):
|
||||
control = create_elements(fem_mesh)
|
||||
if not control:
|
||||
FreeCAD.Console.PrintError("Error on creating elements.\n")
|
||||
femmesh_obj = analysis.addObject(
|
||||
ObjectsFem.makeMeshGmsh(doc, mesh_name)
|
||||
)[0]
|
||||
femmesh_obj = analysis.addObject(ObjectsFem.makeMeshGmsh(doc, mesh_name))[0]
|
||||
femmesh_obj.FemMesh = fem_mesh
|
||||
femmesh_obj.Part = geom_obj
|
||||
femmesh_obj.SecondOrderLinear = False
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
# ***************************************************************************
|
||||
# * Copyright (c) 2020 Sudhanshu Dubey <sudhanshu.thethunder@gmail.com> *
|
||||
# * Copyright (c) 2021 Bernd Hahnebach <bernd@bimstatik.org> *
|
||||
# * *
|
||||
# * This file is part of the FreeCAD CAx development system. *
|
||||
# * *
|
||||
@@ -25,6 +26,7 @@
|
||||
"""
|
||||
from femexamples.material_multiple_bendingbeam_fivefaces import setup
|
||||
setup()
|
||||
|
||||
"""
|
||||
|
||||
import FreeCAD
|
||||
@@ -42,23 +44,24 @@ def init_doc(doc=None):
|
||||
|
||||
|
||||
def get_information():
|
||||
info = {"name": "Multimaterial bending beam 5 faces",
|
||||
"meshtype": "solid",
|
||||
"meshelement": "Tria6",
|
||||
"constraints": ["fixed", "force"],
|
||||
"solvers": ["calculix"],
|
||||
"material": "solid",
|
||||
"equation": "mechanical"
|
||||
}
|
||||
return info
|
||||
return {
|
||||
"name": "Multimaterial bending beam 5 faces",
|
||||
"meshtype": "solid",
|
||||
"meshelement": "Tria6",
|
||||
"constraints": ["fixed", "force"],
|
||||
"solvers": ["calculix"],
|
||||
"material": "solid",
|
||||
"equation": "mechanical"
|
||||
}
|
||||
|
||||
|
||||
def setup(doc=None, solvertype="ccxtools"):
|
||||
|
||||
# init FreeCAD document
|
||||
if doc is None:
|
||||
doc = init_doc()
|
||||
|
||||
# geometry object
|
||||
# geometric objects
|
||||
# name is important because the other method in this module use obj name
|
||||
# parts
|
||||
face_obj1 = doc.addObject('Part::Plane', 'Face1')
|
||||
@@ -102,95 +105,83 @@ def setup(doc=None, solvertype="ccxtools"):
|
||||
|
||||
# solver
|
||||
if solvertype == "calculix":
|
||||
solver_object = analysis.addObject(
|
||||
ObjectsFem.makeSolverCalculix(doc, "SolverCalculiX")
|
||||
)[0]
|
||||
solver_obj = ObjectsFem.makeSolverCalculix(doc, "SolverCalculiX")
|
||||
elif solvertype == "ccxtools":
|
||||
solver_object = analysis.addObject(
|
||||
ObjectsFem.makeSolverCalculixCcxTools(doc, "CalculiXccxTools")
|
||||
)[0]
|
||||
solver_object.WorkingDir = u""
|
||||
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_object.SplitInputWriter = False
|
||||
solver_object.AnalysisType = "static"
|
||||
solver_object.GeometricalNonlinearity = "linear"
|
||||
solver_object.ThermoMechSteadyState = False
|
||||
solver_object.MatrixSolverType = "default"
|
||||
solver_object.IterationsControlParameterTimeUse = False
|
||||
solver_obj.SplitInputWriter = False
|
||||
solver_obj.AnalysisType = "static"
|
||||
solver_obj.GeometricalNonlinearity = "linear"
|
||||
solver_obj.ThermoMechSteadyState = False
|
||||
solver_obj.MatrixSolverType = "default"
|
||||
solver_obj.IterationsControlParameterTimeUse = False
|
||||
analysis.addObject(solver_obj)
|
||||
|
||||
# shell thickness
|
||||
analysis.addObject(
|
||||
ObjectsFem.makeElementGeometry2D(doc, 10, 'ShellThickness')
|
||||
)
|
||||
thickness_obj = ObjectsFem.makeElementGeometry2D(doc, 10, 'ShellThickness')
|
||||
analysis.addObject(thickness_obj)
|
||||
|
||||
# materials
|
||||
# material1
|
||||
material_object1 = analysis.addObject(
|
||||
ObjectsFem.makeMaterialSolid(doc, 'FemMaterial1')
|
||||
)[0]
|
||||
material_object1.References = [(doc.Face3, "Face1")]
|
||||
mat = material_object1.Material
|
||||
material_obj1 = ObjectsFem.makeMaterialSolid(doc, 'FemMaterial1')
|
||||
material_obj1.References = [(doc.Face3, "Face1")]
|
||||
mat = material_obj1.Material
|
||||
mat['Name'] = "Concrete-Generic"
|
||||
mat['YoungsModulus'] = "32000 MPa"
|
||||
mat['PoissonRatio'] = "0.17"
|
||||
mat['Density'] = "0 kg/m^3"
|
||||
material_object1.Material = mat
|
||||
material_obj1.Material = mat
|
||||
analysis.addObject(material_obj1)
|
||||
|
||||
# material2
|
||||
material_object2 = analysis.addObject(
|
||||
ObjectsFem.makeMaterialSolid(doc, 'FemMaterial2')
|
||||
)[0]
|
||||
material_object2.References = [
|
||||
material_obj2 = ObjectsFem.makeMaterialSolid(doc, 'FemMaterial2')
|
||||
material_obj2.References = [
|
||||
(doc.Face2, "Face1"),
|
||||
(doc.Face4, "Face1")
|
||||
]
|
||||
mat = material_object2.Material
|
||||
mat = material_obj2.Material
|
||||
mat['Name'] = "PLA"
|
||||
mat['YoungsModulus'] = "3640 MPa"
|
||||
mat['PoissonRatio'] = "0.36"
|
||||
mat['Density'] = "0 kg/m^3"
|
||||
material_object2.Material = mat
|
||||
material_obj2.Material = mat
|
||||
analysis.addObject(material_obj2)
|
||||
|
||||
# material3
|
||||
material_object3 = analysis.addObject(
|
||||
ObjectsFem.makeMaterialSolid(doc, 'FemMaterial3')
|
||||
)[0]
|
||||
material_object3.References = []
|
||||
mat = material_object3.Material
|
||||
material_obj3 = ObjectsFem.makeMaterialSolid(doc, 'FemMaterial3')
|
||||
material_obj3.References = []
|
||||
mat = material_obj3.Material
|
||||
mat['Name'] = "Steel-Generic"
|
||||
mat['YoungsModulus'] = "200000 MPa"
|
||||
mat['PoissonRatio'] = "0.30"
|
||||
mat['Density'] = "7900 kg/m^3"
|
||||
material_object3.Material = mat
|
||||
material_obj3.Material = mat
|
||||
analysis.addObject(material_obj3)
|
||||
|
||||
# fixed_constraint
|
||||
fixed_constraint = analysis.addObject(
|
||||
ObjectsFem.makeConstraintFixed(doc, name="ConstraintFixed")
|
||||
)[0]
|
||||
fixed_constraint.References = [
|
||||
# constraint fixed
|
||||
con_fixed = ObjectsFem.makeConstraintFixed(doc, "ConstraintFixed")
|
||||
con_fixed.References = [
|
||||
(doc.Face1, "Edge1"),
|
||||
(doc.Face5, "Edge3")
|
||||
]
|
||||
analysis.addObject(con_fixed)
|
||||
|
||||
# force_constraint
|
||||
force_constraint = analysis.addObject(
|
||||
ObjectsFem.makeConstraintForce(doc, name="ConstraintForce")
|
||||
)[0]
|
||||
force_constraint.References = [
|
||||
# constraint force
|
||||
con_force = ObjectsFem.makeConstraintForce(doc, "ConstraintForce")
|
||||
con_force.References = [
|
||||
(doc.Face1, "Edge4"),
|
||||
(doc.Face2, "Edge4"),
|
||||
(doc.Face3, "Edge4"),
|
||||
(doc.Face4, "Edge4"),
|
||||
(doc.Face5, "Edge4")
|
||||
]
|
||||
force_constraint.Force = 10000.00
|
||||
force_constraint.Direction = (doc.Face1, ["Edge1"])
|
||||
force_constraint.Reversed = True
|
||||
con_force.Force = 10000.00
|
||||
con_force.Direction = (doc.Face1, ["Edge1"])
|
||||
con_force.Reversed = True
|
||||
analysis.addObject(con_force)
|
||||
|
||||
# mesh
|
||||
from .meshes.mesh_multibodybeam_tria6 import create_nodes, create_elements
|
||||
@@ -201,9 +192,7 @@ def setup(doc=None, solvertype="ccxtools"):
|
||||
control = create_elements(fem_mesh)
|
||||
if not control:
|
||||
FreeCAD.Console.PrintError("Error on creating elements.\n")
|
||||
femmesh_obj = analysis.addObject(
|
||||
ObjectsFem.makeMeshGmsh(doc, mesh_name)
|
||||
)[0]
|
||||
femmesh_obj = analysis.addObject(ObjectsFem.makeMeshGmsh(doc, mesh_name))[0]
|
||||
femmesh_obj.FemMesh = fem_mesh
|
||||
femmesh_obj.Part = geom_obj
|
||||
femmesh_obj.SecondOrderLinear = False
|
||||
|
||||
@@ -46,24 +46,24 @@ def init_doc(doc=None):
|
||||
|
||||
|
||||
def get_information():
|
||||
info = {"name": "Multimaterial tension rod 2 boxes",
|
||||
"meshtype": "solid",
|
||||
"meshelement": "Tet10",
|
||||
"constraints": ["fixed", "pressure"],
|
||||
"solvers": ["calculix"],
|
||||
"material": "multimaterial",
|
||||
"equation": "mechanical"
|
||||
}
|
||||
return info
|
||||
return {
|
||||
"name": "Multimaterial tension rod 2 boxes",
|
||||
"meshtype": "solid",
|
||||
"meshelement": "Tet10",
|
||||
"constraints": ["fixed", "pressure"],
|
||||
"solvers": ["calculix"],
|
||||
"material": "multimaterial",
|
||||
"equation": "mechanical"
|
||||
}
|
||||
|
||||
|
||||
def setup(doc=None, solvertype="ccxtools"):
|
||||
# setup model
|
||||
|
||||
# init FreeCAD document
|
||||
if doc is None:
|
||||
doc = init_doc()
|
||||
|
||||
# geometry objects
|
||||
# geometric objects
|
||||
# two boxes
|
||||
boxlow = doc.addObject("Part::Box", "BoxLower")
|
||||
boxupp = doc.addObject("Part::Box", "BoxUpper")
|
||||
@@ -100,64 +100,56 @@ def setup(doc=None, solvertype="ccxtools"):
|
||||
|
||||
# solver
|
||||
if solvertype == "calculix":
|
||||
solver_object = analysis.addObject(
|
||||
ObjectsFem.makeSolverCalculix(doc, "SolverCalculiX")
|
||||
)[0]
|
||||
solver_obj = ObjectsFem.makeSolverCalculix(doc, "SolverCalculiX")
|
||||
elif solvertype == "ccxtools":
|
||||
solver_object = analysis.addObject(
|
||||
ObjectsFem.makeSolverCalculixCcxTools(doc, "CalculiXccxTools")
|
||||
)[0]
|
||||
solver_object.WorkingDir = u""
|
||||
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_object.SplitInputWriter = False
|
||||
solver_object.AnalysisType = "static"
|
||||
solver_object.GeometricalNonlinearity = "linear"
|
||||
solver_object.ThermoMechSteadyState = False
|
||||
solver_object.MatrixSolverType = "default"
|
||||
solver_object.IterationsControlParameterTimeUse = False
|
||||
solver_obj.SplitInputWriter = False
|
||||
solver_obj.AnalysisType = "static"
|
||||
solver_obj.GeometricalNonlinearity = "linear"
|
||||
solver_obj.ThermoMechSteadyState = False
|
||||
solver_obj.MatrixSolverType = "default"
|
||||
solver_obj.IterationsControlParameterTimeUse = False
|
||||
analysis.addObject(solver_obj)
|
||||
|
||||
# material
|
||||
material_object_low = analysis.addObject(
|
||||
ObjectsFem.makeMaterialSolid(doc, "MechanicalMaterialLow")
|
||||
)[0]
|
||||
mat = material_object_low.Material
|
||||
# materials
|
||||
material_obj_low = ObjectsFem.makeMaterialSolid(doc, "MechanicalMaterialLow")
|
||||
mat = material_obj_low.Material
|
||||
mat["Name"] = "Aluminium-Generic"
|
||||
mat["YoungsModulus"] = "70000 MPa"
|
||||
mat["PoissonRatio"] = "0.35"
|
||||
mat["Density"] = "2700 kg/m^3"
|
||||
material_object_low.Material = mat
|
||||
material_object_low.References = [(boxlow, "Solid1")]
|
||||
analysis.addObject(material_object_low)
|
||||
material_obj_low.Material = mat
|
||||
material_obj_low.References = [(boxlow, "Solid1")]
|
||||
analysis.addObject(material_obj_low)
|
||||
|
||||
material_object_upp = analysis.addObject(
|
||||
ObjectsFem.makeMaterialSolid(doc, "MechanicalMaterialUpp")
|
||||
)[0]
|
||||
mat = material_object_upp.Material
|
||||
material_obj_upp = ObjectsFem.makeMaterialSolid(doc, "MechanicalMaterialUpp")
|
||||
mat = material_obj_upp.Material
|
||||
mat["Name"] = "Steel-Generic"
|
||||
mat["YoungsModulus"] = "200000 MPa"
|
||||
mat["PoissonRatio"] = "0.30"
|
||||
mat["Density"] = "7980 kg/m^3"
|
||||
material_object_upp.Material = mat
|
||||
material_object_upp.References = [(boxupp, "Solid1")]
|
||||
material_obj_upp.Material = mat
|
||||
material_obj_upp.References = [(boxupp, "Solid1")]
|
||||
analysis.addObject(material_obj_upp)
|
||||
|
||||
# fixed_constraint
|
||||
fixed_constraint = analysis.addObject(
|
||||
ObjectsFem.makeConstraintFixed(doc, "ConstraintFixed")
|
||||
)[0]
|
||||
fixed_constraint.References = [(geom_obj, "Face5")]
|
||||
# constraint fixed
|
||||
con_fixed = ObjectsFem.makeConstraintFixed(doc, "ConstraintFixed")
|
||||
con_fixed.References = [(geom_obj, "Face5")]
|
||||
analysis.addObject(con_fixed)
|
||||
|
||||
# pressure_constraint
|
||||
pressure_constraint = analysis.addObject(
|
||||
ObjectsFem.makeConstraintPressure(doc, "ConstraintPressure")
|
||||
)[0]
|
||||
pressure_constraint.References = [(geom_obj, "Face11")]
|
||||
pressure_constraint.Pressure = 1000.0
|
||||
pressure_constraint.Reversed = False
|
||||
# constraint pressure
|
||||
con_pressure = ObjectsFem.makeConstraintPressure(doc, "ConstraintPressure")
|
||||
con_pressure.References = [(geom_obj, "Face11")]
|
||||
con_pressure.Pressure = 1000.0
|
||||
con_pressure.Reversed = False
|
||||
analysis.addObject(con_pressure)
|
||||
|
||||
# mesh
|
||||
from .meshes.mesh_boxes_2_vertikal_tetra10 import create_nodes, create_elements
|
||||
@@ -168,9 +160,7 @@ def setup(doc=None, solvertype="ccxtools"):
|
||||
control = create_elements(fem_mesh)
|
||||
if not control:
|
||||
FreeCAD.Console.PrintError("Error on creating elements.\n")
|
||||
femmesh_obj = analysis.addObject(
|
||||
ObjectsFem.makeMeshGmsh(doc, mesh_name)
|
||||
)[0]
|
||||
femmesh_obj = analysis.addObject(ObjectsFem.makeMeshGmsh(doc, mesh_name))[0]
|
||||
femmesh_obj.FemMesh = fem_mesh
|
||||
femmesh_obj.Part = geom_obj
|
||||
femmesh_obj.SecondOrderLinear = False
|
||||
|
||||
@@ -26,7 +26,6 @@
|
||||
"""
|
||||
from femexamples.material_nl_platewithhole import setup
|
||||
setup()
|
||||
|
||||
"""
|
||||
|
||||
# Nonlinear material example, plate with hole.
|
||||
@@ -63,24 +62,24 @@ def init_doc(doc=None):
|
||||
|
||||
|
||||
def get_information():
|
||||
info = {"name": "Material NL Plate with Hole",
|
||||
"meshtype": "solid",
|
||||
"meshelement": "Tet10",
|
||||
"constraints": ["fixed", "force"],
|
||||
"solvers": ["calculix"],
|
||||
"material": "multimaterial",
|
||||
"equation": "mechanical"
|
||||
}
|
||||
return info
|
||||
return {
|
||||
"name": "Material NL Plate with Hole",
|
||||
"meshtype": "solid",
|
||||
"meshelement": "Tet10",
|
||||
"constraints": ["fixed", "force"],
|
||||
"solvers": ["calculix"],
|
||||
"material": "multimaterial",
|
||||
"equation": "mechanical"
|
||||
}
|
||||
|
||||
|
||||
def setup(doc=None, solvertype="ccxtools"):
|
||||
# setup model
|
||||
|
||||
# init FreeCAD document
|
||||
if doc is None:
|
||||
doc = init_doc()
|
||||
|
||||
# geometry objects
|
||||
# geometric object
|
||||
v1 = vec(-200, -100, 0)
|
||||
v2 = vec(200, -100, 0)
|
||||
v3 = vec(200, 100, 0)
|
||||
@@ -105,61 +104,55 @@ def setup(doc=None, solvertype="ccxtools"):
|
||||
|
||||
# solver
|
||||
if solvertype == "calculix":
|
||||
solver = analysis.addObject(
|
||||
ObjectsFem.makeSolverCalculix(doc, "SolverCalculiX")
|
||||
)[0]
|
||||
solver_obj = ObjectsFem.makeSolverCalculix(doc, "SolverCalculiX")
|
||||
elif solvertype == "ccxtools":
|
||||
solver = analysis.addObject(
|
||||
ObjectsFem.makeSolverCalculixCcxTools(doc, "CalculiXccxTools")
|
||||
)[0]
|
||||
solver.WorkingDir = u""
|
||||
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.SplitInputWriter = False
|
||||
solver.AnalysisType = "static"
|
||||
solver.GeometricalNonlinearity = "linear"
|
||||
solver.ThermoMechSteadyState = False
|
||||
solver.MatrixSolverType = "default"
|
||||
solver.IterationsControlParameterTimeUse = False
|
||||
solver.GeometricalNonlinearity = 'nonlinear'
|
||||
solver.MaterialNonlinearity = 'nonlinear'
|
||||
solver_obj.SplitInputWriter = False
|
||||
solver_obj.AnalysisType = "static"
|
||||
solver_obj.GeometricalNonlinearity = "linear"
|
||||
solver_obj.ThermoMechSteadyState = False
|
||||
solver_obj.MatrixSolverType = "default"
|
||||
solver_obj.IterationsControlParameterTimeUse = False
|
||||
solver_obj.GeometricalNonlinearity = 'nonlinear'
|
||||
solver_obj.MaterialNonlinearity = 'nonlinear'
|
||||
analysis.addObject(solver_obj)
|
||||
|
||||
# linear material
|
||||
matprop = {}
|
||||
material_obj = ObjectsFem.makeMaterialSolid(doc, "Material_lin")
|
||||
matprop = material_obj.Material
|
||||
matprop["Name"] = "CalculiX-Steel"
|
||||
matprop["YoungsModulus"] = "210000 MPa"
|
||||
matprop["PoissonRatio"] = "0.30"
|
||||
matprop["Density"] = "7900 kg/m^3"
|
||||
material = analysis.addObject(
|
||||
ObjectsFem.makeMaterialSolid(doc, "Material_lin")
|
||||
)[0]
|
||||
material.Material = matprop
|
||||
material_obj.Material = matprop
|
||||
analysis.addObject(material_obj)
|
||||
|
||||
# nonlinear material
|
||||
nonlinear_material = analysis.addObject(
|
||||
ObjectsFem.makeMaterialMechanicalNonlinear(doc, material, "Material_nonlin")
|
||||
)[0]
|
||||
nonlinear_material.YieldPoint1 = '240.0, 0.0'
|
||||
nonlinear_material.YieldPoint2 = '270.0, 0.025'
|
||||
name_nlm = "Material_nonlin"
|
||||
nonlinear_mat = ObjectsFem.makeMaterialMechanicalNonlinear(doc, material_obj, name_nlm)
|
||||
nonlinear_mat.YieldPoint1 = '240.0, 0.0'
|
||||
nonlinear_mat.YieldPoint2 = '270.0, 0.025'
|
||||
analysis.addObject(nonlinear_mat)
|
||||
# check solver attributes, Nonlinearity needs to be set to nonlinear
|
||||
|
||||
# fixed_constraint
|
||||
fixed_constraint = analysis.addObject(
|
||||
ObjectsFem.makeConstraintFixed(doc, "ConstraintFixed")
|
||||
)[0]
|
||||
fixed_constraint.References = [(geom_obj, "Face4")]
|
||||
# constraint fixed
|
||||
con_fixed = ObjectsFem.makeConstraintFixed(doc, "ConstraintFixed")
|
||||
con_fixed.References = [(geom_obj, "Face4")]
|
||||
analysis.addObject(con_fixed)
|
||||
|
||||
# force constraint
|
||||
pressure_constraint = doc.Analysis.addObject(
|
||||
ObjectsFem.makeConstraintPressure(doc, "ConstraintPressure")
|
||||
)[0]
|
||||
pressure_constraint.References = [(geom_obj, "Face2")]
|
||||
pressure_constraint.Pressure = 130.0
|
||||
pressure_constraint.Reversed = True
|
||||
# pressure constraint
|
||||
con_pressure = ObjectsFem.makeConstraintPressure(doc, "ConstraintPressure")
|
||||
con_pressure.References = [(geom_obj, "Face2")]
|
||||
con_pressure.Pressure = 130.0
|
||||
con_pressure.Reversed = True
|
||||
analysis.addObject(con_pressure)
|
||||
|
||||
# mesh
|
||||
from .meshes.mesh_platewithhole_tetra10 import create_nodes, create_elements
|
||||
@@ -170,9 +163,7 @@ def setup(doc=None, solvertype="ccxtools"):
|
||||
control = create_elements(fem_mesh)
|
||||
if not control:
|
||||
FreeCAD.Console.PrintError("Error on creating elements.\n")
|
||||
femmesh_obj = analysis.addObject(
|
||||
ObjectsFem.makeMeshGmsh(doc, mesh_name)
|
||||
)[0]
|
||||
femmesh_obj = analysis.addObject(ObjectsFem.makeMeshGmsh(doc, mesh_name))[0]
|
||||
femmesh_obj.FemMesh = fem_mesh
|
||||
femmesh_obj.Part = geom_obj
|
||||
femmesh_obj.SecondOrderLinear = False
|
||||
|
||||
@@ -50,25 +50,24 @@ def init_doc(doc=None):
|
||||
|
||||
|
||||
def get_information():
|
||||
info = {"name": "RC Wall 2D",
|
||||
"meshtype": "solid",
|
||||
"meshelement": "Tria6",
|
||||
"constraints": ["fixed", "force", "displacement"],
|
||||
"solvers": ["calculix"],
|
||||
"material": "reinforced",
|
||||
"equation": "mechanical"
|
||||
}
|
||||
return info
|
||||
return {
|
||||
"name": "RC Wall 2D",
|
||||
"meshtype": "solid",
|
||||
"meshelement": "Tria6",
|
||||
"constraints": ["fixed", "force", "displacement"],
|
||||
"solvers": ["calculix"],
|
||||
"material": "reinforced",
|
||||
"equation": "mechanical"
|
||||
}
|
||||
|
||||
|
||||
def setup(doc=None, solvertype="ccxtools"):
|
||||
# setup reinfoced wall in 2D
|
||||
|
||||
# init FreeCAD document
|
||||
if doc is None:
|
||||
doc = init_doc()
|
||||
|
||||
# geom objects
|
||||
|
||||
# geometric object
|
||||
v1 = vec(0, -2000, 0)
|
||||
v2 = vec(500, -2000, 0)
|
||||
v3 = vec(500, 0, 0)
|
||||
@@ -88,7 +87,6 @@ def setup(doc=None, solvertype="ccxtools"):
|
||||
geom_obj = doc.addObject("Part::Feature", "FIB_Wall")
|
||||
geom_obj.Shape = Part.Face(Part.Wire([l1, l2, l3, l4, l5, l6, l7, l8]))
|
||||
doc.recompute()
|
||||
|
||||
if FreeCAD.GuiUp:
|
||||
geom_obj.ViewObject.Document.activeView().viewAxonometric()
|
||||
geom_obj.ViewObject.Document.activeView().fitAll()
|
||||
@@ -98,32 +96,27 @@ def setup(doc=None, solvertype="ccxtools"):
|
||||
|
||||
# solver
|
||||
if solvertype == "calculix":
|
||||
solver = analysis.addObject(
|
||||
ObjectsFem.makeSolverCalculix(doc, "SolverCalculiX")
|
||||
)[0]
|
||||
solver_obj = ObjectsFem.makeSolverCalculix(doc, "SolverCalculiX")
|
||||
elif solvertype == "ccxtools":
|
||||
solver = analysis.addObject(
|
||||
ObjectsFem.makeSolverCalculixCcxTools(doc, "CalculiXccxTools")
|
||||
)[0]
|
||||
solver.WorkingDir = u""
|
||||
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.SplitInputWriter = False
|
||||
solver.AnalysisType = "static"
|
||||
solver.GeometricalNonlinearity = "linear"
|
||||
solver.ThermoMechSteadyState = False
|
||||
solver.MatrixSolverType = "default"
|
||||
solver.IterationsControlParameterTimeUse = False
|
||||
solver_obj.SplitInputWriter = False
|
||||
solver_obj.AnalysisType = "static"
|
||||
solver_obj.GeometricalNonlinearity = "linear"
|
||||
solver_obj.ThermoMechSteadyState = False
|
||||
solver_obj.MatrixSolverType = "default"
|
||||
solver_obj.IterationsControlParameterTimeUse = False
|
||||
analysis.addObject(solver_obj)
|
||||
|
||||
# shell thickness
|
||||
thickness = analysis.addObject(
|
||||
ObjectsFem.makeElementGeometry2D(doc, 0, "ShellThickness")
|
||||
)[0]
|
||||
thickness.Thickness = 150.0
|
||||
thickness_obj = ObjectsFem.makeElementGeometry2D(doc, 150.0, "ShellThickness")
|
||||
analysis.addObject(thickness_obj)
|
||||
|
||||
# material
|
||||
matrixprop = {}
|
||||
@@ -139,33 +132,29 @@ def setup(doc=None, solvertype="ccxtools"):
|
||||
reinfoprop["YieldStrength"] = "315 MPa"
|
||||
# not an official FreeCAD material property
|
||||
reinfoprop["ReinforcementRatio"] = "0.0"
|
||||
material_reinforced = analysis.addObject(
|
||||
ObjectsFem.makeMaterialReinforced(doc, "MaterialReinforced")
|
||||
)[0]
|
||||
material_reinforced = ObjectsFem.makeMaterialReinforced(doc, "MaterialReinforced")
|
||||
material_reinforced.Material = matrixprop
|
||||
material_reinforced.Reinforcement = reinfoprop
|
||||
analysis.addObject(material_reinforced)
|
||||
|
||||
# fixed_constraint
|
||||
fixed_constraint = analysis.addObject(
|
||||
ObjectsFem.makeConstraintFixed(doc, name="ConstraintFixed")
|
||||
)[0]
|
||||
fixed_constraint.References = [(geom_obj, "Edge1"), (geom_obj, "Edge5")]
|
||||
# constraint fixed
|
||||
con_fixed = ObjectsFem.makeConstraintFixed(doc, "ConstraintFixed")
|
||||
con_fixed.References = [(geom_obj, "Edge1"), (geom_obj, "Edge5")]
|
||||
analysis.addObject(con_fixed)
|
||||
|
||||
# force constraint
|
||||
force_constraint = doc.Analysis.addObject(
|
||||
ObjectsFem.makeConstraintForce(doc, name="ConstraintForce")
|
||||
)[0]
|
||||
force_constraint.References = [(geom_obj, "Edge7")]
|
||||
force_constraint.Force = 1000000.0
|
||||
force_constraint.Direction = (geom_obj, ["Edge8"])
|
||||
force_constraint.Reversed = False
|
||||
# constraint force
|
||||
con_force = ObjectsFem.makeConstraintForce(doc, "ConstraintForce")
|
||||
con_force.References = [(geom_obj, "Edge7")]
|
||||
con_force.Force = 1000000.0
|
||||
con_force.Direction = (geom_obj, ["Edge8"])
|
||||
con_force.Reversed = False
|
||||
analysis.addObject(con_force)
|
||||
|
||||
# displacement_constraint
|
||||
displacement_constraint = doc.Analysis.addObject(
|
||||
ObjectsFem.makeConstraintDisplacement(doc, name="ConstraintDisplacmentPrescribed")
|
||||
)[0]
|
||||
displacement_constraint.References = [(geom_obj, "Face1")]
|
||||
displacement_constraint.zFix = True
|
||||
# constraint displacement
|
||||
con_disp = ObjectsFem.makeConstraintDisplacement(doc, "ConstraintDisplacmentPrescribed")
|
||||
con_disp.References = [(geom_obj, "Face1")]
|
||||
con_disp.zFix = True
|
||||
analysis.addObject(con_disp)
|
||||
|
||||
# mesh
|
||||
from .meshes.mesh_rc_wall_2d_tria6 import create_nodes, create_elements
|
||||
@@ -176,9 +165,7 @@ def setup(doc=None, solvertype="ccxtools"):
|
||||
control = create_elements(fem_mesh)
|
||||
if not control:
|
||||
FreeCAD.Console.PrintError("Error on creating elements.\n")
|
||||
femmesh_obj = analysis.addObject(
|
||||
ObjectsFem.makeMeshGmsh(doc, mesh_name)
|
||||
)[0]
|
||||
femmesh_obj = analysis.addObject(ObjectsFem.makeMeshGmsh(doc, mesh_name))[0]
|
||||
femmesh_obj.FemMesh = fem_mesh
|
||||
femmesh_obj.Part = geom_obj
|
||||
femmesh_obj.SecondOrderLinear = False
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
# ***************************************************************************
|
||||
# * Copyright (c) 2020 Sudhanshu Dubey <sudhanshu.thethunder@gmail.com> *
|
||||
# * Copyright (c) 2021 Bernd Hahnebach <bernd@bimstatik.org> *
|
||||
# * *
|
||||
# * This file is part of the FreeCAD CAx development system. *
|
||||
# * *
|
||||
@@ -25,6 +26,7 @@
|
||||
"""
|
||||
from femexamples.square_pipe_end_twisted_edgeforces import setup
|
||||
setup()
|
||||
|
||||
"""
|
||||
|
||||
import FreeCAD
|
||||
@@ -44,23 +46,24 @@ def init_doc(doc=None):
|
||||
|
||||
|
||||
def get_information():
|
||||
info = {"name": "Square Pipe End Twisted Edgeforces",
|
||||
"meshtype": "solid",
|
||||
"meshelement": "Tria6",
|
||||
"constraints": ["force", "fixed"],
|
||||
"solvers": ["calculix"],
|
||||
"material": "solid",
|
||||
"equation": "mechanical"
|
||||
}
|
||||
return info
|
||||
return {
|
||||
"name": "Square Pipe End Twisted Edgeforces",
|
||||
"meshtype": "solid",
|
||||
"meshelement": "Tria6",
|
||||
"constraints": ["force", "fixed"],
|
||||
"solvers": ["calculix"],
|
||||
"material": "solid",
|
||||
"equation": "mechanical"
|
||||
}
|
||||
|
||||
|
||||
def setup(doc=None, solvertype="ccxtools"):
|
||||
|
||||
# init FreeCAD document
|
||||
if doc is None:
|
||||
doc = init_doc()
|
||||
|
||||
# geometry object
|
||||
# geometric object
|
||||
# name is important because the other method in this module use obj name
|
||||
l1 = Part.makeLine((-142.5, -142.5, 0), (142.5, -142.5, 0))
|
||||
l2 = Part.makeLine((142.5, -142.5, 0), (142.5, 142.5, 0))
|
||||
@@ -81,84 +84,78 @@ def setup(doc=None, solvertype="ccxtools"):
|
||||
|
||||
# solver
|
||||
if solvertype == "calculix":
|
||||
solver_object = analysis.addObject(
|
||||
ObjectsFem.makeSolverCalculix(doc, "SolverCalculiX")
|
||||
)[0]
|
||||
solver_obj = ObjectsFem.makeSolverCalculix(doc, "SolverCalculiX")
|
||||
elif solvertype == "ccxtools":
|
||||
solver_object = analysis.addObject(
|
||||
ObjectsFem.makeSolverCalculixCcxTools(doc, "CalculiXccxTools")
|
||||
)[0]
|
||||
solver_object.WorkingDir = u""
|
||||
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_object.SplitInputWriter = False
|
||||
solver_object.AnalysisType = "static"
|
||||
solver_object.GeometricalNonlinearity = "linear"
|
||||
solver_object.ThermoMechSteadyState = False
|
||||
solver_object.MatrixSolverType = "default"
|
||||
solver_object.IterationsControlParameterTimeUse = False
|
||||
solver_obj.SplitInputWriter = False
|
||||
solver_obj.AnalysisType = "static"
|
||||
solver_obj.GeometricalNonlinearity = "linear"
|
||||
solver_obj.ThermoMechSteadyState = False
|
||||
solver_obj.MatrixSolverType = "default"
|
||||
solver_obj.IterationsControlParameterTimeUse = False
|
||||
analysis.addObject(solver_obj)
|
||||
|
||||
# shell thickness
|
||||
thickness = analysis.addObject(
|
||||
ObjectsFem.makeElementGeometry2D(doc, 0, "ShellThickness")
|
||||
)[0]
|
||||
thickness.Thickness = 15.0
|
||||
thickness_obj = ObjectsFem.makeElementGeometry2D(doc, 15.0, "ShellThickness")
|
||||
analysis.addObject(thickness_obj)
|
||||
|
||||
# material
|
||||
material_object = analysis.addObject(
|
||||
ObjectsFem.makeMaterialSolid(doc, "FemMaterial")
|
||||
)[0]
|
||||
mat = material_object.Material
|
||||
material_obj = ObjectsFem.makeMaterialSolid(doc, "FemMaterial")
|
||||
mat = material_obj.Material
|
||||
mat["Name"] = "Steel-Generic"
|
||||
mat["YoungsModulus"] = "200000 MPa"
|
||||
mat["PoissonRatio"] = "0.30"
|
||||
mat["Density"] = "7900 kg/m^3"
|
||||
material_object.Material = mat
|
||||
material_obj.Material = mat
|
||||
analysis.addObject(material_obj)
|
||||
|
||||
# fixed_constraint
|
||||
fixed_constraint = analysis.addObject(
|
||||
ObjectsFem.makeConstraintFixed(doc, name="ConstraintFixed"))[0]
|
||||
fixed_constraint.References = [
|
||||
# constraint fixed
|
||||
con_fixed = ObjectsFem.makeConstraintFixed(doc, "ConstraintFixed")
|
||||
con_fixed.References = [
|
||||
(doc.SquareTube, "Edge4"),
|
||||
(doc.SquareTube, "Edge7"),
|
||||
(doc.SquareTube, "Edge10"),
|
||||
(doc.SquareTube, "Edge12")]
|
||||
analysis.addObject(con_fixed)
|
||||
|
||||
# force_constraint1
|
||||
force_constraint1 = analysis.addObject(
|
||||
ObjectsFem.makeConstraintForce(doc, name="ConstraintForce1"))[0]
|
||||
force_constraint1.References = [(doc.SquareTube, "Edge9")]
|
||||
force_constraint1.Force = 100000.00
|
||||
force_constraint1.Direction = (doc.SquareTube, ["Edge9"])
|
||||
force_constraint1.Reversed = True
|
||||
# con_force1
|
||||
con_force1 = ObjectsFem.makeConstraintForce(doc, name="ConstraintForce1")
|
||||
con_force1.References = [(geom_obj, "Edge9")]
|
||||
con_force1.Force = 100000.00
|
||||
con_force1.Direction = (geom_obj, ["Edge9"])
|
||||
con_force1.Reversed = True
|
||||
analysis.addObject(con_force1)
|
||||
|
||||
# force_constraint2
|
||||
force_constraint2 = analysis.addObject(
|
||||
ObjectsFem.makeConstraintForce(doc, name="ConstraintForce2"))[0]
|
||||
force_constraint2.References = [(doc.SquareTube, "Edge3")]
|
||||
force_constraint2.Force = 100000.00
|
||||
force_constraint2.Direction = (doc.SquareTube, ["Edge3"])
|
||||
force_constraint2.Reversed = True
|
||||
# con_force2
|
||||
con_force2 = ObjectsFem.makeConstraintForce(doc, name="ConstraintForce2")
|
||||
con_force2.References = [(geom_obj, "Edge3")]
|
||||
con_force2.Force = 100000.00
|
||||
con_force2.Direction = (geom_obj, ["Edge3"])
|
||||
con_force2.Reversed = True
|
||||
analysis.addObject(con_force2)
|
||||
|
||||
# force_constraint3
|
||||
force_constraint3 = analysis.addObject(
|
||||
ObjectsFem.makeConstraintForce(doc, name="ConstraintForce3"))[0]
|
||||
force_constraint3.References = [(doc.SquareTube, "Edge11")]
|
||||
force_constraint3.Force = 100000.00
|
||||
force_constraint3.Direction = (doc.SquareTube, ["Edge11"])
|
||||
force_constraint3.Reversed = True
|
||||
# con_force3
|
||||
con_force3 = ObjectsFem.makeConstraintForce(doc, name="ConstraintForce3")
|
||||
con_force3.References = [(geom_obj, "Edge11")]
|
||||
con_force3.Force = 100000.00
|
||||
con_force3.Direction = (geom_obj, ["Edge11"])
|
||||
con_force3.Reversed = True
|
||||
analysis.addObject(con_force3)
|
||||
|
||||
# force_constraint4
|
||||
force_constraint4 = analysis.addObject(
|
||||
ObjectsFem.makeConstraintForce(doc, name="ConstraintForce4"))[0]
|
||||
force_constraint4.References = [(doc.SquareTube, "Edge6")]
|
||||
force_constraint4.Force = 100000.00
|
||||
force_constraint4.Direction = (doc.SquareTube, ["Edge6"])
|
||||
force_constraint4.Reversed = True
|
||||
# con_force4
|
||||
con_force4 = ObjectsFem.makeConstraintForce(doc, name="ConstraintForce4")
|
||||
con_force4.References = [(geom_obj, "Edge6")]
|
||||
con_force4.Force = 100000.00
|
||||
con_force4.Direction = (geom_obj, ["Edge6"])
|
||||
con_force4.Reversed = True
|
||||
analysis.addObject(con_force4)
|
||||
|
||||
# mesh
|
||||
from .meshes.mesh_square_pipe_end_twisted_tria6 import create_nodes, create_elements
|
||||
@@ -169,9 +166,7 @@ def setup(doc=None, solvertype="ccxtools"):
|
||||
control = create_elements(fem_mesh)
|
||||
if not control:
|
||||
FreeCAD.Console.PrintError("Error on creating elements.\n")
|
||||
femmesh_obj = analysis.addObject(
|
||||
ObjectsFem.makeMeshGmsh(doc, mesh_name)
|
||||
)[0]
|
||||
femmesh_obj = analysis.addObject(ObjectsFem.makeMeshGmsh(doc, mesh_name))[0]
|
||||
femmesh_obj.FemMesh = fem_mesh
|
||||
femmesh_obj.Part = geom_obj
|
||||
femmesh_obj.SecondOrderLinear = False
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
# ***************************************************************************
|
||||
# * Copyright (c) 2020 Sudhanshu Dubey <sudhanshu.thethunder@gmail.com> *
|
||||
# * Copyright (c) 2021 Bernd Hahnebach <bernd@bimstatik.org> *
|
||||
# * *
|
||||
# * This file is part of the FreeCAD CAx development system. *
|
||||
# * *
|
||||
@@ -25,6 +26,7 @@
|
||||
"""
|
||||
from femexamples.square_pipe_end_twisted_nodeforces import setup
|
||||
setup()
|
||||
|
||||
"""
|
||||
|
||||
import FreeCAD
|
||||
@@ -44,23 +46,24 @@ def init_doc(doc=None):
|
||||
|
||||
|
||||
def get_information():
|
||||
info = {"name": "Square Pipe End Twisted Nodeforces",
|
||||
"meshtype": "solid",
|
||||
"meshelement": "Tria6",
|
||||
"constraints": ["force", "fixed"],
|
||||
"solvers": ["calculix"],
|
||||
"material": "solid",
|
||||
"equation": "mechanical"
|
||||
}
|
||||
return info
|
||||
return {
|
||||
"name": "Square Pipe End Twisted Nodeforces",
|
||||
"meshtype": "solid",
|
||||
"meshelement": "Tria6",
|
||||
"constraints": ["force", "fixed"],
|
||||
"solvers": ["calculix"],
|
||||
"material": "solid",
|
||||
"equation": "mechanical"
|
||||
}
|
||||
|
||||
|
||||
def setup(doc=None, solvertype="ccxtools"):
|
||||
|
||||
# init FreeCAD document
|
||||
if doc is None:
|
||||
doc = init_doc()
|
||||
|
||||
# geometry object
|
||||
# geometric object
|
||||
# name is important because the other method in this module use obj name
|
||||
l1 = Part.makeLine((-142.5, -142.5, 0), (142.5, -142.5, 0))
|
||||
l2 = Part.makeLine((142.5, -142.5, 0), (142.5, 142.5, 0))
|
||||
@@ -171,18 +174,18 @@ def setup(doc=None, solvertype="ccxtools"):
|
||||
points_fixes.append(Part.Vertex(-71.25, 142.5, 1000.0))
|
||||
points_fixes.append(Part.Vertex(-118.75, 142.5, 1000.0))
|
||||
|
||||
forces_obj = doc.addObject('Part::Feature', 'Forces')
|
||||
forces_obj.Shape = Part.makeCompound(points_forces)
|
||||
fixes_obj = doc.addObject('Part::Feature', 'Fixes')
|
||||
fixes_obj.Shape = Part.makeCompound(points_fixes)
|
||||
geoforces_obj = doc.addObject('Part::Feature', 'Forces')
|
||||
geoforces_obj.Shape = Part.makeCompound(points_forces)
|
||||
geofixes_obj = doc.addObject('Part::Feature', 'Fixes')
|
||||
geofixes_obj.Shape = Part.makeCompound(points_fixes)
|
||||
|
||||
doc.recompute()
|
||||
|
||||
if FreeCAD.GuiUp:
|
||||
forces_obj.ViewObject.PointColor = (1.0, 0.0, 0.0, 0.0)
|
||||
forces_obj.ViewObject.PointSize = 10.0
|
||||
fixes_obj.ViewObject.PointColor = (1.0, 0.0, 0.0, 0.0)
|
||||
fixes_obj.ViewObject.PointSize = 10.0
|
||||
geoforces_obj.ViewObject.PointColor = (1.0, 0.0, 0.0, 0.0)
|
||||
geoforces_obj.ViewObject.PointSize = 10.0
|
||||
geofixes_obj.ViewObject.PointColor = (1.0, 0.0, 0.0, 0.0)
|
||||
geofixes_obj.ViewObject.PointSize = 10.0
|
||||
geom_obj.ViewObject.Document.activeView().viewAxonometric()
|
||||
geom_obj.ViewObject.Document.activeView().fitAll()
|
||||
|
||||
@@ -191,236 +194,230 @@ def setup(doc=None, solvertype="ccxtools"):
|
||||
|
||||
# solver
|
||||
if solvertype == "calculix":
|
||||
solver_object = analysis.addObject(
|
||||
ObjectsFem.makeSolverCalculix(doc, "SolverCalculiX")
|
||||
)[0]
|
||||
solver_obj = ObjectsFem.makeSolverCalculix(doc, "SolverCalculiX")
|
||||
elif solvertype == "ccxtools":
|
||||
solver_object = analysis.addObject(
|
||||
ObjectsFem.makeSolverCalculixCcxTools(doc, "CalculiXccxTools")
|
||||
)[0]
|
||||
solver_object.WorkingDir = u""
|
||||
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_object.SplitInputWriter = False
|
||||
solver_object.AnalysisType = "static"
|
||||
solver_object.GeometricalNonlinearity = "linear"
|
||||
solver_object.ThermoMechSteadyState = False
|
||||
solver_object.MatrixSolverType = "default"
|
||||
solver_object.IterationsControlParameterTimeUse = False
|
||||
solver_obj.SplitInputWriter = False
|
||||
solver_obj.AnalysisType = "static"
|
||||
solver_obj.GeometricalNonlinearity = "linear"
|
||||
solver_obj.ThermoMechSteadyState = False
|
||||
solver_obj.MatrixSolverType = "default"
|
||||
solver_obj.IterationsControlParameterTimeUse = False
|
||||
analysis.addObject(solver_obj)
|
||||
|
||||
# shell thickness
|
||||
thickness = analysis.addObject(
|
||||
ObjectsFem.makeElementGeometry2D(doc, 0, "ShellThickness")
|
||||
)[0]
|
||||
thickness.Thickness = 15.0
|
||||
thickness_obj = ObjectsFem.makeElementGeometry2D(doc, 15.0, "ShellThickness")
|
||||
analysis.addObject(thickness_obj)
|
||||
|
||||
# material
|
||||
material_object = analysis.addObject(
|
||||
ObjectsFem.makeMaterialSolid(doc, "FemMaterial")
|
||||
)[0]
|
||||
mat = material_object.Material
|
||||
material_obj = ObjectsFem.makeMaterialSolid(doc, "FemMaterial")
|
||||
mat = material_obj.Material
|
||||
mat["Name"] = "Steel-Generic"
|
||||
mat["YoungsModulus"] = "200000 MPa"
|
||||
mat["PoissonRatio"] = "0.30"
|
||||
mat["Density"] = "7900 kg/m^3"
|
||||
material_object.Material = mat
|
||||
material_obj.Material = mat
|
||||
analysis.addObject(material_obj)
|
||||
|
||||
# fixed_constraint
|
||||
fixed_constraint = analysis.addObject(
|
||||
ObjectsFem.makeConstraintFixed(doc, name="ConstraintFixed"))[0]
|
||||
fixed_constraint.References = [
|
||||
(doc.Fixes, 'Vertex6'),
|
||||
(doc.Fixes, 'Vertex15'),
|
||||
(doc.Fixes, 'Vertex5'),
|
||||
(doc.Fixes, 'Vertex29'),
|
||||
(doc.Fixes, 'Vertex42'),
|
||||
(doc.Fixes, 'Vertex30'),
|
||||
(doc.Fixes, 'Vertex9'),
|
||||
(doc.Fixes, 'Vertex31'),
|
||||
(doc.Fixes, 'Vertex33'),
|
||||
(doc.Fixes, 'Vertex32'),
|
||||
(doc.Fixes, 'Vertex3'),
|
||||
(doc.Fixes, 'Vertex34'),
|
||||
(doc.Fixes, 'Vertex46'),
|
||||
(doc.Fixes, 'Vertex1'),
|
||||
(doc.Fixes, 'Vertex36'),
|
||||
(doc.Fixes, 'Vertex11'),
|
||||
(doc.Fixes, 'Vertex38'),
|
||||
(doc.Fixes, 'Vertex12'),
|
||||
(doc.Fixes, 'Vertex39'),
|
||||
(doc.Fixes, 'Vertex13'),
|
||||
(doc.Fixes, 'Vertex40'),
|
||||
(doc.Fixes, 'Vertex16'),
|
||||
(doc.Fixes, 'Vertex35'),
|
||||
(doc.Fixes, 'Vertex14'),
|
||||
(doc.Fixes, 'Vertex47'),
|
||||
(doc.Fixes, 'Vertex20'),
|
||||
(doc.Fixes, 'Vertex37'),
|
||||
(doc.Fixes, 'Vertex18'),
|
||||
(doc.Fixes, 'Vertex41'),
|
||||
(doc.Fixes, 'Vertex17'),
|
||||
(doc.Fixes, 'Vertex10'),
|
||||
(doc.Fixes, 'Vertex26'),
|
||||
(doc.Fixes, 'Vertex43'),
|
||||
(doc.Fixes, 'Vertex21'),
|
||||
(doc.Fixes, 'Vertex44'),
|
||||
(doc.Fixes, 'Vertex19'),
|
||||
(doc.Fixes, 'Vertex4'),
|
||||
(doc.Fixes, 'Vertex28'),
|
||||
(doc.Fixes, 'Vertex48'),
|
||||
(doc.Fixes, 'Vertex22'),
|
||||
(doc.Fixes, 'Vertex8'),
|
||||
(doc.Fixes, 'Vertex23'),
|
||||
(doc.Fixes, 'Vertex7'),
|
||||
(doc.Fixes, 'Vertex24'),
|
||||
(doc.Fixes, 'Vertex45'),
|
||||
(doc.Fixes, 'Vertex27'),
|
||||
(doc.Fixes, 'Vertex2'),
|
||||
(doc.Fixes, 'Vertex25')]
|
||||
# constraint fixed
|
||||
con_fixed = ObjectsFem.makeConstraintFixed(doc, "ConstraintFixed")
|
||||
con_fixed.References = [
|
||||
(geofixes_obj, 'Vertex6'),
|
||||
(geofixes_obj, 'Vertex15'),
|
||||
(geofixes_obj, 'Vertex5'),
|
||||
(geofixes_obj, 'Vertex29'),
|
||||
(geofixes_obj, 'Vertex42'),
|
||||
(geofixes_obj, 'Vertex30'),
|
||||
(geofixes_obj, 'Vertex9'),
|
||||
(geofixes_obj, 'Vertex31'),
|
||||
(geofixes_obj, 'Vertex33'),
|
||||
(geofixes_obj, 'Vertex32'),
|
||||
(geofixes_obj, 'Vertex3'),
|
||||
(geofixes_obj, 'Vertex34'),
|
||||
(geofixes_obj, 'Vertex46'),
|
||||
(geofixes_obj, 'Vertex1'),
|
||||
(geofixes_obj, 'Vertex36'),
|
||||
(geofixes_obj, 'Vertex11'),
|
||||
(geofixes_obj, 'Vertex38'),
|
||||
(geofixes_obj, 'Vertex12'),
|
||||
(geofixes_obj, 'Vertex39'),
|
||||
(geofixes_obj, 'Vertex13'),
|
||||
(geofixes_obj, 'Vertex40'),
|
||||
(geofixes_obj, 'Vertex16'),
|
||||
(geofixes_obj, 'Vertex35'),
|
||||
(geofixes_obj, 'Vertex14'),
|
||||
(geofixes_obj, 'Vertex47'),
|
||||
(geofixes_obj, 'Vertex20'),
|
||||
(geofixes_obj, 'Vertex37'),
|
||||
(geofixes_obj, 'Vertex18'),
|
||||
(geofixes_obj, 'Vertex41'),
|
||||
(geofixes_obj, 'Vertex17'),
|
||||
(geofixes_obj, 'Vertex10'),
|
||||
(geofixes_obj, 'Vertex26'),
|
||||
(geofixes_obj, 'Vertex43'),
|
||||
(geofixes_obj, 'Vertex21'),
|
||||
(geofixes_obj, 'Vertex44'),
|
||||
(geofixes_obj, 'Vertex19'),
|
||||
(geofixes_obj, 'Vertex4'),
|
||||
(geofixes_obj, 'Vertex28'),
|
||||
(geofixes_obj, 'Vertex48'),
|
||||
(geofixes_obj, 'Vertex22'),
|
||||
(geofixes_obj, 'Vertex8'),
|
||||
(geofixes_obj, 'Vertex23'),
|
||||
(geofixes_obj, 'Vertex7'),
|
||||
(geofixes_obj, 'Vertex24'),
|
||||
(geofixes_obj, 'Vertex45'),
|
||||
(geofixes_obj, 'Vertex27'),
|
||||
(geofixes_obj, 'Vertex2'),
|
||||
(geofixes_obj, 'Vertex25')]
|
||||
analysis.addObject(con_fixed)
|
||||
|
||||
# force_constraint1
|
||||
force_constraint1 = analysis.addObject(
|
||||
ObjectsFem.makeConstraintForce(doc, name="ConstraintForce1"))[0]
|
||||
force_constraint1.References = [(forces_obj, 'Vertex1'), (forces_obj, 'Vertex14')]
|
||||
force_constraint1.Force = 5555.56
|
||||
force_constraint1.Direction = (doc.SquareTube, ["Edge9"])
|
||||
force_constraint1.Reversed = False
|
||||
# con_force1
|
||||
con_force1 = ObjectsFem.makeConstraintForce(doc, name="ConstraintForce1")
|
||||
con_force1.References = [(geoforces_obj, 'Vertex1'), (geoforces_obj, 'Vertex14')]
|
||||
con_force1.Force = 5555.56
|
||||
con_force1.Direction = (geom_obj, ["Edge9"])
|
||||
con_force1.Reversed = False
|
||||
analysis.addObject(con_force1)
|
||||
|
||||
# force_constraint2
|
||||
force_constraint2 = analysis.addObject(
|
||||
ObjectsFem.makeConstraintForce(doc, name="ConstraintForce2"))[0]
|
||||
force_constraint2.References = [(forces_obj, 'Vertex2'), (forces_obj, 'Vertex8')]
|
||||
force_constraint2.Force = 5555.56
|
||||
force_constraint2.Direction = (doc.SquareTube, ["Edge3"])
|
||||
force_constraint2.Reversed = False
|
||||
# con_force2
|
||||
con_force2 = ObjectsFem.makeConstraintForce(doc, name="ConstraintForce2")
|
||||
con_force2.References = [(geoforces_obj, 'Vertex2'), (geoforces_obj, 'Vertex8')]
|
||||
con_force2.Force = 5555.56
|
||||
con_force2.Direction = (geom_obj, ["Edge3"])
|
||||
con_force2.Reversed = False
|
||||
analysis.addObject(con_force2)
|
||||
|
||||
# force_constraint3
|
||||
force_constraint3 = analysis.addObject(
|
||||
ObjectsFem.makeConstraintForce(doc, name="ConstraintForce3"))[0]
|
||||
force_constraint3.References = [
|
||||
(forces_obj, 'Vertex20'),
|
||||
(forces_obj, 'Vertex21'),
|
||||
(forces_obj, 'Vertex22'),
|
||||
(forces_obj, 'Vertex23'),
|
||||
(forces_obj, 'Vertex24'), ]
|
||||
force_constraint3.Force = 27777.78
|
||||
force_constraint3.Direction = (doc.SquareTube, ["Edge9"])
|
||||
force_constraint3.Reversed = False
|
||||
# con_force3
|
||||
con_force3 = ObjectsFem.makeConstraintForce(doc, name="ConstraintForce3")
|
||||
con_force3.References = [
|
||||
(geoforces_obj, 'Vertex20'),
|
||||
(geoforces_obj, 'Vertex21'),
|
||||
(geoforces_obj, 'Vertex22'),
|
||||
(geoforces_obj, 'Vertex23'),
|
||||
(geoforces_obj, 'Vertex24'), ]
|
||||
con_force3.Force = 27777.78
|
||||
con_force3.Direction = (geom_obj, ["Edge9"])
|
||||
con_force3.Reversed = False
|
||||
analysis.addObject(con_force3)
|
||||
|
||||
# force_constraint4
|
||||
force_constraint4 = analysis.addObject(
|
||||
ObjectsFem.makeConstraintForce(doc, name="ConstraintForce4"))[0]
|
||||
force_constraint4.References = [
|
||||
(forces_obj, 'Vertex9'),
|
||||
(forces_obj, 'Vertex10'),
|
||||
(forces_obj, 'Vertex11'),
|
||||
(forces_obj, 'Vertex12'),
|
||||
(forces_obj, 'Vertex13'), ]
|
||||
force_constraint4.Force = 27777.78
|
||||
force_constraint4.Direction = (doc.SquareTube, ["Edge3"])
|
||||
force_constraint4.Reversed = False
|
||||
# con_force4
|
||||
con_force4 = ObjectsFem.makeConstraintForce(doc, name="ConstraintForce4")
|
||||
con_force4.References = [
|
||||
(geoforces_obj, 'Vertex9'),
|
||||
(geoforces_obj, 'Vertex10'),
|
||||
(geoforces_obj, 'Vertex11'),
|
||||
(geoforces_obj, 'Vertex12'),
|
||||
(geoforces_obj, 'Vertex13'), ]
|
||||
con_force4.Force = 27777.78
|
||||
con_force4.Direction = (geom_obj, ["Edge3"])
|
||||
con_force4.Reversed = False
|
||||
analysis.addObject(con_force4)
|
||||
|
||||
# force_constraint5
|
||||
force_constraint5 = analysis.addObject(
|
||||
ObjectsFem.makeConstraintForce(doc, name="ConstraintForce5"))[0]
|
||||
force_constraint5.References = [
|
||||
(forces_obj, 'Vertex43'),
|
||||
(forces_obj, 'Vertex44'),
|
||||
(forces_obj, 'Vertex45'),
|
||||
(forces_obj, 'Vertex46'),
|
||||
(forces_obj, 'Vertex47'),
|
||||
(forces_obj, 'Vertex48'), ]
|
||||
force_constraint5.Force = 66666.67
|
||||
force_constraint5.Direction = (doc.SquareTube, ["Edge9"])
|
||||
force_constraint5.Reversed = False
|
||||
# con_force5
|
||||
con_force5 = ObjectsFem.makeConstraintForce(doc, name="ConstraintForce5")
|
||||
con_force5.References = [
|
||||
(geoforces_obj, 'Vertex43'),
|
||||
(geoforces_obj, 'Vertex44'),
|
||||
(geoforces_obj, 'Vertex45'),
|
||||
(geoforces_obj, 'Vertex46'),
|
||||
(geoforces_obj, 'Vertex47'),
|
||||
(geoforces_obj, 'Vertex48'), ]
|
||||
con_force5.Force = 66666.67
|
||||
con_force5.Direction = (geom_obj, ["Edge9"])
|
||||
con_force5.Reversed = False
|
||||
analysis.addObject(con_force5)
|
||||
|
||||
# force_constraint6
|
||||
force_constraint6 = analysis.addObject(
|
||||
ObjectsFem.makeConstraintForce(doc, name="ConstraintForce6"))[0]
|
||||
force_constraint6.References = [
|
||||
(forces_obj, 'Vertex31'),
|
||||
(forces_obj, 'Vertex32'),
|
||||
(forces_obj, 'Vertex33'),
|
||||
(forces_obj, 'Vertex34'),
|
||||
(forces_obj, 'Vertex35'),
|
||||
(forces_obj, 'Vertex36'), ]
|
||||
force_constraint6.Force = 66666.67
|
||||
force_constraint6.Direction = (doc.SquareTube, ["Edge3"])
|
||||
force_constraint6.Reversed = False
|
||||
# con_force6
|
||||
con_force6 = ObjectsFem.makeConstraintForce(doc, name="ConstraintForce6")
|
||||
con_force6.References = [
|
||||
(geoforces_obj, 'Vertex31'),
|
||||
(geoforces_obj, 'Vertex32'),
|
||||
(geoforces_obj, 'Vertex33'),
|
||||
(geoforces_obj, 'Vertex34'),
|
||||
(geoforces_obj, 'Vertex35'),
|
||||
(geoforces_obj, 'Vertex36'), ]
|
||||
con_force6.Force = 66666.67
|
||||
con_force6.Direction = (geom_obj, ["Edge3"])
|
||||
con_force6.Reversed = False
|
||||
analysis.addObject(con_force6)
|
||||
|
||||
# force_constraint7
|
||||
force_constraint7 = analysis.addObject(
|
||||
ObjectsFem.makeConstraintForce(doc, name="ConstraintForce7"))[0]
|
||||
force_constraint7.References = [(forces_obj, 'Vertex1'), (forces_obj, 'Vertex2')]
|
||||
force_constraint7.Force = 5555.56
|
||||
force_constraint7.Direction = (doc.SquareTube, ["Edge11"])
|
||||
force_constraint7.Reversed = False
|
||||
# con_force7
|
||||
con_force7 = ObjectsFem.makeConstraintForce(doc, name="ConstraintForce7")
|
||||
con_force7.References = [(geoforces_obj, 'Vertex1'), (geoforces_obj, 'Vertex2')]
|
||||
con_force7.Force = 5555.56
|
||||
con_force7.Direction = (geom_obj, ["Edge11"])
|
||||
con_force7.Reversed = False
|
||||
analysis.addObject(con_force7)
|
||||
|
||||
# force_constraint8
|
||||
force_constraint8 = analysis.addObject(
|
||||
ObjectsFem.makeConstraintForce(doc, name="ConstraintForce8"))[0]
|
||||
force_constraint8.References = [(forces_obj, 'Vertex8'), (forces_obj, 'Vertex14')]
|
||||
force_constraint8.Force = 5555.56
|
||||
force_constraint8.Direction = (doc.SquareTube, ["Edge6"])
|
||||
force_constraint8.Reversed = False
|
||||
# con_force8
|
||||
con_force8 = ObjectsFem.makeConstraintForce(doc, name="ConstraintForce8")
|
||||
con_force8.References = [(geoforces_obj, 'Vertex8'), (geoforces_obj, 'Vertex14')]
|
||||
con_force8.Force = 5555.56
|
||||
con_force8.Direction = (geom_obj, ["Edge6"])
|
||||
con_force8.Reversed = False
|
||||
analysis.addObject(con_force8)
|
||||
|
||||
# force_constraint9
|
||||
force_constraint9 = analysis.addObject(
|
||||
ObjectsFem.makeConstraintForce(doc, name="ConstraintForce9"))[0]
|
||||
force_constraint9.References = [
|
||||
(forces_obj, 'Vertex3'),
|
||||
(forces_obj, 'Vertex4'),
|
||||
(forces_obj, 'Vertex5'),
|
||||
(forces_obj, 'Vertex6'),
|
||||
(forces_obj, 'Vertex7'), ]
|
||||
force_constraint9.Force = 27777.78
|
||||
force_constraint9.Direction = (doc.SquareTube, ["Edge11"])
|
||||
force_constraint9.Reversed = False
|
||||
# con_force9
|
||||
con_force9 = ObjectsFem.makeConstraintForce(doc, name="ConstraintForce9")
|
||||
con_force9.References = [
|
||||
(geoforces_obj, 'Vertex3'),
|
||||
(geoforces_obj, 'Vertex4'),
|
||||
(geoforces_obj, 'Vertex5'),
|
||||
(geoforces_obj, 'Vertex6'),
|
||||
(geoforces_obj, 'Vertex7'), ]
|
||||
con_force9.Force = 27777.78
|
||||
con_force9.Direction = (geom_obj, ["Edge11"])
|
||||
con_force9.Reversed = False
|
||||
analysis.addObject(con_force9)
|
||||
|
||||
# force_constraint10
|
||||
force_constraint10 = analysis.addObject(
|
||||
ObjectsFem.makeConstraintForce(doc, name="ConstraintForce10"))[0]
|
||||
force_constraint10.References = [
|
||||
(forces_obj, 'Vertex15'),
|
||||
(forces_obj, 'Vertex16'),
|
||||
(forces_obj, 'Vertex17'),
|
||||
(forces_obj, 'Vertex18'),
|
||||
(forces_obj, 'Vertex19'), ]
|
||||
force_constraint10.Force = 27777.78
|
||||
force_constraint10.Direction = (doc.SquareTube, ["Edge6"])
|
||||
force_constraint10.Reversed = False
|
||||
# con_force10
|
||||
con_force10 = ObjectsFem.makeConstraintForce(doc, name="ConstraintForce10")
|
||||
con_force10.References = [
|
||||
(geoforces_obj, 'Vertex15'),
|
||||
(geoforces_obj, 'Vertex16'),
|
||||
(geoforces_obj, 'Vertex17'),
|
||||
(geoforces_obj, 'Vertex18'),
|
||||
(geoforces_obj, 'Vertex19'), ]
|
||||
con_force10.Force = 27777.78
|
||||
con_force10.Direction = (geom_obj, ["Edge6"])
|
||||
con_force10.Reversed = False
|
||||
analysis.addObject(con_force10)
|
||||
|
||||
# force_constraint11
|
||||
force_constraint11 = analysis.addObject(
|
||||
ObjectsFem.makeConstraintForce(doc, name="ConstraintForce11"))[0]
|
||||
force_constraint11.References = [
|
||||
(forces_obj, 'Vertex25'),
|
||||
(forces_obj, 'Vertex26'),
|
||||
(forces_obj, 'Vertex27'),
|
||||
(forces_obj, 'Vertex28'),
|
||||
(forces_obj, 'Vertex29'),
|
||||
(forces_obj, 'Vertex30'), ]
|
||||
force_constraint11.Force = 66666.67
|
||||
force_constraint11.Direction = (doc.SquareTube, ["Edge11"])
|
||||
force_constraint11.Reversed = False
|
||||
# con_force11
|
||||
con_force11 = ObjectsFem.makeConstraintForce(doc, name="ConstraintForce11")
|
||||
con_force11.References = [
|
||||
(geoforces_obj, 'Vertex25'),
|
||||
(geoforces_obj, 'Vertex26'),
|
||||
(geoforces_obj, 'Vertex27'),
|
||||
(geoforces_obj, 'Vertex28'),
|
||||
(geoforces_obj, 'Vertex29'),
|
||||
(geoforces_obj, 'Vertex30'), ]
|
||||
con_force11.Force = 66666.67
|
||||
con_force11.Direction = (geom_obj, ["Edge11"])
|
||||
con_force11.Reversed = False
|
||||
analysis.addObject(con_force11)
|
||||
|
||||
# force_constraint12
|
||||
force_constraint12 = analysis.addObject(
|
||||
ObjectsFem.makeConstraintForce(doc, name="ConstraintForce12"))[0]
|
||||
force_constraint12.References = [
|
||||
(forces_obj, 'Vertex37'),
|
||||
(forces_obj, 'Vertex38'),
|
||||
(forces_obj, 'Vertex39'),
|
||||
(forces_obj, 'Vertex40'),
|
||||
(forces_obj, 'Vertex41'),
|
||||
(forces_obj, 'Vertex42'), ]
|
||||
force_constraint12.Force = 66666.67
|
||||
force_constraint12.Direction = (doc.SquareTube, ["Edge6"])
|
||||
force_constraint12.Reversed = False
|
||||
# con_force12
|
||||
con_force12 = ObjectsFem.makeConstraintForce(doc, name="ConstraintForce12")
|
||||
con_force12.References = [
|
||||
(geoforces_obj, 'Vertex37'),
|
||||
(geoforces_obj, 'Vertex38'),
|
||||
(geoforces_obj, 'Vertex39'),
|
||||
(geoforces_obj, 'Vertex40'),
|
||||
(geoforces_obj, 'Vertex41'),
|
||||
(geoforces_obj, 'Vertex42'), ]
|
||||
con_force12.Force = 66666.67
|
||||
con_force12.Direction = (geom_obj, ["Edge6"])
|
||||
con_force12.Reversed = False
|
||||
analysis.addObject(con_force12)
|
||||
|
||||
# mesh
|
||||
from .meshes.mesh_square_pipe_end_twisted_tria6 import create_nodes, create_elements
|
||||
@@ -431,9 +428,7 @@ def setup(doc=None, solvertype="ccxtools"):
|
||||
control = create_elements(fem_mesh)
|
||||
if not control:
|
||||
FreeCAD.Console.PrintError("Error on creating elements.\n")
|
||||
femmesh_obj = analysis.addObject(
|
||||
ObjectsFem.makeMeshGmsh(doc, mesh_name)
|
||||
)[0]
|
||||
femmesh_obj = analysis.addObject(ObjectsFem.makeMeshGmsh(doc, mesh_name))[0]
|
||||
femmesh_obj.FemMesh = fem_mesh
|
||||
femmesh_obj.Part = geom_obj
|
||||
femmesh_obj.SecondOrderLinear = False
|
||||
|
||||
@@ -52,24 +52,24 @@ def init_doc(doc=None):
|
||||
|
||||
|
||||
def get_information():
|
||||
info = {"name": "Thermomech Bimetall",
|
||||
"meshtype": "solid",
|
||||
"meshelement": "Tet10",
|
||||
"constraints": ["fixed", "initial temperature", "temperature"],
|
||||
"solvers": ["calculix", "elmer"],
|
||||
"material": "multimaterial",
|
||||
"equation": "thermomechanical"
|
||||
}
|
||||
return info
|
||||
return {
|
||||
"name": "Thermomech Bimetall",
|
||||
"meshtype": "solid",
|
||||
"meshelement": "Tet10",
|
||||
"constraints": ["fixed", "initial temperature", "temperature"],
|
||||
"solvers": ["calculix", "elmer"],
|
||||
"material": "multimaterial",
|
||||
"equation": "thermomechanical"
|
||||
}
|
||||
|
||||
|
||||
def setup(doc=None, solvertype="ccxtools"):
|
||||
# setup model
|
||||
|
||||
# init FreeCAD document
|
||||
if doc is None:
|
||||
doc = init_doc()
|
||||
|
||||
# geom objects
|
||||
# geometric objects
|
||||
# bottom box
|
||||
bottom_box_obj = doc.addObject("Part::Box", "BottomBox")
|
||||
bottom_box_obj.Length = 100
|
||||
@@ -105,22 +105,18 @@ def setup(doc=None, solvertype="ccxtools"):
|
||||
|
||||
# solver
|
||||
if solvertype == "calculix":
|
||||
solver_object = analysis.addObject(
|
||||
ObjectsFem.makeSolverCalculix(doc, "SolverCalculiX")
|
||||
)[0]
|
||||
solver_obj = ObjectsFem.makeSolverCalculix(doc, "SolverCalculiX")
|
||||
elif solvertype == "ccxtools":
|
||||
solver_object = analysis.addObject(
|
||||
ObjectsFem.makeSolverCalculixCcxTools(doc, "CalculiXccxTools")
|
||||
)[0]
|
||||
solver_object.WorkingDir = u""
|
||||
solver_obj = ObjectsFem.makeSolverCalculixCcxTools(doc, "CalculiXccxTools")
|
||||
solver_obj.WorkingDir = u""
|
||||
elif solvertype == "elmer":
|
||||
solver_object = analysis.addObject(ObjectsFem.makeSolverElmer(doc, "SolverElmer"))[0]
|
||||
solver_object.SteadyStateMinIterations = 1
|
||||
solver_object.SteadyStateMaxIterations = 10
|
||||
eq_heat = ObjectsFem.makeEquationHeat(doc, solver_object)
|
||||
solver_obj = analysis.addObject(ObjectsFem.makeSolverElmer(doc, "SolverElmer"))[0]
|
||||
solver_obj.SteadyStateMinIterations = 1
|
||||
solver_obj.SteadyStateMaxIterations = 10
|
||||
eq_heat = ObjectsFem.makeEquationHeat(doc, solver_obj)
|
||||
eq_heat.Bubbles = True
|
||||
eq_heat.Priority = 2
|
||||
eq_elasticity = ObjectsFem.makeEquationElasticity(doc, solver_object)
|
||||
eq_elasticity = ObjectsFem.makeEquationElasticity(doc, solver_obj)
|
||||
eq_elasticity.Bubbles = True
|
||||
eq_elasticity.Priority = 1
|
||||
eq_elasticity.LinearSolverType = "Direct"
|
||||
@@ -130,19 +126,18 @@ def setup(doc=None, solvertype="ccxtools"):
|
||||
"No solver object was created.\n".format(solvertype)
|
||||
)
|
||||
if solvertype == "calculix" or solvertype == "ccxtools":
|
||||
solver_object.AnalysisType = "thermomech"
|
||||
solver_object.GeometricalNonlinearity = "linear"
|
||||
solver_object.ThermoMechSteadyState = True
|
||||
# solver_object.MatrixSolverType = "default"
|
||||
solver_object.MatrixSolverType = "spooles" # thomas
|
||||
solver_object.SplitInputWriter = False
|
||||
solver_object.IterationsThermoMechMaximum = 2000
|
||||
# solver_object.IterationsControlParameterTimeUse = True # thermomech spine
|
||||
solver_obj.AnalysisType = "thermomech"
|
||||
solver_obj.GeometricalNonlinearity = "linear"
|
||||
solver_obj.ThermoMechSteadyState = True
|
||||
# solver_obj.MatrixSolverType = "default"
|
||||
solver_obj.MatrixSolverType = "spooles" # thomas
|
||||
solver_obj.SplitInputWriter = False
|
||||
solver_obj.IterationsThermoMechMaximum = 2000
|
||||
# solver_obj.IterationsControlParameterTimeUse = True # thermomech spine
|
||||
analysis.addObject(solver_obj)
|
||||
|
||||
# material
|
||||
material_obj_bottom = analysis.addObject(
|
||||
ObjectsFem.makeMaterialSolid(doc, "MaterialCopper")
|
||||
)[0]
|
||||
material_obj_bottom = ObjectsFem.makeMaterialSolid(doc, "MaterialCopper")
|
||||
mat = material_obj_bottom.Material
|
||||
mat["Name"] = "Copper"
|
||||
mat["YoungsModulus"] = "130000 MPa"
|
||||
@@ -155,9 +150,7 @@ def setup(doc=None, solvertype="ccxtools"):
|
||||
material_obj_bottom.References = [(geom_obj, "Solid1")]
|
||||
analysis.addObject(material_obj_bottom)
|
||||
|
||||
material_obj_top = analysis.addObject(
|
||||
ObjectsFem.makeMaterialSolid(doc, "MaterialInvar")
|
||||
)[0]
|
||||
material_obj_top = ObjectsFem.makeMaterialSolid(doc, "MaterialInvar")
|
||||
mat = material_obj_top.Material
|
||||
mat["Name"] = "Invar"
|
||||
mat["YoungsModulus"] = "137000 MPa"
|
||||
@@ -171,25 +164,21 @@ def setup(doc=None, solvertype="ccxtools"):
|
||||
analysis.addObject(material_obj_top)
|
||||
|
||||
# constraint fixed
|
||||
con_fixed = analysis.addObject(
|
||||
ObjectsFem.makeConstraintFixed(doc, "ConstraintFixed")
|
||||
)[0]
|
||||
con_fixed = ObjectsFem.makeConstraintFixed(doc, "ConstraintFixed")
|
||||
con_fixed.References = [
|
||||
(geom_obj, "Face1"),
|
||||
(geom_obj, "Face7"),
|
||||
]
|
||||
analysis.addObject(con_fixed)
|
||||
|
||||
# constraint initial temperature
|
||||
constraint_initialtemp = analysis.addObject(
|
||||
ObjectsFem.makeConstraintInitialTemperature(doc, "ConstraintInitialTemperature")
|
||||
)[0]
|
||||
constraint_initialtemp.initialTemperature = 273.0
|
||||
con_inittemp = ObjectsFem.makeConstraintInitialTemperature(doc, "ConstraintInitialTemperature")
|
||||
con_inittemp.initialTemperature = 273.0
|
||||
analysis.addObject(con_inittemp)
|
||||
|
||||
# constraint temperature
|
||||
constraint_temperature = analysis.addObject(
|
||||
ObjectsFem.makeConstraintTemperature(doc, "ConstraintTemperature")
|
||||
)[0]
|
||||
constraint_temperature.References = [
|
||||
con_temp = ObjectsFem.makeConstraintTemperature(doc, "ConstraintTemperature")
|
||||
con_temp.References = [
|
||||
(geom_obj, "Face1"),
|
||||
(geom_obj, "Face2"),
|
||||
(geom_obj, "Face3"),
|
||||
@@ -201,8 +190,9 @@ def setup(doc=None, solvertype="ccxtools"):
|
||||
(geom_obj, "Face10"),
|
||||
(geom_obj, "Face11"),
|
||||
]
|
||||
constraint_temperature.Temperature = 373.0
|
||||
constraint_temperature.CFlux = 0.0
|
||||
con_temp.Temperature = 373.0
|
||||
con_temp.CFlux = 0.0
|
||||
analysis.addObject(con_temp)
|
||||
|
||||
# mesh
|
||||
from .meshes.mesh_thermomech_bimetall_tetra10 import create_nodes, create_elements
|
||||
@@ -213,9 +203,7 @@ def setup(doc=None, solvertype="ccxtools"):
|
||||
control = create_elements(fem_mesh)
|
||||
if not control:
|
||||
FreeCAD.Console.PrintError("Error on creating elements.\n")
|
||||
femmesh_obj = analysis.addObject(
|
||||
ObjectsFem.makeMeshGmsh(doc, mesh_name)
|
||||
)[0]
|
||||
femmesh_obj = analysis.addObject(ObjectsFem.makeMeshGmsh(doc, mesh_name))[0]
|
||||
femmesh_obj.FemMesh = fem_mesh
|
||||
femmesh_obj.Part = geom_obj
|
||||
femmesh_obj.SecondOrderLinear = False
|
||||
|
||||
@@ -49,24 +49,24 @@ def init_doc(doc=None):
|
||||
|
||||
|
||||
def get_information():
|
||||
info = {"name": "Thermomech Flow 1D",
|
||||
"meshtype": "solid",
|
||||
"meshelement": "Seg3",
|
||||
"constraints": ["self weight"],
|
||||
"solvers": ["calculix"],
|
||||
"material": "fluid",
|
||||
"equation": "thermomechanical"
|
||||
}
|
||||
return info
|
||||
return {
|
||||
"name": "Thermomech Flow 1D",
|
||||
"meshtype": "solid",
|
||||
"meshelement": "Seg3",
|
||||
"constraints": ["self weight"],
|
||||
"solvers": ["calculix"],
|
||||
"material": "fluid",
|
||||
"equation": "thermomechanical"
|
||||
}
|
||||
|
||||
|
||||
def setup(doc=None, solvertype="ccxtools"):
|
||||
# setup model
|
||||
|
||||
# init FreeCAD document
|
||||
if doc is None:
|
||||
doc = init_doc()
|
||||
|
||||
# geometry objects
|
||||
# geometric objects
|
||||
p1 = vec(0, 0, 50)
|
||||
p2 = vec(0, 0, -50)
|
||||
p3 = vec(0, 0, -4300)
|
||||
@@ -116,71 +116,64 @@ def setup(doc=None, solvertype="ccxtools"):
|
||||
|
||||
# solver
|
||||
if solvertype == "calculix":
|
||||
solver_object = analysis.addObject(
|
||||
solver_obj = analysis.addObject(
|
||||
ObjectsFem.makeSolverCalculix(doc, "SolverCalculiX")
|
||||
)[0]
|
||||
elif solvertype == "ccxtools":
|
||||
solver_object = analysis.addObject(
|
||||
ObjectsFem.makeSolverCalculixCcxTools(doc, "CalculiXccxTools") # CalculiX
|
||||
)[0]
|
||||
solver_object.WorkingDir = u""
|
||||
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_object.SplitInputWriter = False
|
||||
solver_object.AnalysisType = "thermomech"
|
||||
solver_object.GeometricalNonlinearity = "linear"
|
||||
solver_object.ThermoMechSteadyState = True
|
||||
solver_object.MatrixSolverType = "default"
|
||||
solver_object.IterationsThermoMechMaximum = 2000
|
||||
solver_object.IterationsControlParameterTimeUse = False
|
||||
solver_obj.SplitInputWriter = False
|
||||
solver_obj.AnalysisType = "thermomech"
|
||||
solver_obj.GeometricalNonlinearity = "linear"
|
||||
solver_obj.ThermoMechSteadyState = True
|
||||
solver_obj.MatrixSolverType = "default"
|
||||
solver_obj.IterationsThermoMechMaximum = 2000
|
||||
solver_obj.IterationsControlParameterTimeUse = False
|
||||
analysis.addObject(solver_obj)
|
||||
|
||||
# material
|
||||
material_object = analysis.addObject(
|
||||
ObjectsFem.makeMaterialFluid(doc, "FluidMaterial")
|
||||
)[0]
|
||||
mat = material_object.Material
|
||||
material_obj = ObjectsFem.makeMaterialFluid(doc, "FluidMaterial")
|
||||
mat = material_obj.Material
|
||||
mat["Name"] = "Water"
|
||||
mat["Density"] = "998 kg/m^3"
|
||||
mat["SpecificHeat"] = "4.182 J/kg/K"
|
||||
mat["DynamicViscosity"] = "1.003e-3 kg/m/s"
|
||||
mat["VolumetricThermalExpansionCoefficient"] = "2.07e-4 m/m/K"
|
||||
mat["ThermalConductivity"] = "0.591 W/m/K"
|
||||
material_object.Material = mat
|
||||
material_obj.Material = mat
|
||||
analysis.addObject(material_obj)
|
||||
|
||||
inlet = analysis.addObject(
|
||||
ObjectsFem.makeElementFluid1D(doc, "ElementFluid1D")
|
||||
)[0]
|
||||
inlet = ObjectsFem.makeElementFluid1D(doc, "ElementFluid1D")
|
||||
inlet.SectionType = "Liquid"
|
||||
inlet.LiquidSectionType = "PIPE INLET"
|
||||
inlet.InletPressure = 0.1
|
||||
inlet.References = [(geom_obj, "Edge1")]
|
||||
analysis.addObject(inlet)
|
||||
|
||||
entrance = analysis.addObject(
|
||||
ObjectsFem.makeElementFluid1D(doc, "ElementFluid1D")
|
||||
)[0]
|
||||
entrance = ObjectsFem.makeElementFluid1D(doc, "ElementFluid1D")
|
||||
entrance.SectionType = "Liquid"
|
||||
entrance.LiquidSectionType = "PIPE ENTRANCE"
|
||||
entrance.EntrancePipeArea = 31416.00
|
||||
entrance.EntranceArea = 25133.00
|
||||
entrance.References = [(geom_obj, "Edge2")]
|
||||
analysis.addObject(entrance)
|
||||
|
||||
manning1 = analysis.addObject(
|
||||
ObjectsFem.makeElementFluid1D(doc, "ElementFluid1D")
|
||||
)[0]
|
||||
manning1 = ObjectsFem.makeElementFluid1D(doc, "ElementFluid1D")
|
||||
manning1.SectionType = "Liquid"
|
||||
manning1.LiquidSectionType = "PIPE MANNING"
|
||||
manning1.ManningArea = 31416
|
||||
manning1.ManningRadius = 50
|
||||
manning1.ManningCoefficient = 0.002
|
||||
manning1.References = [(geom_obj, "Edge3"), (geom_obj, "Edge5")]
|
||||
analysis.addObject(manning1)
|
||||
|
||||
bend = analysis.addObject(
|
||||
ObjectsFem.makeElementFluid1D(doc, "ElementFluid1D")
|
||||
)[0]
|
||||
bend = ObjectsFem.makeElementFluid1D(doc, "ElementFluid1D")
|
||||
bend.SectionType = "Liquid"
|
||||
bend.LiquidSectionType = "PIPE BEND"
|
||||
bend.BendPipeArea = 31416
|
||||
@@ -188,78 +181,71 @@ def setup(doc=None, solvertype="ccxtools"):
|
||||
bend.BendAngle = 45
|
||||
bend.BendLossCoefficient = 0.4
|
||||
bend.References = [(geom_obj, "Edge4")]
|
||||
analysis.addObject(bend)
|
||||
|
||||
enlargement1 = analysis.addObject(
|
||||
ObjectsFem.makeElementFluid1D(doc, "ElementFluid1D")
|
||||
)[0]
|
||||
enlargement1 = ObjectsFem.makeElementFluid1D(doc, "ElementFluid1D")
|
||||
enlargement1.SectionType = "Liquid"
|
||||
enlargement1.LiquidSectionType = "PIPE ENLARGEMENT"
|
||||
enlargement1.EnlargeArea1 = 31416.00
|
||||
enlargement1.EnlargeArea2 = 70686.00
|
||||
enlargement1.References = [(geom_obj, "Edge6")]
|
||||
analysis.addObject(enlargement1)
|
||||
|
||||
manning2 = analysis.addObject(
|
||||
ObjectsFem.makeElementFluid1D(doc, "ElementFluid1D")
|
||||
)[0]
|
||||
manning2 = ObjectsFem.makeElementFluid1D(doc, "ElementFluid1D")
|
||||
manning2.SectionType = "Liquid"
|
||||
manning2.LiquidSectionType = "PIPE MANNING"
|
||||
manning2.ManningArea = 70686.00
|
||||
manning2.ManningRadius = 75
|
||||
manning2.ManningCoefficient = 0.002
|
||||
manning2.References = [(geom_obj, "Edge7")]
|
||||
analysis.addObject(manning2)
|
||||
|
||||
contraction = analysis.addObject(
|
||||
ObjectsFem.makeElementFluid1D(doc, "ElementFluid1D")
|
||||
)[0]
|
||||
contraction = ObjectsFem.makeElementFluid1D(doc, "ElementFluid1D")
|
||||
contraction.SectionType = "Liquid"
|
||||
contraction.LiquidSectionType = "PIPE CONTRACTION"
|
||||
contraction.ContractArea1 = 70686
|
||||
contraction.ContractArea2 = 17671
|
||||
contraction.References = [(geom_obj, "Edge8")]
|
||||
analysis.addObject(contraction)
|
||||
|
||||
manning3 = analysis.addObject(
|
||||
ObjectsFem.makeElementFluid1D(doc, "ElementFluid1D")
|
||||
)[0]
|
||||
manning3 = ObjectsFem.makeElementFluid1D(doc, "ElementFluid1D")
|
||||
manning3.SectionType = "Liquid"
|
||||
manning3.LiquidSectionType = "PIPE MANNING"
|
||||
manning3.ManningArea = 17671.00
|
||||
manning3.ManningRadius = 37.5
|
||||
manning3.ManningCoefficient = 0.002
|
||||
manning3.References = [(geom_obj, "Edge11"), (geom_obj, "Edge9")]
|
||||
analysis.addObject(manning3)
|
||||
|
||||
gate_valve = analysis.addObject(
|
||||
ObjectsFem.makeElementFluid1D(doc, "ElementFluid1D")
|
||||
)[0]
|
||||
gate_valve = ObjectsFem.makeElementFluid1D(doc, "ElementFluid1D")
|
||||
gate_valve.SectionType = "Liquid"
|
||||
gate_valve.LiquidSectionType = "PIPE GATE VALVE"
|
||||
gate_valve.GateValvePipeArea = 17671
|
||||
gate_valve.GateValveClosingCoeff = 0.5
|
||||
gate_valve.References = [(geom_obj, "Edge10")]
|
||||
analysis.addObject(gate_valve)
|
||||
|
||||
enlargement2 = analysis.addObject(
|
||||
ObjectsFem.makeElementFluid1D(doc, "ElementFluid1D")
|
||||
)[0]
|
||||
enlargement2 = ObjectsFem.makeElementFluid1D(doc, "ElementFluid1D")
|
||||
enlargement2.SectionType = "Liquid"
|
||||
enlargement2.LiquidSectionType = "PIPE ENLARGEMENT"
|
||||
enlargement2.EnlargeArea1 = 17671
|
||||
enlargement2.EnlargeArea2 = 1e12
|
||||
enlargement2.References = [(geom_obj, "Edge12")]
|
||||
analysis.addObject(enlargement2)
|
||||
|
||||
outlet = analysis.addObject(
|
||||
ObjectsFem.makeElementFluid1D(doc, "ElementFluid1D")
|
||||
)[0]
|
||||
outlet = ObjectsFem.makeElementFluid1D(doc, "ElementFluid1D")
|
||||
outlet.SectionType = "Liquid"
|
||||
outlet.LiquidSectionType = "PIPE OUTLET"
|
||||
outlet.OutletPressure = 0.1
|
||||
outlet.References = [(geom_obj, "Edge13")]
|
||||
analysis.addObject(outlet)
|
||||
|
||||
# self_weight_constraint
|
||||
self_weight = analysis.addObject(
|
||||
ObjectsFem.makeConstraintSelfWeight(doc, "ConstraintSelfWeight")
|
||||
)[0]
|
||||
self_weight = ObjectsFem.makeConstraintSelfWeight(doc, "ConstraintSelfWeight")
|
||||
self_weight.Gravity_x = 0.0
|
||||
self_weight.Gravity_y = 0.0
|
||||
self_weight.Gravity_z = -1.0
|
||||
analysis.addObject(self_weight)
|
||||
|
||||
# mesh
|
||||
from .meshes.mesh_thermomech_flow1d_seg3 import create_nodes, create_elements
|
||||
@@ -270,9 +256,7 @@ def setup(doc=None, solvertype="ccxtools"):
|
||||
control = create_elements(fem_mesh)
|
||||
if not control:
|
||||
FreeCAD.Console.PrintError("Error on creating elements.\n")
|
||||
femmesh_obj = analysis.addObject(
|
||||
ObjectsFem.makeMeshGmsh(doc, mesh_name)
|
||||
)[0]
|
||||
femmesh_obj = analysis.addObject(ObjectsFem.makeMeshGmsh(doc, mesh_name))[0]
|
||||
femmesh_obj.FemMesh = fem_mesh
|
||||
femmesh_obj.Part = geom_obj
|
||||
femmesh_obj.SecondOrderLinear = False
|
||||
|
||||
@@ -44,24 +44,24 @@ def init_doc(doc=None):
|
||||
|
||||
|
||||
def get_information():
|
||||
info = {"name": "Thermomech Spine",
|
||||
"meshtype": "solid",
|
||||
"meshelement": "Tet10",
|
||||
"constraints": ["fixed", "initial temperature", "temperature", "heatflux"],
|
||||
"solvers": ["calculix"],
|
||||
"material": "solid",
|
||||
"equation": "thermomechanical"
|
||||
}
|
||||
return info
|
||||
return {
|
||||
"name": "Thermomech Spine",
|
||||
"meshtype": "solid",
|
||||
"meshelement": "Tet10",
|
||||
"constraints": ["fixed", "initial temperature", "temperature", "heatflux"],
|
||||
"solvers": ["calculix"],
|
||||
"material": "solid",
|
||||
"equation": "thermomechanical"
|
||||
}
|
||||
|
||||
|
||||
def setup(doc=None, solvertype="ccxtools"):
|
||||
# setup model
|
||||
|
||||
# init FreeCAD document
|
||||
if doc is None:
|
||||
doc = init_doc()
|
||||
|
||||
# geometry object
|
||||
# geometric object
|
||||
geom_obj = doc.addObject("Part::Box", "Box")
|
||||
geom_obj.Height = 25.4
|
||||
geom_obj.Width = 25.4
|
||||
@@ -77,14 +77,10 @@ def setup(doc=None, solvertype="ccxtools"):
|
||||
|
||||
# solver
|
||||
if solvertype == "calculix":
|
||||
solver_object = analysis.addObject(
|
||||
ObjectsFem.makeSolverCalculix(doc, "SolverCalculiX")
|
||||
)[0]
|
||||
solver_obj = ObjectsFem.makeSolverCalculix(doc, "SolverCalculiX")
|
||||
elif solvertype == "ccxtools":
|
||||
solver_object = analysis.addObject(
|
||||
ObjectsFem.makeSolverCalculixCcxTools(doc, "CalculiXccxTools")
|
||||
)[0]
|
||||
solver_object.WorkingDir = u""
|
||||
solver_obj = ObjectsFem.makeSolverCalculixCcxTools(doc, "CalculiXccxTools")
|
||||
solver_obj.WorkingDir = u""
|
||||
# should be possible with elmer too
|
||||
# elif solvertype == "elmer":
|
||||
# analysis.addObject(ObjectsFem.makeSolverElmer(doc, "SolverElmer"))
|
||||
@@ -94,19 +90,18 @@ def setup(doc=None, solvertype="ccxtools"):
|
||||
"No solver object was created.\n".format(solvertype)
|
||||
)
|
||||
if solvertype == "calculix" or solvertype == "ccxtools":
|
||||
solver_object.SplitInputWriter = False
|
||||
solver_object.AnalysisType = "thermomech"
|
||||
solver_object.GeometricalNonlinearity = "linear"
|
||||
solver_object.ThermoMechSteadyState = True
|
||||
solver_object.MatrixSolverType = "default"
|
||||
solver_object.IterationsThermoMechMaximum = 2000
|
||||
solver_object.IterationsControlParameterTimeUse = True
|
||||
solver_obj.SplitInputWriter = False
|
||||
solver_obj.AnalysisType = "thermomech"
|
||||
solver_obj.GeometricalNonlinearity = "linear"
|
||||
solver_obj.ThermoMechSteadyState = True
|
||||
solver_obj.MatrixSolverType = "default"
|
||||
solver_obj.IterationsThermoMechMaximum = 2000
|
||||
solver_obj.IterationsControlParameterTimeUse = True
|
||||
analysis.addObject(solver_obj)
|
||||
|
||||
# material
|
||||
material_object = analysis.addObject(
|
||||
ObjectsFem.makeMaterialSolid(doc, "MechanicalMaterial")
|
||||
)[0]
|
||||
mat = material_object.Material
|
||||
material_obj = ObjectsFem.makeMaterialSolid(doc, "MechanicalMaterial")
|
||||
mat = material_obj.Material
|
||||
mat["Name"] = "Steel-Generic"
|
||||
mat["YoungsModulus"] = "200000 MPa"
|
||||
mat["PoissonRatio"] = "0.30"
|
||||
@@ -114,39 +109,37 @@ def setup(doc=None, solvertype="ccxtools"):
|
||||
mat["ThermalConductivity"] = "43.27 W/m/K" # SvdW: Change to Ansys model values
|
||||
mat["ThermalExpansionCoefficient"] = "12 um/m/K"
|
||||
mat["SpecificHeat"] = "500 J/kg/K" # SvdW: Change to Ansys model values
|
||||
material_object.Material = mat
|
||||
material_obj.Material = mat
|
||||
analysis.addObject(material_obj)
|
||||
|
||||
# fixed_constraint
|
||||
fixed_constraint = analysis.addObject(
|
||||
ObjectsFem.makeConstraintFixed(doc, "FemConstraintFixed")
|
||||
)[0]
|
||||
fixed_constraint.References = [(geom_obj, "Face1")]
|
||||
# constraint fixed
|
||||
con_fixed = ObjectsFem.makeConstraintFixed(doc, "FemConstraintFixed")
|
||||
con_fixed.References = [(geom_obj, "Face1")]
|
||||
analysis.addObject(con_fixed)
|
||||
|
||||
# initialtemperature_constraint
|
||||
initialtemperature_constraint = analysis.addObject(
|
||||
ObjectsFem.makeConstraintInitialTemperature(doc, "FemConstraintInitialTemperature")
|
||||
)[0]
|
||||
initialtemperature_constraint.initialTemperature = 300.0
|
||||
# constraint initialtemperature
|
||||
name_inittemp = "FemConstraintInitialTemperature"
|
||||
con_inittemp = ObjectsFem.makeConstraintInitialTemperature(doc, name_inittemp)
|
||||
con_inittemp.initialTemperature = 300.0
|
||||
analysis.addObject(con_inittemp)
|
||||
|
||||
# temperature_constraint
|
||||
temperature_constraint = analysis.addObject(
|
||||
ObjectsFem.makeConstraintTemperature(doc, "FemConstraintTemperature")
|
||||
)[0]
|
||||
temperature_constraint.References = [(geom_obj, "Face1")]
|
||||
temperature_constraint.Temperature = 310.93
|
||||
# constraint temperature
|
||||
con_temp = ObjectsFem.makeConstraintTemperature(doc, "FemConstraintTemperature")
|
||||
con_temp.References = [(geom_obj, "Face1")]
|
||||
con_temp.Temperature = 310.93
|
||||
analysis.addObject(con_temp)
|
||||
|
||||
# heatflux_constraint
|
||||
heatflux_constraint = analysis.addObject(
|
||||
ObjectsFem.makeConstraintHeatflux(doc, "FemConstraintHeatflux")
|
||||
)[0]
|
||||
heatflux_constraint.References = [
|
||||
# constraint heatflux
|
||||
con_heatflux = ObjectsFem.makeConstraintHeatflux(doc, "FemConstraintHeatflux")
|
||||
con_heatflux.References = [
|
||||
(geom_obj, "Face3"),
|
||||
(geom_obj, "Face4"),
|
||||
(geom_obj, "Face5"),
|
||||
(geom_obj, "Face6")
|
||||
]
|
||||
heatflux_constraint.AmbientTemp = 255.3722
|
||||
heatflux_constraint.FilmCoef = 5.678
|
||||
con_heatflux.AmbientTemp = 255.3722
|
||||
con_heatflux.FilmCoef = 5.678
|
||||
analysis.addObject(con_heatflux)
|
||||
|
||||
# mesh
|
||||
from .meshes.mesh_thermomech_spine_tetra10 import create_nodes, create_elements
|
||||
@@ -157,9 +150,7 @@ def setup(doc=None, solvertype="ccxtools"):
|
||||
control = create_elements(fem_mesh)
|
||||
if not control:
|
||||
FreeCAD.Console.PrintError("Error on creating elements.\n")
|
||||
femmesh_obj = analysis.addObject(
|
||||
ObjectsFem.makeMeshGmsh(doc, mesh_name)
|
||||
)[0]
|
||||
femmesh_obj = analysis.addObject(ObjectsFem.makeMeshGmsh(doc, mesh_name))[0]
|
||||
femmesh_obj.FemMesh = fem_mesh
|
||||
femmesh_obj.Part = geom_obj
|
||||
femmesh_obj.SecondOrderLinear = False
|
||||
|
||||
Reference in New Issue
Block a user