Change colour of spheres when based on Movement
Hey Guys
New to Yade, been building a model for a tunnel simulation. What i'm trying to acheieve is have the spheres change colour based on there displacement so that I can see where the movement is occuring. Not sure if it's necessary to post the whole code?
Right now the line I am using is
for s in O.bodies:
s.shape.
What currently happens is the spheres change colour, but only initially. Is this the right code to do that? Could someone explain what this code is actually doing?
Question information
- Language:
- English Edit question
- Status:
- Solved
- For:
- Yade Edit question
- Assignee:
- No assignee Edit question
- Solved by:
- Clinton Schramm
- Solved:
- Last query:
- Last reply:
Revision history for this message
|
#1 |
Hello,
Yade (Python) goes through the script and executes line by line. If you
have it like that in your script (once), then it is executed just once.
To execute is regulary, use PyRunner [1] in your engines:
#######
def colorSpheres():
for s in O.bodies:
s.shape.color = ....
O.engines = [
...
PyRunner(
realPeriod or virtPeriod instead of irerPeriod
]
#######
cheers
Jan
[1] https:/
2016-05-28 12:56 GMT+02:00 Clinton Schramm <
<email address hidden>>:
> New question #294531 on Yade:
> https:/
>
> Hey Guys
> New to Yade, been building a model for a tunnel simulation. What i'm
> trying to acheieve is have the spheres change colour based on there
> displacement so that I can see where the movement is occuring. Not sure if
> it's necessary to post the whole code?
>
> Right now the line I am using is
>
> for s in O.bodies:
>
> s.shape.
>
> What currently happens is the spheres change colour, but only initially.
> Is this the right code to do that? Could someone explain what this code is
> actually doing?
>
>
>
> --
> You received this question notification because your team yade-users is
> an answer contact for Yade.
>
> _______
> Mailing list: https:/
> Post to : <email address hidden>
> Unsubscribe : https:/
> More help : https:/
>
Revision history for this message
|
#2 |
Hi Jan
Thanks for the prompt reply. I have already placed the code within Pyrunner, and still get the same results. I'll post my code below (it is just a modified Odometer Example code with the change sphere colour). Can you see any reason why it shouldn't be working?
# load parameters from file if run in batch
# default values are used if not run from batch
readParamsFromT
# make rMean, rRelFuzz, maxLoad accessible directly as variables later
from yade.params.table import *
# create box with free top, and ceate loose packing inside the box
from yade import pack, plot
O.bodies.
sp=pack.
sp.makeCloud(
sp.toSimulation()
O.engines=[
ForceResetter(),
# sphere, facet, wall
InsertionSor
InteractionLoop(
# the loading plate is a wall, we need to handle sphere+sphere, sphere+facet, sphere+wall
[
[
[
),
NewtonIntegr
# the label creates an automatic variable referring to this engine
# we use it below to change its attributes from the functions called
PyRunner(
]
O.dt=.5*
# the following checkUnbalanced, unloadPlate and stopUnloading functions are all called by the 'checker'
# (the last engine) one after another; this sequence defines progression of different stages of the
# simulation, as each of the functions, when the condition is satisfied, updates 'checker' to call
# the next function when it is run from within the simulation next time
# check whether the gravity deposition has already finished
# if so, add wall on the top of the packing and start the oedometric test
def checkUnbalanced():
# at the very start, unbalanced force can be low as there is only few contacts, but it does not mean the packing is stable
if O.iter<5000: return
# the rest will be run only if unbalanced is < .1 (stabilized packing)
if unbalancedForce
# add plate at the position on the top of the packing
# the maximum finds the z-coordinate of the top of the topmost particle
for s in O.bodies
s.shape.
print 0.1*s.state.displ() #Check to see if repeating
O.bodies.
global plate # without this line, the plate variable would only exist inside this function
plate=
# Wall objects are "fixed" by default, i.e. not subject to forces
# prescribing a velocity will therefore make it move at constant velocity (downwards)
plate.
# start plotting the data now, it was not interesting before
O.engines=
# next time, do not call this function anymore, but the next one (unloadPlate) instead
checker.
def unloadPlate():
# if the force on plate exceeds maximum load, start unloading
if abs(O.forces.
plate.
# next time, do not call this function anymore, but the next one (stopUnloading) instead
checker.
def stopUnloading():
if abs(O.forces.
# O.tags can be used to retrieve unique identifiers of the simulation
# if running in batch, subsequent simulation would overwrite each other's output files otherwise
# d (or description) is simulation description (composed of parameter values)
# while the id is composed of time and process number
plot.
O.pause()
def addPlotData():
if not isinstance(
plot.
Fz=O.
plot.
# besides unbalanced force evolution, also plot the displacement-force diagram
plot.plots=
plot.plot()
O.run()
Revision history for this message
|
#3 |
Sorry ignore that previous post. It is a bad example and obviously isn't running the way it was supposed to. Here is the actual problem code.
readParamsFromT
# make rMean, rRelFuzz, maxLoad accessible directly as variables later
from yade.params.table import *
numspherespack1
numspherespack2 = 173
Zextentbox = 0.200
width = 0.154
length = 0.441
cylinderheight = 0.130
cylinderradius = 0.05
nosides = 10
#Set materials for spheres, and box
O.materials.
O.materials.
# create box with free top, and ceate loose packing inside the box
from yade import pack, plot
O.bodies.
TBM=O.bodies.
sp=pack.
sp.makeCloud(
#May need to make cloud larger tos full up the model
sp.makeCloud(
sp.toSimulation
O.engines=[
ForceResetter(),
# sphere, facet, wall
InsertionSor
InteractionLoop(
# the loading plate is a wall, we need to handle sphere+sphere, sphere+facet, sphere+wall
[
[
[
),
NewtonIntegr
#SnapshotEng
# the label creates an automatic variable referring to this engines
PyRunner(
]
O.dt=.5*
# the following checkUnbalanced, unloadPlate and stopUnloading functions are all called by the 'checker'
# (the last engine) one after another; this sequence defines progression of different stages of the
# simulation, as each of the functions, when the condition is satisfied, updates 'checker' to call
# the next function when it is run from within the simulation next time
# check whether the gravity deposition has already finished
# if so, add wall on the top of the packing and start the oedometric test
def checkUnbalanced1():
# at the very start, unbalanced force can be low as there is only few contacts, but it does not mean the packing is stable
if O.iter<5000: return
# the rest will be run only if unbalanced is < .1 (stabilized packing)
if unbalancedForce
# add plate at the position on the top of the packing
# the maximum finds the z-coordinate of the top of the topmost particle
O.bodies.
global plate # without this line, the plate variable would only exist inside this function
plate=
# Wall objects are "fixed" by default, i.e. not subject to forces
# prescribing a velocity will therefore make it move at constant velocity (downwards)
plate.
# start plotting the data now, it was not interesting before
#O.engines=
# next time, do not call this function anymore, but the next one (unloadPlate) instead
checker.
def unloadPlate1():
# if the force on plate exceeds maximum load, start unloading
if abs(O.forces.
plate.
# next time, do not call this function anymore, but the next one (stopUnloading) instead
checker.
def stopUnloading():
if abs(O.forces.
plate.state.vel*=0
areacylinder = (.5*nosides*
Volcylinder = areacylinder*
height = max([b.
print 'Height of heighest sphere is: ',height
v1=Volcylinder
v2=width*
Voidratio=
print'The Void Ratio:'
checker.
def checkUnbalanced
O.engines=
# start plotting the data now, it was not interesting before
#O.
# we use it below to changefor s in O.bodies if isinstance(
global CylinderforceX, CylinderforceY, CylinderforceZ
for s in O.bodies:
s.shape.
#print 0.1*s.state.displ()
#s.shape.
# for changing color based on the movement of sheres. its attributes from the functions called
#print 'Change'
CylinderforceX = utils.sumForces
CylinderforceY = utils.sumForces
CylinderforceZ = utils.sumForces
#Cylindernorma
print 'The sum of normal forces are: ',Cylindernorma
plot.addData(
# start plotting the data now, it was not interesting before
#O.
# next time, do not call this function anymore, but the next one (unloadPlate) instead
#O.pause()
#plot.saveDataT
def addPlotData():
if not isinstance(
plot.
Fz=O.
plot.
#Plotting the force on the tunnel face
def addPlotDataForc
print 'test => ',CylinderforceX
plot.
# besides unbalanced force evolution, also plot the displacement-force diagram
plot.plots=
#plot.plots=
plot.plot()
#O.saveTmp()
from yade import qt
v=qt.View()
v.eyePosition=
Revision history for this message
|
#4 |
Hi Clinton,
create a separate function and separate PyRunner with desired period for
coloring your particles. Then everything works as expected :-) Do not put
it inside functions of totally different purpose.
In your first example, checkUnbalanced was called 2x in my case, in your
second example checkUnbalanced
Hence no changes were visible
cheers
Jan
2016-05-29 1:32 GMT+02:00 Clinton Schramm <
<email address hidden>>:
> Question #294531 on Yade changed:
> https:/
>
> Clinton Schramm gave more information on the question:
> Sorry ignore that previous post. It is a bad example and obviously isn't
> running the way it was supposed to. Here is the actual problem code.
>
> readParamsFromT
> # make rMean, rRelFuzz, maxLoad accessible directly as variables later
> from yade.params.table import *
> numspherespack1
> numspherespack2 = 173
> Zextentbox = 0.200
> width = 0.154
> length = 0.441
> cylinderheight = 0.130
> cylinderradius = 0.05
> nosides = 10
>
> #Set materials for spheres, and box
> O.materials.
> #Need to find youngs modulus
>
> O.materials.
>
> # create box with free top, and ceate loose packing inside the box
> from yade import pack, plot
> O.bodies.
> #(centre),(x,y,z) Old Box with correct dimensions
>
> TBM=O.bodies.
>
> sp=pack.
> sp.makeCloud(
> #Cloud for under tunnel
> #May need to make cloud larger tos full up the model
> sp.makeCloud(
> #Move cloud in +z 400
> sp.toSimulation
>
> O.engines=[
> ForceResetter(),
> # sphere, facet, wall
>
> InsertionSortCo
> InteractionLoop(
> # the loading plate is a wall, we need to handle sphere+sphere,
> sphere+facet, sphere+wall
>
> [Ig2_Sphere_
> [Ip2_FrictMat_
> [Law2_ScGeom_
> ),
> NewtonIntegrato
>
> #SnapshotEngine
> # the label creates an automatic variable referring to this engines
> PyRunner(
> ]
> O.dt=.5*
>
> # the following checkUnbalanced, unloadPlate and stopUnloading functions
> are all called by the 'checker'
> # (the last engine) one after another; this sequence defines progression
> of different stages of the
> # simulation, as each of the functions, when the condition is satisfied,
> updates 'checker' to call
> # the next function when it is run from within the simulation next time
>
> # check whether the gravity deposition has already finished
> # if so, add wall on the top of the packing and start the oedometric test
> def checkUnbalanced1():
> # at the very start, unbalanced force can be low as there is only few
> contacts, but it does not mean the packing is stable
> if O.iter<5000: return
> # the rest will be run only if unbalanced is < .1 (stabilized packing)
> if unbalancedForce
> # add plate at the position on the top of the packing
> # the maximum finds the z-coordinate of the top of the topmost particle
> O.bodies.
> O.bodies if isinstance(
> global plate # without this line, the plate variable would only
> exist inside this function
> plate=O.bodies[-1] # the last particles is the plate
> # Wall objects are "fixed" by default, i.e. not subject to forces
> # prescribing a velocity will therefore make it move at constant
> velocity (downwards)
> plate.state.
> # start plotting the data now, it was not interesting before
> #O.engines=
> # next time, do not call this function anymore, but the next one
> (unloadPlate) instead
> checker.
>
> def unloadPlate1():
> # if the force on plate exceeds maximum load, start unloading
> if abs(O.forces.
> plate.state.vel*=-3
> # next time, do not call this function anymore, but the next one
> (stopUnloading) instead
> checker.
>
> def stopUnloading():
>
> if abs(O.forces.
> plate.state.vel*=0
> areacylinder =
> (.5*nosides*
> Volcylinder = areacylinder*
> height = max([b.
> isinstance(
> print 'Height of heighest sphere is: ',height
> v1=Volcylinder+
> O.bodies if isinstance(
> v2=width*
> Voidratio=
> print'The Void Ratio:'
>
> checker.
>
> def checkUnbalanced
>
> O.engines=
> # start plotting the data now, it was not interesting before
>
> #O.engines=
> # we use it below to changefor s in O.bodies if
> isinstance(
> global CylinderforceX, CylinderforceY, CylinderforceZ
>
> for s in O.bodies:
>
> s.shape.
> #print 0.1*s.state.displ()
>
> #s.shape.
> # for changing color based on the movement of sheres. its
> attributes from the functions called
> #print 'Change'
> CylinderforceX =
> utils.sumForces
> CylinderforceY =
> utils.sumForces
> CylinderforceZ =
> utils.sumForces
>
> #Cylindernormal
> sumFacetNormalF
> print 'The sum of normal forces are: ',Cylindernorma
>
>
> plot.addData(
> # start plotting the data now, it was not interesting before
>
> #O.engines=
> # next time, do not call this function anymore, but the next one
> (unloadPlate) instead
> #O.pause()
>
> #plot.saveDataT
>
>
>
> def addPlotData():
>
> if not isinstance(
> plot.addData(); return
> Fz=O.forces.
>
> plot.addData(
>
> #Plotting the force on the tunnel face
> def addPlotDataForc
> print 'test => ',CylinderforceX
>
> plot.addData(
>
>
>
> # besides unbalanced force evolution, also plot the displacement-force
> diagram
>
> plot.plots=
> #plot.plots=
>
> plot.plot()
>
>
> #O.saveTmp()
> from yade import qt
> v=qt.View()
> v.eyePosition=
> v.axes=False; v.sceneRadius=1.9
>
> --
> You received this question notification because your team yade-users is
> an answer contact for Yade.
>
> _______
> Mailing list: https:/
> Post to : <email address hidden>
> Unsubscribe : https:/
> More help : https:/
>
Revision history for this message
|
#5 |
Thank you again Jan. I have done what you said, but still I can cannot see the spheres changing color.
If I put the pyrunner(
To work around this I tried calling a pyrunner after this piece of code was started. It is below, and sadly doesn't work. I think the procedure of code implementation is correct though?
Another method I thought was running the code in the main engine, and then setting the spheres to the base color just before the cylinder was initiated but this did not seem to work either.
readParamsFromT
# make rMean, rRelFuzz, maxLoad accessible directly as variables later
from yade.params.table import *
numspherespack1
numspherespack2 = 173
Zextentbox = 0.600 #was .200
width = 0.154
length = 0.441
cylinderheight = 0.130
cylinderradius = 0.05
nosides = 10
#Set materials for spheres, and box
O.materials.
O.materials.
# create box with free top, and ceate loose packing inside the box
from yade import pack, plot
O.bodies.
TBM=O.bodies.
sp=pack.
sp.makeCloud(
#May need to make cloud larger tos full up the model
sp.makeCloud(
sp.toSimulation
O.engines=[
ForceResetter(),
# sphere, facet, wall
InsertionSor
InteractionLoop(
# the loading plate is a wall, we need to handle sphere+sphere, sphere+facet, sphere+wall
[
[
[
),
NewtonIntegr
SnapshotEngi
# the label creates an automatic variable referring to this engines
PyRunner(
#PyRunner(
]
O.dt=.5*
# the following checkUnbalanced, unloadPlate and stopUnloading functions are all called by the 'checker'
# (the last engine) one after another; this sequence defines progression of different stages of the
# simulation, as each of the functions, when the condition is satisfied, updates 'checker' to call
# the next function when it is run from within the simulation next time
# check whether the gravity deposition has already finished
# if so, add wall on the top of the packing and start the oedometric test
def checkUnbalanced1():
# at the very start, unbalanced force can be low as there is only few contacts, but it does not mean the packing is stable
if O.iter<5000: return
# the rest will be run only if unbalanced is < .1 (stabilized packing)
if unbalancedForce
# add plate at the position on the top of the packing
# the maximum finds the z-coordinate of the top of the topmost particle
O.bodies.
global plate # without this line, the plate variable would only exist inside this function
plate=
# Wall objects are "fixed" by default, i.e. not subject to forces
# prescribing a velocity will therefore make it move at constant velocity (downwards)
plate.
# start plotting the data now, it was not interesting before
#O.engines=
# next time, do not call this function anymore, but the next one (unloadPlate) instead
checker.
def unloadPlate1():
# if the force on plate exceeds maximum load, start unloading
if abs(O.forces.
plate.
# next time, do not call this function anymore, but the next one (stopUnloading) instead
checker.
def stopUnloading():
if abs(O.forces.
plate.state.vel*=0
areacylinder = (.5*nosides*
Volcylinder = areacylinder*
height = max([b.
print 'Height of heighest sphere is: ',height
v1=Volcylinder
v2=width*
Voidratio=
print'The Void Ratio:'
checker.
def checkUnbalanced
O.engines=
# start plotting the data now, it was not interesting before
#O.
# we use it below to changefor s in O.bodies if isinstance(
global CylinderforceX, CylinderforceY, CylinderforceZ
O.engines=
CylinderforceX = utils.sumForces
CylinderforceY = utils.sumForces
CylinderforceZ = utils.sumForces
Cylindernormal
#print 'The sum of normal forces are: ',Cylindernorma
plot.addData(
# start plotting the data now, it was not interesting before
#O.
# next time, do not call this function anymore, but the next one (unloadPlate) instead
#O.pause()
#plot.saveDataT
def Changecolor():
for s in O.bodies:
s.shape.
#print 0.1*s.state.displ()
# for changing color based on the movement of sheres. its attributes from the functions called
#print 'Change'
def addPlotData():
if not isinstance(
plot.
Fz=O.
plot.
#Plotting the force on the tunnel face
def addPlotDataForc
print 'test => ',CylinderforceX
plot.
# besides unbalanced force evolution, also plot the displacement-force diagram
plot.plots=
#plot.plots=
plot.plot()
#O.saveTmp()
from yade import qt
v=qt.View()
v.eyePosition=
Revision history for this message
|
#6 |
****Ammended Code
readParamsFromT
# make rMean, rRelFuzz, maxLoad accessible directly as variables later
from yade.params.table import *
numspherespack1
numspherespack2 = 173
Zextentbox = 0.200 #was .200
width = 0.154
length = 0.441
cylinderheight = 0.130
cylinderradius = 0.05
nosides = 10
#Set materials for spheres, and box
O.materials.
O.materials.
# create box with free top, and ceate loose packing inside the box
from yade import pack, plot
O.bodies.
TBM=O.bodies.
sp=pack.
sp.makeCloud(
#May need to make cloud larger tos full up the model
sp.makeCloud(
sp.toSimulation
O.engines=[
ForceResetter(),
# sphere, facet, wall
InsertionSor
InteractionLoop(
# the loading plate is a wall, we need to handle sphere+sphere, sphere+facet, sphere+wall
[
[
[
),
NewtonIntegr
SnapshotEngi
# the label creates an automatic variable referring to this engines
PyRunner(
#PyRunner(
]
O.dt=.5*
# the following checkUnbalanced, unloadPlate and stopUnloading functions are all called by the 'checker'
# (the last engine) one after another; this sequence defines progression of different stages of the
# simulation, as each of the functions, when the condition is satisfied, updates 'checker' to call
# the next function when it is run from within the simulation next time
# check whether the gravity deposition has already finished
# if so, add wall on the top of the packing and start the oedometric test
def checkUnbalanced1():
# at the very start, unbalanced force can be low as there is only few contacts, but it does not mean the packing is stable
if O.iter<5000: return
# the rest will be run only if unbalanced is < .1 (stabilized packing)
if unbalancedForce
# add plate at the position on the top of the packing
# the maximum finds the z-coordinate of the top of the topmost particle
O.bodies.
global plate # without this line, the plate variable would only exist inside this function
plate=
# Wall objects are "fixed" by default, i.e. not subject to forces
# prescribing a velocity will therefore make it move at constant velocity (downwards)
plate.
# start plotting the data now, it was not interesting before
#O.engines=
# next time, do not call this function anymore, but the next one (unloadPlate) instead
checker.
def unloadPlate1():
# if the force on plate exceeds maximum load, start unloading
if abs(O.forces.
plate.
# next time, do not call this function anymore, but the next one (stopUnloading) instead
checker.
def stopUnloading():
if abs(O.forces.
plate.state.vel*=0
areacylinder = (.5*nosides*
Volcylinder = areacylinder*
height = max([b.
print 'Height of heighest sphere is: ',height
v1=Volcylinder
v2=width*
Voidratio=
print'The Void Ratio:'
checker.
def checkUnbalanced
O.engines=
# start plotting the data now, it was not interesting before
#O.
# we use it below to changefor s in O.bodies if isinstance(
global CylinderforceX, CylinderforceY, CylinderforceZ
O.engines=
CylinderforceX = utils.sumForces
CylinderforceY = utils.sumForces
CylinderforceZ = utils.sumForces
Cylindernormal
#print 'The sum of normal forces are: ',Cylindernorma
plot.addData(
# start plotting the data now, it was not interesting before
#O.
# next time, do not call this function anymore, but the next one (unloadPlate) instead
#O.pause()
#plot.saveDataT
def Changecolor():
for s in O.bodies:
s.shape.
#print 0.1*s.state.displ()
# for changing color based on the movement of sheres. its attributes from the functions called
#print 'Change'
def addPlotData():
if not isinstance(
plot.
Fz=O.
plot.
#Plotting the force on the tunnel face
def addPlotDataForc
print 'test => ',CylinderforceX
plot.
# besides unbalanced force evolution, also plot the displacement-force diagram
plot.plots=
#plot.plots=
plot.plot()
#O.saveTmp()
from yade import qt
v=qt.View()
v.eyePosition=
Revision history for this message
|
#7 |
Sorry for just spamming the code.
I'm not sure how else to explain it.
Cheers
Revision history for this message
|
#8 |
Hi Clinton,
There could be several problems, why you don't see the spheres colored:
- the PyRynner is called not very often
- the scale is wrong (too small or too large)
follows your first example, for me works ok (particles goes from green to
yellow and to green again)
#######
readParamsFromT
from yade.params.table import *
from yade import pack, plot
O.bodies.
sp=pack.
sp.makeCloud(
sp.toSimulation()
O.engines=[
ForceResetter(),
InsertionSortCo
InteractionLoop(
[Ig2_Sphere_
[Ip2_FrictMat_
[Law2_L3Geom_
),
NewtonIntegrato
PyRunner(
PyRunner(
]
O.dt=.5*
def checkUnbalanced():
print O.iter
if O.iter<5000: return
if unbalancedForce
O.bodies.
if isinstance(
global plate
plate=O.bodies[-1]
plate.state.
O.engines=
checker.
def unloadPlate():
if abs(O.forces.
plate.state.vel*=-1
checker.
def stopUnloading():
if abs(O.forces.
plot.saveDataTx
O.pause()
def addPlotData():
if not isinstance(
plot.addData(); return
Fz=O.forces.
plot.addData(
def ccc():
for s in O.bodies:
s.shape.
O.run()
#######
cheers
Jan
PS: when posting a code, try to make it minimal - deleting functions, lines
and comments, that are not important (like plots)
2016-05-29 5:16 GMT+02:00 Clinton Schramm <
<email address hidden>>:
> Question #294531 on Yade changed:
> https:/
>
> Clinton Schramm gave more information on the question:
> Sorry for just spamming the code.
>
> I'm not sure how else to explain it.
>
> Cheers
>
> --
> You received this question notification because your team yade-users is
> an answer contact for Yade.
>
> _______
> Mailing list: https:/
> Post to : <email address hidden>
> Unsubscribe : https:/
> More help : https:/
>
Revision history for this message
|
#9 |
And if you need the color information not directly in simulation but for
postprocessing, another option is to export displacement information to vtk
files and use paraview for the postprocessing
cheers
Jan
2016-05-29 12:07 GMT+02:00 Jan Stránský <email address hidden>:
> Hi Clinton,
>
> There could be several problems, why you don't see the spheres colored:
> - the PyRynner is called not very often
> - the scale is wrong (too small or too large)
>
> follows your first example, for me works ok (particles goes from green to
> yellow and to green again)
> #######
> readParamsFromT
> from yade.params.table import *
>
> from yade import pack, plot
> O.bodies.
> sp=pack.
> sp.makeCloud(
> sp.toSimulation()
>
> O.engines=[
> ForceResetter(),
>
> InsertionSortCo
> InteractionLoop(
>
> [Ig2_Sphere_
> [Ip2_FrictMat_
> [Law2_L3Geom_
> ),
> NewtonIntegrato
> PyRunner(
> PyRunner(
> ]
> O.dt=.5*
> def checkUnbalanced():
> print O.iter
> if O.iter<5000: return
> if unbalancedForce
> O.bodies.
> if isinstance(
> global plate
> plate=O.bodies[-1]
> plate.state.
> O.engines=
> checker.
>
> def unloadPlate():
> if abs(O.forces.
> plate.state.vel*=-1
> checker.
>
> def stopUnloading():
> if abs(O.forces.
> plot.saveDataTx
> O.pause()
>
> def addPlotData():
> if not isinstance(
> plot.addData(); return
> Fz=O.forces.
>
> plot.addData(
>
> def ccc():
> for s in O.bodies:
> s.shape.
>
> O.run()
> #######
>
>
> cheers
> Jan
>
> PS: when posting a code, try to make it minimal - deleting functions,
> lines and comments, that are not important (like plots)
>
>
> 2016-05-29 5:16 GMT+02:00 Clinton Schramm <
> <email address hidden>>:
>
>> Question #294531 on Yade changed:
>> https:/
>>
>> Clinton Schramm gave more information on the question:
>> Sorry for just spamming the code.
>>
>> I'm not sure how else to explain it.
>>
>> Cheers
>>
>> --
>> You received this question notification because your team yade-users is
>> an answer contact for Yade.
>>
>> _______
>> Mailing list: https:/
>> Post to : <email address hidden>
>> Unsubscribe : https:/
>> More help : https:/
>>
>
>
Revision history for this message
|
#10 |
Thanks for all the tips Jan. I'll be sure to use them next time.
I've managed to get the colors changing, but the s.state.
Is there a way to reset that value?
Revision history for this message
|
#11 |
>
>
> I've managed to get the colors changing, but the s.state.
> function seems to have a value even before that part of the code has
> been run (perhaps stored previosu displacements?
>
> Is there a way to reset that value?
state.displ() is computed internally as state.pos - state.refPos, so the
displacement from the "original position".
state.refPos may be set manually to arbitrary value, you can try something
like b.state.refPos = b.state.pos. You can do this regularly to color the
particles according to "displacement increment" from previous color change.
This way is quite flexible, so depending on your needs you can use
different approaches.
cheers
Jan
Revision history for this message
|
#12 |
Hi Jan
I have tried to implement what you said, but get the error "State object has no attribute 'Pos'
Could you give an example on how to reference this correctly. Ideally I would like to see the colour change based on the cummunulative displacement from a certain point. (When the translation engine begins)
def checkUnbalanced
global voidcheck
if voidcheck==2:
O.engines=
for s in O.bodies:
s.
O.engines=
print O.engines, '2'
voidcheck=1
# start plotting the data now, it was not interesting before
#O.
checker.
def Changecolor():
for s in O.bodies:
s.shape.
Revision history for this message
|
#13 |
Got it! Thanks so much for all your help Jan!