.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "examples/plasticity/torsion_test.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. note:: :class: sphx-glr-download-link-note :ref:`Go to the end ` to download the full example code. .. rst-class:: sphx-glr-example-title .. _sphx_glr_examples_plasticity_torsion_test.py: Large torsion of a cube (finite strain, UL) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ A unit cube (hex8 elements) is clamped on its left face and its right face is twisted by 180 degrees about the :math:`x` axis. The right face is driven as a rigid surface with :class:`fedoo.constraint.RigidTie`, whose rotation dof ``RigidRotX`` is prescribed. The problem is solved with the updated Lagrangian formulation (``nlgeom="UL"``). By default (``mat = 0``) the material is linear elastic (Simcoon ``ELISO``); ``mat = 1`` or ``mat = 2`` switch to J2 elastoplasticity. The von Mises stress at the end of the loading is plotted, and an animation of the twist is written in ``results/torsion_test.mp4``. .. GENERATED FROM PYTHON SOURCE LINES 16-22 .. code-block:: Python import os import fedoo as fd import numpy as np .. GENERATED FROM PYTHON SOURCE LINES 23-28 Geometry, mesh and material --------------------------- Units: N, mm, MPa. ``mat`` selects the law: 0 elastic (Simcoon ``ELISO``), 1 Simcoon ``EPICP``, 2 native :class:`fedoo.constitutivelaw.ElastoPlasticity`. .. GENERATED FROM PYTHON SOURCE LINES 28-75 .. code-block:: Python fd.ModelingSpace("3D") NLGEOM = "UL" h = 1 w = 1 L = 1 E = 200e3 nu = 0.3 alpha = 1e-5 # thermal expansion coefficient (required by Simcoon, isothermal here) filename = "torsion_test" res_dir = "results/" mesh = fd.mesh.box_mesh( nx=11, ny=11, nz=11, x_min=0, x_max=L, y_min=0, y_max=h, z_min=0, z_max=w, elm_type="hex8", name="Domain", ) mat = 0 if mat == 0: props = np.array([E, nu, alpha]) material = fd.constitutivelaw.Simcoon("ELISO", props, name="ConstitutiveLaw") elif mat == 1 or mat == 2: Re = 300 k = 1000 m = 0.3 if mat == 1: props = np.array([E, nu, alpha, Re, k, m]) material = fd.constitutivelaw.Simcoon("EPICP", props, name="ConstitutiveLaw") elif mat == 2: material = fd.constitutivelaw.ElastoPlasticity( E, nu, Re, name="ConstitutiveLaw" ) material.set_hardening_function("power", h=k, beta=m) else: material = fd.constitutivelaw.ElasticIsotrop(E, nu, name="ConstitutiveLaw") .. GENERATED FROM PYTHON SOURCE LINES 76-78 Weak form, assembly and problem ------------------------------- .. GENERATED FROM PYTHON SOURCE LINES 78-100 .. code-block:: Python wf = fd.weakform.StressEquilibrium("ConstitutiveLaw", nlgeom=NLGEOM, name="wf") wf.incompressibility = "auto" assemb = fd.Assembly.create("wf", mesh, name="Assembling") # node set for boundary conditions left = mesh.find_nodes("X", 0) right = mesh.find_nodes("X", 1) pb = fd.problem.NonLinear("Assembling") # create a 'results' folder and set the desired outputs if not (os.path.isdir("results")): os.mkdir("results") results = pb.add_output( res_dir + filename, "Assembling", ["Disp", "Stress", "Strain"], ) .. GENERATED FROM PYTHON SOURCE LINES 101-103 Rigid tie on the right face and twist ------------------------------------- .. GENERATED FROM PYTHON SOURCE LINES 103-111 .. code-block:: Python pb.bc.add(fd.constraint.RigidTie(right)) pb.bc.add("Dirichlet", left, "Disp", 0) pb.bc.add("Dirichlet", "RigidRotX", np.pi) # 180 deg twist of the right end pb.nlsolve(dt=0.05, tmax=1, update_dt=True, print_info=1, interval_output=0.025) .. GENERATED FROM PYTHON SOURCE LINES 112-116 Von Mises stress and animation ------------------------------ ``write_movie`` also accepts camera options, for instance ``rot_azimuth=-1.5`` to turn the camera around the scene. .. GENERATED FROM PYTHON SOURCE LINES 116-120 .. code-block:: Python results.plot("Stress", component="vm", data_type="Node", show=True) results.write_movie(res_dir + filename, "Stress", "vm", framerate=12, quality=5) .. _sphx_glr_download_examples_plasticity_torsion_test.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: torsion_test.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: torsion_test.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: torsion_test.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_