The error about defining a CohFrictPhys bond between two different materials?

Asked by Jingchi Yu

Hi, everyone

Here is Jingchi Yu, and i have this code, and i want to simulate the brazilian experiment of a concrete sample, which is made of rock and mortar. For the purpose of defining the tensile strength between rock and mortar, I used the "matchmaker", but I got the error information:

Traceback (most recent call last):
  File "/usr/bin/yade", line 342, in runScript
    execfile(script,globals())
  File "uniCom_2d.py", line 98, in <module>
    normalCohesion=MatchMaker(matches=((rockId,mortarId,6.0e6))),
TypeError: No registered converter was able to produce a C++ rvalue of type Eigen::Matrix<double, 3, 1, 0, 3, 1> from this Python object of type int

Hope your apply!

My code is here:

from __future__ import division
from yade import bodiesHandling
from numpy import arange
from yade import ymport
from yade import export
from yade import utils
from yade import pack
from yade import plot
from yade import qt
import xlsxwriter
import math
import numpy

###########################
# DEFINE MATERIALS
###########################
# input parameters
porosity = 0.05
Young = 1.0e11 # 100Gpa
FrictAng = radians(18)
Density = 2240/(1-porosity)
Poisson = 1/3.0
Cohesion = 4.5e7 # pa
TensileStr = 10*4.5e6 # pa

#for Mat in (rock,mortar,steel):
# O.materials.append(Mat)
rockId = O.materials.append(CohFrictMat(young=4.8e10,poisson=.2,density=Density,frictionAngle=radians(38),normalCohesion=4.2e7,shearCohesion=8.4e7,label='mat1'))
mortarId = O.materials.append(CohFrictMat(young=3.2e10,poisson=.2,density=Density,frictionAngle=radians(38),normalCohesion=1.5e7,shearCohesion=3e7,label='mat2'))
steelId = O.materials.append(CohFrictMat(young=2.06e11,poisson=.3,density=7800,frictionAngle=radians(30),normalCohesion=0,shearCohesion=0))

######################################
# IMPORT PACKING & UNIAXIAL TENSION
######################################

OutputName = 'uniCom_rdp_2d'

# import packing
#assembly = O.bodies.append(ymport.text('sim1.txt',color=(1,0,1),material=rock))

f = open('sim1.txt','r')
ls = f.readlines()
f.close()

for i in range(8434):
 l = ls[i].split()
 if i<1000:
  x0,y0,z0,r0 = float(l[0]),float(l[1]),float(l[2]),float(l[3])
  assembly = O.bodies.append(sphere(center=(x0,y0,z0),radius=r0,color=(0,0,1),material=rockId))
 else:
  x1,y1,z1,r1 = float(l[0]),float(l[1]),float(l[2]),float(l[3])
  assembly = O.bodies.append(sphere(center=(x1,y1,z1),radius=r1,color=(1,0,1),material=mortarId))

# define a 2d simulation
#for i in assembly:
# O.bodies[i].state.blockedDOFs = 'zXY'

# aabbWalls
wall = O.bodies.append(utils.aabbWalls(material=steelId,thickness=0.001,color=(1,1,1)))

# delete other walls only save walls in y axis
O.bodies.erase(wall[0])
O.bodies.erase(wall[1])
O.bodies.erase(wall[4])
O.bodies.erase(wall[5])

# set velocity for upper wall
upper_wall = O.bodies[wall[3]]
upper_wall.state.blockedDOFs = 'xyzXYZ'
upper_wall.state.vel = (0,-0.01,0) # 10 mm/s

# fixed the bottom wall
bottom_wall = O.bodies[wall[2]]
bottom_wall.state.blockedDOFs = 'xyzXYZ'

###########################
# ENGINES
###########################

O.engines=[
 ForceResetter(),
 InsertionSortCollider([Bo1_Sphere_Aabb(aabbEnlargeFactor=1.25,label='Aabb'),Bo1_Box_Aabb()]),
 InteractionLoop(
  [Ig2_Sphere_Sphere_ScGeom6D(interactionDetectionFactor=1.25,label='IntFactor'),Ig2_Box_Sphere_ScGeom6D()],
  [Ip2_CohFrictMat_CohFrictMat_CohFrictPhys(
          normalCohesion=MatchMaker(matches=((rockId,mortarId,6.0e6))),
          shearCohesion=MatchMaker(matches=((rockId,mortarId,12e6))))],
  [Law2_ScGeom6D_CohFrictPhys_CohesionMoment()]
 ),
 VTKRecorder(fileName='post/uniCom-',recorders=['all'],iterPeriod=1000),
 GlobalStiffnessTimeStepper(active=1,timeStepUpdateInterval=5,timestepSafetyCoefficient=0.8,defaultDt=PWaveTimeStep()),
 NewtonIntegrator(damping=0.3,gravity=(0,-9.81,0)),
 PyRunner(command='addPlotData()',iterPeriod=500),
 PyRunner(command='damageRatio()',iterPeriod=500),
 PyRunner(command='writeData()',iterPeriod=500),
 PyRunner(command='stopSimu()',iterPeriod=500),
# inter

]
O.trackEnergy=True
O.step()

Question information

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

Hello,

MatchMaker(matches=((rockId,mortarId,6.0e6)))
is equivalent (notice the "useless" brackets) to
MatchMaker(matches=(rockId,mortarId,6.0e6))
which is invalid format for matches

change it to
MatchMaker(matches=[(rockId,mortarId,6.0e6)])
or
MatchMaker(matches=((rockId,mortarId,6.0e6),))
(notice the comma, making the brackets "tuple", not "useless")

cheers
Jan

Revision history for this message
Jingchi Yu (yujc-17) said :
#2

Thanks for your answer, Jan!

I did as your advice ,and I got a further error,:

terminate called after throwing an instance of 'std::invalid_argument'
  what(): MatchMaker: no match for (2,0), and values required for algo computation 'avg' not specified.

My code is here:
O.engines=[
 ForceResetter(),
 InsertionSortCollider([Bo1_Sphere_Aabb(aabbEnlargeFactor=1.25,label='Aabb'),Bo1_Box_Aabb()]),
 InteractionLoop(
  [Ig2_Sphere_Sphere_ScGeom6D(interactionDetectionFactor=1.25,label='IntFactor'),Ig2_Box_Sphere_ScGeom6D()],
  [Ip2_CohFrictMat_CohFrictMat_CohFrictPhys(
          normalCohesion=MatchMaker(matches=((rockId,mortarId,6.0e6),)),
          shearCohesion=MatchMaker(matches=((rockId,mortarId,12e6),)))],
  [Law2_ScGeom6D_CohFrictPhys_CohesionMoment()]
 ),
 VTKRecorder(fileName='post/uniCom-',recorders=['all'],iterPeriod=1000),
 GlobalStiffnessTimeStepper(active=1,timeStepUpdateInterval=5,timestepSafetyCoefficient=0.8,defaultDt=PWaveTimeStep()),
 NewtonIntegrator(damping=0.3,gravity=(0,-9.81,0)),
 PyRunner(command='addPlotData()',iterPeriod=500),
 PyRunner(command='damageRatio()',iterPeriod=500),
 PyRunner(command='writeData()',iterPeriod=500),
 PyRunner(command='stopSimu()',iterPeriod=500),
# inter

]

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

You have to define values also for material id 2 (steel according to your code)
cheers
Jan

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

Or define "algo" - "Algorithm used to compute value when no match for ids is found". See documentation [1] first of all.
cheers
Jan

[1] https://yade-dem.org/doc/yade.wrapper.html#yade.wrapper.MatchMaker

Revision history for this message
Jingchi Yu (yujc-17) said :
#5

Thanks Jan Stránský, that solved my question.