def test_drawR_squeezed(self):

        D = 1e-12
        kf = 1e-8
        sigma = 1e-8
        a = 1.01e-8

        t = 1e-6
        r0 = 1.005e-8
        gf = mod.GreensFunction3DRadAbs(D, kf, r0, sigma, a)
        r = gf.drawR(0.5, t)
        self.failIf(r < sigma or r > a)

        # near s
        r = 1.0001e-8
        r0 = 1.0001e-8
        gf = mod.GreensFunction3DRadAbs(D, kf, r0, sigma, a)
        r = gf.drawR(0.5, t)
        self.failIf(r < sigma or r > a)

        # near a
        r = 1.0099e-8
        r0 = 1.0099e-8
        gf = mod.GreensFunction3DRadAbs(D, kf, r0, sigma, a)
        r = gf.drawR(0.5, t)
        self.failIf(r < sigma or r > a)
    def test_draw_theta_squeezed(self):

        D = 1e-12
        kf = 1e-8
        sigma = 1e-8
        a = 1.001e-8

        t = 1e-8
        r = 1.0001e-8
        r0 = 1.0001e-8
        gf = mod.GreensFunction3DRadAbs(D, kf, r0, sigma, a)
        theta = gf.drawTheta(0.5, r, t)
        self.failIf(theta < 0.0 or theta > numpy.pi)

        # near s
        r = 1.00001e-8
        r0 = 1.00001e-8
        gf = mod.GreensFunction3DRadAbs(D, kf, r0, sigma, a)
        theta = gf.drawTheta(0.5, r, t)
        self.failIf(theta < 0.0 or theta > numpy.pi)

        # near a
        r = 1.00099e-8
        r0 = 1.00099e-8
        gf = mod.GreensFunction3DRadAbs(D, kf, r0, sigma, a)
        theta = gf.drawTheta(0.5, r, t)
        self.failIf(theta < 0.0 or theta > numpy.pi)
    def test_ip_theta_is_int_p_theta(self):

        import scipy.integrate

        D = 1e-12
        sigma = 1e-8
        kf = 1e-10

        t = 1e-2  #FIXME: smaller t should be fine
        r0 = 5e-8

        a = 1e-7

        gf = mod.GreensFunction3DRadAbs(D, kf, r0, sigma, a)
        r = r0

        ip = gf.ip_theta(0.0, r, t)
        self.assertEqual(0.0, ip)

        resolution = 10
        for i in range(1, resolution):
            theta = i * numpy.pi / resolution
            ip = gf.ip_theta(theta, r, t)
            result = scipy.integrate.quad(gf.p_theta, 0.0, theta, args=(r, t))
            np = result[0]
            self.assertAlmostEqual(0.0, (np - ip) / ip, 5)
    def test_p_theta_never_negative(self):

        D = 1e-12
        sigma = 1e-8
        kf = 1e-8

        # smaller t causes problem
        t = 1e-3
        r0 = 5e-8
        r = r0
        a = 1e-7

        gf = mod.GreensFunction3DRadAbs(D, kf, r0, sigma, a)

        pint = gf.ip_theta(numpy.pi, r, t)

        pmin = 0.0
        resolution = 50
        for i in range(resolution):
            theta = i * numpy.pi / resolution
            p = gf.p_theta(theta, r, t) / pint / resolution
            pmin = min(pmin, p)
            #print 'theta: ', theta, '\tp: ', p

        self.failIf(pmin < 0.0, 'Negative p_theta; t= %g, %s' % (t, gf.dump()))
    def test_p_int_r_never_decrease(self):

        D = 1e-12
        sigma = 1e-8
        kf = 1e-8

        # smaller t causes problem
        t = 1e-3
        r0 = sigma

        a = 3e-7

        gf = mod.GreensFunction3DRadAbs(D, kf, r0, sigma, a)

        psurv = gf.p_survival(t)

        pintr_prev = 0.0
        resolution = 500
        for i in range(resolution):
            r = i * (a - sigma) / resolution + sigma
            pintr = gf.p_int_r(r, t)
            #print r, pintr, psurv
            self.failIf(pintr > psurv)
            self.failIf(pintr < pintr_prev)
            pintr_prev = pintr
    def test_ip_theta_squeezed(self):

        D = 1e-12
        kf = 1e-8
        sigma = 1e-8
        a = 1.001e-8

        t = 1e-10
        r = 1.00099e-8
        r0 = 1.00099e-8
        gf = mod.GreensFunction3DRadAbs(D, kf, r0, sigma, a)
        ip = gf.ip_theta(1, r, t)

        r = 1.0000001e-8
        r0 = 1.0000001e-8
        gf = mod.GreensFunction3DRadAbs(D, kf, r0, sigma, a)
        ip = gf.ip_theta(1, r, t)
    def test_instantiation(self):
        D = 1e-12
        kf = 1e8
        sigma = 1e-8
        a = 1e-7
        r0 = 5e-8

        gf = mod.GreensFunction3DRadAbs(D, kf, r0, sigma, a)
        self.failIf(gf == None)
    def test_draw_time_a_near_sigma(self):
        D = 1e-12
        kf = 1e-8
        sigma = 1e-8
        a = sigma + sigma * 1e-6
        r0 = (a + sigma) * .5

        gf = mod.GreensFunction3DRadAbs(D, kf, r0, sigma, a)

        t = gf.drawTime(0.5)
        self.failIf(t <= 0.0 or t >= numpy.inf)
    def test_draw_time_r0_equal_a(self):
        D = 1e-12
        kf = 1e-8
        sigma = 1e-8
        a = 1e-7
        r0 = a

        gf = mod.GreensFunction3DRadAbs(D, kf, r0, sigma, a)

        t = gf.drawTime(0.5)
        self.assertEqual(0.0, t)
Exemplo n.º 10
0
    def test_draw_time_r0_equal_sigma_kf_zero(self):
        D = 1e-12
        kf = 0.0  # note this
        sigma = 1e-8
        a = 1e-7
        r0 = sigma

        gf = mod.GreensFunction3DRadAbs(D, kf, r0, sigma, a)

        t = gf.drawTime(0.5)
        self.failIf(t < 0.0 or t >= numpy.inf)
Exemplo n.º 11
0
    def no_test_draw_time_r0_equal_sigma_kf_large(self):
        D = 1e-12
        kf = 1e-8
        sigma = 1e-8
        a = 10e-7
        r0 = sigma + 1e-12

        gf = mod.GreensFunction3DRadAbs(D, kf, r0, sigma, a)

        t = gf.drawTime(0.5)
        self.failIf(t < 0.0 or t >= numpy.inf)
Exemplo n.º 12
0
    def test_draw_theta_zerot(self):
        D = 1e-12
        kf = 1e-8
        sigma = 1e-8
        a = 1e-7
        r = 5e-8
        r0 = 5e-8

        gf = mod.GreensFunction3DRadAbs(D, kf, r0, sigma, a)

        t = 0.0
        theta = gf.drawTheta(0.5, r0, t)
        self.assertEqual(0.0, theta)
Exemplo n.º 13
0
    def test_drawR_r0_equal_sigma(self):
        D = 1e-12
        kf = 1e-8
        sigma = 1e-8
        a = 1e-7
        r0 = sigma

        t = 1e-3

        gf = mod.GreensFunction3DRadAbs(D, kf, r0, sigma, a)

        r = gf.drawR(0.5, t)
        self.failIf(r < sigma or r > a)
Exemplo n.º 14
0
    def test_drawR_zerot(self):
        D = 1e-12
        kf = 1e-8
        sigma = 1e-8
        a = 1e-7
        r0 = 2e-8

        gf = mod.GreensFunction3DRadAbs(D, kf, r0, sigma, a)

        t = 0.0

        r = gf.drawR(0.5, t)
        self.assertEqual(r0, r)
Exemplo n.º 15
0
    def test_draw_theta_1(self):
        r0 = 1.0206416181e-07
        t = 4.41358538629e-08
        D = 4e-11
        sigma = 1e-07
        a = 1.05134e-07
        kf = 0  # h = 0

        r = 1.03421535312e-07

        gf = mod.GreensFunction3DRadAbs(D, kf, r0, sigma, a)

        theta = gf.drawTheta(0.5, r, t)
        self.failIf(theta < 0.0 or theta > numpy.pi)
Exemplo n.º 16
0
    def test_draw_theta_r_equal_a(self):
        D = 1e-12
        kf = 1e-8
        sigma = 1e-8
        a = 1e-7
        r0 = 9e-8

        t = 1e-3
        r = a

        gf = mod.GreensFunction3DRadAbs(D, kf, r0, sigma, a)

        theta = gf.drawTheta(0.5, r, t)
        self.failIf(theta < 0.0 or theta > numpy.pi)
Exemplo n.º 17
0
    def test_p_int_r_at_s_is_zero(self):

        D = 1e-12
        sigma = 1e-8
        kf = 1e-8

        t = 1e-3
        r0 = 5e-8

        a = 1e-7

        gf = mod.GreensFunction3DRadAbs(D, kf, r0, sigma, a)

        pintr = gf.p_int_r(gf.getSigma(), t)
        self.assertEqual(0.0, pintr)
Exemplo n.º 18
0
    def test_draw_theta_smallt(self):

        D = 1e-12
        kf = 1e-8
        sigma = 1e-8
        a = 1e-7
        r = 2e-8
        r0 = 2e-8

        gf = mod.GreensFunction3DRadAbs(D, kf, r0, sigma, a)

        t = 1e-7  # well this is not *very* small..
        theta = gf.drawTheta(0.5, r, t)

        self.failIf(theta < 0.0 or theta > numpy.pi)
Exemplo n.º 19
0
    def test_draw_theta_regression2(self):

        r0 = 5.50265e-09

        rnd = 0.749325
        dt = 1.43732e-06
        r = 6.9928e-09
        D = 2e-12
        sigma = 5e-09
        a = 1.16464e-08
        kf = 0

        gf = mod.GreensFunction3DRadAbs(D, kf, r0, sigma, a)

        theta = gf.drawTheta(rnd, r, dt)
        self.failIf(theta < 0.0 or theta > numpy.pi)
Exemplo n.º 20
0
    def test_draw_time(self):
        D = 1e-12
        kf = 1e-8
        sigma = 1e-8
        a = 1e-7
        r0 = 5e-8

        gf = mod.GreensFunction3DRadAbs(D, kf, r0, sigma, a)

        t = gf.drawTime(0.5)
        self.failIf(t <= 0.0 or t >= numpy.inf)

        t = gf.drawTime(0.0)
        self.failIf(t < 0.0 or t >= numpy.inf)

        t = gf.drawTime(1 - 1e-16)
        self.failIf(t <= 0.0 or t >= numpy.inf)
Exemplo n.º 21
0
    def test_int_dp_theta_at_a_is_leavea(self):

        D = 1e-12
        sigma = 1e-8
        kf = 1e-8

        # smaller t causes problem
        t = 1e-4
        r0 = 9e-8
        a = 1e-7

        gf = mod.GreensFunction3DRadAbs(D, kf, r0, sigma, a)

        leavea = gf.leavea(t) * numpy.pi * a * a * 2
        iptheta = gf.idp_theta(numpy.pi, a, t) * numpy.pi * a * a

        self.assertAlmostEqual(leavea / iptheta, 1.0, 5)  # SBG's accuracy
Exemplo n.º 22
0
    def test_p_int_r(self):

        D = 1e-12
        sigma = 1e-8
        kf = 1e-8

        t = 1e-3
        r0 = 5e-8

        a = 1e-7

        gf = mod.GreensFunction3DRadAbs(D, kf, r0, sigma, a)

        r = r0
        pintr = gf.p_int_r(r, t)

        self.failIf(pintr < 0.0 or pintr > 1.0, 'pintr %f' % pintr)
Exemplo n.º 23
0
    def test_p_int_r_at_a_is_p_survival(self):

        D = 1e-12
        sigma = 1e-8
        kf = 1e-8

        t = 1e-3
        r0 = 5e-8

        a = 1e-7

        gf = mod.GreensFunction3DRadAbs(D, kf, r0, sigma, a)
        r = r0

        pintr = gf.p_int_r(a, t)
        psurv = gf.p_survival(t)
        self.assertAlmostEqual(pintr, psurv)
Exemplo n.º 24
0
    def no_test_draw_event_type_smallt(self):
        D = 1e-12
        kf = 1e-8
        sigma = 1e-8
        a = 1e-6  #sigma + sigma * 0.001
        r0 = 1.1e-8  #sigma+(a-sigma)/2

        gf = mod.GreensFunction3DRadAbs(D, kf, r0, sigma, a)

        t = gf.drawTime(0.999)

        event_type = gf.drawEventType(0.5, t)
        self.failIf(event_type != mod.EventType.IV_REACTION
                    and event_type != mod.EventType.IV_ESCAPE)

        event_type = gf.drawEventType(0.0, t)
        self.assertEqual(event_type, mod.EventType.IV_REACTION)

        event_type = gf.drawEventType(0.9999, t)
Exemplo n.º 25
0
    def test_alpha0(self):

        D = 1e-12
        sigma = 1e-8
        kf = 1e-8

        a = 1e-7
        r0 = 5e-8

        gf = mod.GreensFunction3DRadAbs(D, kf, r0, sigma, a)
        maxerror = 0.0

        for i in range(100):
            alpha = gf.alpha0_i(i)
            error = abs(gf.f_alpha0(alpha) / alpha)
            #print error/alpha, gf.f_alpha0(alpha*1.1)/alpha
            maxerror = max(error, maxerror)

        self.failIf(abs(maxerror) > 1e-10)
Exemplo n.º 26
0
    def test_ip_theta_pi_is_p_0(self):

        D = 1e-12
        sigma = 1e-8
        kf = 1e-8

        t = 1e-5
        r0 = 5e-8
        r = r0

        a = 1e-7

        gf = mod.GreensFunction3DRadAbs(D, kf, r0, sigma, a)

        ip = gf.ip_theta(numpy.pi, r, t)
        p0 = gf.p_0(t, r) * 2

        self.assertNotEqual(0.0, ip)
        self.assertAlmostEqual(1.0, ip / p0, 5)
Exemplo n.º 27
0
    def test_draw_event_type(self):
        D = 1e-12
        kf = 1e-8
        sigma = 1e-8
        a = 1e-7
        r0 = 5e-8

        gf = mod.GreensFunction3DRadAbs(D, kf, r0, sigma, a)

        t = gf.drawTime(0.5)
        event_type = gf.drawEventType(0.5, t)
        self.failIf(event_type != mod.PairEventKind.IV_REACTION
                    and event_type != mod.PairEventKind.IV_ESCAPE)

        event_type = gf.drawEventType(0.0, t)
        self.assertEqual(event_type, mod.PairEventKind.IV_REACTION)

        event_type = gf.drawEventType(0.999999, t)
        self.assertEqual(event_type, mod.PairEventKind.IV_ESCAPE)
Exemplo n.º 28
0
    def test_dpsurvival_is_leaves_plus_leavea(self):

        D = 1e-12
        sigma = 1e-8
        kf = 1e-13

        t = 1e-3
        r0 = 2e-8

        a = 1e-7

        gf = mod.GreensFunction3DRadAbs(D, kf, r0, sigma, a)

        dsurv = gf.dp_survival(t)
        leaves = gf.leaves(t) * 4.0 * numpy.pi * sigma * sigma
        leavea = gf.leavea(t) * 4.0 * numpy.pi * a * a
        #print 'll', leavea, leaves, dsurv
        self.assertNotEqual(0.0, dsurv)
        self.assertAlmostEqual(dsurv, leaves + leavea)
Exemplo n.º 29
0
    def test_psurvival_is_pleaves_plus_pleavea(self):

        D = 1e-12
        sigma = 1e-8
        kf = 1e-8

        t = 1e-5
        r0 = 5e-8

        a = 1e-7

        gf = mod.GreensFunction3DRadAbs(D, kf, r0, sigma, a)

        surv = gf.p_survival(t)
        pleaves = gf.p_leaves(t)
        pleavea = gf.p_leavea(t)
        #print 'pll', surv, pleaves, pleavea
        self.failIf(surv <= 0.0)
        self.failIf(pleavea <= 0.0 or pleaves <= 0.0)
        self.assertAlmostEqual(surv, pleaves + pleavea)
Exemplo n.º 30
0
    def test_psurvival_smallt(self):

        D = 1e-12
        sigma = 1e-8
        kf = 1e-8

        t = 1e-4
        r0 = 2e-8

        a = 1e-7

        gf = mod.GreensFunction3DRadAbs(D, kf, r0, sigma, a)

        for i in range(5):
            psurv = gf.p_survival(t)
            pleaves = gf.p_leaves(t)
            pleavea = gf.p_leavea(t)
            self.assertNotEqual(0.0, psurv)
            self.assertAlmostEqual(pleaves + pleavea, psurv)
            t *= .1