Knowing the particle coordinates, generate sphere particles in batches

Asked by xuanshenyu

Hi, everyone!

In a certain area, I want to compose some polygons with a lot of particles[1].

I now have the coordinates file (csv) of the sphere particles[2].

How can I call this file to generate sphere particles in batches

Thanks for your kind reply.

[1]https://www.dropbox.com/s/7b3eiqyyupp54xw/particle.jpg?dl=0
[2]https://www.dropbox.com/s/n2yumjm7v82jr2v/xyz.csv?dl=0

Question information

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

Hello,

please read [3], section "Please, no external links!"

> I now have the coordinates file (csv) of the sphere particles[2].

for spheres, you also need radius, or (?)

> How can I call this file to generate sphere particles in batches

Please try to be as specific as possible.
What does "call file" mean?
What does "to generate" mean?
What does "in batches" mean?
I.e., what should be the results? (ideally specified by "hard numbers", using a MWE, see below)

Manipulation of this kind of files in Python is easy, we just need to know what should be the output (which is not clear from OP)

Please provide a MWE [3], i.e.:
- M=minimal: "a lot of particles" -> just a few particles necessary to demonstrate the problem
- describing expected result (e.g. "From this CSV file with 3 lines, I need to generate 3 spheres, with centers (0,0,0), (1,2,3) and (4,5,6)")

I **guess** that what you are looking for is this:
###
radius = 0.5
coordinates = numpy.genfromtxt("xyz.csv",delimiter=",") # there are other approaches
O.bodies.append([sphere((x,y,z),radius) for x,y,z in coordinates]) # can be written more verbose
###

But next time please try to follow instructions in this answer:
- no / as few as possible external links (images are still problems in launchpad, but the .csv file can be inserted directly)
- MWE (just a few spheres is enough for the problem specification / solution)
- describing expected result
- omitting / better explaining terms like "call file", "in batch" etc.
- ...

Cheers
Jan

[3] https://www.yade-dem.org/wiki/Howtoask

Revision history for this message
xuanshenyu (shenyuxuan) said :
#2

Hi,Jan
I'm sorry for inappropriate expression.

First, I know the coordinates of sphere particle, and they are saved in CSV or txt files.
Just like:
1,1,0
1,2,0
1,3,0
1,4,0
...
Then,I want to call the csv or txt file in yade to generate sphere particles.

>###
radius = 0.5
coordinates = numpy.genfromtxt("xyz.csv",delimiter=",")
O.bodies.append([sphere((x,y,z),radius) for x,y,z in coordinates]) # can be written more verbose
###

-this is amazing, so powerful.

> I still have a question about linux system. The user manual recommends running yade in the Ubuntu system, but the research group cluster is the centos system. Will that cause any problems?

Shenyu

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

> I want to call the csv or txt file ...

In programming/scripting terminology, you call a function.
With file, more appropriate is something like read data from file or something similar.

> so powerful

yes, sometimes the ratio of code / effect is impressive :-)

> I still have a question about ...

Please create a new question for a separate problem ([3], point 5).
Also read [3], paragraph "Before asking any question, you may consider searching through the mailing list..."
In this case, e.g. go to [4] and search "CentOS".

Cheers
Jan

[3] https://www.yade-dem.org/wiki/Howtoask
[4] https://answers.launchpad.net/yade/

Revision history for this message
xuanshenyu (shenyuxuan) said :
#4

thank you Jan. My problem has been solved.