{ "cells": [ { "cell_type": "code", "execution_count": 1, "metadata": { "autoscroll": false, "collapsed": false, "ein.hycell": false, "ein.tags": "worksheet-0", "slideshow": { "slide_type": "-" } }, "outputs": [], "source": [ "%matplotlib inline\n", "import numpy as np\n", "import sys\n", "sys.path.append(\"build-clang-5.0/language_bindings/python\")\n", "import muSpectre as msp\n", "import matplotlib.pyplot as plt\n", "\n" ] }, { "cell_type": "code", "execution_count": 2, "metadata": { "autoscroll": false, "collapsed": false, "ein.hycell": false, "ein.tags": "worksheet-0", "slideshow": { "slide_type": "-" } }, "outputs": [ { "ename": "RuntimeError", "evalue": "Failure at load step 3 of 30. In Newton-Raphson step 4:\nConjugate gradient has not converged. After 1000 steps, the solver FAILED with |r|/|b| = -nan, cg_tol = 1e-06\n\nThe applied boundary condition is F =\n 0 0.003\n 0 0\nand the load increment is ΔF =\n 0 0.001\n 0 0\n", "output_type": "error", "traceback": [ "\u001b[0;31m\u001b[0m", "\u001b[0;31mRuntimeError\u001b[0mTraceback (most recent call last)", "\u001b[0;32m\u001b[0m in \u001b[0;36m\u001b[0;34m()\u001b[0m\n\u001b[1;32m 71\u001b[0m \u001b[0;31m## de_geus: is described in de Geus et al. see Ref above\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 72\u001b[0m \u001b[0;31m## newton_cg: classical Newton-Conjugate Gradient solver. Recommended\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m---> 73\u001b[0;31m \u001b[0mresult\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mmsp\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0msolvers\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mnewton_cg\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mrve\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mDel0\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0msolver\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mtol\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0meq_tol\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mverbose\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0mverbose\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m", "\u001b[0;31mRuntimeError\u001b[0m: Failure at load step 3 of 30. In Newton-Raphson step 4:\nConjugate gradient has not converged. After 1000 steps, the solver FAILED with |r|/|b| = -nan, cg_tol = 1e-06\n\nThe applied boundary condition is F =\n 0 0.003\n 0 0\nand the load increment is ΔF =\n 0 0.001\n 0 0\n" ] } ], "source": [ "## currently, muSpectre is restricted to odd-numbered resolutions for\n", "## reasons explained in T.W.J. de Geus, J. Vondřejc, J. Zeman,\n", "## R.H.J. Peerlings, M.G.D. Geers, Finite strain FFT-based non-linear\n", "## solvers made simple, Computer Methods in Applied Mechanics and\n", "## Engineering, Volume 318, 2017\n", "## https://doi.org/10.1016/j.cma.2016.12.032\n", "resolution = [51, 51]\n", "center = np.array([r//2 for r in resolution])\n", "incl = resolution[0]//5\n", "\n", "\n", "## Domain dimensions\n", "lengths = [7., 5.]\n", "## formulation (small_strain or finite_strain)\n", "formulation = msp.Formulation.finite_strain\n", "\n", "## build a computational domain\n", "rve = msp.Cell(resolution, lengths, formulation)\n", "\n", "## define the material properties of the matrix and inclusion\n", "hard = msp.material.MaterialHyperElastoPlastic1_2d.make(\n", " rve, \"hard\", 10e9, .33, .006e9, h=.01e9)\n", "#hard = msp.material.MaterialLinearElastic1_2d.make(\n", "# rve, \"hard\", 10e9, .33)\n", "soft = msp.material.MaterialLinearElastic1_2d.make(\n", " rve, \"soft\", 70e9, .33)\n", "\n", "## assign each pixel to exactly one material\n", "for i, pixel in enumerate(rve):\n", " if np.linalg.norm(center - np.array(pixel),2)