Python Forum
ln in for loop - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: Homework (https://python-forum.io/forum-9.html)
+--- Thread: ln in for loop (/thread-3723.html)



ln in for loop - pikm57 - Jun-17-2017

Hi,
I m trying to solve PDE with finite elements method. Problem is, when I put the part, which has ln(x) in it, I get error. I tried np.log() and math.log() but no luck. Can someone help me?

T[0,:] = T_ok
T[:,0] = T_in


for t in range(Nt):
    for z in range(1,Nz+1):
        T[t+1,z] = T[t,z]-(v_avg*dt/dz)*(T[t,z]-T[t,z-1])-(U*2*dt*L/(r_1*dz))*(((T_in-T_h)-(T[t,z]-T_h))/(np.log((T_in-T_h)/(T[t,z]-T_h))))
        
    T[t+1,Nz+1] = T[t+1,Nz]



RE: ln in for loop - buran - Jun-17-2017

(Jun-17-2017, 07:21 AM)pikm57 Wrote: I get error.
Please, post the full Traceback in error tags


RE: ln in for loop - pikm57 - Jun-17-2017

I just solved it. Tnx.


RE: ln in for loop - buran - Jun-17-2017

would be nice to expalin what the problem was for the benefit of other members who may come here searching for solution


RE: ln in for loop - pikm57 - Jun-20-2017

The problem was that some values in ln() were <0.... such a stupid mistake Confused