Exemple #1
0
def calculate_collision_rates(rhor, fr, save=True, pyt=False, full_output=False):
    start = time.time()
    cnt = 0

    rates = np.zeros(len(qifracs))
    ls = np.zeros(len(qifracs))
    for i,qifrac in enumerate(qifracs):
        print 'step %s/%s: %s'%(i, len(qifracs), qifrac)
        status = s.set_properties_from_env(rhor, fr, qifrac)
        ls[i] = s.l
        if(status != 1):
            print '-'
            cnt += 1
        else:
            print '+'
        got_sol = True
        if(pyt):
            rates[i] = collision_rate_pyt(s.dgr, s.dcr, s.rhog, fr, s.mu, s.l)
        else:
            rates[i] = collision_rate(s.dgr, s.dcr, s.rhog, fr, s.mu, s.l)

    if(save and cnt<3):
        path = pathbase%(fr*100, rhor)
        np.save(path, rates)
        print 'file saved as %s.npy'%(path)

    end = time.time()
    print 'time elapsed for computing rates: %s'%(end-start)

    if(full_output):
        return rates, cnt, ls
    else:
        return rates, cnt
Exemple #2
0
def integrate(rhor, fr, nitot, qitot, ttot, dt, dtout):
    fig = plt.figure()
    ax = fig.add_subplot(111, projection='3d')
    ax.set_xlabel('log(D) in m')
    ax.set_ylabel('t in s')
    ax.set_zlabel('dN/dlog(D)')

    qifrac = qitot/nitot
    status = s.set_properties_from_env(rhor, fr, qifrac)
    D = np.logspace(-5, -2, 100)
    tt = np.ones_like(D)
    if(status != 1):
        print '-'
    else:
        print '+'
        
    t = 0.0
    while(t < ttot):
        if(t%dtout == 0):
            ax.plot(np.log10(D), tt*t, D*gammapdf(D, s.mu, s.l)*nitot, color=(0,0,0))
        rate = collision_rate_pyt(s.dgr, s.dcr, s.rhog, fr, s.mu, s.l)*nitot**2
        nitot = nitot - dt*rate
        t += dt
        qifrac = qitot/nitot
        status = s.set_properties_from_env(rhor, fr, qifrac)
        print 'step %i/%i: %s'%(t/dt, float(ttot)/dt, status)
        print 'N_i = %i'%(nitot)