Commit 4fce502b authored by mozul's avatar mozul
Browse files

Merge commit '0836c2fc'

Merge examples
parents be532f60 0836c2fc
......@@ -174,7 +174,7 @@ for k in xrange(1, nb_steps + 1, 1):
utilities_logMes('COMPUTE DOF, FIELDS, etc.')
mecaMAILx_ComputeDof()
RBDY2_ComputeDof()
mecaMAILx_ComputeBulk()
mecaMAILx_ComputeField()
#
utilities_logMes('UPDATE DOF, FIELDS')
TimeEvolution_UpdateStep()
......
import os,sys
sys.path.append('/Users/mrenouf/GitLab_LMGC90/build_dev_rc2015')
from pylmgc90.chipy import *
checkDirectories()
......
import os,sys
sys.path.append('/Users/mrenouf/GitLab_LMGC90/build_dev_rc2015')
from pylmgc90.chipy import *
checkDirectories()
......
import os,sys
sys.path.append('/Users/mrenouf/GitLab_LMGC90/build_dev_rc2015')
from pylmgc90.chipy import *
......@@ -99,6 +96,7 @@ for i in xrange(0,nb_steps_ther,1):
IncrementStep()
mp_solver_RecupTemperature()
mp_solver_SolveThermoProblem()
mecaMAILx_ComputeField()
UpdateStep()
### postpro ###
......
import os,sys
sys.path.append('/Users/mrenouf/GitLab_LMGC90/build_dev_rc2015')
from pylmgc90.chipy import *
from numpy import *
......@@ -99,7 +97,7 @@ nbspher = SPHER_GetNbSPHER()
Ts = np.zeros([nbspher])
spher2rbdy3 = SPHER_GetPtrSPHER2RBDY3()
spher2rbdy3 = SPHER_GetPtrSPHER2BDYTY()
#
for i in xrange(0,nb_iter,1):
......
{
"cells": [
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "slide"
}
},
"source": [
"# Biaxial compression of a rectangular box filled with disks\n",
"\n",
"F. Dubois - 2016"
]
},
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "slide"
}
},
"source": [
"## Pre-processing"
]
},
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "fragment"
}
},
"source": [
"Initialisation"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false,
"slideshow": {
"slide_type": "fragment"
}
},
"outputs": [],
"source": [
"import numpy as np\n",
"from pylmgc90.pre_lmgc import *\n",
"if not os.path.isdir('./DATBOX'):\n",
" os.mkdir('./DATBOX')\n",
"\n",
"# 2D\n",
"dim = 2\n",
"\n",
"# containers\n",
"# * bodies\n",
"bodies = avatars()\n",
"# * materials\n",
"mat = materials()\n",
"# * see tables\n",
"svs = see_tables()\n",
"# * contact laws\n",
"tacts = tact_behavs()\n",
"\n",
"# creations de deux materiaux\n",
"tdur = material(name='TDURx',type='RIGID',density=1000.)\n",
"plex = material(name='PLEXx',type='RIGID',density=100.)\n",
"mat.addMaterial(tdur,plex)\n",
"\n",
"# on cree un modele de rigide\n",
"mod = model(name='rigid', type='MECAx', element='Rxx2D', dimension=dim)\n",
"\n",
"# on genere 1000 particules\n",
"nb_particles=1000\n",
"\n",
"# distribtion aleatoire dans [0.5, 2.[ \n",
"radii=granulo_Random(nb_particles, 0.5, 2.)\n",
"\n",
"# on recupere le plus petit et le plus grand rayon\n",
"radius_min=min(radii)\n",
"radius_max=max(radii)\n",
"\n",
"# depot dans une boite rectangulaire\n",
"lx = 75.\n",
"ly = 50. \n",
"[nb_remaining_particles, coor]=depositInBox2D(radii, lx, ly)\n",
"\n",
"# si toutes les particules deposees n'ont pas ete conservees\n",
"if (nb_remaining_particles < nb_particles):\n",
" # on affiche un avertissement\n",
" print \"Warning: granulometry changed, since some particles were removed!\"\n",
"\n",
"# boucle d'ajout des disques :\n",
"for i in xrange(0,nb_remaining_particles,1):\n",
" # creation un nouveau disque rigide, constitue du materiau plex\n",
" body=rigidDisk(r=radii[i], center=coor[2*i : 2*(i + 1)], \n",
" model=mod, material=plex, color='BLEUx') \n",
" # ajout du disque dans le conteneur de corps\n",
" bodies += body\n",
"\n",
"# ajout d'une boite lisse, i.e. faite de joncs :\n",
"\n",
"# on declare un corps par paroi\n",
"down = rigidJonc(axe1=0.5*lx+radius_max, axe2=radius_max, center=[0.5*lx, -radius_max],\n",
" model=mod, material=tdur, color='WALLx')\n",
"up = rigidJonc(axe1=0.5*lx+radius_max, axe2=radius_max, center=[0.5*lx, ly+radius_max],\n",
" model=mod, material=tdur, color='WALLx')\n",
"left = rigidJonc(axe1=0.5*ly+radius_max, axe2=radius_max, center=[-radius_max, 0.5*ly],\n",
" model=mod, material=tdur, color='WALLx')\n",
"right= rigidJonc(axe1=0.5*ly+radius_max, axe2=radius_max, center=[lx+radius_max, 0.5*ly],\n",
" model=mod, material=tdur, color='WALLx')\n",
"\n",
"# on ajoute les parois a la liste des corps\n",
"bodies += down; bodies += up; bodies += left; bodies += right\n",
"\n",
"# on tourne les parois verticales (par rapport a leur propres \n",
"# centre d'inertie)\n",
"left.rotate(psi=-math.pi/2., center=left.nodes[1].coor)\n",
"right.rotate(psi=math.pi/2., center=right.nodes[1].coor)\n",
"\n",
"# on fixe les parois\n",
"down.imposeDrivenDof(component=[1, 2, 3], dofty='vlocy')\n",
"up.imposeDrivenDof(component=[1, 2, 3], dofty='vlocy')\n",
"left.imposeDrivenDof(component=[1, 2, 3], dofty='vlocy')\n",
"right.imposeDrivenDof(component=[1, 2, 3], dofty='vlocy')\n",
"\n",
"# gestion des interactions :\n",
"# * declaration des lois\n",
"# - entre particules\n",
"ldkdk=tact_behav(name='iqsc0',type='IQS_CLB',fric=0.3)\n",
"tacts+=ldkdk\n",
"# - avec les parois\n",
"ldkjc=tact_behav(name='iqsc1',type='IQS_CLB',fric=0.5)\n",
"tacts+=ldkjc\n",
"# * declaration des tables de visibilite\n",
{
"cells": [
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "slide"
}
},
"source": [
"# How to build a rigid avatar\n",
"\n",
"F. Dubois 2016 "
]
},
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "fragment"
}
},
"source": [
"All avatars are made of nodes, elements, contactors and need a material and a model."
]
},
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "slide"
}
},
"source": [
"## 2D Case"
]
},
{
"cell_type": "code",
"execution_count": 1,
"metadata": {
"collapsed": false,
"slideshow": {
"slide_type": "fragment"
}
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Info : med file reading module not available\n"
]
}
],
"source": [
"#Initialization\n",
"from pylmgc90.pre_lmgc import *\n",
"# 2D\n",
"dim = 2"
]
},
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "fragment"
}
},
"source": [
"Defining a material suitable for rigid objects. "
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {
"collapsed": false,
"slideshow": {
"slide_type": "fragment"
}
},
"outputs": [],
"source": [
"mut = material(name='TDURx',type='RIGID',density=1000.)"
]
},
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "fragment"
}
},
"source": [
"Defining a model suitable for rigid objects."
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {
"collapsed": true,
"slideshow": {
"slide_type": "fragment"
}
},
"outputs": [],
"source": [
"mod = model(name='rigid', type='MECAx', element='Rxx2D', dimension=dim)"
]
},
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "slide"
}
},
"source": [
"Defining an empty avatar"
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {
"collapsed": false,
"slideshow": {
"slide_type": "fragment"
}
},
"outputs": [],
"source": [
"disk = avatar(type='RBDY2',dimension=2)\n",
"\n",
"## some introspection\n",
"## what is disk ? \n",
"#help(disk)\n",
"## what is nodes in disk ? \n",
"#help(disk.nodes)\n",
"## what are the keys in nodes ? \n",
"#print disk.nodes.viewkeys()\n",
"## what are the values in nodes ? \n",
"#print disk.nodes.viewvalues()"
]
},
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "fragment"
}
},
"source": [
"Creating a node and adding it to the avatar (number MUST be 1)"
]
},
{
"cell_type": "code",
"execution_count": 5,
"metadata": {
"collapsed": false,
"slideshow": {
"slide_type": "fragment"
}
},
"outputs": [],
"source": [
"no = node(type='NO2xx',coor=numpy.array([0.,0.1]),number=1)\n",
"\n",
"## some introspection\n",
"## what is no ? \n",
"#help(no)\n",
"## what is containing no ? \n",
"#dir(no)\n",
"#print no.coor\n",
"\n",
"# adding no to avatar\n",
"disk.addNode( no )\n",
"\n",
"## some introspection\n",
"## does no.nodes change ?\n",
"#print disk.nodes.viewkeys()\n",
"#print disk.nodes.viewvalues()\n",
"## key to access to value of first node stored\n",
"#id=disk.nodes.keys()[0]\n",
"#print 'id= ',id\n",
"## what is this value ?\n",
"#help(disk.nodes[id])\n",
"#dir(disk.nodes[id])\n",
"#print disk.nodes[id].coor\n",
"#print disk.nodes[id].getCoor()\n",
"#print disk.nodes[id].number\n",
{
"cells": [
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "slide"
}
},
"source": [
"# Managing 2D deposit\n",
"\n",
"F. Dubois - 2016"
]
},
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "slide"
}
},
"source": [
"Importing necessary modules for the tutorial "
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false,
"slideshow": {
"slide_type": "fragment"
}
},
"outputs": [],
"source": [
"%matplotlib inline\n",
"\n",
"import os,sys\n",
"import numpy\n",
"import matplotlib.pyplot as plt\n",
"\n",
"from pylmgc90.pre_lmgc import *\n"
]
},
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "slide"
}
},
"source": [
"For this tutorial we need a function able to draw circles."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false,
"slideshow": {
"slide_type": "fragment"
}
},
"outputs": [],
"source": [
"def draw(coor,radii):\n",
"\n",
" plt.axes()\n",
"\n",
" for k in range(len(radii)):\n",
" circle = plt.Circle((coor[k,0], coor[k,1]), radius=radii[k], fc='y')\n",
" plt.gca().add_patch(circle)\n",
"\n",
" plt.axis('scaled')\n",
" plt.show()\n"
]
},
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "slide"
}
},
"source": [
"Nice we can draw ... Mickey Mouse !"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false,
"slideshow": {
"slide_type": "fragment"
}
},
"outputs": [],
"source": [
"coor=numpy.array([[0., 0.],[1.,1.],[-1.,1.],[0.,0.],[0.5,0.5],[-0.5,0.5]])\n",
"rayon=[1.,0.5,0.5,0.2,0.1,0.3]\n",
"draw(coor,rayon)\n"
]
},
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "slide"
}
},
"source": [
"Lets consider a more interesting problem. We need a set of radius."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true,
"slideshow": {
"slide_type": "fragment"
}
},
"outputs": [],
"source": [
"# Generating a list of radius\n",
"nb_particles = 10000\n",
{
"cells": [
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "slide"
}
},
"source": [
"# Managing granulometry\n",
"\n",
"F. Dubois - 2016"
]
},
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "slide"
}
},
"source": [
"Importing necessary modules"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false,
"slideshow": {
"slide_type": "subslide"
}
},
"outputs": [],
"source": [
"%matplotlib inline\n",
"%config InlineBackend.figure_formats = {'svg',}\n",
"#%config InlineBackend.figure_formats = {'png', 'retina'}\n",
"\n",
"import os,sys\n",
"import numpy\n",
"import math\n",
"import scipy\n",
"import scipy.special\n",
"import random\n",
"import matplotlib.pyplot as plt\n",
"\n",
"# Seaborn, useful for graphics\n",
"import seaborn as sns\n",
"\n",
"# JB's favorite Seaborn settings for notebooks\n",
"rc = {'lines.linewidth': 2, \n",
" 'axes.labelsize': 18, \n",
" 'axes.titlesize': 18, \n",
" 'axes.facecolor': 'DFDFE5'}\n",
"sns.set_context('notebook', rc=rc)\n",
"sns.set_style('darkgrid', rc=rc)\n",
"\n",
"\n",
"# Import Bokeh modules for interactive plotting\n",
"import bokeh.io\n",
"import bokeh.mpl\n",
"import bokeh.plotting\n",
"bokeh.io.output_notebook()\n",
"\n",
"from pylmgc90.pre_lmgc import *\n"
]
},
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "slide"
}
},
"source": [
"A function to draw the cumulated volume of particles"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false,
"slideshow": {
"slide_type": "subslide"
}
},
"outputs": [],
"source": [
"def draw_granulo(radii):\n",
" \"\"\"\n",
" A function to draw the cumulative volume occupied by a list of particles with respect to the radius \n",
" \n",
" :param radii: an array of radii\n",
" \"\"\" \n",
" \n",
" rd = numpy.sort(radii)\n",
"\n",
" # computing total volume (4pi/3 voluntarily omitted)\n",
" vv=0.\n",
" for radius in radii:\n",
" vv+=math.pow(radius,3)\n",