# Model particles (polyhedra) have moved far from each other from the first

Hi there

I drew my whole polygons in Autocad (2D) and exported the vertices of them (of AutoCad) as text for using in YADE and creating polyhedra. I did that because I want pack of many polyhedrons with very small void and certain shape and size.
Here is my code:

import numpy as np
from numpy import *

RawVer=np.genfromtxt('polyline.txt',names=True,dtype=None)
# ListVer is list of all the vertices of all the polygons
Ver=()
ListVer=[]
for b in RawVer:
if b[0]=='*LWPOLYLINE':
ListVer.append(Ver)
Ver=()
continue
Cordn=b[0]
Cordn=np.fromstring(Cordn, sep=',')
Cordn=tuple(Cordn.tolist())
Cordn1=Cordn+(0.1,) # add z vertex to coordinates
Cordn2=Cordn+(0.3,) # add z vertex to coordinates
if not Cordn1 in Ver:
Ver=Ver+(Cordn1,Cordn2)
ListVer.append(Ver)

Dolomite = PolyhedraMat()
Dolomite.density = 2870
Dolomite.young = 24.36e9
Dolomite.poisson = 0.2

for ii in ListVer:

for b in O.bodies:
b.state.blockedDOFs='zXYZ'

O.engines=[
ForceResetter(),
InsertionSortCollider([Bo1_Polyhedra_Aabb(),]),
InteractionLoop(
[Ig2_Polyhedra_Polyhedra_PolyhedraGeom(),],
[Ip2_PolyhedraMat_PolyhedraMat_PolyhedraPhys()],
[Law2_PolyhedraGeom_PolyhedraPhys_Volumetric()]
),
NewtonIntegrator(damping=0.6,gravity=(0,-9.81,0)),
]

O.engines=O.engines+[PyRunner(iterPeriod=20,command='calm()',label="calmRunner")]

O.dt=10e-6

O.run(50000,True)
print(O.dt)

After run script, when I see graphical interface, particles are not near each other and they have moved far from each other. If I decrease young module, particles will be near each other same as initial model in AutoCad.
But I don`t want to decrease young module. I thought this distance and exploding between particles is because of overlapping of polyhedra vertices and then with Offset in AUTOCAD I moved polygons vertices so they hadn`t overlapping any more but the problem didn`t solve.

I should mention; after this step, I should allow particles move down under gravity.
How I should fix this problem

## Question information

Language:
English Edit question
Status:
Solved
For:
Assignee:
No assignee Edit question
Solved by:
Jan Stránský
Solved:
2019-10-02
Last query:
2019-10-02
2019-10-02
 Jan Stránský (honzik) said on 2019-09-30: #1

Hello,

please provide the content of polyline.txt file [1]

> Why the particles move and aren`t near each other?

there must be some interaction between them pushing them from each other.
Gravity applies the same force (i.e. the same acceleration) to all bodies, so it has no effect on this behavior.

> After run script

Please also investigate the situation BEFORE running the script, just after loading the polyhedrons (or after one iteration to be able to investigate interactions - if there are some, what are the overlaps etc.).

cheers
Jan

 Mahdeyeh (mahdiye.sky) said on 2019-09-30: #2

Thank you Jan Stránský for reply.

This is the content of polyline.txt file:

*LWPOLYLINE
5.250,17.171
5.355,17.216
5.396,17.308
5.494,17.349
5.464,17.149
5.405,17.079
5.358,17.140
5.250,17.171
*LWPOLYLINE
5.685,17.037
5.719,17.000
5.814,17.000
5.842,17.109
5.813,17.140
5.760,17.113
5.728,17.088
5.685,17.037
5.719,17.000
*LWPOLYLINE
5.016,17.593
5.211,17.560
5.270,17.458
5.351,17.502
5.330,17.736
5.313,17.918
5.203,17.972
5.118,17.880
5.063,17.830
5.016,17.593
5.211,17.560
*LWPOLYLINE
5.351,17.502
5.440,17.484
5.494,17.517
5.500,17.519
5.634,17.726
5.601,17.879
5.489,17.964
5.342,17.898
5.351,17.502
*LWPOLYLINE
5.500,17.502
5.634,17.726
5.779,17.678
5.673,17.500
5.500,17.502
*LWPOLYLINE
3.984,18.388
3.803,18.388
3.963,18.209
3.784,18.022
3.967,17.894
4.278,17.770
4.506,17.901
4.586,18.146
4.547,18.286
4.411,18.547
3.984,18.388
*LWPOLYLINE
4.877,17.257
4.962,17.281
5.112,17.225
5.254,17.354
5.211,17.560
5.016,17.593
4.872,17.593
4.872,17.362
4.877,17.257
4.962,17.281
*LWPOLYLINE
5.013,19.593
5.208,19.560
5.267,19.458
5.348,19.502
5.326,19.736
5.310,19.918
5.200,19.972
5.115,19.880
5.059,19.830
5.013,19.593
5.208,19.560
*LWPOLYLINE
5.511,20.321
5.699,20.201
5.798,20.289
5.846,20.531
5.746,20.623
5.482,20.506
5.511,20.321
*LWPOLYLINE
5.598,19.885
5.735,19.971
5.694,20.192
5.511,20.309
5.491,19.966
5.598,19.885
*LWPOLYLINE
5.497,21.000
5.626,20.885
5.747,20.629
5.476,20.509
5.288,20.487
5.227,20.840
5.227,20.994
5.497,21.000
*LWPOLYLINE
4.872,20.203
5.165,20.203
5.283,20.487
5.222,20.840
5.222,20.989
4.872,20.995
4.872,20.203
*LWPOLYLINE
5.352,19.506
5.436,19.489
5.488,19.521
5.494,19.523
5.625,19.727
5.593,19.876
5.485,19.958
5.344,19.895
5.352,19.506
*LWPOLYLINE
5.504,19.505
5.633,19.720
5.768,19.675
5.667,19.505
5.504,19.505
*LWPOLYLINE
5.618,19.342
5.663,19.495
5.497,19.497
5.438,19.479
5.271,19.454
5.255,19.352
5.116,19.225
5.307,19.007
5.457,19.152
5.618,19.342
5.618,19.342
*LWPOLYLINE
4.878,19.264
4.959,19.286
5.108,19.231
5.245,19.356
5.204,19.555
5.012,19.588
4.874,19.588
4.874,19.362
4.878,19.264
*LWPOLYLINE
4.874,19.598
5.009,19.598
5.055,19.833
5.195,19.974
5.164,20.193
4.872,20.193
4.872,20.019
4.874,19.598
*LWPOLYLINE
5.307,19.000
5.109,19.225
5.061,19.228
4.929,19.054
4.929,18.999
5.307,19.000
*LWPOLYLINE
5.628,19.339
5.673,19.494
5.831,19.451
5.866,19.354
5.811,19.313
5.747,19.252
5.628,19.339
*LWPOLYLINE
5.869,19.163
5.745,19.241
5.620,19.320
5.466,19.147
5.501,19.006
5.654,19.038
5.806,19.006
5.869,19.163
*LWPOLYLINE
5.303,19.004
5.261,18.963
5.365,18.878
5.503,18.996
5.463,19.158
5.303,19.004
*LWPOLYLINE
5.500,18.993
5.625,18.882
5.743,18.631
5.478,18.514
5.295,18.492
5.235,18.841
5.235,18.984
5.365,18.878
5.500,18.993
*LWPOLYLINE
4.875,18.203
5.168,18.203
5.286,18.487
5.225,18.840
5.225,18.986
5.050,18.908
4.875,18.992
4.875,18.203
*LWPOLYLINE
5.514,18.321
5.702,18.201
5.801,18.289
5.850,18.531
5.749,18.623
5.485,18.506
5.514,18.321
*LWPOLYLINE
5.177,18.197
5.295,18.482
5.475,18.503
5.504,18.317
5.485,17.967
5.314,17.923
5.208,17.975
5.177,18.197
*LWPOLYLINE
5.601,17.885
5.738,17.971
5.698,18.192
5.514,18.309
5.494,17.966
5.601,17.885
*LWPOLYLINE
4.877,17.598
5.012,17.598
5.058,17.833
5.198,17.974
5.167,18.193
4.875,18.193
4.875,18.018
4.877,17.598
*LWPOLYLINE
4.860,17.088
4.860,17.188
4.881,17.253
4.961,17.275
5.057,17.227
4.950,17.086
4.931,17.060
4.860,17.088
*LWPOLYLINE
4.941,17.056
5.066,17.223
5.110,17.220
5.187,17.144
5.187,17.070
5.119,17.043
5.066,17.006
4.941,17.056
*LWPOLYLINE
5.196,17.150
5.120,17.225
5.202,17.287
5.255,17.348
5.350,17.305
5.350,17.219
5.248,17.176
5.196,17.150
*LWPOLYLINE
5.083,17.005
5.124,17.034
5.187,17.059
5.187,17.005
5.083,17.005
*LWPOLYLINE
5.197,17.005
5.308,17.005
5.398,17.080
5.355,17.136
5.250,17.166
5.197,17.143
5.197,17.005
*LWPOLYLINE
5.461,17.138
5.409,17.076
5.324,17.005
5.495,17.005
5.461,17.138
*LWPOLYLINE
5.507,16.995
5.533,16.885
5.746,16.867
5.715,16.995
5.576,16.995
5.507,16.995
*LWPOLYLINE
5.583,17.008
5.607,17.107
5.659,17.177
5.742,17.177
5.724,17.090
5.682,17.041
5.583,17.008
*LWPOLYLINE
5.505,17.005
5.572,17.005
5.597,17.108
5.541,17.205
5.469,17.147
5.505,17.005
*LWPOLYLINE
5.660,17.187
5.743,17.187
5.746,17.243
5.632,17.325
5.660,17.187
*LWPOLYLINE
5.603,17.118
5.651,17.183
5.621,17.332
5.501,17.343
5.547,17.215
5.603,17.118
*LWPOLYLINE
5.631,17.339
5.676,17.494
5.834,17.451
5.870,17.354
5.815,17.313
5.750,17.252
5.631,17.339
*LWPOLYLINE
5.736,17.100
5.758,17.118
5.814,17.146
5.841,17.118
5.869,17.168
5.816,17.301
5.756,17.243
5.753,17.181
5.736,17.100
*LWPOLYLINE
5.004,16.894
4.850,17.083
4.850,17.189
4.867,17.356
4.410,17.253
4.144,17.253
4.054,17.047
4.454,17.047
4.649,16.894
5.004,16.894
*LWPOLYLINE
4.453,17.034
4.377,16.920
4.291,16.804
4.419,16.738
4.639,16.890
4.453,17.034
*LWPOLYLINE
4.135,17.256
4.015,17.327
3.970,17.432
3.803,17.039
4.043,17.046
4.135,17.256
*LWPOLYLINE
4.676,18.013
4.548,18.013
4.510,17.898
4.281,17.765
4.099,17.661
3.976,17.444
4.022,17.335
4.409,17.263
4.778,17.346
4.867,17.366
4.865,18.013
4.676,18.013
*LWPOLYLINE
2.431,17.050
3.156,17.479
2.780,17.068
2.431,17.050
*LWPOLYLINE
3.221,17.754
2.852,18.099
2.774,18.125
2.678,18.283
2.595,18.040
2.449,17.925
2.388,17.809
2.282,17.610
2.416,17.363
2.416,17.053
3.177,17.503
3.221,17.754
*LWPOLYLINE
3.731,18.461
3.662,18.548
3.611,18.611
3.356,18.449
3.019,18.449
2.941,18.279
2.861,18.105
3.061,17.977
3.229,17.761
3.741,17.819
3.779,18.024
3.957,18.209
3.731,18.461
*LWPOLYLINE
2.586,18.567
2.756,18.737
3.010,18.453
2.932,18.284
2.778,18.137
2.682,18.297
2.586,18.567
*LWPOLYLINE
4.278,17.770
3.774,17.971
3.746,17.815
3.227,17.756
3.182,17.500
3.248,17.262
3.389,17.034
3.795,17.034
3.970,17.445
4.095,17.664
4.278,17.770
*LWPOLYLINE
4.269,18.995
4.416,18.549
4.484,18.419
4.550,18.291
4.702,18.291
4.784,18.995
4.269,18.995
*LWPOLYLINE
3.560,18.923
3.703,18.674
3.740,18.468
3.984,18.394
4.131,18.448
4.404,18.550
4.332,18.687
4.287,18.874
4.258,18.995
3.560,18.923
*LWPOLYLINE
2.764,18.743
2.952,18.873
2.952,18.994
3.549,18.923
3.631,18.780
3.691,18.674
3.353,18.459
3.018,18.459
2.916,18.592
2.764,18.743
*LWPOLYLINE
4.131,19.256
4.012,19.327
3.967,19.432
3.800,19.039
4.039,19.046
4.131,19.256
*LWPOLYLINE
4.858,19.010
4.842,19.083
4.789,19.334
4.407,19.248
4.144,19.248
4.053,19.039
4.053,18.989
4.261,19.010
4.858,19.010
*LWPOLYLINE
4.672,20.013
4.545,20.013
4.507,19.898
4.277,19.765
4.096,19.661
3.973,19.445
4.019,19.335
4.406,19.263
4.775,19.346
4.864,19.366
4.862,20.013
4.672,20.013
*LWPOLYLINE
4.782,21.005
4.699,20.287
4.667,20.013
4.872,20.013
4.872,21.005
4.782,21.005
*LWPOLYLINE
4.550,20.281
4.618,20.036
4.697,20.281
4.550,20.281
*LWPOLYLINE
3.982,20.383
3.811,20.383
3.967,20.208
3.788,20.023
3.966,19.899
4.274,19.775
4.499,19.904
4.577,20.146
4.539,20.284
4.405,20.541
3.982,20.383
*LWPOLYLINE
4.266,20.995
4.412,20.549
4.480,20.419
4.547,20.291
4.699,20.291
4.781,20.995
4.266,20.995
*LWPOLYLINE
3.557,20.923
3.699,20.674
3.736,20.468
3.981,20.394
4.128,20.448
4.401,20.550
4.329,20.687
4.284,20.874
4.255,20.995
3.557,20.923
*LWPOLYLINE
2.761,20.744
2.948,20.873
2.948,20.994
3.546,20.923
3.627,20.780
3.688,20.674
3.350,20.459
3.015,20.459
2.913,20.592
2.761,20.744
*LWPOLYLINE
3.728,20.461
3.659,20.548
3.608,20.611
3.353,20.449
3.016,20.449
2.938,20.279
2.858,20.105
3.058,19.977
3.226,19.761
3.738,19.819
3.776,20.024
3.953,20.209
3.728,20.461
*LWPOLYLINE
3.376,19.031
3.235,19.258
3.174,19.480
2.796,19.067
2.949,19.010
3.375,18.959
3.376,19.031
*LWPOLYLINE
4.263,19.769
3.775,19.964
3.747,19.810
3.228,19.751
3.184,19.500
3.249,19.264
3.389,19.039
3.789,19.039
3.963,19.447
4.088,19.668
4.263,19.769
*LWPOLYLINE
2.583,20.567
2.753,20.737
3.007,20.453
2.929,20.284
2.775,20.137
2.678,20.297
2.583,20.567
*LWPOLYLINE
3.213,19.752
2.846,20.095
2.767,20.121
2.676,20.271
2.596,20.037
2.450,19.922
2.389,19.806
2.285,19.610
2.418,19.364
2.418,19.061
3.170,19.506
3.213,19.752
*LWPOLYLINE
2.447,19.056
3.126,19.457
2.774,19.073
2.447,19.056
*LWPOLYLINE
4.560,18.276
4.622,18.053
4.693,18.276
4.560,18.276
*LWPOLYLINE
5.173,20.197
5.292,20.482
5.472,20.503
5.501,20.317
5.481,19.967
5.310,19.923
5.205,19.975
5.173,20.197
*LWPOLYLINE
5.471,17.161
5.536,17.214
5.496,17.297
5.471,17.161
*LWPOLYLINE
5.445,17.480
5.495,17.495
5.489,17.356
5.445,17.376
5.445,17.480
*LWPOLYLINE
5.409,17.319
5.442,17.367
5.481,17.349
5.409,17.319
*LWPOLYLINE
5.274,17.455
5.352,17.497
5.435,17.480
5.435,17.375
5.393,17.313
5.356,17.313
5.259,17.357
5.274,17.455
*LWPOLYLINE
4.790,19.000
4.707,18.286
4.676,18.018
4.870,18.018
4.870,19.000
4.790,19.000

 Mahdeyeh (mahdiye.sky) said on 2019-09-30: #3

Dear Jan Stránský

> Please also investigate the situation BEFORE running the script, just after loading the polyhedrons (or after one iteration to be able to investigate interactions - if there are some, what are the overlaps etc.).

The situation of particles before running the script are correct and they are loaded quite correctly. they are near each other.

 Jan Stránský (honzik) said on 2019-10-01: #4

Hi,

> they are near each other.

not only they are near each other, they DOES overlap, which generates repulsive forces and results in "they have moved far from each other"

Try before O.run():
###
O.step()
for i in O.interactions:
print(i.geom.penetrationVolume)
###

Visually, you can try:
###
for b in O.bodies:
b.shape.wire = True
b.shape.color = randomColor()
###
which reveals significant overlaps in the initial geometry

cheers
Jan

 Mahdeyeh (mahdiye.sky) said on 2019-10-02: #5

>Try before O.run():
>###
>O.step()
>for i in O.interactions:
> print(i.geom.penetrationVolume)
I did it and I Saw they had very small penetrationVolume, I really confused;when I check the geometry in AutoCad the particles are quite seperate from each other. Between the edge of neighbour polygons is distance, of course their distance is very very small but it exists. But when I load model in YADE without running, unbelievably I see visually some particles overlap!!!
1- Is that possible this overlap is because of very small distance between particles?

2- Is there any solution for this problem instead of changing their geometry?

 Jan Stránský (honzik) said on 2019-10-02: #6

> they had very small penetrationVolume

"very small" is very relative :-) the value it far above rounding error and (as mentioned above) the result of "explosion"

> The situation of particles before running the script are correct and they are loaded quite correctly.
> But when I load model in YADE without running, unbelievably I see visually some particles overlap!!!

That was my point. So the polyhedrons are NOT loaded quite correctly :-)

There might be several reasons:
- first, the saving / loading phase, double check your implementation (you cen use some toy data like two rectangles)
- the saved data has only 3 decimal digits (probably it it not the problem, but try with more precise values)
- polyhedrons in Yade are convex. Dos your geometry contains only convex shapes?
- ...

> 1- Is that possible this overlap is because of very small distance between particles?

no, if there is very small distance between particles in your input data, the same very small distance but no overlap should exist in loaded data

cheers
Jan

 Mahdeyeh (mahdiye.sky) said on 2019-10-02: #7

Dear Jan Stránský

> the saved data has only 3 decimal digits (probably it it not the problem, but try with more precise values)
> polyhedrons in Yade are convex. Dos your geometry contains only convex shapes?

They were two important points that solved my problem, some of particles were in concave shape. you are so great and wonderful.

Best regards,
Mahdeyeh

 Mahdeyeh (mahdiye.sky) said on 2019-10-02: #8

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