I’m a newbie of julia, and I want to improve the performance of the code included massive iteration and calculation.
I
Even I red the manual, but I have no ability to adapt all of the solutions…
Here is simplified code.
using DelimitedFiles
using Plots
global main=readdlm("main.txt");
global main=reshape(main,150,27,55)
function Iteration()
#Temporary parameter
Pres=760; T1=500; T2=500; T3=5000;
experiment=readdlm("experiment.txt")
experiment=ifelse.(isnan.(experiment), 0, experiment)
main_raw=experiment[:,1]; I_raw=experiment[:,2];
main_start=findmin(main_raw); main_end=findmax(main_raw);
main_start=main_start[1]; main_end=main_end[1]
if main_start<300; main_start=300; end
if main_end>1200; main_end=1200; end
main_div=trunc(Int,(100*(main_end-main_start)))
#call parameters
para_A2C=readdlm("para_A2C.txt");
a1=para_A2C[:,1]; Ya1=para_A2C[:,2]; Ba1=para_A2C[:,3]; Da1=para_A2C[:,4]; wa1=para_A2C[:,5]; wb1=para_A2C[:,6]; wc1=para_A2C[:,7]; Ea1=para_A2C[:,8]; JG1=para_A2C[:,9]; DAN1=para_A2C[:,10];
para_A2B=readdlm("para_A2B.txt");
a2=para_A2B[:,1]; Ya2=para_A2B[:,2]; Ba2=para_A2B[:,3]; Da2=para_A2B[:,4]; wa2=para_A2B[:,5]; wb2=para_A2B[:,6]; wc2=para_A2B[:,7]; Ea2=para_A2B[:,8]; JG2=para_A2B[:,9]; DAN2=para_A2B[:,10];
CAR=readdlm("CAR.txt");
Re=readdlm("Re.txt");
MainCar=readdlm("MainCar.txt");
main_div=1000; #temporary
#### sub-coefficient calculation ####
Rv=Array{Float64,2}(undef,5,11);
Gv=Array{Float64,2}(undef,5,11);
I_sharp=Array{Float64,2}(undef,150,27);
I_broad=Array{Float64,1}(undef,main_div);
for A_2C=1:1:5;
for A_2B=1:1:11;
Rv[A_2C,A_2B]=(wa1[A_2C]*(a1[A_2C]+0.5)-wb1[A_2C]*(a1[A_2C]+0.5)^2+wc1[A_2C]*(a1[A_2C]+0.5)^3)-(wa2[A_2B]*(a2[A_2B]+0.5)-wb2[A_2B]*(a2[A_2B]+0.5)^2+wc2[A_2B]*(a2[A_2B]+0.5)^3);
Gv[A_2C,A_2B]=wa1[A_2C]*(a1[A_2C]+0.5)-wb1[A_2C]*(a1[A_2C]+0.5)^2+((a1[A_2C]+0.5)^3);
end
end
main_start=390; main_end=400; main_div=1000; #temporary
main_shift=zeros(55); #temporary
main_cal=LinRange(main_start,main_end,main_div); k=1:1:main_div
# 'crazy bottle neck'!!!
for A_2C=1:1:5 #A_2C 5
for A_2B=1:1:5 #A_2B 11
numb_v=(A_2B+11*(A_2C-1))
for branch=1:1:27
for J1=1:1:150 # 150
I_sharp[J1,branch]= Re[A_2C,A_2B]^2+*(1/(main[J1,branch,numb_v].-main_shift[numb_v])^4)*CAR[A_2C,A_2B]*MainCar[J1*exp(-1/T2)
I_broad[k]=I_broad[k]+I_sharp[J1,branch].*exp.(-1*(main_cal[k].-(main[J1,branch,numb_v].-main_shift[numb_v])))
end
end
end
end
end
In particular, most of the time is spent in the section where the ‘crazy bottle neck’ i denoted. (4 times for)
Please share your experiences and/or good paper (materials).