cyl_02.ipynb 4.76 KB
Newer Older
florez's avatar
florez committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "59a9f2d7-aadb-4d96-9b19-0cfcf7c950dc",
   "metadata": {},
   "outputs": [],
   "source": [
    "import numpy as np\n",
    "import akantu as aka"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "c1339e28-e6b1-4155-b25e-f3b848025838",
   "metadata": {},
   "outputs": [],
   "source": [
    "material_file = \"\"\"\n",
    "material elastic [\n",
    "    name = steel\n",
    "    rho = 1     # density\n",
    "    E   = 1   # young's modulus\n",
    "    nu  = 0.3      # poisson's ratio\n",
    "]\"\"\"\n",
    "# writing the material file\n",
    "open('material.dat', 'w').write(material_file)\n",
    "#reading the material file\n",
    "material_file = 'material.dat'\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "30c1bb68-80b2-41ea-9aa6-a08daf741c9b",
   "metadata": {},
   "outputs": [],
   "source": [
florez's avatar
changes    
florez committed
41
42
43
    "spatial_dimension = 3\n",
    "mesh = aka.Mesh(spatial_dimension)\n",
    "mesh.read('cyl_03.msh')\n",
florez's avatar
florez committed
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
    "\n",
    "model = aka.SolidMechanicsModel(mesh)\n",
    "model.initFull(_analysis_method=aka._static)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "23cdc1b2-692e-4457-a454-89d49722e94a",
   "metadata": {},
   "outputs": [],
   "source": [
    "aka.parseInput(material_file)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "id": "a1d797dd-c63c-4b8b-9aaa-5d00947a414a",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
florez's avatar
changes    
florez committed
68
       "array([[0.00000000e+00, 0.00000000e+00, 7.84378210e-06],\n",
florez's avatar
change    
florez committed
69
       "       [0.00000000e+00, 0.00000000e+00, 0.00000000e+00],\n",
florez's avatar
changes    
florez committed
70
       "       [0.00000000e+00, 0.00000000e+00, 8.40429458e-06],\n",
florez's avatar
florez committed
71
       "       ...,\n",
florez's avatar
change    
florez committed
72
73
74
       "       [0.00000000e+00, 0.00000000e+00, 0.00000000e+00],\n",
       "       [0.00000000e+00, 0.00000000e+00, 0.00000000e+00],\n",
       "       [0.00000000e+00, 0.00000000e+00, 0.00000000e+00]])"
florez's avatar
florez committed
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
      ]
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "for dir in [aka._x, aka._y, aka._z]:\n",
    "    model.applyBC(aka.FixedValue(0, dir), \"bottom\")\n",
    "\n",
    "# trac = np.eye(3)\n",
    "trac = [0, 0, 1]\n",
    "model.applyBC(aka.FromTraction(trac), \"top\")\n",
    "np.set_printoptions(threshold=10)\n",
    "model.getExternalForce()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "id": "e26678ea-2a60-44fb-8956-6ce84db4174f",
   "metadata": {},
   "outputs": [
    {
     "ename": "Exception",
     "evalue": "akantu::debug::CriticalError : Error in mumps during solve process, check mumps user guide INFO(1) = -3 [/tmp/app/spack-stage/spack-stage-akantu-master-t5tv2fws2j5an4dr4sqytng27g7b3fyr/spack-src/src/solver/sparse_solver_mumps.cc:445]",
     "output_type": "error",
     "traceback": [
      "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
      "\u001b[0;31mException\u001b[0m                                 Traceback (most recent call last)",
florez's avatar
changes    
florez committed
106
      "\u001b[0;32m<ipython-input-6-539bd27ab881>\u001b[0m in \u001b[0;36m<module>\u001b[0;34m\u001b[0m\n\u001b[1;32m      4\u001b[0m \u001b[0msolver\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mset\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m\"convergence_type\"\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0maka\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mSolveConvergenceCriteria\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mresidual\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m      5\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m----> 6\u001b[0;31m \u001b[0mmodel\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0msolveStep\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m",
florez's avatar
florez committed
107
108
109
110
111
112
      "\u001b[0;31mException\u001b[0m: akantu::debug::CriticalError : Error in mumps during solve process, check mumps user guide INFO(1) = -3 [/tmp/app/spack-stage/spack-stage-akantu-master-t5tv2fws2j5an4dr4sqytng27g7b3fyr/spack-src/src/solver/sparse_solver_mumps.cc:445]"
     ]
    }
   ],
   "source": [
    "solver = model.getNonLinearSolver()\n",
florez's avatar
changes    
florez committed
113
    "solver.set(\"max_iterations\", 100)\n",
florez's avatar
florez committed
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
    "solver.set(\"threshold\", 1e-10)\n",
    "solver.set(\"convergence_type\", aka.SolveConvergenceCriteria.residual)\n",
    "\n",
    "model.solveStep()"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "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": 5
}