I am doing some conversion from Fortran to Python and I would like iterate over a list and perform an if statement. Here is my attempt so far:
step = 10000
stepsize = 0.0001
const = 0.09929
cor = 25519.223
output = []
Tin1[1] = 1.
for i in range(2,step):
Tin[i] = Tin[i-1] + stepsize
LHS[i] = Tin1[i]**(3.125)*np.absolute(1-Tin1[i]**(-1.5))
if (LHS[i] > const) and (LHS[i-1] < const):
Re1 = Tin[i]
Re1_cor = Re1 * cor
output.append(Re1_cor)
I would like to receive the following list
Tin[1] = 1
Tin[2] = 1 + 0.0001 = 1.0001
Tin[3] = 1.0001 + 0.0001 = 1.0002
.
.
and then use this to find the LHS list and do the if condition and so on. At first, I got the error 'Tin1' is not defined, since such a list does not exist and I am trying to assign the first index at the top. So, I tried to first create an empty list with NumPy zero and then do this. So updated the code with the following line: Tin1 = np.zeros(shape=(step,1))
However, I am still getting the same error. I seem like a trivial problem but I am new to python and couldn't find a way to do this. I appreciate any help. I will be dealing with much higher steps/stepsize and more for loop so if there is an alternative algorithm that provides the results faster, I would also appreciate it if you point me in the right direction.
Aucun commentaire:
Enregistrer un commentaire