Commit 937f99dd authored by florez's avatar florez
Browse files

add files

parent 8a0a4a14
{
"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",
"aka.parseInput(material_file)"
]
},
{
"cell_type": "code",
"execution_count": 7,
"id": "e70a5ac5-9f8e-4cd7-af1d-931ccb725052",
"metadata": {},
"outputs": [],
"source": [
"mesh = aka.Mesh(3)\n",
"mesh.read('cyl_01.msh')\n",
"\n",
"model = aka.SolidMechanicsModel(mesh)\n",
"model.initFull(_analysis_method=aka._static)"
]
},
{
"cell_type": "code",
"execution_count": 19,
"id": "18ffad89-ec5f-41ae-9705-21ba5ac967d6",
"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)",
"\u001b[0;32m<ipython-input-19-52b1c10eaa2d>\u001b[0m in \u001b[0;36m<module>\u001b[0;34m\u001b[0m\n\u001b[1;32m 5\u001b[0m \u001b[0mmodel\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mapplyBC\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0maka\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mFromTraction\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mtrac\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m\"top\"\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 6\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m----> 7\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",
"\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": [
"for dir in [aka._x, aka._y, aka._z]:\n",
" model.applyBC(aka.FixedValue(0, dir), \"bottom\")\n",
"\n",
"trac = [0, 0, 1]\n",
"model.applyBC(aka.FromTraction(trac), \"top\")\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
}
%% Cell type:code id:59a9f2d7-aadb-4d96-9b19-0cfcf7c950dc tags:
``` python
import numpy as np
import akantu as aka
```
%% Cell type:code id:c1339e28-e6b1-4155-b25e-f3b848025838 tags:
``` python
material_file = """
material elastic [
name = steel
rho = 1 # density
E = 1 # young's modulus
nu = 0.3 # poisson's ratio
]"""
# writing the material file
open('material.dat', 'w').write(material_file)
#reading the material file
material_file = 'material.dat'
aka.parseInput(material_file)
```
%% Cell type:code id:e70a5ac5-9f8e-4cd7-af1d-931ccb725052 tags:
``` python
mesh = aka.Mesh(3)
mesh.read('cyl_01.msh')
model = aka.SolidMechanicsModel(mesh)
model.initFull(_analysis_method=aka._static)
```
%% Cell type:code id:18ffad89-ec5f-41ae-9705-21ba5ac967d6 tags:
``` python
for dir in [aka._x, aka._y, aka._z]:
model.applyBC(aka.FixedValue(0, dir), "bottom")
trac = [0, 0, 1]
model.applyBC(aka.FromTraction(trac), "top")
model.solveStep()
```
%%%% Output: error
---------------------------------------------------------------------------
Exception Traceback (most recent call last)
<ipython-input-19-52b1c10eaa2d> in <module>
5 model.applyBC(aka.FromTraction(trac), "top")
6
----> 7 model.solveStep()
Exception: 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]
//+
SetFactory("OpenCASCADE");
//+
t = 0.05;
Circle(1) = {0, -0, 0, 0.5, 0, 2*Pi};
Circle(2) = {0, -0, 0, 0.5+t, 0, 2*Pi};
//+
Extrude {0, 0, 5} {
Curve{1};
}
Extrude {0, 0, 5} {
Curve{2};
}
//+
Physical Surface("Inside") = {1};
//+
Physical Curve("top") = {1};
//+
Physical Point("fixpoint") = {3,4};
//+
//+
Curve Loop(3) = {6};
//+
Curve Loop(4) = {4};
//+
Plane Surface(3) = {3, 4};
Physical Surface("bottom") = {3};
//+
Curve Loop(5) = {2};
//+
Curve Loop(6) = {1};
Plane Surface(4) = {5, 6};
//+
Surface Loop(1) = {3, 2, 4, 1};
//+
Volume(1) = {1};
{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"id": "1dbbab78-6ef1-4e97-8440-f6db326755e9",
"metadata": {},
"outputs": [],
"source": [
"import akantu as aka\n",
"import numpy as np\n",
"import pygmsh\n",
"\n",
"# import the pyplot submodule to draw figures\n",
"import matplotlib.pyplot as plt\n",
"# import triangluation routine to plot meshes\n",
"import matplotlib.tri as tri\n",
"# setting a default image size large enough\n",
"plt.rcParams['figure.figsize'] = [10, 10]"
]
},
{
"cell_type": "code",
"execution_count": 2,
"id": "4f3b63d5-abe9-43ce-9eca-80cd47fb4d49",
"metadata": {},
"outputs": [],
"source": [
"# reading the mesh\n",
"spatial_dimension = 3 \n",
"mesh_file = 'shell_cyl_2.msh'\n",
"mesh = aka.Mesh(spatial_dimension)\n",
"mesh.read(mesh_file)\n"
]
},
{
"cell_type": "code",
"execution_count": 3,
"id": "ac11734f-f415-43aa-a1a3-92edca236554",
"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",
"\n",
"# writing the material file\n",
"open('material.dat', 'w').write(material_file)\n",
"#reading the material file\n",
"material_file = 'material.dat'\n",
"aka.parseInput(material_file)\n",
"\n",
"# creating the solid mechanics model\n",
"model = aka.SolidMechanicsModel(mesh)\n",
"\n",
"# initialize a static solver\n",
"model.initFull(_analysis_method=aka._static)"
]
},
{
"cell_type": "code",
"execution_count": 4,
"id": "e2379428-0b40-406f-bfed-160eb297f730",
"metadata": {},
"outputs": [],
"source": [
"# Bottom ring 'bottom', top ring 'top', cylinder surface 'surface'\n",
"\n",
"# set the displacement/Dirichlet boundary conditions\n",
"for dir in [aka._x, aka._y, aka._z]:\n",
" model.applyBC(aka.FixedValue(0, dir), \"bottom\")\n",
"\n",
"\n",
"\n",
"# set the force/Neumann boundary conditions\n",
"\n",
"trac = np.eye(3) # Newtons/m^2\n",
"trac = [0,0,1]\n",
"\n",
"model.applyBC(aka.FromTraction(trac), \"top\")\n"
]
},
{
"cell_type": "code",
"execution_count": 5,
"id": "6d82b932-ca93-45eb-8e3e-c0ec2c24f381",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"array([[0., 0., 0.],\n",
" [0., 0., 0.],\n",
" [0., 0., 0.],\n",
" ...,\n",
" [0., 0., 0.],\n",
" [0., 0., 0.],\n",
" [0., 0., 0.]])"
]
},
"execution_count": 5,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"np.set_printoptions(threshold=20)\n",
"\n",
"model.getExternalForce()[:]\n",
"# np.size(model.getExternalForce(),0)\n",
"# model.getBlockedDOFs()"
]
},
{
"cell_type": "code",
"execution_count": 6,
"id": "09675758-79eb-4314-b23f-f34fe359dc9f",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"array([[0., 0., 0.],\n",
" [0., 0., 0.],\n",
" [0., 0., 0.],\n",
" ...,\n",
" [0., 0., 0.],\n",
" [0., 0., 0.],\n",
" [0., 0., 0.]])"
]
},
"execution_count": 6,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"# configure the linear algebra solver\n",
"solver = model.getNonLinearSolver()\n",
"solver.set(\"max_iterations\", 3)\n",
"solver.set(\"threshold\", 1e-8)\n",
"solver.set(\"convergence_type\", aka.SolveConvergenceCriteria.residual)\n",
"\n",
"# compute the solution\n",
"model.solveStep()\n",
"\n",
"u = model.getDisplacement()\n",
"np.set_printoptions(threshold=120)\n",
"u"
]
},
{
"cell_type": "code",
"execution_count": 7,
"id": "a81b557e-7adb-452a-9982-efeef3070962",
"metadata": {},
"outputs": [
{
"ename": "Exception",
"evalue": "akantu::debug::Exception : No element of type (not_ghost:_cohesive_2d_4) in this const ElementTypeMapArray<unsigned int> class(\"mesh:connectivities\") [/tmp/app/spack-stage/spack-stage-akantu-master-t5tv2fws2j5an4dr4sqytng27g7b3fyr/spack-src/src/mesh/element_type_map_tmpl.hh:293]",
"output_type": "error",
"traceback": [
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
"\u001b[0;31mException\u001b[0m Traceback (most recent call last)",
"\u001b[0;32m<ipython-input-7-254e5de967ab>\u001b[0m in \u001b[0;36m<module>\u001b[0;34m\u001b[0m\n\u001b[1;32m 8\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 9\u001b[0m \u001b[0;31m# generate paraview files\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m---> 10\u001b[0;31m \u001b[0mmodel\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mdump\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",
"\u001b[0;31mException\u001b[0m: akantu::debug::Exception : No element of type (not_ghost:_cohesive_2d_4) in this const ElementTypeMapArray<unsigned int> class(\"mesh:connectivities\") [/tmp/app/spack-stage/spack-stage-akantu-master-t5tv2fws2j5an4dr4sqytng27g7b3fyr/spack-src/src/mesh/element_type_map_tmpl.hh:293]"
]
}
],
"source": [
"# specify what field to output into paraview files\n",
"model.setBaseName(\"shell_cyl\")\n",
"model.addDumpFieldVector(\"displacement\")\n",
"model.addDumpFieldVector(\"external_force\")\n",
"model.addDumpField(\"strain\")\n",
"model.addDumpField(\"stress\")\n",
"model.addDumpField(\"blocked_dofs\")\n",
"\n",
"# generate paraview files\n",
"model.dump()"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "b9caba6a-e863-495b-989c-fd3bc3cf44ab",
"metadata": {},
"outputs": [],
"source": []
}
],
"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
}
%% Cell type:code id:1dbbab78-6ef1-4e97-8440-f6db326755e9 tags:
``` python
import akantu as aka
import numpy as np
import pygmsh
# import the pyplot submodule to draw figures
import matplotlib.pyplot as plt
# import triangluation routine to plot meshes
import matplotlib.tri as tri
# setting a default image size large enough
plt.rcParams['figure.figsize'] = [10, 10]
```
%% Cell type:code id:4f3b63d5-abe9-43ce-9eca-80cd47fb4d49 tags:
``` python
# reading the mesh
spatial_dimension = 3
mesh_file = 'shell_cyl_2.msh'
mesh = aka.Mesh(spatial_dimension)
mesh.read(mesh_file)
```
%% Cell type:code id:ac11734f-f415-43aa-a1a3-92edca236554 tags:
``` python
material_file = """
material elastic [
name = steel
rho = 1 # density
E = 1 # young's modulus
nu = 0.3 # poisson's ratio
]"""
# writing the material file
open('material.dat', 'w').write(material_file)
#reading the material file
material_file = 'material.dat'
aka.parseInput(material_file)
# creating the solid mechanics model
model = aka.SolidMechanicsModel(mesh)
# initialize a static solver
model.initFull(_analysis_method=aka._static)
```
%% Cell type:code id:e2379428-0b40-406f-bfed-160eb297f730 tags:
``` python
# Bottom ring 'bottom', top ring 'top', cylinder surface 'surface'
# set the displacement/Dirichlet boundary conditions
for dir in [aka._x, aka._y, aka._z]:
model.applyBC(aka.FixedValue(0, dir), "bottom")
# set the force/Neumann boundary conditions
trac = np.eye(3) # Newtons/m^2
trac = [0,0,1]
model.applyBC(aka.FromTraction(trac), "top")
```
%% Cell type:code id:6d82b932-ca93-45eb-8e3e-c0ec2c24f381 tags:
``` python
np.set_printoptions(threshold=20)
model.getExternalForce()[:]
# np.size(model.getExternalForce(),0)
# model.getBlockedDOFs()
```
%%%% Output: execute_result
array([[0., 0., 0.],
[0., 0., 0.],
[0., 0., 0.],
...,
[0., 0., 0.],
[0., 0., 0.],
[0., 0., 0.]])
%% Cell type:code id:09675758-79eb-4314-b23f-f34fe359dc9f tags:
``` python
# configure the linear algebra solver
solver = model.getNonLinearSolver()
solver.set("max_iterations", 3)
solver.set("threshold", 1e-8)
solver.set("convergence_type", aka.SolveConvergenceCriteria.residual)
# compute the solution
model.solveStep()
u = model.getDisplacement()
np.set_printoptions(threshold=120)
u
```
%%%% Output: execute_result
array([[0., 0., 0.],
[0., 0., 0.],
[0., 0., 0.],
...,
[0., 0., 0.],
[0., 0., 0.],
[0., 0., 0.]])
%% Cell type:code id:a81b557e-7adb-452a-9982-efeef3070962 tags:
``` python
# specify what field to output into paraview files
model.setBaseName("shell_cyl")
model.addDumpFieldVector("displacement")
model.addDumpFieldVector("external_force")
model.addDumpField("strain")
model.addDumpField("stress")
model.addDumpField("blocked_dofs")
# generate paraview files
model.dump()
```
%%%% Output: error
---------------------------------------------------------------------------
Exception Traceback (most recent call last)
<ipython-input-7-254e5de967ab> in <module>
8
9 # generate paraview files
---> 10 model.dump()
Exception: akantu::debug::Exception : No element of type (not_ghost:_cohesive_2d_4) in this const ElementTypeMapArray<unsigned int> class("mesh:connectivities") [/tmp/app/spack-stage/spack-stage-akantu-master-t5tv2fws2j5an4dr4sqytng27g7b3fyr/spack-src/src/mesh/element_type_map_tmpl.hh:293]
%% Cell type:code id:b9caba6a-e863-495b-989c-fd3bc3cf44ab tags:
``` python
```
# florez_akantu
SetFactory("OpenCASCADE");
Point(1) = {0, 0, 0};
Point(2) = {0, .5, 0};
Circle(1) = {0,0,0,0.5,0,2*Pi};
Extrude {0, 0, 1} {
Curve{1};
}
//+
Curve Loop(2) = {3};
//+
Plane Surface(2) = {2};
Curve Loop(3) = {1};
Plane Surface(3) = {3};
Physical Surface("bottom") = {3};
Physical Surface("top") = {2};
Physical Surface("surface") = {1};
{
"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",
"aka.parseInput(material_file)"
]
},
{
"cell_type": "code",
"execution_count": 7,
"id": "e70a5ac5-9f8e-4cd7-af1d-931ccb725052",
"metadata": {},
"outputs": [],
"source": [
"mesh = aka.Mesh(3)\n",
"mesh.read('cyl_01.msh')\n",
"\n",
"model = aka.SolidMechanicsModel(mesh)\n",
"model.initFull(_analysis_method=aka._static)"
]
},
{
"cell_type": "code",
"execution_count": 19,
"id": "18ffad89-ec5f-41ae-9705-21ba5ac967d6",
"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)",
"\u001b[0;32m<ipython-input-19-52b1c10eaa2d>\u001b[0m in \u001b[0;36m<module>\u001b[0;34m\u001b[0m\n\u001b[1;32m 5\u001b[0m \u001b[0mmodel\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mapplyBC\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0maka\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mFromTraction\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mtrac\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m\"top\"\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 6\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m----> 7\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",
"\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": [
"for dir in [aka._x, aka._y, aka._z]:\n",
" model.applyBC(aka.FixedValue(0, dir), \"bottom\")\n",
"\n",
"trac = [0, 0, 1]\n",
"model.applyBC(aka.FromTraction(trac), \"top\")\n",
"\n",
"model.solveStep()"
]
}