{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# General material models" ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [], "source": [ "import numpy as np\n", "\n", "from sigmaepsilon.solid.material import ElasticityTensor\n", "from sigmaepsilon.math.linalg import ReferenceFrame\n", "from sigmaepsilon.solid.material.utils import elastic_stiffness_matrix\n", "from sigmaepsilon.math.logical import isposdef, issymmetric\n", "from sigmaepsilon.solid.material import (\n", " ElasticityTensor,\n", " LinearElasticMaterial,\n", " HuberMisesHenckyFailureCriterion,\n", ")\n", "\n", "hooke = elastic_stiffness_matrix(E=210000, NU=0.3)\n", "assert isposdef(hooke)\n", "assert issymmetric(hooke, 1e-8)\n", "\n", "yield_strength=355.0\n", "\n", "frame = ReferenceFrame(dim=3)\n", "stiffness = ElasticityTensor(hooke, frame=frame, tensorial=False)\n", "failure_model = HuberMisesHenckyFailureCriterion(yield_strength=yield_strength)\n", "material = LinearElasticMaterial(stiffness=stiffness, failure_model=failure_model)" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "array([[ 0.00169048, -0.00050714, -0.00050714, 0. , 0. ,\n", " 0. ]])" ] }, "execution_count": 2, "metadata": {}, "output_type": "execute_result" } ], "source": [ "material.calculate_strains(stresses=np.array([yield_strength, 0.0, 0.0, 0.0, 0.0, 0.0]))" ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "array([0.00454578, 0.00218466, 0.00447378, 0.00593879, 0.00546288,\n", " 0.00251926, 0.00672043, 0.00349326, 0.00330169, 0.00461547])" ] }, "execution_count": 3, "metadata": {}, "output_type": "execute_result" } ], "source": [ "material.utilization(stresses=np.random.rand(10, 6))" ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "(1, 6)" ] }, "execution_count": 4, "metadata": {}, "output_type": "execute_result" } ], "source": [ "material.calculate_stresses(strains=np.random.rand(6)).shape" ] }, { "cell_type": "code", "execution_count": 5, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "(10, 6)" ] }, "execution_count": 5, "metadata": {}, "output_type": "execute_result" } ], "source": [ "material.calculate_stresses(strains=np.random.rand(10, 6)).shape" ] }, { "cell_type": "code", "execution_count": 6, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "100.0" ] }, "execution_count": 6, "metadata": {}, "output_type": "execute_result" } ], "source": [ "stresses=np.array([yield_strength, 0.0, 0.0, 0.0, 0.0, 0.0])\n", "strains = material.calculate_strains(stresses=stresses)\n", "material.utilization(stresses=stresses) * 100" ] }, { "cell_type": "code", "execution_count": 7, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "array([1. , 1. , 1. , 1.73205081, 1.73205081,\n", " 1.73205081])" ] }, "execution_count": 7, "metadata": {}, "output_type": "execute_result" } ], "source": [ "strains = material.calculate_strains(stresses=np.eye(6) * yield_strength)\n", "stresses = material.calculate_stresses(strains=strains)\n", "material.utilization(stresses=stresses)" ] }, { "cell_type": "code", "execution_count": 8, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "array(2.56195691e-15)" ] }, "execution_count": 8, "metadata": {}, "output_type": "execute_result" } ], "source": [ "strains = material.calculate_strains(stresses=np.array([10*yield_strength, 10*yield_strength, 10*yield_strength, 0.0, 0.0, 0.0]))\n", "stresses = material.calculate_stresses(strains=strains)\n", "material.utilization(stresses=stresses)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Utilization for a single state of strain:" ] }, { "cell_type": "code", "execution_count": 9, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "array([0.00173154, 0.00161796, 0.00027652, 0.00169012, 0.00167926,\n", " 0.00118488])" ] }, "execution_count": 9, "metadata": {}, "output_type": "execute_result" } ], "source": [ "strains = 2*np.random.rand(6)/1000\n", "strains" ] }, { "cell_type": "code", "execution_count": 10, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "122.73374966882162" ] }, "execution_count": 10, "metadata": {}, "output_type": "execute_result" } ], "source": [ "stresses = material.calculate_stresses(strains=strains)\n", "material.utilization(stresses=stresses) * 100" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Utilizations for several states with bulk evaluation:" ] }, { "cell_type": "code", "execution_count": 11, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "array([0.00085395, 0.00134484, 0.00071666, 0.00105298, 0.00071055,\n", " 0.00113623, 0.00121962, 0.00046218, 0.00080682, 0.0010324 ])" ] }, "execution_count": 11, "metadata": {}, "output_type": "execute_result" } ], "source": [ "material.utilization(stresses=2*np.random.rand(10, 6)/1000) * 100" ] }, { "cell_type": "code", "execution_count": 12, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "(10,)" ] }, "execution_count": 12, "metadata": {}, "output_type": "execute_result" } ], "source": [ "material.utilization(stresses=2*np.random.rand(10, 6)/1000).shape" ] }, { "cell_type": "code", "execution_count": 13, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "array([0.0010681 , 0.001052 , 0.00089471, 0.00078132, 0.00098108,\n", " 0.0005937 , 0.00108656, 0.00080096, 0.00104349, 0.00110625])" ] }, "execution_count": 13, "metadata": {}, "output_type": "execute_result" } ], "source": [ "material.utilization(stresses=tuple(2*np.random.rand(10)/1000 for _ in range(6))) * 100" ] } ], "metadata": { "kernelspec": { "display_name": ".solid.material", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.8.10" } }, "nbformat": 4, "nbformat_minor": 2 }