.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "examples/thermal/thermal_loading.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_thermal_thermal_loading.py: Heterogeneous material: inclusion in a matrix under thermal loading ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ This example demonstrates how to model a composite material consisting of a disk-shaped inclusion embedded within a matrix, loaded by thermal expansion. It utilizes the :class:`fedoo.constitutivelaw.Heterogeneous` constitutive law to manage different material behaviors (elastic and elastoplastic) within a single Assembly. The temperature is uniform and prescribed: it rises to 400 and returns to 0, while all the exterior edges are clamped. .. GENERATED FROM PYTHON SOURCE LINES 12-16 .. code-block:: Python import fedoo as fd import numpy as np .. GENERATED FROM PYTHON SOURCE LINES 17-22 Geometry and Mesh ----------------- First, we generate a mesh for the matrix (a plate with a hole) and a mesh for the inclusion (a disk). Both meshes are then merged to create a continuous domain. .. GENERATED FROM PYTHON SOURCE LINES 22-38 .. code-block:: Python # Matrix: plate with a central hole mesh = fd.mesh.hole_plate_mesh( nr=11, nt=11, length=100, height=100, radius=20, elm_type="quad4", name="Domain" ) mesh.element_sets["matrix"] = np.arange(0, mesh.n_elements) # Inclusion: disk mesh fitting the hole mesh_disk = fd.mesh.disk_mesh(20, 11, 11) mesh_disk.element_sets["inclusion"] = np.arange(0, mesh_disk.n_elements) # Glue the inclusion to the matrix # We merge nodes at the interface (hole_edge and boundary of the disk) mesh = mesh + mesh_disk mesh.merge_nodes(np.c_[mesh.node_sets["hole_edge"], mesh.node_sets["boundary"]]) .. GENERATED FROM PYTHON SOURCE LINES 39-44 Modeling Space and Field Definitions ------------------------------------ We define a 2D modeling space with a plane stress assumption. A custom temperature field 'Temp' is added to the space. This field is automatically detected by the Simcoon constitutive laws. .. GENERATED FROM PYTHON SOURCE LINES 44-48 .. code-block:: Python space = fd.ModelingSpace("2Dstress") space.new_variable("Temp") .. GENERATED FROM PYTHON SOURCE LINES 49-55 Constitutive Laws and Assembly ------------------------------ We define two distinct materials using the Simcoon interface: 1. An isotropic elastic material for the matrix. 2. An isotropic elastoplastic material (EPICP) for the inclusion. Both are combined into a single ``Heterogeneous`` constitutive law. .. GENERATED FROM PYTHON SOURCE LINES 55-88 .. code-block:: Python # Matrix material: Elastic Isotropic with Thermal Expansion props_matrix = np.array( [ 50e3, # Young's Modulus (E) 0.3, # Poisson's ratio (nu) 1e-5, # Coefficient of thermal expansion ] ) mat_matrix = fd.constitutivelaw.Simcoon("ELISO", props_matrix) # Inclusion material: Elastoplastic with Power Law Hardening props_inclusion = np.array( [ 200e3, # E 0.3, # nu 1e-3, # Thermal expansion 200, # Yield stress 1000, # Hardening power law coefficient 0.3, # Hardening power law exponent ] ) mat_inclusion = fd.constitutivelaw.Simcoon("EPICP", props_inclusion) # Define the Heterogeneous material mapping element sets to laws material = fd.constitutivelaw.Heterogeneous( (mat_matrix, mat_inclusion), ("matrix", "inclusion") ) # Build the weak form and the global assembly wf = fd.weakform.StressEquilibrium(material) assembly = fd.Assembly.create(wf, mesh) .. GENERATED FROM PYTHON SOURCE LINES 89-94 Problem Definition and Boundary Conditions ------------------------------------------ A non-linear static problem is defined to account for the plastic behavior of the inclusion. We apply Dirichlet conditions for displacement (clamped edges) and a time-dependent temperature evolution. .. GENERATED FROM PYTHON SOURCE LINES 94-121 .. code-block:: Python pb = fd.problem.NonLinear(assembly, nlgeom=True) pb.set_nr_criterion("Displacement") # Boundary conditions: Clamp all exterior nodes nodes_ext = np.concatenate( [mesh.node_sets[elset] for elset in ["left", "right", "bottom", "top"]] ) # some nodes are duplicated in nodes_ext, but this is well managed by fedoo pb.bc.add("Dirichlet", nodes_ext, "Disp", 0) # Thermal loading: Temperature increases then decreases over time. # The time function receives the normalized time t / tmax (from 0 to 1), so # the temperature reaches 400 at t = tmax / 2 and returns to 0 at t = tmax. def time_evolution(t): return 2 * t if t < 0.5 else 2 * (1 - t) all_nodes = np.arange(mesh.n_nodes) pb.bc.add("Dirichlet", all_nodes, "Temp", 400, time_func=time_evolution) # Define output results for the whole assembly (in the "results" folder) res = pb.add_output( "results/thermal_loading", assembly, ["Stress", "Strain", "Disp", "Temp"] ) .. GENERATED FROM PYTHON SOURCE LINES 122-126 Solving and Post-Treatment -------------------------- The problem is solved over a predefined time range. Finally, we plot the Von Mises stress distribution across the entire heterogeneous domain. .. GENERATED FROM PYTHON SOURCE LINES 126-131 .. code-block:: Python pb.nlsolve(tmax=2, print_info=1) # Plotting the Von Mises stress at the last time increment res.plot("Stress", "vm") .. image-sg:: /examples/thermal/images/sphx_glr_thermal_loading_001.png :alt: thermal loading :srcset: /examples/thermal/images/sphx_glr_thermal_loading_001.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-script-out .. code-block:: none Iter 1 - Time: 0.10000 - dt 0.10000 - NR iter: 1 - Err: 0.00000 Iter 2 - Time: 0.20000 - dt 0.12500 - NR iter: 1 - Err: 0.00048 Iter 3 - Time: 0.30000 - dt 0.12500 - NR iter: 1 - Err: 0.00033 Iter 4 - Time: 0.40000 - dt 0.12500 - NR iter: 1 - Err: 0.00024 Iter 5 - Time: 0.50000 - dt 0.12500 - NR iter: 1 - Err: 0.00016 Iter 6 - Time: 0.60000 - dt 0.12500 - NR iter: 1 - Err: 0.00009 Iter 7 - Time: 0.70000 - dt 0.12500 - NR iter: 1 - Err: 0.00002 Iter 8 - Time: 0.80000 - dt 0.12500 - NR iter: 1 - Err: 0.00003 Iter 9 - Time: 0.90000 - dt 0.12500 - NR iter: 1 - Err: 0.00007 Iter 10 - Time: 1.00000 - dt 0.12500 - NR iter: 1 - Err: 0.00010 Iter 11 - Time: 1.10000 - dt 0.12500 - NR iter: 1 - Err: 0.00013 Iter 12 - Time: 1.20000 - dt 0.12500 - NR iter: 1 - Err: 0.00060 Iter 13 - Time: 1.30000 - dt 0.12500 - NR iter: 1 - Err: 0.00053 Iter 14 - Time: 1.40000 - dt 0.12500 - NR iter: 1 - Err: 0.00048 Iter 15 - Time: 1.50000 - dt 0.12500 - NR iter: 1 - Err: 0.00044 Iter 16 - Time: 1.60000 - dt 0.12500 - NR iter: 1 - Err: 0.00041 Iter 17 - Time: 1.70000 - dt 0.12500 - NR iter: 1 - Err: 0.00040 Iter 18 - Time: 1.80000 - dt 0.12500 - NR iter: 1 - Err: 0.00040 Iter 19 - Time: 1.90000 - dt 0.12500 - NR iter: 1 - Err: 0.00041 Iter 20 - Time: 2.00000 - dt 0.12500 - NR iter: 1 - Err: 0.00043 .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 2.552 seconds) .. _sphx_glr_download_examples_thermal_thermal_loading.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: thermal_loading.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: thermal_loading.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: thermal_loading.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_