# Converted from vanheerden_0.m - Van Heerden: theta vs T/conv (s-shaped curve)importnumpyasnpfromscipy.optimizeimportfsolvefrommiscimportsave_asciip=dict(k_m=0.001,T_m=298.,E=8000.,c_Af=2.,C_p=4.,rho=1000.,T_f=298.,T_a=298.,U=0.,DeltaH_R=-3e5,)p['C_ps']=p['rho']*p['C_p']defst_st_cA(x,c_A,p):theta=x[0];T=x[1]k=p['k_m']*np.exp(-p['E']*(1./T-1./p['T_m']))return[p['c_Af']-(1+k*theta)*c_A,p['U']*theta*(p['T_a']-T)+p['C_ps']*(p['T_f']-T)-k*theta*c_A*p['DeltaH_R']]x0=[1.,p['T_f']]nc_As=200c_Avect=np.linspace(0.995*p['c_Af'],0.003*p['c_Af'],nc_As)tmp_table=[[0.,p['T_f'],0.,0.]]forc_Ainc_Avect:X,info_d,ier,msg=fsolve(lambdax:st_st_cA(x,c_A,p),x0,full_output=True)theta=X[0];T=X[1]conv=(p['c_Af']-c_A)/p['c_Af']tmp_table.append([theta,T,conv,float(ier)])x0=Xtable=np.array(tmp_table)save_ascii('vanheerden_0.dat',table)