How to call the set function again

Asked by 孙灿

How to call the set function again?

Question information

English Edit question
Yade Edit question
No assignee Edit question
Last query:
Last reply:
Revision history for this message
Jan Stránský (honzik) said :


please read [1] and provide (much) more context and information.



Revision history for this message
孙灿 (suncan) said :

I used the function output () in my code. I want to get the height difference between the particles before and after operation, so I need to use output twice to get the height before and after the particles. Is that right? The first time I used def output() to get the height of particles, what should I do next?

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

what "the function output ()" look like?
what is "operation"?
... ?

> Is that right?

maybe yes, maybe, no.
How can we know? Based on the amount (approaching zero) of provided information?

> what should I do next?

- read [1] carefully
- thinking about the information you provide and trying to read it as somebody who has no idea about your problem (like we are). Try to reformulate it / add information accordingly
- ideally provide a MWE [1], illustrating "operation" and "the function output ()", how you run and stop the simulation, describing desired result etc. etc.



Revision history for this message
孙灿 (suncan) said :

I'm sorry the information I provided is not accurate enough.
Relevant codes are as follows:
def Output():
    #particle info
    f = open('./pdata/pInfo'+'{:.5f}'.format(e22-ini_e22a), 'w')
    print (('Particle information at Iter %d' % O.iter),file=f)

    f.write('Box position: \n')
    print (('left wall: %.5f %.5f %.5f' % (O.bodies[2].state.pos[0], O.bodies[2].state.pos[1], O.bodies[2].state.pos[2])),file=f)
    print (('right wall: %.5f %.5f %.5f' % (O.bodies[3].state.pos[0], O.bodies[3].state.pos[1], O.bodies[3].state.pos[2])),file=f)
    print (('top wall: %.5f %.5f %.5f' % (O.bodies[1].state.pos[0], O.bodies[1].state.pos[1], O.bodies[1].state.pos[2])),file=f)
    print (('bottom wall: %.5f %.5f %.5f' % (O.bodies[0].state.pos[0], O.bodies[0].state.pos[1], O.bodies[0].state.pos[2])),file=f)
    print (('front wall: %.5f %.5f %.5f' % (O.bodies[5].state.pos[0], O.bodies[5].state.pos[1], O.bodies[5].state.pos[2])),file=f)
    print (('back wall: %.5f %.5f %.5f' % (O.bodies[4].state.pos[0], O.bodies[4].state.pos[1], O.bodies[4].state.pos[2])),file=f)

    f.write('ID x y z radius disx disy disz rotx roty rotz \n')
    for b in O.bodies:
        if isinstance(b.shape, Sphere):
            print (,b.state.pos[0],b.state.pos[1],b.state.pos[2],b.shape.radius,b.state.displ()[0],b.state.displ()[1],b.state.displ()[2],b.state.rot()[0],b.state.rot()[1],b.state.rot()[2],file=f)


    #contact info
    g = open('./cdata/cInfo'+'{:.5f}'.format(e22-ini_e22a), 'w')
    print (('Contact information at Iter %d' % O.iter),file=g)
    g.write('ctype id1 id2 nfx nfy nfz tfx tfy tfz \n')

    for k in O.interactions:
        if isinstance(O.bodies[k.id1].shape,Sphere) and isinstance(O.bodies[k.id2].shape,Box):
            print ('01',k.id1,k.id2,k.phys.normalForce[0], k.phys.normalForce[1],k.phys.normalForce[2],k.phys.shearForce[0],k.phys.shearForce[1],k.phys.shearForce[2],file=g)
        elif isinstance(O.bodies[k.id1].shape,Box) and isinstance(O.bodies[k.id2].shape,Sphere):
            print ('10',k.id1,k.id2,k.phys.normalForce[0], k.phys.normalForce[1],k.phys.normalForce[2],k.phys.shearForce[0],k.phys.shearForce[1],k.phys.shearForce[2],file=g)
        elif isinstance(O.bodies[k.id1].shape,Sphere) and isinstance(O.bodies[k.id2].shape,Sphere):
            print ('00',k.id1,k.id2,k.phys.normalForce[0], k.phys.normalForce[1],k.phys.normalForce[2],k.phys.shearForce[0],k.phys.shearForce[1],k.phys.shearForce[2],file=g)


This string of code can get the particle information (ID, radius and coordinates). I only use it to get the particle information before the code runs, and I don't know how to use this string of code again to get the particle information (coordinates).

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

Just call call the function again when you want the second output..

For better answer, please provide requested information:
> ... provide a MWE [1], illustrating "operation" ..., how you run and stop the simulation, ... etc. etc.


Can you help with this problem?

Provide an answer of your own, or ask 孙灿 for more information if necessary.

To post a message you must log in.