Re: [Yade-users] [Question #691026]: Loading the stored the position of plank, but it wrong

2020-06-01 Thread yang yi
Question #691026 on Yade changed:
https://answers.launchpad.net/yade/+question/691026

yang yi posted a new comment:
To Jan Stránský :
Thank you very much. I am sorry that the script can not meet  MWE.  My script 
is similar with yours.  The facet rotate and restore the location , then 
display the rotation process by reload the location. How ever my facet is a 
quadrangle, and consist with two  triangles.   
  I used the " pack.sweptPolylines2gtsSurface([positionWind[0]], 
capStart=True, capEnd=True)" to create the plank, but I do not know why the 
quadrangle consists with two triangles.  That is source of my problem.  In the 
rotation process, the quadrangle moving with the two triangles sticks together 
in the 3D show.  However, If I read the location from the storage, in the 3D 
show,  the two triangles separated.

I desire your help. so I modified the script as follow, I hope it
can meet the MWE

(1) Rotation process:

positionWind = []
temp = [Vector3(0, 0, 0),
Vector3(0, 10, 0),
Vector3(10, 10, 0),
Vector3(10, 0, 0)]
positionWind.append(temp)
Wind1 = pack.sweptPolylines2gtsSurface([positionWind[0]], capStart=True, 
capEnd=True)
IDWind = O.bodies.append(pack.gtsSurface2Facets(Wind1))
saveCounter = 0
##---##
def WindowsAction_SaveLoaction(IDWind):
global WinAction, windPosition, saveCounter, RotationW1
RotationW1.angularVelocity = -0.01
outputDir = "Output/location/"
if not os.path.exists(outputDir):
os.makedirs(outputDir)
Position = []
for i in IDWind:
temp = [i, o.bodies[i].state.pos]
Position.append(temp)
location_name = outputDir + 'wind' + '_' + str(saveCounter)
np.save(location_name, Position)
saveCounter += 1

O.engines = [
ForceResetter(),
GlobalStiffnessTimeStepper(),
NewtonIntegrator(gravity=(0, 0, 9.8), damping=0.5, label='down'),
RotationEngine(rotationAxis=(1, 0, 0), rotateAroundZero=True, ids=IDWind, 
zeroPoint=positionWind[0][0],
   label='RotationW1'),
PyRunner(command="WindowsAction_SaveLoaction(IDWind)", iterPeriod=20),
]

==
(2) Read the location

positionWind = []
temp = [Vector3(0, 0, 0),
Vector3(0, 10, 0),
Vector3(10, 10, 0),
Vector3(10, 0, 0)]
positionWind.append(temp)
Wind1 = pack.sweptPolylines2gtsSurface([positionWind[0]], capStart=True, 
capEnd=True)
IDWind = O.bodies.append(pack.gtsSurface2Facets(Wind1))

saveCounter = 0
import os.path
rootdir = "Output/location/"
wind_locations = []
for parent, dirnames, filenames in os.walk(rootdir):
for filename in filenames:
if filename[0:4] == 'wind':
wind_locations.append(filename)
fileNum = len(filenames)
saveCounter=0

def Display():
global fileNum,saveCounter
path = 'Output/location/'
wind_name = path + 'wind_' + str(saveCounter) + '.npy'
locationWind = np.load(wind_name, allow_pickle=True)
print(locationWind)
print('--')
for i in range(0, len(locationWind)):
n = locationWind[i][0]
o.bodies[n].state.pos = locationWind[i][1]
saveCounter +=1

O.engines = [
ForceResetter(),
GlobalStiffnessTimeStepper(),
NewtonIntegrator(gravity=(0, 0, 9.8), damping=0.5, label='down'),
PyRunner(command="Display()", iterPeriod=20),
]

Thank you very much

-- 
You received this question notification because your team yade-users is
an answer contact for Yade.

___
Mailing list: https://launchpad.net/~yade-users
Post to : yade-users@lists.launchpad.net
Unsubscribe : https://launchpad.net/~yade-users
More help   : https://help.launchpad.net/ListHelp


Re: [Yade-users] [Question #691026]: Loading the stored the position of plank, but it wrong

2020-06-01 Thread yang yi
Question #691026 on Yade changed:
https://answers.launchpad.net/yade/+question/691026

yang yi posted a new comment:
To Jan Stránský:
Thank you very much.  I modified the script as follow, there just a plank.  In 
the first It rotates around a axis and the location stored. Then the location 
load by the second script and display in the 3D show.
The plank consist of two triangles. The 3D show of the first script that the 
two triangles rotate together, however in the display script, the triangles are 
separated.  As  you found the location is the same.  So please help me how to 
modify that. 


(1) Rotation script
#!/usr/bin/env python
#  encoding: utf-8
from __future__ import print_function
import sys

sys.path.append('~/PycharmProjects/Yade20191229/')
# from yadeImport import *
import numpy as np
import os
from yade.gridpfacet import *
o = Omega()
o.dt = 1e-12
outputDir = 'Output'
positionWind = []

def HydraulicSupport():
global  positionWind
temp = [Vector3(0,  0, 0),
Vector3(0,  10, 0),
Vector3(10, 10, 0),
Vector3(10, 0, 0)]
positionWind.append(temp)
Wind1 = pack.sweptPolylines2gtsSurface([positionWind[0]], capStart=True, 
capEnd=True)
IDWind = O.bodies.append(pack.gtsSurface2Facets(Wind1))
return IDWind

def Ground():
O.bodies.append(utils.wall(position=-10, sense=0, axis=2, material=-1))

##---##
def WindowsAction(IDWind):
global WinAction, windPosition, saveCounter, nEpisode,RotationW1
RotationW1.angularVelocity = -0.01
SaveProcessLocation(nEpisode, saveCounter)
saveCounter += 1

def SaveProcessLocation(Episode, iter):
outputDir = "Output/location/"
if not os.path.exists(outputDir):
os.makedirs(outputDir)
Position = []

for i in IDWind:
print(o.bodies[i].state.pos)
temp = [i, o.bodies[i].state.pos]
Position.append(temp)
location_name = outputDir + 'wind_' + str(Episode)+ '_' + str(iter)
np.save(location_name, Position)

def WindowsControl():
global saveCounter, nEpisode
nEpisode += 1
saveCounter = 0

nEpisode = 0
saveCounter = 0
IDWind = HydraulicSupport()
Ground()

O.engines = [
ForceResetter(),
InsertionSortCollider([Bo1_Sphere_Aabb(),Bo1_Facet_Aabb(),Bo1_Wall_Aabb()]),
InteractionLoop(
[Ig2_Sphere_Sphere_ScGeom(), Ig2_Facet_Sphere_ScGeom(), 
Ig2_Wall_Sphere_ScGeom()],
[Ip2_FrictMat_FrictMat_FrictPhys(),
 Ip2_JCFpmMat_JCFpmMat_JCFpmPhys(xSectionWeibullScaleParameter=0.5,
xSectionWeibullShapeParameter=0.5,
weibullCutOffMin=0,
weibullCutOffMax=10)],
[Law2_ScGeom_JCFpmPhys_JointedCohesiveFrictionalPM(recordCracks=False, 
recordMoments=False,label='interactionLaw'),
Law2_ScGeom_FrictPhys_CundallStrack()]
),
GlobalStiffnessTimeStepper(),
NewtonIntegrator(gravity=(0, 0, 9.8), damping=0.5, label='down'),
RotationEngine(rotationAxis=(1, 0, 0), rotateAroundZero=True, ids=IDWind, 
zeroPoint=positionWind[0][0],
   label='RotationW1'),
PyRunner(command="WindowsAction(IDWind)", iterPeriod=20),
PyRunner(command="WindowsControl()", iterPeriod=200),
]
# o.run(12)


(2) Display script
from __future__ import print_function
import sys
sys.path.append('~/PycharmProjects/Yade20191229/')
# from yadeImport import *
import numpy as np
import os
from yade.gridpfacet import *
o = Omega()
o.dt = 1e-12

positionWind=[]

def HydraulicSupport():
global  positionWind
temp = [Vector3(0, 0, 0),
Vector3(0, 10, 0),
Vector3(10,10, 0),
Vector3(10,0, 0)]
positionWind.append(temp)
Wind1 = pack.sweptPolylines2gtsSurface([positionWind[0]], capStart=True, 
capEnd=True)
IDWind = O.bodies.append(pack.gtsSurface2Facets(Wind1))
return IDWind

def Ground():
O.bodies.append(utils.wall(position=-10, sense=0, axis=2, material=-1))


def Relocation():
global nEpisode, nIter, index
path = 'Output/location/'
wind_name = path + 'wind_' + str(nEpisode) + '_' + str(nIter) + '.npy'

if nIter >= index[nEpisode, 1]:
nIter = 0
nEpisode += 1
else:
nIter += 1
if nEpisode >= len(index):
O.pause()

locationWind = np.load(wind_name, allow_pickle=True)
print(nEpisode,nIter)
print(locationWind)
print('--')
for i in range(0, len(locationWind)):
n = locationWind[i][0]
o.bodies[n].state.pos = locationWind[i][1]


import os.path
rootdir = "Output/location/"
wind_locations = []

for parent, dirnames, filenames in os.walk(rootdir):
for filename in filenames:
if filename[0:4] == 'wind':
wind_locations.append(filename)

episodeMax = 0
endNumber =  1
for i in wind_locations:
   n = int(i[5])
   if n >= episodeMax:
   episodeMax = n

i

Re: [Yade-users] [Question #691026]: Loading the stored the position of plank, but it wrong

2020-05-29 Thread yang yi
Question #691026 on Yade changed:
https://answers.launchpad.net/yade/+question/691026

yang yi posted a new comment:
To Jan Stránský (honzik) :
Thank you very much.  I attach the script as follow.  There are two scripts: 
(1) the simulation to produce the position of 5 windows (2) display the process.



script (1)  Simulation script:

#!/usr/bin/env python
#  encoding: utf-8
from __future__ import print_function
import sys

sys.path.append('~/PycharmProjects/Yade20191229/')
# from yadeImport import *

import math
import numpy as np
import os
from yade.gridpfacet import *
o = Omega()
o.dt = 1e-12
outputDir = 'Output'
checkCounter = 0
numWinds = 5
WinAction = np.zeros((5,1), dtype=int)

## === Environment ##
widthSpace = 6.8  ## width is the distance from the front coal wall to the back
widthHydr = 1.5
lengthSpace = widthHydr * numWinds  ## length is the width of 5 windows
highHydr = 3.8
CheckThick = 1
highDummy =  3
colorWind =   (0, 1, 1)
angleShield = 50 * 3.1415926 / 180
angleSwingPositive = 15 * 3.1415926 / 180
angleSwingNegtive = 40 * 3.1415926 / 180
lengthShield = 3
lengthTail = 2
windUpperBoundary = 0.9
windLowerBoundary = 0.5019
stateUpperBoundary = highHydr
stateLowerBoundary = windLowerBoundary

positionWind = []
windPosition = np.zeros(5)

shield_y_0 = lengthTail * math.cos(angleShield - angleSwingPositive)
shield_y_1 = shield_y_0 + lengthShield * math.cos(angleShield)
shield_z_0 = highHydr - lengthShield * math.sin(angleShield)
shield_z_1 = highHydr  #
wind_y_0 = lengthTail * (math.cos(angleShield - angleSwingPositive) - 
math.cos(angleShield))
wind_y_1 = shield_y_0
wind_z_0 = highHydr - (lengthShield + lengthTail) * math.sin(angleShield)
wind_z_1 = highHydr - lengthShield * math.sin(angleShield)
HyMat = O.materials.append(FrictMat(frictionAngle=0.1, density=3000, young=2e9))
myGraviaty = -1200
def HydraulicSupport():
for i in range(0, numWinds):

temp = [
Vector3(widthHydr * i, wind_y_0, wind_z_0),
Vector3(widthHydr * (i + 1), wind_y_0, wind_z_0),
Vector3(widthHydr * (i + 1), wind_y_1, wind_z_1),
Vector3(widthHydr * i, wind_y_1, wind_z_1)
]
positionWind.append(temp)

Wind1 = pack.sweptPolylines2gtsSurface([positionWind[0]], capStart=True, 
capEnd=True)
Wind2 = pack.sweptPolylines2gtsSurface([positionWind[1]], capStart=True, 
capEnd=True)
Wind3 = pack.sweptPolylines2gtsSurface([positionWind[2]], capStart=True, 
capEnd=True)
Wind4 = pack.sweptPolylines2gtsSurface([positionWind[3]], capStart=True, 
capEnd=True)
Wind5 = pack.sweptPolylines2gtsSurface([positionWind[4]], capStart=True, 
capEnd=True)

IDWind1 = O.bodies.append(pack.gtsSurface2Facets(Wind1, color=colorWind))
IDWind2 = O.bodies.append(pack.gtsSurface2Facets(Wind2, color=colorWind))
IDWind3 = O.bodies.append(pack.gtsSurface2Facets(Wind3, color=colorWind))
IDWind4 = O.bodies.append(pack.gtsSurface2Facets(Wind4, color=colorWind))
IDWind5 = O.bodies.append(pack.gtsSurface2Facets(Wind5, color=colorWind))

IDWind = [IDWind1, IDWind2, IDWind3, IDWind4, IDWind5]
WindList = IDWind1 + IDWind2 + IDWind3 + IDWind4 + IDWind5
return IDWind, WindList

##---##
def WindowsAction(IDWind):
global WinAction, windPosition, saveCounter, nEpisode
RotationW = [RotationW1, RotationW2, RotationW3, RotationW4, RotationW5]

for nW in range(0, numWinds):
RotationW[nW].angularVelocity = -0.01
SaveProcessLocation(nEpisode, saveCounter)
saveCounter += 1

def SaveProcessLocation(Episode, iter):
outputDir = "Output/location/"
if not os.path.exists(outputDir):
os.makedirs(outputDir)
Position = []
for i in WindList:
print(o.bodies[i].state.pos)
temp = [i, o.bodies[i].state.pos]
Position.append(temp)
location_name = outputDir + 'wind_' + str(Episode)+ '_' + str(iter)
np.save(location_name, Position)

def WindowsControl():
global saveCounter,nEpisode
nEpisode += 1
saveCounter = 0

nEpisode = 0
saveCounter = 0
IDWind, WindList = HydraulicSupport()


O.engines = [
ForceResetter(),
InsertionSortCollider([Bo1_Sphere_Aabb(),Bo1_Facet_Aabb(),Bo1_Wall_Aabb()]),
InteractionLoop(
[Ig2_Sphere_Sphere_ScGeom(), Ig2_Facet_Sphere_ScGeom(), 
Ig2_Wall_Sphere_ScGeom()],
[Ip2_FrictMat_FrictMat_FrictPhys(),
 Ip2_JCFpmMat_JCFpmMat_JCFpmPhys(xSectionWeibullScaleParameter=0.5,
xSectionWeibullShapeParameter=0.5,
weibullCutOffMin=0,
weibullCutOffMax=10)],
[Law2_ScGeom_JCFpmPhys_JointedCohesiveFrictionalPM(recordCracks=False, 
recordMoments=False,label='interactionLaw'),
Law2_ScGeom_FrictPhys_CundallStrack()]
),
GlobalStiffnessTimeStepper(),

NewtonIntegrator(gravity=(0, 0, myGraviaty), damping=0.5, label='down'),
RotationEngine(ro

[Yade-users] [Question #691026]: Loading the stored the position of plank, but it wrong

2020-05-28 Thread yang yi
New question #691026 on Yade:
https://answers.launchpad.net/yade/+question/691026

Dear friend:

It is me again. Sorry. The new problem.

I design five plank(window),  and they rotates around a axis. So I storage the 
position of them,  and hope display the rotation process of them, but the 
reload location is wrong.

# (1) Define the plank:
temp = [
Vector3(widthHydr * i, wind_y_0, wind_z_0),
Vector3(widthHydr * (i + 1), wind_y_0, wind_z_0),
Vector3(widthHydr * (i + 1), wind_y_1, wind_z_1),
Vector3(widthHydr * i, wind_y_1, wind_z_1)
]
positionWind.append(temp)

Wind1 = pack.sweptPolylines2gtsSurface([positionWind[0]], capStart=True, 
capEnd=True)
Wind2 = pack.sweptPolylines2gtsSurface([positionWind[1]], capStart=True, 
capEnd=True)
Wind3 = pack.sweptPolylines2gtsSurface([positionWind[2]], capStart=True, 
capEnd=True)
Wind4 = pack.sweptPolylines2gtsSurface([positionWind[3]], capStart=True, 
capEnd=True)
Wind5 = pack.sweptPolylines2gtsSurface([positionWind[4]], capStart=True, 
capEnd=True)
   
 WindList = IDWind1 + IDWind2 +IDWind3 + IDWind4 + IDWind5

   # (2) Rotation the plank(window) in the O.engines 

RotationEngine(rotationAxis=(1, 0, 0), rotateAroundZero=True, 
ids=IDWind[0], zeroPoint=positionWind[0][2],
   label='RotationW1'),
RotationEngine(rotationAxis=(1, 0, 0), rotateAroundZero=True, 
ids=IDWind[1], zeroPoint=positionWind[1][2],
   label='RotationW2'),
RotationEngine(rotationAxis=(1, 0, 0), rotateAroundZero=True, 
ids=IDWind[2], zeroPoint=positionWind[2][2],
   label='RotationW3'),
RotationEngine(rotationAxis=(1, 0, 0), rotateAroundZero=True, 
ids=IDWind[3], zeroPoint=positionWind[3][2],
   label='RotationW4'),
RotationEngine(rotationAxis=(1, 0, 0), rotateAroundZero=True, 
ids=IDWind[4], zeroPoint=positionWind[4][2],
   label='RotationW5'),

# (3) Control the speed and direction of the windows

def WindowsAction(IDWind):
global WinAction, windPosition
RotationW = [RotationW1, RotationW2, RotationW3, RotationW4, RotationW5]
for nW in range(0, numWinds):
## action
Pos_z = sum(O.bodies[i].state.pos[2] for i in IDWind[nW]) / 
len(IDWind[nW])
if WinAction[nW] == 0:
RotationW[nW].angularVelocity = -VelocityWindNegative
else:
RotationW[nW].angularVelocity = VelocityWindPositive

NegtiveStop = (RotationW[nW].angularVelocity > 0) & (Pos_z <= 
windLowerBoundary)
PostiveStop = (RotationW[nW].angularVelocity < 0) & (Pos_z >= 
windUpperBoundary)

if NegtiveStop: windPosition[nW] = windPositionNegative
elif PostiveStop: windPosition[nW] = windPositionPositive
else: windPosition[nW] = 0

if NegtiveStop | PostiveStop:
RotationW[nW].angularVelocity = 0


#  (4) save the location of windows
def SaveProcessLocation(Episode, iter):
global WindList
outputDir = "Output/location/"
if not os.path.exists(outputDir):
os.makedirs(outputDir)

PositonWind = []
   
for i in WindList:
temp = [i, o.bodies[i].state.pos]
PositonWind.append(temp)

wind_name = outputDir + 'wind_' + str(Episode) + '_' + str(iter)

np.save(wind_name, PositonWind)


#(5) display the location of the windows

def Relocation():
global  nEpisode, nIter, index
path = 'Output/location/'
wind_name = path + 'wind_' + str(nEpisode) + '_' + str(nIter) + '.npy'

if nIter >= index[nEpisode, 1]:
nIter = 0
nEpisode += 1
else:
nIter += 1

if nEpisode >= len(index):
O.pause()

locationWind = np.load(wind_name, allow_pickle=True)

for i in range(0, len(locationWind)):
n = locationWind[i][0]
o.bodies[n].state.pos = locationWind[i][1]
print(locationWind[i][1])


Problem: the each window constitute of 2 triangle. So if reload the location, 
the 2 triangles comes off. and the rotation angle does not  look right.

Thank you very much
 






-- 
You received this question notification because your team yade-users is
an answer contact for Yade.

___
Mailing list: https://launchpad.net/~yade-users
Post to : yade-users@lists.launchpad.net
Unsubscribe : https://launchpad.net/~yade-users
More help   : https://help.launchpad.net/ListHelp


Re: [Yade-users] [Question #690973]: running on a server is slower than on a PC

2020-05-28 Thread yang yi
Question #690973 on Yade changed:
https://answers.launchpad.net/yade/+question/690973

Status: Answered => Solved

yang yi confirmed that the question is solved:
Bruno Chareyre (bruno-chareyre)

Thank you very much. It is not a good news for me.  OK. I will try.
Thank youo

-- 
You received this question notification because your team yade-users is
an answer contact for Yade.

___
Mailing list: https://launchpad.net/~yade-users
Post to : yade-users@lists.launchpad.net
Unsubscribe : https://launchpad.net/~yade-users
More help   : https://help.launchpad.net/ListHelp


Re: [Yade-users] [Question #690973]: running on a server is slower than on a PC

2020-05-28 Thread yang yi
Question #690973 on Yade changed:
https://answers.launchpad.net/yade/+question/690973

yang yi posted a new comment:
To Bruno Chareyre (bruno-chareyre):

Thank you very much.  I test -j1 and -j8 on my PC, yes.  the speed is
the same.  And I test the command  ~$ export OMP_NUM_THREADS=1  and the
result is the same with you.

I explain my understanding about  your mean: the parallel programming,
means there are 98 programming copies, and each copy for a cores. If my
understanding right or not?

If  my understanding is right, I have the following question.  I know
that my programming cannot parallelly operated. I just want the
calculation of particles in a programming is parallel,  such as
calculation the  pressure between the particles. Because there are huge
number of particles, so the calculation is huge.  If I increase the
core, this kind of calculation can be improved?

Thank you for you second suggestion. Actually, the algorithm can not be
trained parallelly. The aim of the training is to make the parameters to
close the optimal value. The next episode must based on the current
training result.

Thank you very much.

-- 
You received this question notification because your team yade-users is
an answer contact for Yade.

___
Mailing list: https://launchpad.net/~yade-users
Post to : yade-users@lists.launchpad.net
Unsubscribe : https://launchpad.net/~yade-users
More help   : https://help.launchpad.net/ListHelp


Re: [Yade-users] [Question #690973]: running on a server is slower than on a PC

2020-05-27 Thread yang yi
Question #690973 on Yade changed:
https://answers.launchpad.net/yade/+question/690973

yang yi posted a new comment:
To Jan Stránský (honzik)  and Bruno Chareyre (bruno-chareyre) :
 
Thank you very much for you professional response. 
My the simulation process likes this:  
 The two kinds of particles falling down and the plank will open or close 
according to the rate of one kind of particle.  My job is to design the control 
algorithm of the plank.

Because if the martial parameter of particles  different,  the falling
speed of particles and action speed of plank is different.  So I must to
check if the two speeds are matching or not.  And, because I just want
to verify the control algorithm, so I hope the falling process could be
as fast as possible since training the control algorithm needs a great
number of episodes, maybe need two days or three days.  So we buy the
server. And the server is just for this simulation now.  That is why I
hope to use the maximum core of this server. I understand you suggestion
to get the optimal price of cores. But now for me, to get the fastest
speed of the simulation is the aim.

I am the author of the posted script.  Actually, I just  know the
running  model of pytorch and just to call the neural network package, I
do not deeply to learning what the script structure is the best for
matching YADE.Bruno Chareyre  is right, the pyrunner decide the
runing speed.  But my question is  I use the same OS, the same script,
and same configuration in both of PC and server,  if I get 3D show, the
speed in PC is faster than in the server.   However, if I closed the 3D
show, the calculation speed of server is faster than PC.

Jan Stránský told me  the simulation-world speed is the same regardless
of the 3D show open or close and the simulation state definitely is not
influenced by the 3D view. So it makes me very confusion.

without 3D show the calculation speed of server is faster than PC,  that
mean the iteration number is more than PC. so the 3D view checks the
locations roughly, we could find the falling speed is faster than PC.
But actually, I find the speed in the server is slower than in PC.

So, I will try like this way, to storage the location and check  what
will happen.

Thank you very much

-- 
You received this question notification because your team yade-users is
an answer contact for Yade.

___
Mailing list: https://launchpad.net/~yade-users
Post to : yade-users@lists.launchpad.net
Unsubscribe : https://launchpad.net/~yade-users
More help   : https://help.launchpad.net/ListHelp


Re: [Yade-users] [Question #690973]: running on a server is slower than on a PC

2020-05-26 Thread yang yi
Question #690973 on Yade changed:
https://answers.launchpad.net/yade/+question/690973

yang yi posted a new comment:

 Janek Kozicki (cosurgi) , Jan Stránský (honzik) , Bruno Chareyre 
(bruno-chareyre) 

 Thank you very much for answer my question. According to your
suggestion, I checked the server like this

(1) Run  yade by the command: 
  ~/myYade/install/bin/yade -j90 20200522.py
(2)  Start the script by the 'start' button on the Controller(), without "3D" 
show
 
(3) I did 10 iteration test and the time result as follows
 
 PC: -j8 39.45s \ 47.79s
 Server:-j32   26.1s
   -j48   24.51s
   -j50   25.32s
   -j52   24.55s
   -j60   26.53s
   -j88   23.29s \  23.12s
   -j90   23.27s \ 23.72s
   -j92   23.05s \ 23.76s \ 24.24s \ 24.09s
   -j94   23.48s
   -j96   23.91s
 Because I get the time by hand, so there is errors.  The results seems 
that the server is faster than PC without 3D show  and the -j92 or -j90 maybe 
the optimal jobs.

(4)  I used the command :   yade --stdperformance -j8   to test the 
performance
 But I just to guess the result, I wirte as below
 -j8  1465.98 iter/s
 -j48 1386.40  iter/s
 -j881427   iter/s
 -j901279  iter/s   1467 iter/s
 -j921385 iter/s
 -j961313  iter/s

 I find the number is unstable. It seems that -j90 is the best.

(5)  For the above test,  I guess that:
  The before test,  I take 3D show, the server is slower than PC very 
slowly, that is becuase the GUI is  depend on just one core of the CPU.  For 
one core of I7-9700k 3.6GH  is better than 6146 , 3.2GH.  IF my guess is right 
or not? 


(6) I have two questions:
 1)  It looks that the falling speed of particles and the roation speed of 
the plank in the 3D show are different,  if the I modify the number of the 
particles.  So in the Server,  I hope to check  if the rotation speed matches 
the falling speed of particles or not.  The direct way is the 3D show. However, 
if 3D show is used, the speed is very very slow.   my question is :
if I close the 3D show, the speed of the plank and particles are the same 
with 3D show open or not?

2)  If the speed of plank and particles are not depend on the 3D
show.  I  will storage the bodies' location of the simulation process,
and replay the locations after the simulation is over.  my question :
is there a better way to do that?


Thank you very much

-- 
You received this question notification because your team yade-users is
an answer contact for Yade.

___
Mailing list: https://launchpad.net/~yade-users
Post to : yade-users@lists.launchpad.net
Unsubscribe : https://launchpad.net/~yade-users
More help   : https://help.launchpad.net/ListHelp


Re: [Yade-users] [Question #690973]: running on a server is slower than on a PC

2020-05-26 Thread yang yi
Question #690973 on Yade changed:
https://answers.launchpad.net/yade/+question/690973

yang yi posted a new comment:

1.  Jan Stránský (honzik)
Than you very much for you quickly response. I explain as the follows

(1) The script 
The script must import torch.  The code is use to simulated particles falling 
down with the gravity.


#!/usr/bin/env python
#  encoding: utf-8
## this programmig is DQN with HMRF-2-NH.

from __future__ import print_function
# import sys
# sys.path.append('~/PycharmProjects/yangyi/yade/Yade20200419_for_Journal of 
Coal/')
# from yadeImport import *

import random
import math
import csv
import torch
import torch.nn as nn
import numpy as np
import os
import torch.nn.functional as F
from torch.distributions import Categorical
from yade.gridpfacet import *

pi = math.pi

Testing = False
AddCoalRock = False

loadPoint = '00088'
o = Omega()
o.dt = 1e-12
totalLoss = 0
LastState = []
LastAction = np.zeros((5, 1), dtype=int)
saveLoss = []
outputDir = 'Output'
checkCounter = 0

numWinds = 5
WinAction = np.zeros((5,1), dtype=int)

RewardCoal = 1
RewardRock = -3

nParameters = 2
mu_in = np.zeros((5, nParameters))
sigma_in = np.ones((5, nParameters))
MAP_iter_number = 5
EM_iter = 5

## === Environment ##
widthSpace = 6.8  ## width is the distance from the front coal wall to the back
widthHydr = 1.5
lengthSpace = widthHydr * numWinds  ## length is the width of 5 windows
highCoal = 2
highRock = 2
if AddCoalRock:
highCoalRock1 = 1
highCoalRock2 = 1
highCoalRock3 = 1
else:
highCoalRock1 = 0
highCoalRock2 = 0
highCoalRock3 = 0

highHydr = 3.8
highUnderground = 10
highBottom = 0.5
highSpace = highUnderground + highHydr + highCoal + highCoalRock1 + 
highCoalRock2 + highCoalRock3 + highRock
radiusCoal = 0.15
radiusRock = 0.15
CheckThick = 1
highDummy = 3

colorCoal = (0, 1, 0)
colorRock = (1, 0, 0)

colorState = (0, 0, 1)
colorReceive = (238/255, 233/255, 191/255)

colorShield = (205/255, 150/255, 205/255)
colorWind = (0, 1, 1)
colorGround = (54/255,54/255, 54/255)

angleShield = 50 * 3.1415926 / 180
angleSwingPositive = 15 * 3.1415926 / 180
angleSwingNegtive = 40 * 3.1415926 / 180
lengthShield = 3
lengthTail = 2
windUpperBoundary = 0.9
windLowerBoundary = 0.5019
stateUpperBoundary = highHydr
stateLowerBoundary = windLowerBoundary
##———##
positionShield = []
positionWind = []
positionTopBeam = []
positionDummy = []
windPosition = np.zeros(5)
windPositionPositive = 1
windPositionNegative = 2

shield_y_0 = lengthTail * math.cos(angleShield - angleSwingPositive)
shield_y_1 = shield_y_0 + lengthShield * math.cos(angleShield)
shield_z_0 = highHydr - lengthShield * math.sin(angleShield)
shield_z_1 = highHydr  #
wind_y_0 = lengthTail * (math.cos(angleShield - angleSwingPositive) - 
math.cos(angleShield))
wind_y_1 = shield_y_0
wind_z_0 = highHydr - (lengthShield + lengthTail) * math.sin(angleShield)
wind_z_1 = highHydr - lengthShield * math.sin(angleShield)
topBeam_y_0 = lengthTail * math.cos(angleShield - angleSwingPositive) + 
lengthShield * math.cos(angleShield)
topBean_y_1 = widthSpace

# matRock = O.materials.append(JCFpmMat(young=13.5e9, 
cohesion=2.06e6,density=2487, frictionAngle=radians(10),
#   tensileStrength=1.13e6, poisson=0.123, jointNormalStiffness=1e8, 
jointShearStiffness=1e7, jointCohesion=1e6))

HyMat = O.materials.append(FrictMat(frictionAngle=0.1, density=3000, young=2e9))
#
matRock = O.materials.append(JCFpmMat(young=13.5e9, 
cohesion=2.06e6,density=2487, frictionAngle=radians(30),
  tensileStrength=1.13e1, poisson=0.123, jointNormalStiffness=1e1, 
jointShearStiffness=1e1, jointCohesion=1e1))

# matCoal = O.materials.append(JCFpmMat(young=4.2e9, cohesion=2.11e6, 
density=1420, frictionAngle=radians(19.5),
#   tensileStrength=2.6e6, poisson=0.22, jointNormalStiffness=1e1, 
jointShearStiffness=1e1, jointCohesion=1e1))

# matRock = O.materials.append(FrictMat(frictionAngle=radians(30), 
density=2487, young=13.5e9))
matCoal = O.materials.append(FrictMat(frictionAngle=radians(29.5), 
density=1420, young=4.2e9))

myGraviaty = -1200
nIterControl = 1000
nCheckEnd = 3000
nIterReload =1

VelocityWindPositive = 40
VelocityWindNegative = 60
percentCoalStopEpisode = 20

# matGround = O.materials.append(CohFrictMat(young=E, poisson=0.3, 
density=2650, frictionAngle=radians(30), normalCohesion=3e100,
# shearCohesion=3e100, momentRotationLaw=True))

def Boundary():
boundary = O.bodies.append(geom.facetBox((lengthSpace / 2, widthSpace / 2, 
highSpace / 2 - highUnderground),
 (lengthSpace / 2, widthSpace / 2, 
highSpace / 2), wallMask=63, material =HyMat ))

def Ground():
O.bodies.append(utils.wall(position=-highUnderground, sense=0, axis=2, 
color=colorGround, material=-1))

def Dummy():
for i in range (1, numWinds):
temp=[
Vector3(widthHydr*i, 0 , -highUnderground),
Vector3(widthHydr*i

[Yade-users] [Question #690973]: running on a server is slower than on a PC

2020-05-26 Thread yang yi
New question #690973 on Yade:
https://answers.launchpad.net/yade/+question/690973

Dear friend

I  meet a very strange question.   Our Lab.  take a new server and I install 
the yade on the server. But I find that running on the server is slower than on 
the PC. 

(1) The hardware and configuration of the server is 
 CPU: Intel XEON Gold 6146  *  4,  3.2GH   96 core
 Memory : 256GB
 OS: Ubuntu 18.04  64bits
 Yade: https://gitlab.com/yade-dev/trunk

(2)  The hardware and configuration of the PC 
CPU : I7-9700k 3.6GH 8 core
Memory :32GB
OS Ubunut 18.04 64bit
Yade: https://gitlab.com/yade-dev/trunk

I operate the server by remote desktop -- VNC viewer

I cmake and install the yade like this:

   cd ~/myYade/build
   cmake -DCMAKE_INSTALL_PREFIX=../install ../trunk -DNOSUFFIX=ON 
-DENABLE_OPENMP=ON
   make -j96
   make install

I run the yade like this:
(1) On the server 
~/PycharmProjects/myname/yade/Yade20200519_for_Journal of Coal$
~/myYade/install/bin/yade -j96 20200522.py

(2) On the PC
~/PycharmProjects/myname/yade/Yade20200519_for_Journal of Coal$
~/myYade/install/bin/yade -j8 20200522.py


I open the yade simulation, show 3D

The speed of simulation process on server is slower than on the PC, and it is 
very very obviously. 

When I make the yade : make -j96. The speed is very quickly. But when I running 
the yade is slower than on the PC. 

The server supplier can insure that the hardware of the server is right. 

Please kindly help me. If the OS on server is right? If process of installation 
yade on server right? If the running the yade is right?  It makes me very 
confusion. 

Thank you very much.

Yang Yi









-- 
You received this question notification because your team yade-users is
an answer contact for Yade.

___
Mailing list: https://launchpad.net/~yade-users
Post to : yade-users@lists.launchpad.net
Unsubscribe : https://launchpad.net/~yade-users
More help   : https://help.launchpad.net/ListHelp


Re: [Yade-users] [Question #687514]: Ask help for the materials setting

2020-01-06 Thread yang yi
Question #687514 on Yade changed:
https://answers.launchpad.net/yade/+question/687514

Status: Open => Solved

yang yi confirmed that the question is solved:
Hi, Jan Stránský (honzik), thank you  for your responce. I have find the
answer from the question.

-- 
You received this question notification because your team yade-users is
an answer contact for Yade.

___
Mailing list: https://launchpad.net/~yade-users
Post to : yade-users@lists.launchpad.net
Unsubscribe : https://launchpad.net/~yade-users
More help   : https://help.launchpad.net/ListHelp


Re: [Yade-users] [Question #687646]: no view about qt.View() and yade.qt.Controller()

2020-01-06 Thread yang yi
Question #687646 on Yade changed:
https://answers.launchpad.net/yade/+question/687646

yang yi posted a new comment:
Jan Stránský (honzik), Thank you very much! I will try

-- 
You received this question notification because your team yade-users is
an answer contact for Yade.

___
Mailing list: https://launchpad.net/~yade-users
Post to : yade-users@lists.launchpad.net
Unsubscribe : https://launchpad.net/~yade-users
More help   : https://help.launchpad.net/ListHelp


Re: [Yade-users] [Question #687514]: Ask help for the materials setting

2020-01-05 Thread yang yi
Question #687514 on Yade changed:
https://answers.launchpad.net/yade/+question/687514

yang yi gave more information on the question:
Sorry, maybe my description is not clear.  
My aim is to establish a environment to simulation the process of coal and rock 
falling.  The upper layer is rock, then a coal layer.   The particles falls by 
gravity.  My question is 


(1) The particles will damp,   but I want that the coal and rock falls down and 
stays on the ground, or the bounce is very small. So I do not know  which kind 
of material I should to use.  I tried the  FricMat, CpmMat, ViscElMa...
  Today, I try the "CohesiveDeformableElementMaterial", but there is a 
error that 
  "Undefined or ambiguous IPhys dispatch for types 
CohesiveDeformableElementMaterial and CohesiveDeformableElementMaterial."  So, 
here is subproblem:  If the "CohesiveDeformableElementMaterial" is right, which 
kind of Engine should I used??

(2) Sometimes , the particles will through the wall.

Please kindly help me.

My code 
#!/usr/bin/env python
#  encoding: utf-8
from __future__ import print_function
import sys
sys.path.append('~/PycharmProjects/Yade20191229/')
# from yadeImport import *
import math
import numpy as np

o = Omega()
tc = 0.01
o.dt = 0.02 * tc
numWinds = 5
VelocityWind = 20
WinAction = np.zeros(5, dtype=int)
## === Environment ##
widthSpace = 10.5  ## width is the distance from the front coal wall to the back
widthHydr = 1.5
lengthSpace = widthHydr * numWinds  ## length is the width of 5 windows
highCoal = 2

highRock = 1
highHydr = 3.8
highUnderground = 12
highSpace = highUnderground + highHydr + highCoal + highRock
radiusCoal = 0.15
radiusRock = 0.2
CheckThick = 1

colorCoal = (0, 1, 0)
colorRock = (1, 0, 0)
colorNote = (0, 0, 1)
colorHydr = (1, 0, 1)
colorShield = (1, 0, 1)
colorWind = (0, 1, 1)
colorGround = (1, 1, 0)
angleShield = 50 * 3.1415926 / 180
angleSwingPositive = 15 * 3.1415926 / 180
angleSwingNegtive = 40 * 3.1415926 / 180
lengthShield = 3
lengthTail = 2
windUpperBoundary = 0.9
windLowerBoundary = 0.5019
stateUpperBoundary = highHydr
stateLowerBoundary = windLowerBoundary
positionShield = []
positionWind = []
positionTopBeam = []

shield_y_0 = lengthTail * math.cos(angleShield - angleSwingPositive)
shield_y_1 = shield_y_0 + lengthShield * math.cos(angleShield)
shield_z_0 = highHydr - lengthShield * math.sin(angleShield)
shield_z_1 = highHydr  #
wind_y_0 = lengthTail * (math.cos(angleShield - angleSwingPositive) - 
math.cos(angleShield))
wind_y_1 = shield_y_0
wind_z_0 = highHydr - (lengthShield + lengthTail) * math.sin(angleShield)
wind_z_1 = highHydr - lengthShield * math.sin(angleShield)
topBeam_y_0 = lengthTail * math.cos(angleShield - angleSwingPositive) + 
lengthShield * math.cos(angleShield)
topBean_y_1 = widthSpace

##=###
### problem 1 #
matCoal = O.materials.append(ViscElMat(frictionAngle=0.5, mR=0.05, mRtype=1, 
density=2, tc=0.001, en=0.7, et=0.7))
matRock = O.materials.append(ViscElMat(frictionAngle=0.5, mR=0.05, mRtype=1, 
density=2, tc=0.001, en=0.7, et=0.7))
mat1 = O.materials.append(FrictMat(frictionAngle=0.1, density=2000, young=2e10))
def Boundary():
boundary = O.bodies.append(geom.facetBox((lengthSpace / 2, widthSpace / 2, 
highSpace / 2 - highUnderground),
 (lengthSpace / 2, widthSpace / 2, 
highSpace / 2), wallMask=63))
def Ground():
positionGround = [
Vector3(0,
lengthTail * (math.cos(angleShield - angleSwingPositive) - 
math.cos(angleShield + angleSwingNegtive)),
0),
Vector3(lengthSpace,
lengthTail * (math.cos(angleShield - angleSwingPositive) - 
math.cos(angleShield + angleSwingNegtive)),
0),
Vector3(lengthSpace, widthSpace, 0),
Vector3(0, widthSpace, 0)
]
Ground = pack.sweptPolylines2gtsSurface([positionGround], capStart=True, 
capEnd=True)
IDGround = O.bodies.append(pack.gtsSurface2Facets(Ground, 
color=colorGround))

def HydraulicSupport():
for i in range(0, numWinds):
temp = [Vector3(widthHydr * i, shield_y_0, shield_z_0),
Vector3(widthHydr * (i + 1), shield_y_0, shield_z_0),
Vector3(widthHydr * (i + 1), shield_y_1, shield_z_1),
Vector3(widthHydr * i, shield_y_1, shield_z_1)
]
positionShield.append(temp)
temp = [
Vector3(widthHydr * i, wind_y_0, wind_z_0),
Vector3(widthHydr * (i + 1), wind_y_0, wind_z_0),
Vector3(widthHydr * (i + 1), wind_y_1, wind_z_1),
Vector3(widthHydr * i, wind_y_1, wind_z_1)
]
positionWind.append(temp)
temp = [
Vector3(widthHydr * i, topBeam_y_0, highHydr),
Vector3(widthHydr * (i + 1), topBeam_y_0, highHydr),
Vector3(widthHydr * (i + 1), topBean_y_1, highHydr),
Vector3(widthH

Re: [Yade-users] [Question #687646]: no view about qt.View() and yade.qt.Controller()

2020-01-01 Thread yang yi
Question #687646 on Yade changed:
https://answers.launchpad.net/yade/+question/687646

Status: Open => Solved

yang yi confirmed that the question is solved:
I know the answer of the frist question

I run my script in the Pycharm, not in the terminal. If I run the code
in the terminal like : 'yade my.py', I can get the controller and View

-- 
You received this question notification because your team yade-users is
an answer contact for Yade.

___
Mailing list: https://launchpad.net/~yade-users
Post to : yade-users@lists.launchpad.net
Unsubscribe : https://launchpad.net/~yade-users
More help   : https://help.launchpad.net/ListHelp


Re: [Yade-users] [Question #687646]: no view about qt.View() and yade.qt.Controller()

2019-12-31 Thread yang yi
Question #687646 on Yade changed:
https://answers.launchpad.net/yade/+question/687646

yang yi posted a new comment:
I find the controller and O.run() are in different threadings. So I
tried to communicate the two threadings with queue. It is hard to me.
Please help me..

Thank you

-- 
You received this question notification because your team yade-users is
an answer contact for Yade.

___
Mailing list: https://launchpad.net/~yade-users
Post to : yade-users@lists.launchpad.net
Unsubscribe : https://launchpad.net/~yade-users
More help   : https://help.launchpad.net/ListHelp


Re: [Yade-users] [Question #687646]: no view about qt.View() and yade.qt.Controller()

2019-12-31 Thread yang yi
Question #687646 on Yade changed:
https://answers.launchpad.net/yade/+question/687646

yang yi posted a new comment:
Actually, I want to get a loop simulation of the same environment.  The above 
problem could be use run() in the yade command line. 
But there another problem: how to reset the evnironment and restart it?
I try this way:

PyRunner(command='Test()', iterPeriod = 500)

def Test():
   o.reload()
   o.run()


I failed

Could you kindly help me.

-- 
You received this question notification because your team yade-users is
an answer contact for Yade.

___
Mailing list: https://launchpad.net/~yade-users
Post to : yade-users@lists.launchpad.net
Unsubscribe : https://launchpad.net/~yade-users
More help   : https://help.launchpad.net/ListHelp


[Yade-users] [Question #687646]: no view about qt.View() and yade.qt.Controller()

2019-12-31 Thread yang yi
New question #687646 on Yade:
https://answers.launchpad.net/yade/+question/687646

My yade is come from GitLib source, and cmake, make, make-install to my 
computer.  I build a symbol link named "yadeImport".
The system can run very nice, if I use the command in terminal 
"~/myYade/install/bin/yade  my.py". I can controll the simulation by 
controller, and see the 3D simuliation process. 

But, today, I want run the code by script.  the yade.qt.View(),  
yade.qt.Controller(), just get two black windows. I hope to find the answer 
from there. And somebody says that the  example of "triax-tutorial" could be 
help me. So I use the code as script-session2.py
The problem is the same. The yade.qt.View() and yade.qt.controller() just the 
black windows.  I have two problems:

(1) How to get 3D view() by runing the script?
(2) If I cannot get the 3D process during simulation, how to save the date of 
each step of process, and replay after simulation?


Beacause my code is complex, I put the script-session2.py as below, the problem 
is the same.



# -*- coding: utf-8 -*-
from __future__ import print_function
from yade import pack

num_spheres=500
## corners of the initial packing
mn,mx=Vector3(0,0,0),Vector3(1,1,1)
thick = 0.01
compFricDegree = 2
rate=0.2
damp=0.1
stabilityThreshold=0.001
key='_define_a_name_'

## create material #0, which will be used as default
O.materials.append(FrictMat(young=5e6,poisson=0.5,frictionAngle=radians(compFricDegree),density=2600,label='spheres'))
O.materials.append(FrictMat(young=5e6,poisson=0.5,frictionAngle=0,density=0,label='walls'))

## create walls around the packing
walls=aabbWalls([mn,mx],thickness=thick,material='walls')
wallIds=O.bodies.append(walls)

sp=pack.SpherePack()
sp.makeCloud(mn,mx,-1,0.,num_spheres,False, 0.95)

volume = (mx[0]-mn[0])*(mx[1]-mn[1])*(mx[2]-mn[2])
mean_rad = pow(0.09*volume/num_spheres,0.)

clumps=False
if clumps:

c1=pack.SpherePack([((-0.2*mean_rad,0,0),0.5*mean_rad),((0.2*mean_rad,0,0),0.5*mean_rad)])
sp.makeClumpCloud((0,0,0),(1,1,1),[c1],periodic=False)
O.bodies.append([sphere(center,rad,material='spheres') for center,rad 
in sp])
standalone,clumps=sp.getClumps()
for clump in clumps:
O.bodies.clump(clump)
for i in clump[1:]: 
O.bodies[i].shape.color=O.bodies[clump[0]].shape.color
#sp.toSimulation()
else:
O.bodies.append([sphere(center,rad,material='spheres') for center,rad 
in sp])

O.dt=.5*PWaveTimeStep() # initial timestep, to not explode right away
O.usesTimeStepper=True

triax=ThreeDTriaxialEngine(
maxMultiplier=1.005,
finalMaxMultiplier=1.002,
thickness = thick,
stressControl_1 = False,
stressControl_2 = False,
stressControl_3 = False,
## Independant stress values for anisotropic loadings
goal1=-1,
goal2=-1,
goal3=-1,
internalCompaction=True,
Key=key,
)

newton=NewtonIntegrator(damping=damp)

O.engines=[
ForceResetter(),

InsertionSortCollider([Bo1_Sphere_Aabb(),Bo1_Box_Aabb()],verletDist=-mean_rad*0.06),
InteractionLoop(
[Ig2_Sphere_Sphere_ScGeom(),Ig2_Box_Sphere_ScGeom()],
[Ip2_FrictMat_FrictMat_FrictPhys()],
[Law2_ScGeom_FrictPhys_CundallStrack()]
),

GlobalStiffnessTimeStepper(active=1,timeStepUpdateInterval=100,timestepSafetyCoefficient=0.8,
 defaultDt=4*PWaveTimeStep()),
triax,
TriaxialStateRecorder(iterPeriod=100,file='WallStresses'+key),
newton
]

#Display spheres with 2 colors for seeing rotations better
Gl1_Sphere.stripes=0
yade.qt.Controller(), yade.qt.View()

while 1:
  O.run(1000, True)
  #the global unbalanced force on dynamic bodies, thus excluding boundaries, 
which are not at equilibrium
  unb=unbalancedForce()
  #average stress
  #note: triax.stress(k) returns a stress vector, so we need to keep only the 
normal component
  
meanS=(triax.stress(triax.wall_right_id)[0]+triax.stress(triax.wall_top_id)[1]+triax.stress(triax.wall_front_id)[2])/3
  print('unbalanced force:',unb,' mean stress: ',meanS)
  if unbhttps://launchpad.net/~yade-users
Post to : yade-users@lists.launchpad.net
Unsubscribe : https://launchpad.net/~yade-users
More help   : https://help.launchpad.net/ListHelp


[Yade-users] [Question #687514]: Ask help for the materials setting

2019-12-24 Thread yang yi
New question #687514 on Yade:
https://answers.launchpad.net/yade/+question/687514

I hope to simulate the coal seam collapsing, but my major is computer and 
control.  And  I  tried several different material about the particle. such as 
FricMat, CpmMat, ViscElMat  But all of them has the following problme
(1)  The particle will  bounce if it collide the wall of boundary.
(2)  My friend to me to increase the damping of NewtonIntegrator, but it desnot 
work.   and if I increase the greavity, the particle will through the wall.

my engines is :
 ForceResetter()
 InsertionSortCollider()


So, please kindly tell me, which kind of material I should to use. and how to 
set the parameters   that the particle will not bounce.
Thank you very much 



-- 
You received this question notification because your team yade-users is
an answer contact for Yade.

___
Mailing list: https://launchpad.net/~yade-users
Post to : yade-users@lists.launchpad.net
Unsubscribe : https://launchpad.net/~yade-users
More help   : https://help.launchpad.net/ListHelp


Re: [Yade-users] [Question #686076]: Problem of Bodies rotation

2019-11-22 Thread yang yi
Question #686076 on Yade changed:
https://answers.launchpad.net/yade/+question/686076

Status: Answered => Solved

yang yi confirmed that the question is solved:
Thanks Jan Stránský, that solved my question.

-- 
You received this question notification because your team yade-users is
an answer contact for Yade.

___
Mailing list: https://launchpad.net/~yade-users
Post to : yade-users@lists.launchpad.net
Unsubscribe : https://launchpad.net/~yade-users
More help   : https://help.launchpad.net/ListHelp


Re: [Yade-users] [Question #686076]: Problem of Bodies rotation

2019-11-22 Thread yang yi
Question #686076 on Yade changed:
https://answers.launchpad.net/yade/+question/686076

yang yi posted a new comment:
Thank you very much!! Jan Stránský
Now  I  have two problem

(1) for  using RotationEngine,   I hope the following code can change
the direction of the plane by  the PyRunner function ChangeVelocity, but
it cannot, the value of Velocity can be changed, but the plane still
Rotation as the initial speed and direction.

velocity = 10 
def ChangeVelocity():
global velocity
velocity = -1 * velocity


O.engines = [
ForceResetter(),
InsertionSortCollider([Bo1_Sphere_Aabb(), Bo1_Facet_Aabb()]),
InteractionLoop(
# handle sphere+sphere and facet+sphere collisions
[Ig2_Sphere_Sphere_ScGeom(), Ig2_Facet_Sphere_ScGeom()],
[Ip2_FrictMat_FrictMat_FrictPhys()],
[Law2_ScGeom_FrictPhys_CundallStrack()]),
# [Ip2_ViscElMat_ViscElMat_ViscElPhys()],
# [Law2_ScGeom_ViscElPhys_Basic()]),
NewtonIntegrator(gravity=(-9.8, 0, 0), damping=0.001, label='down'),
RotationEngine(rotationAxis=(0, 0, 1), angularVelocity=velocity, 
rotateAroundZero=True, zeroPoint=(0, 0, 0)),
PyRunner(command="ChangeVelocity()", iterPeriod=10)

]

(2)  The problem of transform the C++ code  of RotationEngine to python,
I hope I can control the rotation velocity of the plane.

def myRotation():
ZeroPos = Vector3(1, 1, 0)
rotationAxis = Vector3(0, 0, 1)
angVel = 10
for i in IDGround:
O.bodies[i].state.angVel += rotationAxis * angVel
l = O.bodies[i].state.pos - ZeroPos
q = Quaternion(AngleAxis(rotationAxis, angVel* O.dt))
# q = Quaternion(rotationAxis, angVel * O.dt)
newp = q*l + ZeroPos
O.bodies[i].state.vel += (newp - O.bodies[i].state.pos)/O.dt

O.engines = [
ForceResetter(),
InsertionSortCollider([Bo1_Sphere_Aabb(), Bo1_Facet_Aabb()]),
InteractionLoop(
# handle sphere+sphere and facet+sphere collisions
[Ig2_Sphere_Sphere_ScGeom(), Ig2_Facet_Sphere_ScGeom()],
[Ip2_FrictMat_FrictMat_FrictPhys()],
[Law2_ScGeom_FrictPhys_CundallStrack()]),
# [Ip2_ViscElMat_ViscElMat_ViscElPhys()],
# [Law2_ScGeom_ViscElPhys_Basic()]),
NewtonIntegrator(gravity=(-9.8, 0, 0), damping=0.001, label='down'),
PyRunner(command="myRotation()",iterPeriod=40)
# RotationEngine(rotationAxis=(0, 0, 1), angularVelocity=velocity, 
rotateAroundZero=True, zeroPoint=(0, 0, 0)),
# PyRunner(command="ChangeVelocity()", iterPeriod=10)
]

I  can find the "AngleAxis", and the error is "name 'AngleAxis' is
not defined".  The above code is follow the C++ in the
KinematicEngines.cpp.   I don't know if the  transform is correct or
not.

 Please help me,Thank you very much,

-- 
You received this question notification because your team yade-users is
an answer contact for Yade.

___
Mailing list: https://launchpad.net/~yade-users
Post to : yade-users@lists.launchpad.net
Unsubscribe : https://launchpad.net/~yade-users
More help   : https://help.launchpad.net/ListHelp


Re: [Yade-users] [Question #686076]: Problem of Bodies rotation

2019-11-21 Thread yang yi
Question #686076 on Yade changed:
https://answers.launchpad.net/yade/+question/686076

yang yi posted a new comment:
Thanks for Jan Stránský (honzik)   and Chareyre (bruno-chareyre-9) very much.
I tired the RotationEngine before using O.bodies[i].state.angVel .  However, 
the speed I cound not change during simulation.  The Code is as below:


O.engines = [
   。。
RotationEngine(rotationAxis=(0, 0, 1), angularVelocity= velocity, 
rotateAroundZero=True, zeroPoint=(0, 0, 0)),
PyRunner(comment= "ChangeVelocity()")
]

But the velocity can not changed.  So I tried the third way.  Yestoday
night, I fund the function of RotationEngine in the
KinematicEngines.cpp,   I understand the Chareyre's advise that the
velocity should be improved during the angleVelocity.  I wirte the code
now, But I meet a  new problem,  I can not find the function of
AngleAxisr().  The code of RotationEngine is


void RotationEngine::apply(const vector& ids){
if (ids.size()>0) {
#ifdef YADE_OPENMP
const long size=ids.size();
#pragma omp parallel for schedule(static)
for(long i=0; ibodies->size());
Body* b=Body::byId(id,scene).get();
if(!b) continue;
b->state->angVel+=rotationAxis*angularVelocity;
if(rotateAroundZero){
const Vector3r l=b->state->pos-zeroPoint;
Quaternionr 
q(AngleAxisr(angularVelocity*scene->dt,rotationAxis));
Vector3r newPos=q*l+zeroPoint;

b->state->vel+=Vector3r(newPos-b->state->pos)/scene->dt;
}
}
} else {
LOG_WARN("The list of ids is empty! Can't move any body.");
}
}


So  I need to write the function AngleAxisr(). 
Thank you very much

Yang Yi

-- 
You received this question notification because your team yade-users is
an answer contact for Yade.

___
Mailing list: https://launchpad.net/~yade-users
Post to : yade-users@lists.launchpad.net
Unsubscribe : https://launchpad.net/~yade-users
More help   : https://help.launchpad.net/ListHelp


[Yade-users] [Question #686076]: Problem of Bodies rotation

2019-11-21 Thread yang yi
New question #686076 on Yade:
https://answers.launchpad.net/yade/+question/686076

I hope to design a plane named IDGround, it can rotate with the given velocity, 
and it can be controlled to start, stop, change the speed and the direction in 
the simulation.
I used the pack.sweptPolylines2gtsSurface to establish the plane, and used the 
O.bodies[i].state.angVel to set the velocity. It can rotate. But the plane is 
combined by two triangles, so there are two bodies in the plane, and each of 
them rotates around the itself axis.  I hope both of them rotating around a 
given axis. How can I change my code as follows??
Thank you very much.

Yang Yi

positionGround = [
 Vector3(0,0,0),
 Vector3(1,0,0),
 Vector3(1,1,0),
 Vector3(0,1,0)
 ]
Ground = pack.sweptPolylines2gtsSurface([positionGround], capStart=True, 
capEnd=True)
IDGround = O.bodies.append(pack.gtsSurface2Facets(Ground, color=(1,0,1)))

def myRotation():
for i in IDGround:
O.bodies[i].state.angVel=(0, 0, 1)

O.engines = [
ForceResetter(),
InsertionSortCollider([Bo1_Sphere_Aabb(), Bo1_Facet_Aabb()]),
InteractionLoop(
# handle sphere+sphere and facet+sphere collisions
[Ig2_Sphere_Sphere_ScGeom(), Ig2_Facet_Sphere_ScGeom()],
[Ip2_FrictMat_FrictMat_FrictPhys()],
[Law2_ScGeom_FrictPhys_CundallStrack()]),
NewtonIntegrator(gravity=(-9.8, 0, 0), damping=0.001, label='down'),
PyRunner(command="myRotation()",iterPeriod=40)
# RotationEngine(rotationAxis=(0, 0, 1), angularVelocity=10.0, 
rotateAroundZero=True, zeroPoint=(0, 0, 0))
]


-- 
You received this question notification because your team yade-users is
an answer contact for Yade.

___
Mailing list: https://launchpad.net/~yade-users
Post to : yade-users@lists.launchpad.net
Unsubscribe : https://launchpad.net/~yade-users
More help   : https://help.launchpad.net/ListHelp