How to generate stress in PARAVIEW when the boulder dropped on the grains, and why my amount of grains model in PARAVIEW is not as much as in YADE simulation?
Dear all,
I have some doubts:
1. Based on my script (attachment on below), why I cannot run "readParamsFrom
Traceback (most recent call last):
File "<string>", line 3, in <module>
NameError: name 'readParamsFrom
What should I do?
2. How to generate stress in PARAVIEW when the boulder dropped on the grains? I don't know how to make on script using vtkExporter..please help me..
3. Why is my amount of grains model in PARAVIEW not as much as in YADE simulation? if you could run my script, I already applied Glyph method to see the particles/grains, but it is not as much as I want like in YADE.
###SCRIPT###
##Sphere Cylinder pack
readParamsFromT
from yade.params.table import *
from yade import export
from yade import pack, plot
from pylab import rand #for sand color
O.bodies.
##Define material of the grains
O.bodies[
O.bodies[
O.materials.
sp=pack.
sp.makeCloud(
sp.toSimulation
##Make a floor
O.bodies.
##Engines and Constitutive Law
O.engines=
InsertionSort
InteractionLo
[Ip2_
[Law2_
NewtonIntegr
PyRunner(
PyRunner(
O.dt=.8*
def checkUnbalanced():
if O.iter<1000:return # 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 unbalancedForce
O.bodies.
O.bodies[
O.materials.
global boulder # without this line, the BOULDER variable would only exist inside this function
boulder=
boulder.
O.engines=
checker.
def unloadBoulder():
# if the force on boulder exceeds maximum load, start unloading
if abs(O.forces.
boulder.
checker.
def stopUnloading():
if abs(O.forces.
O.run()
def addPlotData():
b=O.bodies[-1]
plot.
plot.plots=
plot.plot()
def doExport():
vtkExporter = export.
vtkExporter.
vtkExporter.
vtkExporter.
vtkExporter.
vtkExporter.
vtkExporter.
vtkExporter.
yade.qt.
O.saveTmp()
#######
Thank you in advance!
Cheers!!
Question information
- Language:
- English Edit question
- Status:
- Solved
- For:
- Yade Edit question
- Assignee:
- No assignee Edit question
- Solved by:
- Defri
- Solved:
- 2020-12-16
- Last query:
- 2020-12-16
- Last reply:
- 2020-12-16
Robert Caulk (rcaulk) said : | #1 |
>3. Why is my amount of grains model in PARAVIEW not as much as in YADE simulation? if you could run my script, I already applied Glyph method to see the particles/grains, but it is not as much as I
Go to the glyph settings panel
Find Masking > Glyph Mode >
Then change "Uniform spatial distribution" to "All points."
>2. How to generate stress in PARAVIEW when the boulder dropped on the grains? I don't know how to make on script using vtkExporter..please help me..
You need to find a way to decide what a particle stress is and then export it. It looks like you are only exporting displacements at the moment. Why don't you use VTKRecorder to obtain and export particle stresses [1]
[1]https:/
Robert Caulk (rcaulk) said : | #2 |
> 1. Based on my script (attachment on below), why I cannot run "readParamsFrom
Traceback (most recent call last):
File "<string>", line 3, in <module>
NameError: name 'readParamsFrom
What should I do?
You should probably start with some python basics. NameError is a python error, not a yade one. It means that python does not have any definition of 'readParamsFrom
name 'readParamsFrom
So you need to think about why it is not defined. To do that let's see if I can introduce you to some python basics.
1/ importing libraries.
Python is library based, yade is essentially just a library to be imported. Hence:
from yade.params.table import *
from yade import export
from yade import pack, plot
2/ the code is sequential.
Python reads your script line by line, top to bottom.
I hope the information I have provided is sufficient for you to understand the problem on your own.
Cheers,
Robert
Jan Stránský (honzik) said : | #3 |
Hello,
> 1. Based on my script (attachment on below), why I cannot run "readParamsFrom
**In Yade**, readParamsFromTable is automatically imported (as all functions from utils module) in main scope.
If you run it in Yade, you should not have any problem.
Using "plain python" (or "other python", e.g. pvpython or python in paraview or jupyter notebook or ...) you need to explicitly import it, as suggested by Robert.
> it appeared like this on PARAVIEW when I run script:
on paraview???
Even it is possible to run any python script in paraview, I would not recommend it (e.g. because of different scopes, different imports, I don't know if there is some extra performance decrease or not, etc.)
I suggest to use yade for yade tasks and paraview for paraview tasks.
> What should I do?
you should describe more in detail how you got this error, what steps you did, what commands run, where (linux console, paraview python shell, ...), etc.
cheers
Jan
Defri (daredefri) said : | #4 |
I am sorry for the delay response.
> If you run it in Yade, you should not have any problem.
yes I run it in YADE, and as you can see in my script and if you run it, it is fine.
> I suggest to use yade for yade tasks and paraview for paraview tasks.
I just click "Run Script" in paraview, and then appeared that " NameError: name 'readParamsFrom
I am using vtkRecorder
> you should describe more in detail how you got this error, what steps you did, what commands run, where (linux console, paraview python shell, ...), etc.
So I just run my script in TERMINAL of Ubuntu. I knew about "readParamsFrom
###SCRIPT###
##Sphere Cylinder pack
readParamsFromT
from yade.params.table import *
from yade import export
from yade import pack, plot
from pylab import rand #for sand color
O.bodies.
##Define material of the grains
O.bodies[
O.bodies[
O.materials.
sp=pack.
sp.makeCloud(
sp.toSimulation
##Make a floor
O.bodies.
##Engines and Constitutive Law
O.engines=
InsertionSort
InteractionLo
[Ip2_
[Law2_
NewtonIntegr
PyRunner(
VTKRecorder(
O.dt=.8*
def checkUnbalanced():
if O.iter<1000:return # 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 unbalancedForce
O.bodies.
O.bodies[
O.materials.
global boulder # without this line, the BOULDER variable would only exist inside this function
boulder=
boulder.
O.engines=
checker.
def unloadBoulder():
if abs(O.forces.
boulder.
checker.
def stopUnloading():
if abs(O.forces.
O.run()
def addPlotData():
b=O.bodies[-1]
accel=Force/
plot.
plot.plots=
plot.plot()
O.saveTmp()
#######
my another question:
why after I inputted vtkRecorder (as written on my script), only showed the initial condition (that only grains stand, not dropping like when I run Yade)?
I want to have the result of the stress (boulder dropped onto the grains).
Thank you in advance.
Jan Stránský (honzik) said : | #5 |
> I just click "Run Script" in paraview
why?
Normally, you run the yade script with yade. The running exports some .vtk or .vtu or similar files.
In Paraview, you load these exported files and work with them. But you do not run the script again in paraview!! (at least it is the standard case and if you need it, you probably would not ask here..)
The paraview "run script" is intended for paraview scripts, e.g. you can script some repeating tasks (like take these files, create this glyphs with these parameters, color it this way, export image...).
(yes, in paraview you can run any python script, as I pointed before, but the usual way is to use it just for paraview scripts)
> I want to have the result of the stress
I would start with "any" results. If you just export position, does it work?
If you can export "something", we can proceed to stress. It does not make much sense before..
> why after I inputted vtkRecorder (as written on my script), only showed the initial condition (that only grains stand, not dropping like when I run Yade)?
sorry, I have no idea what you ask :-D what is "only showed"? where? how? what is "initial condition"? ... ?
cheers
Jan
Defri (daredefri) said : | #6 |
Finally I have solved it...I am sorry for some repeating questions.
I just need to run it 1st then I choose which .vtu I need to address.
Thank you so much.