How to set two concentric circles with the same center and different radius?

Asked by 孙灿

How to set two concentric circles with the same center and different radius? I want to use these two circles to simulate the shield tail gap.
My code is as follows:
circleRadius=2
circleCenter = Vector3(30,40,0.1)

for b in O.bodies:
    d = (b.state.pos - circleCenter).norm() # distance of circleCenter and center of "b"
    if d < circleRadius:
        O.bodies.erase(b.id)
for a in O.bodies:
    s = (a.state.pos - circleCenter).norm() # distance of circleCenter and center of "a"
    if s = circleRadius:
        O.bodies.append(a.id)
What's wrong with my code?

Question information

Language:
English Edit question
Status:
Expired
For:
Yade Edit question
Assignee:
No assignee Edit question
Last query:
Last reply:
Revision history for this message
Karol Brzezinski (kbrzezinski) said (last edit ):
#1

Hi,

is it all of your code or just a part of it? There is contradiction in your approach, especially in the second loop. If you iterate over O.bodies, you assume that you check bodies that are already in the simulation. On the other hand O.bodies.append is used to add bodies to the simulation.

I would recommend some learning path, that was helpful in my case. First just reading documentation on https://yade-dem.org/doc/ (such as Introduction, Tutorial, DEM Formulation).

If you want to put a sphere in certain position (e.g. (1,2,3)) you could do it this way:
O.bodies.append(sphere((1,2,3), circleRadius))

You can put it in a loop, where you pass target positions of subsequent spheres.

Cheers,
Karol

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

Hello,

please read [1]. Then read [1] again and follow the instructions.
Please provide a MWE.
Please provide (muuuuch) more information.

> How to set two concentric circles with the same center and different radius? I want to use these two circles to simulate the shield tail gap.

What does "to set" mean?
What is "the" shield tail gap?

> What's wrong with my code?

You should tell us first.
- Do you get errors?
- Do you get different results than expected?
- ... ?

What does "wrong" mean?

> What's wrong with my code?

Very difficult to say with so little information.
Please read [1], following instructions and provide (much much) more information.

One answer is that it is wrong because the "for b in O.bodies" loop is useless, because you have no bodies in the simulation (assuming your code is a MWE).

Another answer could be that it is wrong, because O.bodies.append(a.id) results in ArgumentError. But Yade tells it to you itself and you would not need to ask here..

Another answer could be that in general it is not good idea (or at leas idea to think more about) to modify a container while looping over it ("O.bodies.append" inside "for b in O.bodies").
In this specific case it seems it does not matter, but it could be considered "wrong".

Another answer ...

> What's wrong with my code?

The correct answer depends, as always, on specific circumstances, which we know nothing about.

Cheers
Jan

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

Revision history for this message
Launchpad Janitor (janitor) said :
#3

This question was expired because it remained in the 'Needs information' state without activity for the last 15 days.