necesito adaptar el siguiente codigo de matlab a python:
%Holms case properties
E=120.66e9; %Young modulus, E=120.66GPa
alpha=14.4e-6; %Expansion coef, Alpha=10e-6 mm-1K-1
v=0.3; %Poisson modulus
a=101.6/1000; %Tube inner radius 101.6 mm
b=304.8/1000; %Tube outer radius 304.8 mm
%Calculation of internal and external temperature profiles
r=[a:(b-a)/19:b]; %20 divisions in radial coordinate
Theta=[0:360/71:360]; %72 divisions in circunferential coordinates
Theta=Theta*pi/180; %Angle in radians
T=zeros([size(Theta,2),size(r,2)]); %Temperature array, rows angle variation, column radial variation
for i=1:size(r,2) %To create temperature distribution (See Logie et al. Eq. 53)
for i2=1:size(Theta,2)
T(i2,i)=((555.56*b)/(b^2-a^2))*((r(i)^2-a^2)/r(i))*cos(Theta(i2))+277.78*(1-log(b/r(i))/log(b/a))+273.15;
end
end
Tint=T(:,1);
Text=T(:,size(r,2));
%Fourier fitting
Tm_o=550.9;
B1_o=555.6;
Tm_i=273.15;
B1_i=0;
%Stress calculation
K=(Tm_i-Tm_o)/log(b/a);
for i=1:size(r,2)
for i2=1:size(Theta,2)
K_theta(i2,i)=(r(i)*a*b)/(b^2-a^2)*(((B1_i*b-B1_o*a)/(a^2+b^2))*cos(Theta(i2)));
T_theta(i2,i)=T(i2,i)-(Tm_i-Tm_o)*log(b/r(i))/log(b/a)-Tm_o;
sigma_r(i2,i)=(K*alpha*E/(2*(1-v)))*(-log(b/r(i))-(a^2/(b^2-a^2))*(1-b^2/r(i)^2)*log(b/a))+K_theta(i2,i)*((alpha*E)/(2*(1-v)))*(1-a^2/r(i)^2)*(1-b^2/r(i)^2);
sigma_theta(i2,i)=(K*alpha*E/(2*(1-v)))*(1-log(b/r(i))-(a^2/(b^2-a^2))*(1+b^2/r(i)^2)*log(b/a))+K_theta(i2,i)*(alpha*E/(2*(1-v)))*(3-(a^2+b^2)/r(i)^2-a^2*b^2/r(i)^4);
sigma_z(i2,i)=(K*alpha*E/(2*(1-v)))*(1-2*log(b/r(i))-((2*a^2)/(b^2-a^2))*log(b/a))+(K_theta(i2,i)*alpha*E*v/(1-v))*(2-(a^2+b^2)/r(i)^2)-alpha*E*T_theta(i2,i);
sigma_eq(i2,i)=sqrt(((sigma_r(i2,i)-sigma_theta(i2,i))^2+(sigma_theta(i2,i)-sigma_z(i2,i))^2+(sigma_z(i2,i)-sigma_r(i2,i))^2)/2);
end
end
Hasta ahora, mi codigo de python es:
import math
from math import pi,cos,sqrt,log
import numpy as np
import matplotlib.pyplot as plt
#Holms case properties
E=120.66e9 ##Young modulus E=120.66GPa
alpha=14.4e-6 ##Expansion coef, Alpha=10e-6 mm-1K-1
v=0.3 ##Poisson modulus
a=101.6/1000 ##Tube inner radius 101.6 mm
b=304.8/1000 ##Tube outer radius 304.8 mm
c=20
w=(b-a)/c
z=72
ang=360/z
##Calculation of internal and external temperature profiles
r=[]
Theta=[]
index=0
for i in range(c):
r.append(index)
r[index]=a+index*w
index=index+1
index=0
for i in range(0,73):
Theta.append(index)
Theta[index]=i*ang
Theta[index]=Theta[index]*pi/180
w=len(r)
h=len(Theta)
##Angle in radians
T=np.zeros((w, h))##Temperature array, rows angle variation, column radial variation
for i in range(w):
##To create temperature distribution ##(See Logie et al. Eq. 53)
for i2 in range(h):
T[i][i2] = ((555.56 * b) / (b ** 2 - a ** 2)) * ((r[i] ** 2 - a ** 2) / r[i]) * cos(Theta[i2]) + 277.78 * (1 - log(b / r[i]) / log(b / a)) + 273.15
Tint=T[:,1]
Text=T[:,w]
##Fourier fitting
Tm_o=550.9
B1_o=555.6
Tm_i=273.15
B1_i=0
K_theta=[[],[]]
T_theta=[[],[]]
sigma_r=[[],[]]
sigma_theta=[[],[]]
sigma_z=[[],[]]
sigma_eq=[[],[]]
##Stress calculation
K=(Tm_i-Tm_o)/log(b/a)
for i in range (w):
for i2 in range (h):
K_theta[i2][i] = (r[i]*a*b)/(b**2-a**2)*(((B1_i*b-B1_o*a)/(a**2+b**2))*cos(Theta[i2]))
T_theta[i2][i]=T[i2][i]-(Tm_i-Tm_o)*log(b/r[i])/log(b/a)-Tm_o
sigma_r[i2][i]=(K*alpha*E/(2*(1-v)))*(-log(b/r[i])-(a**2/(b**2-a**2))*(1-b**2/r[i]**2)*log(b/a))+K_theta[i2][i]*((alpha*E)/(2*(1-v)))*(1-a**2/r[i]**2)*(1-b**2/r[i]**2)
sigma_theta[i2][i]=(K*alpha*E/(2*(1-v)))*(1-log(b/r[i])-(a**2/(b**2-a**2))*(1+b**2/r[i]**2)*log(b/a))+K_theta[i2][i]*(alpha*E/(2*(1-v)))*(3-(a**2+b**2)/r[i]**2-a**2*b**2/r[i]**4)
sigma_z[i2][i]=(K*alpha*E/(2*(1-v)))*(1-2*log(b/r[i])-((2*a**2)/(b**2-a**2))*log(b/a))+(K_theta[i2][i]*alpha*E*v/(1-v))*(2-(a**2+b**2)/r[i]**2)-alpha*E*T_theta[i2][i]
sigma_eq[i2][i]=sqrt(((sigma_r[i2][i]-sigma_theta([i2][i])**2+(sigma_theta[i2][i]-sigma_z[i2][i])**2+(sigma_z[i2][i]-sigma_r[i2][i])**2)/2)
Al compilar, me salta el error unexpected EOF while parsing al final del todo y no sé porque. Alguien sabe porque me sale este error?