混淆python无效语法

2024-10-02 20:31:37 发布

您现在位置:Python中文网/ 问答频道 /正文

这是随机模拟的一部分:

elif (D(dist(x, y, z)) > Dp): ### if passing to a region with lower diffusion constant
            rcross = np.sqrt(Dp/D(dist(x, y, z)))
            rd_nb = rd.uniform(0,1)
            if (Dp == 0.001): # in this case, the particle must be reflected
                s = para(x, y, z, R, dx, dy, dz)
                xc = x + s*dx
                yc = y + s*dy
                zc = z + s*dz

            x = 2*xc - xp
            y = 2*yc - yp           
            z = 2*zc - zp
            # position.append(x)
            t = t + delta_t
            #time.append(t)

        else: 
            if (rd_nb < rcross): # cross!
                s = para(x, y, z, rc, dx, dy, dz)
                xc = x + s*dx
                yc = y + s*dy
                zc = z + s*dz

                sqrt_delta_t1 = (xc - x)/(np.sqrt(2*D(dist(x, y, z))*xix)
                sqrt_delta_t2 = np.sqrt(delta_t) - sqrt_delta_t1

运行程序时,终端显示以下消息:

我完全糊涂了,那条线怎么会出错呢?我认为所有其他部分的代码都很好。另外,我也不能在那行之前打印任何东西(作为调试器),这很奇怪。提前谢谢你!在


Tags: ifdistnpzcsqrtrddpdelta