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

    Status: Answered => Open

Mithushan Soundaranathan is still having a problem:
Hi Jan,
Thank you for your reply.

>#o.engines = o.engines+[PyRunner(command='ParticleSwelling()', 
>iterPeriod=100000)]
is really distracting and confusing if one of the main problems is PyRunner 
with ParticleSwelling and iterPeriod 100000 :-)

I combined the particle swelling and the other code together, due to issue with 
loading and applying interparticle force.
I want to run the ParticleSwelling() command every 10000 iteration. I defined 
it like that if save=1, the code will save my code and pause. Otherwise it will 
continue with the ParticleSwelling(). Still the command does not run every 
10000 iteration and I don't understand why.
Here is the code:
def stopUnloading():
    for i in upper_punch: 
        body=O.bodies[i] 
        pos_up=body.state.pos
    if pos_up[2] > Cyl_height/2:
        for i in upper_punch:
            body= O.bodies[i]
            body.state.vel = (0,0,2)
        #plate.state.vel = (0, 0, 0)
        initial_save.append(utils.aabbExtrema()[1][2]+r1)
        initial_save.append(O.iter)
        for j in upper_punch: O.bodies.erase(j)
        fCheck.command = 'Savecheck()'
    
def Savecheck():    
    if save==1:
        o.save('Tablet_swelling.xml')
        o.pause()
    if save==0:
        o.engines = o.engines+[PyRunner(command='ParticleSwelling()', 
iterPeriod=10000)]
   

def ParticleSwelling():
    time_current=(O.iter-initial_save[1])*o.dt
    Liq_pos=0.24*(time_current**0.574)
    Liq_pos=Liq_pos*1e-3 #convert to m
    radius=[]
    radius.append(time_current) 
    for b in O.bodies:
        if isinstance(b.shape, Sphere):
            par_pos=(initial_save[0]-b.state.pos[2])
            k=b.id
            r_now=b.shape.radius
            if Liq_pos>=par_pos:
                r_0=r_save[0][k+1]
                if swell_t[0][k]==0:
                    swell_t[0][k]=time_current
                    radius.append(r_save[0][k+1])
                    continue
                time=time_current-swell_t[0][k]
                t = np.linspace(0,time)
                r = odeint(model,r_0,t,args=(P[0],P[1],P[2],r_0,P[3],))
                r_new=float(r[-1])
                radius.append(r_new)
                b.shape.radius = float(r[-1])
                f=float(r[-1])/r_new
                mcurrent=b.state.mass
                mnew=mcurrent*(f*f*f)
                b.state.mass=mnew
                Icurrent=b.state.inertia
                Inew=Icurrent*(f*f*f*f*f)
                b.state.inertia=Inew
            elif Liq_pos<par_pos:
                radius.append(r_save[0][k+1])
    r_save.append(radius) 
    size_current=[time_current,utils.aabbDim()[2]]
    size_save.append(size_current)
    if time_current>20:
        o.pause()
        radius_data=pd.DataFrame(r_save)
        path_save='/home/mithushan/Swelling'  
        base_filename='PH101_swelling_data.csv'
        radius_data.to_csv(os.path.join(path_save,base_filename))
        size_data=pd.DataFrame(size_save, columns=['time','height'])
        base_filename='PH101_height.csv'
        size_data.to_csv(os.path.join(path_save,base_filename))
>You have O.load after setting O.dt, right? (I am not sure, but I got the 
>feeling from the codes)
If so, O.load overwrites everything it can (O.dt, O.engines, ...) with the 
saved state (just as what load should do).

Thank you this helped, it changed the o.dt to 1e-5. But simulation
becomes unstablet and spheres just flyes away at the new timestep.

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

_______________________________________________
Mailing list: https://launchpad.net/~yade-users
Post to     : [email protected]
Unsubscribe : https://launchpad.net/~yade-users
More help   : https://help.launchpad.net/ListHelp

Reply via email to