.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "examples/finite_strain/rotation_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_finite_strain_rotation_test.py: Large rigid rotation: objectivity check of the finite-strain update ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ A cube of elastoplastic material (simcoon ``EPICP``) is rotated by 90° about :math:`z` as a rigid body, in 20 increments. The motion is prescribed through the mean displacement gradient of a finite strain :class:`fedoo.constraint.PeriodicBC`, with :math:`\mathbf{F}(t) = \mathbf{R}(\theta t)`. A rigid rotation must not produce any stress: the printed maximum stress after the rotation checks the objectivity of the finite-strain (updated Lagrangian) update and should be negligible compared with the yield stress (300 MPa). .. GENERATED FROM PYTHON SOURCE LINES 14-18 .. code-block:: Python import fedoo as fd import numpy as np .. GENERATED FROM PYTHON SOURCE LINES 19-26 Mesh and material ----------------- Units: N, mm, MPa. The ``EPICP`` law (isotropic power-law hardening) is used here; any other law, e.g. ``fd.constitutivelaw.ElasticIsotrop(E, nu)``, should give the same zero stress. The thermal expansion coefficient ``alpha`` is a required property of the law but has no effect here (isothermal problem). .. GENERATED FROM PYTHON SOURCE LINES 26-61 .. code-block:: Python fd.ModelingSpace("3D") NLGEOM = True h = 1 w = 1 L = 1 E = 200e3 nu = 0.3 alpha = 1e-5 # thermal expansion coefficient Re = 300 # yield stress k = 1000 # hardening coefficient m = 0.3 # hardening exponent meshname = "Domain" fd.mesh.box_mesh( nx=5, ny=5, nz=5, x_min=0, x_max=L, y_min=0, y_max=h, z_min=0, z_max=w, elm_type="hex8", name=meshname, ) mesh = fd.Mesh[meshname] props = np.array([E, nu, alpha, Re, k, m]) material = fd.constitutivelaw.Simcoon("EPICP", props, name="ConstitutiveLaw") wf = fd.weakform.StressEquilibrium("ConstitutiveLaw", nlgeom=NLGEOM) .. GENERATED FROM PYTHON SOURCE LINES 62-64 Problem and boundary conditions ------------------------------- .. GENERATED FROM PYTHON SOURCE LINES 64-133 .. code-block:: Python # node set for boundary conditions nodes_bottom = mesh.find_nodes("Y", 0) nodes_top = mesh.find_nodes("Y", 1) node_center = mesh.nearest_node([0.5, 0.5, 0.5]) assemb = fd.Assembly.create(wf, meshname, "hex8", name="Assembling", n_elm_gp=8) pb = fd.problem.NonLinear("Assembling") # No external force acts on a rigid rotation, so the default force criterion # has a zero reference: use the displacement criterion. pb.set_nr_criterion("Displacement") # set the desired outputs (the results folder is created if needed) res = pb.add_output( "results/rot_test", ["Disp", "Stress", "Strain", "P", "EP", "Wm"], ignore_missing=True, ) # Add periodic BC bc_periodic = fd.constraint.PeriodicBC("finite_strain", dim=3) pb.bc.add(bc_periodic) tmax = 1 theta = np.pi / 2 pb.bc.add("Dirichlet", node_center, "Disp", 0) # Prescribe F(t) = R(theta * t) by defining time_func, instead of the default # linear interpolation of grad(u) = R(theta) - I. Linear component interpolation # would give F(t) = I + t * (R(theta) - I), which contains an artificial stretch # between the initial and final rotations. pb.bc.add( "Dirichlet", "DU_xx", 1, start_value=0, time_func=lambda t: np.cos(theta * t) - 1, ) pb.bc.add( "Dirichlet", "DU_xy", 1, start_value=0, time_func=lambda t: -np.sin(theta * t), ) pb.bc.add("Dirichlet", "DU_xz", 0) pb.bc.add( "Dirichlet", "DU_yx", 1, start_value=0, time_func=lambda t: np.sin(theta * t), ) pb.bc.add( "Dirichlet", "DU_yy", 1, start_value=0, time_func=lambda t: np.cos(theta * t) - 1, ) pb.bc.add("Dirichlet", "DU_yz", 0) pb.bc.add("Dirichlet", "DU_zx", 0) pb.bc.add("Dirichlet", "DU_zy", 0) pb.bc.add("Dirichlet", "DU_zz", 0) .. rst-class:: sphx-glr-script-out .. code-block:: none Dirichlet boundary condition: var = 'DU_zz' n_nodes = 1 value = 0 .. GENERATED FROM PYTHON SOURCE LINES 134-136 Solve and check the stress -------------------------- .. GENERATED FROM PYTHON SOURCE LINES 136-142 .. code-block:: Python pb.nlsolve(dt=0.05, tmax=1, update_dt=False, print_info=1, interval_output=0.05) # Objectivity check: a rigid rotation must not produce any stress. print("max |stress| after the rotation:", np.abs(assemb.sv["Stress"].asarray()).max()) .. rst-class:: sphx-glr-script-out .. code-block:: none Iter 1 - Time: 0.05000 - dt 0.05000 - NR iter: 2 - Err: 0.00000 Iter 2 - Time: 0.10000 - dt 0.05000 - NR iter: 2 - Err: 0.00000 Iter 3 - Time: 0.15000 - dt 0.05000 - NR iter: 2 - Err: 0.00000 Iter 4 - Time: 0.20000 - dt 0.05000 - NR iter: 2 - Err: 0.00000 Iter 5 - Time: 0.25000 - dt 0.05000 - NR iter: 2 - Err: 0.00000 Iter 6 - Time: 0.30000 - dt 0.05000 - NR iter: 2 - Err: 0.00000 Iter 7 - Time: 0.35000 - dt 0.05000 - NR iter: 2 - Err: 0.00000 Iter 8 - Time: 0.40000 - dt 0.05000 - NR iter: 2 - Err: 0.00000 Iter 9 - Time: 0.45000 - dt 0.05000 - NR iter: 2 - Err: 0.00000 Iter 10 - Time: 0.50000 - dt 0.05000 - NR iter: 2 - Err: 0.00000 Iter 11 - Time: 0.55000 - dt 0.05000 - NR iter: 2 - Err: 0.00000 Iter 12 - Time: 0.60000 - dt 0.05000 - NR iter: 2 - Err: 0.00000 Iter 13 - Time: 0.65000 - dt 0.05000 - NR iter: 2 - Err: 0.00000 Iter 14 - Time: 0.70000 - dt 0.05000 - NR iter: 2 - Err: 0.00000 Iter 15 - Time: 0.75000 - dt 0.05000 - NR iter: 2 - Err: 0.00000 Iter 16 - Time: 0.80000 - dt 0.05000 - NR iter: 2 - Err: 0.00000 Iter 17 - Time: 0.85000 - dt 0.05000 - NR iter: 2 - Err: 0.00000 Iter 18 - Time: 0.90000 - dt 0.05000 - NR iter: 2 - Err: 0.00000 Iter 19 - Time: 0.95000 - dt 0.05000 - NR iter: 2 - Err: 0.00000 Iter 20 - Time: 1.00000 - dt 0.05000 - NR iter: 2 - Err: 0.00000 max |stress| after the rotation: 2.6581044930706865e-10 .. GENERATED FROM PYTHON SOURCE LINES 143-147 The saved iterations can be browsed interactively with ``fd.viewer(res)`` (requires ``pyvistaqt``), which provides iteration and animation controls as well as field and component selection. Here the final displacement is plotted: the cube has turned by 90° without any distortion. .. GENERATED FROM PYTHON SOURCE LINES 147-149 .. code-block:: Python res.plot("Disp", "norm", "Node") .. image-sg:: /examples/finite_strain/images/sphx_glr_rotation_test_001.png :alt: rotation test :srcset: /examples/finite_strain/images/sphx_glr_rotation_test_001.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 1.410 seconds) .. _sphx_glr_download_examples_finite_strain_rotation_test.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: rotation_test.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: rotation_test.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: rotation_test.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_