← Back to team overview

yade-users team mailing list archive

Re: [Question #701161]: Knowing the particle coordinates, generate sphere particles in batches

 

Question #701161 on Yade changed:
https://answers.launchpad.net/yade/+question/701161

    Status: Open => Answered

Jan Stránský proposed the following answer:
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

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