Commit 0836c2fc authored by mozul's avatar mozul
Browse files

Squashed 'examples/' changes from 06e5e26..c315cae

c315cae maj notebooks
212a33f maj
b187a5d correct ComputeField before UpdateBulk in Pre examples
762edf1 remove sys.path.append from all examples
005bd6b add mecaMAILx_ComputeField before UpdateStep
3404940 command name change
941451a maj
757e441 modifs notebooks
dba1b41 nettoyage
ae4c4dd ajout notebook
be0cfcd exemple de treilli en elements BARxx

git-subtree-dir: examples
git-subtree-split: c315caecbc2e09c8fcfd36ecb0cec242c0d16cdf
parent 2739da53
......@@ -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",
"# - entre particules\n",
"svdkdk = see_table(CorpsCandidat='RBDY2',candidat='DISKx',\n",
" colorCandidat='BLEUx',behav=ldkdk, CorpsAntagoniste='RBDY2', \n",
" antagoniste='DISKx',colorAntagoniste='BLEUx',alert=0.1*radius_min)\n",
"svs+=svdkdk\n",
"# - avec les parois\n",
"svdkjc = see_table(CorpsCandidat='RBDY2',candidat='DISKx',\n",
" colorCandidat='BLEUx',behav=ldkjc, CorpsAntagoniste='RBDY2', \n",
" antagoniste='JONCx',colorAntagoniste='WALLx',alert=0.1*radius_min)\n",
"svs+=svdkjc\n",
"\n",
"# ecriture des fichiers\n",
"writeBodies(bodies,chemin='DATBOX/')\n",
"writeBulkBehav(mat,chemin='DATBOX/')\n",
"writeTactBehav(tacts,svs,chemin='DATBOX/')\n",
"writeDrvDof(bodies,chemin='DATBOX/')\n",
"writeDofIni(bodies,chemin='DATBOX/')\n",
"writeVlocRlocIni(chemin='DATBOX/')\n",
"\n",
"try:\n",
" visuAvatars(bodies)\n",
"except:\n",
" pass\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": []
}
],
"metadata": {
"celltoolbar": "Slideshow",
"kernelspec": {
"display_name": "Python 2",
"language": "python",
"name": "python2"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 2
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython2",
"version": "2.7.11"
}
},
"nbformat": 4,
"nbformat_minor": 0
}
{
"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",
"#print disk.nodes.values()[0].coor"
]
},
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "fragment"
}
},
"source": [
"Creating an element and adding it to the avatar"
]
},
{
"cell_type": "code",
"execution_count": 6,
"metadata": {
"collapsed": false,
"slideshow": {
"slide_type": "fragment"
}
},
"outputs": [],
"source": [
"disk.addBulk( rigid2d() )\n",
"\n",
"## some introspection\n",
"#help(disk.bulks)\n",
"#print disk.bulks.keys()\n",
"#id=disk.bulks.keys()[0]\n",
"#help(disk.bulks[id])\n",
"#dir(disk.bulks[id])\n",
"#print disk.bulks[id].connectivity"
]
},
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "fragment"
}
},
"source": [
" We need groups to add model/material, contactors, drivendof, etc."
]
},
{
"cell_type": "code",
"execution_count": 7,
"metadata": {
"collapsed": false,
"slideshow": {
"slide_type": "fragment"
}
},
"outputs": [],
"source": [
"## does my object contain groups ?\n",
"#dir(disk.groups)\n",
"#print disk.groups.viewkeys()\n",
"\n",
"# \n",
"disk.defineGroups()\n",
"\n",
"## does my object contain groups ?\n",
"#print disk.groups.viewkeys()\n",
"## what is group 'all'?\n",
"#help(disk.groups['all'])\n",
"#dir(disk.groups['all'])\n",
"#help(disk.groups['all'].bulks)\n",
"#dir(disk.groups['all'])\n",
"#print disk.groups['all'].bulks.keys()\n",
"#print disk.groups['all'].bulks[0]\n",
"#print disk.groups['all'].nodes.keys()\n",
"#print disk.groups['all'].contactors.keys()"
]
},
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "fragment"
}
},
"source": [
"Adding model and material (default added to 'all')."
]
},
{
"cell_type": "code",
"execution_count": 8,
"metadata": {
"collapsed": false,
"slideshow": {
"slide_type": "fragment"
}
},
"outputs": [],
"source": [
"disk.defineModel(model=mod)\n",
"disk.defineMaterial(material=mut)\n"
]
},
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "fragment"
}
},
"source": [
"Adding contactor (default added to 'all')"
]
},
{
"cell_type": "code",
"execution_count": 9,
"metadata": {
"collapsed": true,
"slideshow": {
"slide_type": "fragment"
}
},
"outputs": [],
"source": [
"disk.addContactors(type='DISKx', color='BLUEx', byrd=1.)"
]
},
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "fragment"
}
},
"source": [
"Needs to compute some internal values (mass, inertia, frame, etc)"
]
},
{
"cell_type": "code",
"execution_count": 10,
"metadata": {
"collapsed": true,
"slideshow": {
"slide_type": "fragment"
}
},
"outputs": [],
"source": [
"disk.computeRigidProperties()"
]
},
{
"cell_type": "markdown",
"metadata": {
"slideshow": {
"slide_type": "fragment"
}
},
"source": [
"Some magic function"
]
},
{
"cell_type": "code",
"execution_count": 11,
"metadata": {
"collapsed": true,
"slideshow": {
"slide_type": "fragment"
}
},
"outputs": [],
"source": [
"disk2=rigidDisk(r=1., center=[2., 2.], model=mod, material=mut, color='BLUEx') "
]
},
{
"cell_type": "code",
"execution_count": 12,
"metadata": {
"collapsed": false
},