The error of generating particles and importing .mesh file

Asked by xuanshenyu

Hi all,

I'm simulating the collision of a rigid body (.mesh file and FrictMat) with a brittle material (sphere and CohFrictMa).

Below is my script :
from yade import pack
from numpy import genfromtxt
from yade import utils
from yade import export
from yade import ymport
from yade import wrapper
import csv
import numpy as np
import gts, os.path, locale

global h
global waterlevel
waterlevel=0
rho_water=1000
rho_ice=880
gravity=9.85
#matice
matice = O.materials.append(CohFrictMat(isCohesive=True, frictionAngle=radians(42), density=rho_ice, poisson=0.42, young=4.2e9, alphaKr=0.242, alphaKtw=0.1642, normalCohesion=4.2e7, shearCohesion=8.4e7))
Matice=O.materials[matice]

#matsteel
matsteel=O.materials.append(FrictMat(young=1e10,poisson=0.22,density=7580,frictionAngle=radians(30)))
Matsteel=O.materials[matsteel]

#sphere
coordinates=numpy.genfromtxt("zuobiao.csv",delimiter=",")
pack_ice=[sphere((x,y,z),radius=0.02,material=Matice,color=(69./255.,137./255.,148./255.)) for x,y,z in coordinates]
PACK_ICE=O.bodies.append(pack_ice)

#ship
ship=ymport.gmsh('xuelong.mesh',color=(0.42,0.42,0.42))
SHIP=O.bodies.append(ship)

#add ebgines
O.engines=[
      ForceResetter(),
      InsertionSortCollider([Bo1_Sphere_Aabb(aabbEnlargeFactor=1.1), Bo1_Facet_Aabb()]),
      InteractionLoop(
              [Ig2_Sphere_Sphere_ScGeom6D(interactionDetectionFactor=1.1), Ig2_Facet_Sphere_ScGeom()],
              [Ip2_CohFrictMat_CohFrictMat_CohFrictPhys(setCohesionNow=True), Ip2_FrictMat_FrictMat_FrictPhys()],
              [Law2_ScGeom6D_CohFrictPhys_CohesionMoment(),Law2_ScGeom_FrictPhys_CundallStrack()]
      ),
      DragEngine(Cd=0.47,Rho=rho_water,ids=PACK_ICE),
      NewtonIntegrator(gravity=(0, 0, -gravity), damping=0.5),
      TranslationEngine(translationAxis=[0,1,1],velocity=2, ids=SHIP,label='line_velocity')
      #RotationEngine(rotationAxis=[0,0,1],angularVelocity=10,ids=Box1,label='angular_velocity')
]

#buoyancy force
def applyBuoyancy():

         for b in pack_ice:
               h=b.state.pos[2]
               rad=0.05
               if h >= rad:
                      F_buo=0
                      O.forces.setPermF(b.id,(0,0,F_buo))
               elif h >= 0 and h < rad:
                      F_buo=(pi/3.)*h*h*(3.*rad-h)*rho_water*gravity
                      O.forces.setPermF(b.id,(0,0,F_buo))
               elif h >=-rad and h<0:
                      F_buo=((4./3.)*pi*rad*rad*rad-(pi/3.)*(rad+h)*(rad+h)*(3*rad-(rad+h)))*rho_water*gravity
                      O.forces.setPermF(b.id,(0,0,F_buo))
               else:
                      F_buo=(4./3.)*pi*rad*rad*rad*rho_water*gravity
                      O.forces.setPermF(b.id,(0,0,F_buo))

O.engines=O.engines+[PyRunner(iterPeriod=100,command='applyBuoyancy()',label='buolabel')]

O.dt = .5e-2 * PWaveTimeStep()
O.run(10000,True)
O.saveTmp()
##########################
.mesh file :
 MeshVersionFormatted 2
 Dimension
 3
 Vertices
 6472
     -1972.5348641465 2217.7544425058 -126.36521179963 1
     -1817.6871954756 2218.3440546922 -126.36521179963 2
     -1726.3235370492 2221.3487259367 -126.36521179963 3
     -1662.9266797428 2224.9927763124 -126.36521179963 4
     -1485.0446499397 2242.6015236394 -126.36521179963 5
     -1353.5544706967 2263.8767324632 -126.36521179963 6
     -1276.6144899829 2279.9050322631 -126.36521179963 7
     -1200.1244294567 2297.741214602 -126.36521179963 8
      -1123.806072471 2316.3916800594 -126.36521179963 9
......
#############.csv file
0,0,0
0,0.1,0
0,0.2,0
0,0.3,0
0,0.4,0
0,0.5,0
0,0.6,0
0,0.7,0
0,0.8,0
0,0.9,0
0,1,0
......
####################Question
Case one : when I run this script, the .mesh file is imported successfully, but the particles are not generated, and no error message.
Case two : if I remove the .mesh related commands, the particles can be generated.
Please let me know if full file is required or if you find other errors in the script.
Thanks in advance for your help

Question information

Language:
English Edit question
Status:
Solved
For:
Yade Edit question
Assignee:
No assignee Edit question
Solved by:
xuanshenyu
Solved:
Last query:
Last reply:
Revision history for this message
Jan Stránský (honzik) said :
#1

Hello,

> but the particles are not generated

how do you know?
visually from GUI, or examining O.bodies?

> Please let me know if full file is required or if you find other errors in the script.

yes, a full script and all necessary data (e.g. .mesh file) is required, otherwise we are not able to find any error in the script.
The script should be a MWE [1], M = minimal, e.g.:
- applyBuoyancy is not neccesary (?)
- the mesh file can have just a few triangles to reproduce the prolem
- the .csv file can have just a few lines to reproduce the problem
- etc.

Cheers
Jan

[1] https://www.yade-dem.org/wiki/Howtoask

Revision history for this message
xuanshenyu (shenyuxuan) said :
#2

Hi,Jan
Thank you for your reminder.

>but the particles are not generated
I examined O.bodies by command and found that the particles have been generated, but the GUI cannot be displayed.

>What is causing this?

Shenyu

Revision history for this message
Jan Stránský (honzik) said :
#3

>> but the particles are not generated
> I examined O.bodies by command and found that the particles have been generated, but the GUI cannot be displayed.

always try to get "hard" numerical evidence, not only visual "impression"

> What is causing this?
> ...
> sphere((x,y,z),radius=0.02
> ...
> Vertices
> 6472
> -1972.5348641465 2217.7544425058 -126.36521179963 1
> ...

If I am not mistaken, the particle radius is 0.02 and the mesh vertices varies in the ranges of thousands, i.e. there is 5 orders of magnitude difference in the mesh size and spheres size.
So the spheres are just too small to be displayed

Cheers
Jan

Revision history for this message
xuanshenyu (shenyuxuan) said :
#4

Yes, you are right :).
The unit system of the .mesh file is wrong
Thank you for your quick answer.

This Solved My Problem