-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
800 second compile time on ForwardDiff example #27488
Comments
ForwardDiff definitely is written in a way that's pretty mean to the compiler. It's great at triggering crazy compile times since it injects |
So is this a max tuple length being too small kind of thing? #22370 |
BandedMatrices.jl also had an almost 100x slowdown (see "bug-slowmul" branch): julia> A = brand(5,5,1,1); b = randn(5); @time A*b # v0.6.2
0.375991 seconds (335.46 k allocations: 16.421 MiB) VS julia> A = brand(5,5,1,1); b = randn(5); @time A*b # v0.7, branch "bug-slowmul"
24.676427 seconds (57.04 M allocations: 5.038 GiB, 3.76% gc time) I sped this up to "only" 15x slowdown on master by making the code type stable: julia> A = brand(5,5,1,1); b = randn(5); @time A*b # v0.7, branch "master"
5.644144 seconds (16.42 M allocations: 1.252 GiB, 4.54% gc time) |
That seems unrelated. This is true on v0.6.3 and is not related to v0.7 regressions. |
I'm not sure what you mean: julia> A = brand(5,5,1,1); b = randn(5); @time A*b # v0.6.3
0.418718 seconds (557.03 k allocations: 25.756 MiB, 13.73% gc time) Edit: OHH, your issue is true on v0.6.3 |
This is where nobody has a concrete answer for: My feeling also was that type stable code is faster to compile whereas type unstable code might lead to very long compilation times. According to https://discourse.julialang.org/t/meaning-type-piracy-and-method-merging/11003/44 this is not true though. |
I'm not sure this is related though. This is type-stable and was tracked down to issues with large NTuples. |
I filed a separate issue #27512 |
Here's the example updated to work on v1.0. P2D2c = function(dy,y,pars,t)
Dbulk = pars[1]
Dsn = pars[2]
Dsp = pars[3]
F = 96487.000000
R = 8.314300
Rpn = pars[4]
Rpp = pars[5]
Tr = 298.150000
brugn = pars[6]
brugp = pars[7]
brugs = pars[8]
c0 = pars[9]
ctn = pars[10]
ctp = pars[11]
efn = pars[12]
efp = pars[13]
en = pars[14]
ep = pars[15]
es = pars[16]
kn = pars[17]
kp = pars[18]
ln1 = pars[19]
lp = pars[20]
ls = pars[21]
sigmn = pars[22]
sigmp = pars[23]
socn = pars[24]
socp = pars[25]
t1 = pars[26]
current = -1.0
capacity=17.5
rate=-2.
iapp=capacity*rate
up=[0.,0.]
Kr = pars[27]
ap = 3/Rpp*(1-ep-efp)
an = 3/Rpn*(1-en-efn)
sigmap = sigmp*(1-ep-efp)
sigman = sigmn*(1-en-efn)
D2pos = ep^brugp*Dbulk
D2sep = es^brugs*Dbulk
D2neg = en^brugn*Dbulk
dy[1] = 1/ep*(64.0*D2pos/lp^2*(y[60]-2.0*y[1]+y[2])+2.0*ap*(1.0-1.0*t1)*kp*(y[1]*c0)^.5*(-1.0*y[110]*ctp+ctp)^.5*(y[110]*ctp)^.5*sinh(.5*F/R/Tr*(y[86]-1.0*y[65]-1.0*ocp_cathode(y[110],up)))/c0)
dy[2] = 1/ep*(64.0*D2pos/lp^2*(y[1]-2.0*y[2]+y[3])+2.0*ap*(1.0-1.0*t1)*kp*(y[2]*c0)^.5*(-1.0*y[111]*ctp+ctp)^.5*(y[111]*ctp)^.5*sinh(.5*F/R/Tr*(y[87]-1.0*y[66]-1.0*ocp_cathode(y[111],up)))/c0)
dy[3] = 1/ep*(64.0*D2pos/lp^2*(y[2]-2.0*y[3]+y[4])+2.0*ap*(1.0-1.0*t1)*kp*(y[3]*c0)^.5*(-1.0*y[112]*ctp+ctp)^.5*(y[112]*ctp)^.5*sinh(.5*F/R/Tr*(y[88]-1.0*y[67]-1.0*ocp_cathode(y[112],up)))/c0)
dy[4] = 1/ep*(64.0*D2pos/lp^2*(y[3]-2.0*y[4]+y[5])+2.0*ap*(1.0-1.0*t1)*kp*(y[4]*c0)^.5*(-1.0*y[113]*ctp+ctp)^.5*(y[113]*ctp)^.5*sinh(.5*F/R/Tr*(y[89]-1.0*y[68]-1.0*ocp_cathode(y[113],up)))/c0)
dy[5] = 1/ep*(64.0*D2pos/lp^2*(y[4]-2.0*y[5]+y[6])+2.0*ap*(1.0-1.0*t1)*kp*(y[5]*c0)^.5*(-1.0*y[114]*ctp+ctp)^.5*(y[114]*ctp)^.5*sinh(.5*F/R/Tr*(y[90]-1.0*y[69]-1.0*ocp_cathode(y[114],up)))/c0)
dy[6] = 1/ep*(64.0*D2pos/lp^2*(y[5]-2.0*y[6]+y[7])+2.0*ap*(1.0-1.0*t1)*kp*(y[6]*c0)^.5*(-1.0*y[115]*ctp+ctp)^.5*(y[115]*ctp)^.5*sinh(.5*F/R/Tr*(y[91]-1.0*y[70]-1.0*ocp_cathode(y[115],up)))/c0)
dy[7] = 1/ep*(64.0*D2pos/lp^2*(y[6]-2.0*y[7]+y[61])+2.0*ap*(1.0-1.0*t1)*kp*(y[7]*c0)^.5*(-1.0*y[116]*ctp+ctp)^.5*(y[116]*ctp)^.5*sinh(.5*F/R/Tr*(y[92]-1.0*y[71]-1.0*ocp_cathode(y[116],up)))/c0)
dy[8] = 16.0/es*D2sep/ls^2*(y[61]-2.0*y[8]+y[9])
dy[9] = 16.0/es*D2sep/ls^2*(y[8]-2.0*y[9]+y[10])
dy[10] = 16.0/es*D2sep/ls^2*(y[9]-2.0*y[10]+y[62])
dy[11] = 1/en*(64.0*D2neg/ln1^2*(y[62]-2.0*y[11]+y[12])+2.0*an*(1.0-1.0*t1)*kn*(y[11]*c0)^.5*(-1.0*y[124]*ctn+ctn)^.5*(y[124]*ctn)^.5*sinh(.5*F/R/Tr*(y[95]-1.0*y[77]+.5e-1-2.325*exp(-100.0*y[124]^1.15)+.1721*tanh(20.000000*y[124]-21.000000)+.25e-2*tanh(39.347962*y[124]-37.241379)+.34e-1*tanh(89.411765*y[124]-6.0294118)+.2e-2*tanh(7.0422535*y[124]-1.3661972)+.155e-1*tanh(77.519380*y[124]-8.1395349)))/c0)
dy[12] = 1/en*(64.0*D2neg/ln1^2*(y[11]-2.0*y[12]+y[13])+2.0*an*(1.0-1.0*t1)*kn*(y[12]*c0)^.5*(-1.0*y[125]*ctn+ctn)^.5*(y[125]*ctn)^.5*sinh(.5*F/R/Tr*(y[96]-1.0*y[78]+.5e-1-2.325*exp(-100.0*y[125]^1.15)+.1721*tanh(20.000000*y[125]-21.000000)+.25e-2*tanh(39.347962*y[125]-37.241379)+.34e-1*tanh(89.411765*y[125]-6.0294118)+.2e-2*tanh(7.0422535*y[125]-1.3661972)+.155e-1*tanh(77.519380*y[125]-8.1395349)))/c0)
dy[13] = 1/en*(64.0*D2neg/ln1^2*(y[12]-2.0*y[13]+y[14])+2.0*an*(1.0-1.0*t1)*kn*(y[13]*c0)^.5*(-1.0*y[126]*ctn+ctn)^.5*(y[126]*ctn)^.5*sinh(.5*F/R/Tr*(y[97]-1.0*y[79]+.5e-1-2.325*exp(-100.0*y[126]^1.15)+.1721*tanh(20.000000*y[126]-21.000000)+.25e-2*tanh(39.347962*y[126]-37.241379)+.34e-1*tanh(89.411765*y[126]-6.0294118)+.2e-2*tanh(7.0422535*y[126]-1.3661972)+.155e-1*tanh(77.519380*y[126]-8.1395349)))/c0)
dy[14] = 1/en*(64.0*D2neg/ln1^2*(y[13]-2.0*y[14]+y[15])+2.0*an*(1.0-1.0*t1)*kn*(y[14]*c0)^.5*(-1.0*y[127]*ctn+ctn)^.5*(y[127]*ctn)^.5*sinh(.5*F/R/Tr*(y[98]-1.0*y[80]+.5e-1-2.325*exp(-100.0*y[127]^1.15)+.1721*tanh(20.000000*y[127]-21.000000)+.25e-2*tanh(39.347962*y[127]-37.241379)+.34e-1*tanh(89.411765*y[127]-6.0294118)+.2e-2*tanh(7.0422535*y[127]-1.3661972)+.155e-1*tanh(77.519380*y[127]-8.1395349)))/c0)
dy[15] = 1/en*(64.0*D2neg/ln1^2*(y[14]-2.0*y[15]+y[16])+2.0*an*(1.0-1.0*t1)*kn*(y[15]*c0)^.5*(-1.0*y[128]*ctn+ctn)^.5*(y[128]*ctn)^.5*sinh(.5*F/R/Tr*(y[99]-1.0*y[81]+.5e-1-2.325*exp(-100.0*y[128]^1.15)+.1721*tanh(20.000000*y[128]-21.000000)+.25e-2*tanh(39.347962*y[128]-37.241379)+.34e-1*tanh(89.411765*y[128]-6.0294118)+.2e-2*tanh(7.0422535*y[128]-1.3661972)+.155e-1*tanh(77.519380*y[128]-8.1395349)))/c0)
dy[16] = 1/en*(64.0*D2neg/ln1^2*(y[15]-2.0*y[16]+y[17])+2.0*an*(1.0-1.0*t1)*kn*(y[16]*c0)^.5*(-1.0*y[129]*ctn+ctn)^.5*(y[129]*ctn)^.5*sinh(.5*F/R/Tr*(y[100]-1.0*y[82]+.5e-1-2.325*exp(-100.0*y[129]^1.15)+.1721*tanh(20.000000*y[129]-21.000000)+.25e-2*tanh(39.347962*y[129]-37.241379)+.34e-1*tanh(89.411765*y[129]-6.0294118)+.2e-2*tanh(7.0422535*y[129]-1.3661972)+.155e-1*tanh(77.519380*y[129]-8.1395349)))/c0)
dy[17] = 1/en*(64.0*D2neg/ln1^2*(y[16]-2.0*y[17]+y[63])+2.0*an*(1.0-1.0*t1)*kn*(y[17]*c0)^.5*(-1.0*y[130]*ctn+ctn)^.5*(y[130]*ctn)^.5*sinh(.5*F/R/Tr*(y[101]-1.0*y[83]+.5e-1-2.325*exp(-100.0*y[130]^1.15)+.1721*tanh(20.000000*y[130]-21.000000)+.25e-2*tanh(39.347962*y[130]-37.241379)+.34e-1*tanh(89.411765*y[130]-6.0294118)+.2e-2*tanh(7.0422535*y[130]-1.3661972)+.155e-1*tanh(77.519380*y[130]-8.1395349)))/c0)
dy[18] = 16.0*(Dsp*(y[25]-1.0*y[103])+Dsp*(y[103]-2.0*y[18]+y[25]))/Rpp^2
dy[19] = 16.0*(Dsp*(y[26]-1.0*y[104])+Dsp*(y[104]-2.0*y[19]+y[26]))/Rpp^2
dy[20] = 16.0*(Dsp*(y[27]-1.0*y[105])+Dsp*(y[105]-2.0*y[20]+y[27]))/Rpp^2
dy[21] = 16.0*(Dsp*(y[28]-1.0*y[106])+Dsp*(y[106]-2.0*y[21]+y[28]))/Rpp^2
dy[22] = 16.0*(Dsp*(y[29]-1.0*y[107])+Dsp*(y[107]-2.0*y[22]+y[29]))/Rpp^2
dy[23] = 16.0*(Dsp*(y[30]-1.0*y[108])+Dsp*(y[108]-2.0*y[23]+y[30]))/Rpp^2
dy[24] = 16.0*(Dsp*(y[31]-1.0*y[109])+Dsp*(y[109]-2.0*y[24]+y[31]))/Rpp^2
dy[25] = 4.0*(2.0*Dsp*(y[32]-1.0*y[18])+4.0*Dsp*(y[18]-2.0*y[25]+y[32]))/Rpp^2
dy[26] = 4.0*(2.0*Dsp*(y[33]-1.0*y[19])+4.0*Dsp*(y[19]-2.0*y[26]+y[33]))/Rpp^2
dy[27] = 4.0*(2.0*Dsp*(y[34]-1.0*y[20])+4.0*Dsp*(y[20]-2.0*y[27]+y[34]))/Rpp^2
dy[28] = 4.0*(2.0*Dsp*(y[35]-1.0*y[21])+4.0*Dsp*(y[21]-2.0*y[28]+y[35]))/Rpp^2
dy[29] = 4.0*(2.0*Dsp*(y[36]-1.0*y[22])+4.0*Dsp*(y[22]-2.0*y[29]+y[36]))/Rpp^2
dy[30] = 4.0*(2.0*Dsp*(y[37]-1.0*y[23])+4.0*Dsp*(y[23]-2.0*y[30]+y[37]))/Rpp^2
dy[31] = 4.0*(2.0*Dsp*(y[38]-1.0*y[24])+4.0*Dsp*(y[24]-2.0*y[31]+y[38]))/Rpp^2
dy[32] = 1.777777778*(3.0*Dsp*(y[110]-1.0*y[25])+9.0*Dsp*(y[25]-2.0*y[32]+y[110]))/Rpp^2
dy[33] = 1.777777778*(3.0*Dsp*(y[111]-1.0*y[26])+9.0*Dsp*(y[26]-2.0*y[33]+y[111]))/Rpp^2
dy[34] = 1.777777778*(3.0*Dsp*(y[112]-1.0*y[27])+9.0*Dsp*(y[27]-2.0*y[34]+y[112]))/Rpp^2
dy[35] = 1.777777778*(3.0*Dsp*(y[113]-1.0*y[28])+9.0*Dsp*(y[28]-2.0*y[35]+y[113]))/Rpp^2
dy[36] = 1.777777778*(3.0*Dsp*(y[114]-1.0*y[29])+9.0*Dsp*(y[29]-2.0*y[36]+y[114]))/Rpp^2
dy[37] = 1.777777778*(3.0*Dsp*(y[115]-1.0*y[30])+9.0*Dsp*(y[30]-2.0*y[37]+y[115]))/Rpp^2
dy[38] = 1.777777778*(3.0*Dsp*(y[116]-1.0*y[31])+9.0*Dsp*(y[31]-2.0*y[38]+y[116]))/Rpp^2
dy[39] = 16.0*Dsn*(2.0*y[46]-2.0*y[39])/Rpn^2
dy[40] = 16.0*Dsn*(2.0*y[47]-2.0*y[40])/Rpn^2
dy[41] = 16.0*Dsn*(2.0*y[48]-2.0*y[41])/Rpn^2
dy[42] = 16.0*Dsn*(2.0*y[49]-2.0*y[42])/Rpn^2
dy[43] = 16.0*Dsn*(2.0*y[50]-2.0*y[43])/Rpn^2
dy[44] = 16.0*Dsn*(2.0*y[51]-2.0*y[44])/Rpn^2
dy[45] = 16.0*Dsn*(2.0*y[52]-2.0*y[45])/Rpn^2
dy[46] = 4.0*Dsn*(6.0*y[53]+2.0*y[39]-8.0*y[46])/Rpn^2
dy[47] = 4.0*Dsn*(6.0*y[54]+2.0*y[40]-8.0*y[47])/Rpn^2
dy[48] = 4.0*Dsn*(6.0*y[55]+2.0*y[41]-8.0*y[48])/Rpn^2
dy[49] = 4.0*Dsn*(6.0*y[56]+2.0*y[42]-8.0*y[49])/Rpn^2
dy[50] = 4.0*Dsn*(6.0*y[57]+2.0*y[43]-8.0*y[50])/Rpn^2
dy[51] = 4.0*Dsn*(6.0*y[58]+2.0*y[44]-8.0*y[51])/Rpn^2
dy[52] = 4.0*Dsn*(6.0*y[59]+2.0*y[45]-8.0*y[52])/Rpn^2
dy[53] = 1.777777778*Dsn*(12.0*y[124]+6.0*y[46]-18.0*y[53])/Rpn^2
dy[54] = 1.777777778*Dsn*(12.0*y[125]+6.0*y[47]-18.0*y[54])/Rpn^2
dy[55] = 1.777777778*Dsn*(12.0*y[126]+6.0*y[48]-18.0*y[55])/Rpn^2
dy[56] = 1.777777778*Dsn*(12.0*y[127]+6.0*y[49]-18.0*y[56])/Rpn^2
dy[57] = 1.777777778*Dsn*(12.0*y[128]+6.0*y[50]-18.0*y[57])/Rpn^2
dy[58] = 1.777777778*Dsn*(12.0*y[129]+6.0*y[51]-18.0*y[58])/Rpn^2
dy[59] = 1.777777778*Dsn*(12.0*y[130]+6.0*y[52]-18.0*y[59])/Rpn^2
dy[60] = 4.0*D2pos*(-1.0*y[2]-3.0*y[60]+4.0*y[1])/lp
dy[61] = 4.0*D2pos*(y[6]+3.0*y[61]-4.0*y[7])/lp-2.0*D2sep*(-1.0*y[9]-3.0*y[61]+4.0*y[8])/ls
dy[62] = 2.0*D2sep*(y[9]+3.0*y[62]-4.0*y[10])/ls-4.0*D2neg*(-1.0*y[12]-3.0*y[62]+4.0*y[11])/ln1
dy[63] = 4.0*D2neg*(y[16]+3.0*y[63]-4.0*y[17])/ln1
dy[64] = 4.0*(-1.0*y[66]-3.0*y[64]+4.0*y[65])/lp
dy[65] = -4.0*sigmap/lp*(y[87]-1.0*y[85])-4.0*ep^brugp*(.41253e-1+.5007e-3*y[1]-.47212e-6*y[1]^2+.15904e-9*y[1]^3-.16018e-13*y[1]^4)/lp*(y[66]-1.0*y[64])+8.0*ep^brugp*(.41253e-1+.5007e-3*y[1]-.47212e-6*y[1]^2+.15904e-9*y[1]^3-.16018e-13*y[1]^4)*R*Tr/F*(1.0-1.0*t1)/lp*(y[2]-1.0*y[60])/y[1]-iapp
dy[66] = -4.0*sigmap/lp*(y[88]-1.0*y[86])-4.0*ep^brugp*(.41253e-1+.5007e-3*y[2]-.47212e-6*y[2]^2+.15904e-9*y[2]^3-.16018e-13*y[2]^4)/lp*(y[67]-1.0*y[65])+8.0*ep^brugp*(.41253e-1+.5007e-3*y[2]-.47212e-6*y[2]^2+.15904e-9*y[2]^3-.16018e-13*y[2]^4)*R*Tr/F*(1.0-1.0*t1)/lp*(y[3]-1.0*y[1])/y[2]-iapp
dy[67] = -4.0*sigmap/lp*(y[89]-1.0*y[87])-4.0*ep^brugp*(.41253e-1+.5007e-3*y[3]-.47212e-6*y[3]^2+.15904e-9*y[3]^3-.16018e-13*y[3]^4)/lp*(y[68]-1.0*y[66])+8.0*ep^brugp*(.41253e-1+.5007e-3*y[3]-.47212e-6*y[3]^2+.15904e-9*y[3]^3-.16018e-13*y[3]^4)*R*Tr/F*(1.0-1.0*t1)/lp*(y[4]-1.0*y[2])/y[3]-iapp
dy[68] = -4.0*sigmap/lp*(y[90]-1.0*y[88])-4.0*ep^brugp*(.41253e-1+.5007e-3*y[4]-.47212e-6*y[4]^2+.15904e-9*y[4]^3-.16018e-13*y[4]^4)/lp*(y[69]-1.0*y[67])+8.0*ep^brugp*(.41253e-1+.5007e-3*y[4]-.47212e-6*y[4]^2+.15904e-9*y[4]^3-.16018e-13*y[4]^4)*R*Tr/F*(1.0-1.0*t1)/lp*(y[5]-1.0*y[3])/y[4]-iapp
dy[69] = -4.0*sigmap/lp*(y[91]-1.0*y[89])-4.0*ep^brugp*(.41253e-1+.5007e-3*y[5]-.47212e-6*y[5]^2+.15904e-9*y[5]^3-.16018e-13*y[5]^4)/lp*(y[70]-1.0*y[68])+8.0*ep^brugp*(.41253e-1+.5007e-3*y[5]-.47212e-6*y[5]^2+.15904e-9*y[5]^3-.16018e-13*y[5]^4)*R*Tr/F*(1.0-1.0*t1)/lp*(y[6]-1.0*y[4])/y[5]-iapp
dy[70] = -4.0*sigmap/lp*(y[92]-1.0*y[90])-4.0*ep^brugp*(.41253e-1+.5007e-3*y[6]-.47212e-6*y[6]^2+.15904e-9*y[6]^3-.16018e-13*y[6]^4)/lp*(y[71]-1.0*y[69])+8.0*ep^brugp*(.41253e-1+.5007e-3*y[6]-.47212e-6*y[6]^2+.15904e-9*y[6]^3-.16018e-13*y[6]^4)*R*Tr/F*(1.0-1.0*t1)/lp*(y[7]-1.0*y[5])/y[6]-iapp
dy[71] = -4.0*sigmap/lp*(y[93]-1.0*y[91])-4.0*ep^brugp*(.41253e-1+.5007e-3*y[7]-.47212e-6*y[7]^2+.15904e-9*y[7]^3-.16018e-13*y[7]^4)/lp*(y[72]-1.0*y[70])+8.0*ep^brugp*(.41253e-1+.5007e-3*y[7]-.47212e-6*y[7]^2+.15904e-9*y[7]^3-.16018e-13*y[7]^4)*R*Tr/F*(1.0-1.0*t1)/lp*(y[61]-1.0*y[6])/y[7]-iapp
dy[72] = 4.0*ep^brugp*(.41253e-1+.5007e-3*y[61]-.47212e-6*y[61]^2+.15904e-9*y[61]^3-.16018e-13*y[61]^4)*(y[70]+3.0*y[72]-4.0*y[71])/lp-2.0*es^brugs*(.41253e-1+.5007e-3*y[61]-.47212e-6*y[61]^2+.15904e-9*y[61]^3-.16018e-13*y[61]^4)*(-1.0*y[74]-3.0*y[72]+4.0*y[73])/ls
dy[73] = -2.0*es^brugs*(.41253e-1+.5007e-3*y[8]-.47212e-6*y[8]^2+.15904e-9*y[8]^3-.16018e-13*y[8]^4)/ls*(y[74]-1.0*y[72])+4.0*es^brugs*(.41253e-1+.5007e-3*y[8]-.47212e-6*y[8]^2+.15904e-9*y[8]^3-.16018e-13*y[8]^4)*R*Tr/F*(1.0-1.0*t1)/ls*(y[9]-1.0*y[61])/y[8]-iapp
dy[74] = -2.0*es^brugs*(.41253e-1+.5007e-3*y[9]-.47212e-6*y[9]^2+.15904e-9*y[9]^3-.16018e-13*y[9]^4)/ls*(y[75]-1.0*y[73])+4.0*es^brugs*(.41253e-1+.5007e-3*y[9]-.47212e-6*y[9]^2+.15904e-9*y[9]^3-.16018e-13*y[9]^4)*R*Tr/F*(1.0-1.0*t1)/ls*(y[10]-1.0*y[8])/y[9]-iapp
dy[75] = -2.0*es^brugs*(.41253e-1+.5007e-3*y[10]-.47212e-6*y[10]^2+.15904e-9*y[10]^3-.16018e-13*y[10]^4)/ls*(y[76]-1.0*y[74])+4.0*es^brugs*(.41253e-1+.5007e-3*y[10]-.47212e-6*y[10]^2+.15904e-9*y[10]^3-.16018e-13*y[10]^4)*R*Tr/F*(1.0-1.0*t1)/ls*(y[62]-1.0*y[9])/y[10]-iapp
dy[76] = 2.0*es^brugs*(.41253e-1+.5007e-3*y[62]-.47212e-6*y[62]^2+.15904e-9*y[62]^3-.16018e-13*y[62]^4)*(y[74]+3.0*y[76]-4.0*y[75])/ls-4.0*en^brugn*(.41253e-1+.5007e-3*y[62]-.47212e-6*y[62]^2+.15904e-9*y[62]^3-.16018e-13*y[62]^4)*(-1.0*y[78]-3.0*y[76]+4.0*y[77])/ln1
dy[77] = -4.0*sigman/ln1*(y[96]-1.0*y[94])-4.0*en^brugn*(.41253e-1+.5007e-3*y[11]-.47212e-6*y[11]^2+.15904e-9*y[11]^3-.16018e-13*y[11]^4)/ln1*(y[78]-1.0*y[76])+8.0*en^brugn*(.41253e-1+.5007e-3*y[11]-.47212e-6*y[11]^2+.15904e-9*y[11]^3-.16018e-13*y[11]^4)*R*Tr/F*(1.0-1.0*t1)/ln1*(y[12]-1.0*y[62])/y[11]-iapp
dy[78] = -4.0*sigman/ln1*(y[97]-1.0*y[95])-4.0*en^brugn*(.41253e-1+.5007e-3*y[12]-.47212e-6*y[12]^2+.15904e-9*y[12]^3-.16018e-13*y[12]^4)/ln1*(y[79]-1.0*y[77])+8.0*en^brugn*(.41253e-1+.5007e-3*y[12]-.47212e-6*y[12]^2+.15904e-9*y[12]^3-.16018e-13*y[12]^4)*R*Tr/F*(1.0-1.0*t1)/ln1*(y[13]-1.0*y[11])/y[12]-iapp
dy[79] = -4.0*sigman/ln1*(y[98]-1.0*y[96])-4.0*en^brugn*(.41253e-1+.5007e-3*y[13]-.47212e-6*y[13]^2+.15904e-9*y[13]^3-.16018e-13*y[13]^4)/ln1*(y[80]-1.0*y[78])+8.0*en^brugn*(.41253e-1+.5007e-3*y[13]-.47212e-6*y[13]^2+.15904e-9*y[13]^3-.16018e-13*y[13]^4)*R*Tr/F*(1.0-1.0*t1)/ln1*(y[14]-1.0*y[12])/y[13]-iapp
dy[80] = -4.0*sigman/ln1*(y[99]-1.0*y[97])-4.0*en^brugn*(.41253e-1+.5007e-3*y[14]-.47212e-6*y[14]^2+.15904e-9*y[14]^3-.16018e-13*y[14]^4)/ln1*(y[81]-1.0*y[79])+8.0*en^brugn*(.41253e-1+.5007e-3*y[14]-.47212e-6*y[14]^2+.15904e-9*y[14]^3-.16018e-13*y[14]^4)*R*Tr/F*(1.0-1.0*t1)/ln1*(y[15]-1.0*y[13])/y[14]-iapp
dy[81] = -4.0*sigman/ln1*(y[100]-1.0*y[98])-4.0*en^brugn*(.41253e-1+.5007e-3*y[15]-.47212e-6*y[15]^2+.15904e-9*y[15]^3-.16018e-13*y[15]^4)/ln1*(y[82]-1.0*y[80])+8.0*en^brugn*(.41253e-1+.5007e-3*y[15]-.47212e-6*y[15]^2+.15904e-9*y[15]^3-.16018e-13*y[15]^4)*R*Tr/F*(1.0-1.0*t1)/ln1*(y[16]-1.0*y[14])/y[15]-iapp
dy[82] = -4.0*sigman/ln1*(y[101]-1.0*y[99])-4.0*en^brugn*(.41253e-1+.5007e-3*y[16]-.47212e-6*y[16]^2+.15904e-9*y[16]^3-.16018e-13*y[16]^4)/ln1*(y[83]-1.0*y[81])+8.0*en^brugn*(.41253e-1+.5007e-3*y[16]-.47212e-6*y[16]^2+.15904e-9*y[16]^3-.16018e-13*y[16]^4)*R*Tr/F*(1.0-1.0*t1)/ln1*(y[17]-1.0*y[15])/y[16]-iapp
dy[83] = -4.0*sigman/ln1*(y[102]-1.0*y[100])-4.0*en^brugn*(.41253e-1+.5007e-3*y[17]-.47212e-6*y[17]^2+.15904e-9*y[17]^3-.16018e-13*y[17]^4)/ln1*(y[84]-1.0*y[82])+8.0*en^brugn*(.41253e-1+.5007e-3*y[17]-.47212e-6*y[17]^2+.15904e-9*y[17]^3-.16018e-13*y[17]^4)*R*Tr/F*(1.0-1.0*t1)/ln1*(y[63]-1.0*y[16])/y[17]-iapp
dy[84] = y[84]
dy[85] = 4.0*(-1.0*y[87]-3.0*y[85]+4.0*y[86])/lp+1.0*iapp/sigmap
dy[86] = 64.0*sigmap/lp^2*(y[85]-2.0*y[86]+y[87])-2.0*ap*F*kp*(y[1]*c0)^.5*(-1.0*y[110]*ctp+ctp)^.5*(y[110]*ctp)^.5*sinh(.5*F/R/Tr*(y[86]-1.0*y[65]-1.0*ocp_cathode(y[110],up)))
dy[87] = 64.0*sigmap/lp^2*(y[86]-2.0*y[87]+y[88])-2.0*ap*F*kp*(y[2]*c0)^.5*(-1.0*y[111]*ctp+ctp)^.5*(y[111]*ctp)^.5*sinh(.5*F/R/Tr*(y[87]-1.0*y[66]-1.0*ocp_cathode(y[111],up)))
dy[88] = 64.0*sigmap/lp^2*(y[87]-2.0*y[88]+y[89])-2.0*ap*F*kp*(y[3]*c0)^.5*(-1.0*y[112]*ctp+ctp)^.5*(y[112]*ctp)^.5*sinh(.5*F/R/Tr*(y[88]-1.0*y[67]-1.0*ocp_cathode(y[112],up)))
dy[89] = 64.0*sigmap/lp^2*(y[88]-2.0*y[89]+y[90])-2.0*ap*F*kp*(y[4]*c0)^.5*(-1.0*y[113]*ctp+ctp)^.5*(y[113]*ctp)^.5*sinh(.5*F/R/Tr*(y[89]-1.0*y[68]-1.0*ocp_cathode(y[113],up)))
dy[90] = 64.0*sigmap/lp^2*(y[89]-2.0*y[90]+y[91])-2.0*ap*F*kp*(y[5]*c0)^.5*(-1.0*y[114]*ctp+ctp)^.5*(y[114]*ctp)^.5*sinh(.5*F/R/Tr*(y[90]-1.0*y[69]-1.0*ocp_cathode(y[114],up)))
dy[91] = 64.0*sigmap/lp^2*(y[90]-2.0*y[91]+y[92])-2.0*ap*F*kp*(y[6]*c0)^.5*(-1.0*y[115]*ctp+ctp)^.5*(y[115]*ctp)^.5*sinh(.5*F/R/Tr*(y[91]-1.0*y[70]-1.0*ocp_cathode(y[115],up)))
dy[92] = 64.0*sigmap/lp^2*(y[91]-2.0*y[92]+y[93])-2.0*ap*F*kp*(y[7]*c0)^.5*(-1.0*y[116]*ctp+ctp)^.5*(y[116]*ctp)^.5*sinh(.5*F/R/Tr*(y[92]-1.0*y[71]-1.0*ocp_cathode(y[116],up)))
dy[93] = 4.0*(y[91]+3.0*y[93]-4.0*y[92])/lp
dy[94] = 4.0*(-1.0*y[96]-3.0*y[94]+4.0*y[95])/ln1
dy[95] = 64.0*sigman/ln1^2*(y[94]-2.0*y[95]+y[96])-2.0*an*F*kn*(y[11]*c0)^.5*(-1.0*y[124]*ctn+ctn)^.5*(y[124]*ctn)^.5*sinh(.5*F/R/Tr*(y[95]-1.0*y[77]+.5e-1-2.325*exp(-100.0*y[124]^1.15)+.1721*tanh(20.000000*y[124]-21.000000)+.25e-2*tanh(39.347962*y[124]-37.241379)+.34e-1*tanh(89.411765*y[124]-6.0294118)+.2e-2*tanh(7.0422535*y[124]-1.3661972)+.155e-1*tanh(77.519380*y[124]-8.1395349)))
dy[96] = 64.0*sigman/ln1^2*(y[95]-2.0*y[96]+y[97])-2.0*an*F*kn*(y[12]*c0)^.5*(-1.0*y[125]*ctn+ctn)^.5*(y[125]*ctn)^.5*sinh(.5*F/R/Tr*(y[96]-1.0*y[78]+.5e-1-2.325*exp(-100.0*y[125]^1.15)+.1721*tanh(20.000000*y[125]-21.000000)+.25e-2*tanh(39.347962*y[125]-37.241379)+.34e-1*tanh(89.411765*y[125]-6.0294118)+.2e-2*tanh(7.0422535*y[125]-1.3661972)+.155e-1*tanh(77.519380*y[125]-8.1395349)))
dy[97] = 64.0*sigman/ln1^2*(y[96]-2.0*y[97]+y[98])-2.0*an*F*kn*(y[13]*c0)^.5*(-1.0*y[126]*ctn+ctn)^.5*(y[126]*ctn)^.5*sinh(.5*F/R/Tr*(y[97]-1.0*y[79]+.5e-1-2.325*exp(-100.0*y[126]^1.15)+.1721*tanh(20.000000*y[126]-21.000000)+.25e-2*tanh(39.347962*y[126]-37.241379)+.34e-1*tanh(89.411765*y[126]-6.0294118)+.2e-2*tanh(7.0422535*y[126]-1.3661972)+.155e-1*tanh(77.519380*y[126]-8.1395349)))
dy[98] = 64.0*sigman/ln1^2*(y[97]-2.0*y[98]+y[99])-2.0*an*F*kn*(y[14]*c0)^.5*(-1.0*y[127]*ctn+ctn)^.5*(y[127]*ctn)^.5*sinh(.5*F/R/Tr*(y[98]-1.0*y[80]+.5e-1-2.325*exp(-100.0*y[127]^1.15)+.1721*tanh(20.000000*y[127]-21.000000)+.25e-2*tanh(39.347962*y[127]-37.241379)+.34e-1*tanh(89.411765*y[127]-6.0294118)+.2e-2*tanh(7.0422535*y[127]-1.3661972)+.155e-1*tanh(77.519380*y[127]-8.1395349)))
dy[99] = 64.0*sigman/ln1^2*(y[98]-2.0*y[99]+y[100])-2.0*an*F*kn*(y[15]*c0)^.5*(-1.0*y[128]*ctn+ctn)^.5*(y[128]*ctn)^.5*sinh(.5*F/R/Tr*(y[99]-1.0*y[81]+.5e-1-2.325*exp(-100.0*y[128]^1.15)+.1721*tanh(20.000000*y[128]-21.000000)+.25e-2*tanh(39.347962*y[128]-37.241379)+.34e-1*tanh(89.411765*y[128]-6.0294118)+.2e-2*tanh(7.0422535*y[128]-1.3661972)+.155e-1*tanh(77.519380*y[128]-8.1395349)))
dy[100] = 64.0*sigman/ln1^2*(y[99]-2.0*y[100]+y[101])-2.0*an*F*kn*(y[16]*c0)^.5*(-1.0*y[129]*ctn+ctn)^.5*(y[129]*ctn)^.5*sinh(.5*F/R/Tr*(y[100]-1.0*y[82]+.5e-1-2.325*exp(-100.0*y[129]^1.15)+.1721*tanh(20.000000*y[129]-21.000000)+.25e-2*tanh(39.347962*y[129]-37.241379)+.34e-1*tanh(89.411765*y[129]-6.0294118)+.2e-2*tanh(7.0422535*y[129]-1.3661972)+.155e-1*tanh(77.519380*y[129]-8.1395349)))
dy[101] = 64.0*sigman/ln1^2*(y[100]-2.0*y[101]+y[102])-2.0*an*F*kn*(y[17]*c0)^.5*(-1.0*y[130]*ctn+ctn)^.5*(y[130]*ctn)^.5*sinh(.5*F/R/Tr*(y[101]-1.0*y[83]+.5e-1-2.325*exp(-100.0*y[130]^1.15)+.1721*tanh(20.000000*y[130]-21.000000)+.25e-2*tanh(39.347962*y[130]-37.241379)+.34e-1*tanh(89.411765*y[130]-6.0294118)+.2e-2*tanh(7.0422535*y[130]-1.3661972)+.155e-1*tanh(77.519380*y[130]-8.1395349)))
dy[102] = 4.0*(y[100]+3.0*y[102]-4.0*y[101])/ln1+1.0*iapp/sigman
dy[103] = -2.0*(-1.0*y[25]-3.0*y[103]+4.0*y[18])/Rpp
dy[104] = -2.0*(-1.0*y[26]-3.0*y[104]+4.0*y[19])/Rpp
dy[105] = -2.0*(-1.0*y[27]-3.0*y[105]+4.0*y[20])/Rpp
dy[106] = -2.0*(-1.0*y[28]-3.0*y[106]+4.0*y[21])/Rpp
dy[107] = -2.0*(-1.0*y[29]-3.0*y[107]+4.0*y[22])/Rpp
dy[108] = -2.0*(-1.0*y[30]-3.0*y[108]+4.0*y[23])/Rpp
dy[109] = -2.0*(-1.0*y[31]-3.0*y[109]+4.0*y[24])/Rpp
dy[110] = 2.0*Dsp*(y[25]+3.0*y[110]-4.0*y[32])/Rpp+2.0*kp*(y[1]*c0)^.5*(-1.0*y[110]*ctp+ctp)^.5*(y[110]*ctp)^.5*sinh(.5*F/R/Tr*(y[86]-1.0*y[65]-1.0*ocp_cathode(y[110],up)))/ctp
dy[111] = 2.0*Dsp*(y[26]+3.0*y[111]-4.0*y[33])/Rpp+2.0*kp*(y[2]*c0)^.5*(-1.0*y[111]*ctp+ctp)^.5*(y[111]*ctp)^.5*sinh(.5*F/R/Tr*(y[87]-1.0*y[66]-1.0*ocp_cathode(y[111],up)))/ctp
dy[112] = 2.0*Dsp*(y[27]+3.0*y[112]-4.0*y[34])/Rpp+2.0*kp*(y[3]*c0)^.5*(-1.0*y[112]*ctp+ctp)^.5*(y[112]*ctp)^.5*sinh(.5*F/R/Tr*(y[88]-1.0*y[67]-1.0*ocp_cathode(y[112],up)))/ctp
dy[113] = 2.0*Dsp*(y[28]+3.0*y[113]-4.0*y[35])/Rpp+2.0*kp*(y[4]*c0)^.5*(-1.0*y[113]*ctp+ctp)^.5*(y[113]*ctp)^.5*sinh(.5*F/R/Tr*(y[89]-1.0*y[68]-1.0*ocp_cathode(y[113],up)))/ctp
dy[114] = 2.0*Dsp*(y[29]+3.0*y[114]-4.0*y[36])/Rpp+2.0*kp*(y[5]*c0)^.5*(-1.0*y[114]*ctp+ctp)^.5*(y[114]*ctp)^.5*sinh(.5*F/R/Tr*(y[90]-1.0*y[69]-1.0*ocp_cathode(y[114],up)))/ctp
dy[115] = 2.0*Dsp*(y[30]+3.0*y[115]-4.0*y[37])/Rpp+2.0*kp*(y[6]*c0)^.5*(-1.0*y[115]*ctp+ctp)^.5*(y[115]*ctp)^.5*sinh(.5*F/R/Tr*(y[91]-1.0*y[70]-1.0*ocp_cathode(y[115],up)))/ctp
dy[116] = 2.0*Dsp*(y[31]+3.0*y[116]-4.0*y[38])/Rpp+2.0*kp*(y[7]*c0)^.5*(-1.0*y[116]*ctp+ctp)^.5*(y[116]*ctp)^.5*sinh(.5*F/R/Tr*(y[92]-1.0*y[71]-1.0*ocp_cathode(y[116],up)))/ctp
dy[117] = -2.0*(-1.0*y[46]-3.0*y[117]+4.0*y[39])/Rpn
dy[118] = -2.0*(-1.0*y[47]-3.0*y[118]+4.0*y[40])/Rpn
dy[119] = -2.0*(-1.0*y[48]-3.0*y[119]+4.0*y[41])/Rpn
dy[120] = -2.0*(-1.0*y[49]-3.0*y[120]+4.0*y[42])/Rpn
dy[121] = -2.0*(-1.0*y[50]-3.0*y[121]+4.0*y[43])/Rpn
dy[122] = -2.0*(-1.0*y[51]-3.0*y[122]+4.0*y[44])/Rpn
dy[123] = -2.0*(-1.0*y[52]-3.0*y[123]+4.0*y[45])/Rpn
dy[124] = 2.0*Dsn*(y[46]+3.0*y[124]-4.0*y[53])/Rpn+2.0*kn*(y[11]*c0)^.5*(-1.0*y[124]*ctn+ctn)^.5*(y[124]*ctn)^.5*sinh(.5*F/R/Tr*(y[95]-1.0*y[77]+.5e-1-2.325*exp(-100.0*y[124]^1.15)+.1721*tanh(20.000000*y[124]-21.000000)+.25e-2*tanh(39.347962*y[124]-37.241379)+.34e-1*tanh(89.411765*y[124]-6.0294118)+.2e-2*tanh(7.0422535*y[124]-1.3661972)+.155e-1*tanh(77.519380*y[124]-8.1395349)))/ctn
dy[125] = 2.0*Dsn*(y[47]+3.0*y[125]-4.0*y[54])/Rpn+2.0*kn*(y[12]*c0)^.5*(-1.0*y[125]*ctn+ctn)^.5*(y[125]*ctn)^.5*sinh(.5*F/R/Tr*(y[96]-1.0*y[78]+.5e-1-2.325*exp(-100.0*y[125]^1.15)+.1721*tanh(20.000000*y[125]-21.000000)+.25e-2*tanh(39.347962*y[125]-37.241379)+.34e-1*tanh(89.411765*y[125]-6.0294118)+.2e-2*tanh(7.0422535*y[125]-1.3661972)+.155e-1*tanh(77.519380*y[125]-8.1395349)))/ctn
dy[126] = 2.0*Dsn*(y[48]+3.0*y[126]-4.0*y[55])/Rpn+2.0*kn*(y[13]*c0)^.5*(-1.0*y[126]*ctn+ctn)^.5*(y[126]*ctn)^.5*sinh(.5*F/R/Tr*(y[97]-1.0*y[79]+.5e-1-2.325*exp(-100.0*y[126]^1.15)+.1721*tanh(20.000000*y[126]-21.000000)+.25e-2*tanh(39.347962*y[126]-37.241379)+.34e-1*tanh(89.411765*y[126]-6.0294118)+.2e-2*tanh(7.0422535*y[126]-1.3661972)+.155e-1*tanh(77.519380*y[126]-8.1395349)))/ctn
dy[127] = 2.0*Dsn*(y[49]+3.0*y[127]-4.0*y[56])/Rpn+2.0*kn*(y[14]*c0)^.5*(-1.0*y[127]*ctn+ctn)^.5*(y[127]*ctn)^.5*sinh(.5*F/R/Tr*(y[98]-1.0*y[80]+.5e-1-2.325*exp(-100.0*y[127]^1.15)+.1721*tanh(20.000000*y[127]-21.000000)+.25e-2*tanh(39.347962*y[127]-37.241379)+.34e-1*tanh(89.411765*y[127]-6.0294118)+.2e-2*tanh(7.0422535*y[127]-1.3661972)+.155e-1*tanh(77.519380*y[127]-8.1395349)))/ctn
dy[128] = 2.0*Dsn*(y[50]+3.0*y[128]-4.0*y[57])/Rpn+2.0*kn*(y[15]*c0)^.5*(-1.0*y[128]*ctn+ctn)^.5*(y[128]*ctn)^.5*sinh(.5*F/R/Tr*(y[99]-1.0*y[81]+.5e-1-2.325*exp(-100.0*y[128]^1.15)+.1721*tanh(20.000000*y[128]-21.000000)+.25e-2*tanh(39.347962*y[128]-37.241379)+.34e-1*tanh(89.411765*y[128]-6.0294118)+.2e-2*tanh(7.0422535*y[128]-1.3661972)+.155e-1*tanh(77.519380*y[128]-8.1395349)))/ctn
dy[129] = 2.0*Dsn*(y[51]+3.0*y[129]-4.0*y[58])/Rpn+2.0*kn*(y[16]*c0)^.5*(-1.0*y[129]*ctn+ctn)^.5*(y[129]*ctn)^.5*sinh(.5*F/R/Tr*(y[100]-1.0*y[82]+.5e-1-2.325*exp(-100.0*y[129]^1.15)+.1721*tanh(20.000000*y[129]-21.000000)+.25e-2*tanh(39.347962*y[129]-37.241379)+.34e-1*tanh(89.411765*y[129]-6.0294118)+.2e-2*tanh(7.0422535*y[129]-1.3661972)+.155e-1*tanh(77.519380*y[129]-8.1395349)))/ctn
dy[130] = 2.0*Dsn*(y[52]+3.0*y[130]-4.0*y[59])/Rpn+2.0*kn*(y[17]*c0)^.5*(-1.0*y[130]*ctn+ctn)^.5*(y[130]*ctn)^.5*sinh(.5*F/R/Tr*(y[101]-1.0*y[83]+.5e-1-2.325*exp(-100.0*y[130]^1.15)+.1721*tanh(20.000000*y[130]-21.000000)+.25e-2*tanh(39.347962*y[130]-37.241379)+.34e-1*tanh(89.411765*y[130]-6.0294118)+.2e-2*tanh(7.0422535*y[130]-1.3661972)+.155e-1*tanh(77.519380*y[130]-8.1395349)))/ctn
dy[131] = y[131]-y[85]+y[102]+ (current*Kr)
end
function ocp_cathode(theta_p,up)
Up = (-5.057-13.6*theta_p^2+121.6*theta_p^4-185.1*theta_p^6-45.43*theta_p^8+127.7*theta_p^10)/(-1-5.04*theta_p^2+32.3*theta_p^4-40.95*theta_p^6-25.94*theta_p^8+40.63*theta_p^10)
end
yyy = function(pars::Array{Float64})
socn=pars[24]
socp=pars[25]
y0 = [1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,socp,socp,socp,socp,socp,socp,socp,socp,socp,socp,socp,socp,socp,socp,socp,socp,socp,socp,socp,socp,socp,socn,socn,socn,socn,socn,socn,socn,socn,socn,socn,socn,socn,socn,socn,socn,socn,socn,socn,socn,socn,socn,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,(-0.5057e1 - 0.136e2 * socp ^ 2 + 0.1216e3 * socp ^ 4 - 0.1851e3 * socp ^ 6 - 0.4543e2 * socp ^ 8 + 0.1277e3 * socp ^ 10) / (-0.1e1 - 0.504e1 * socp ^ 2 + 0.323e2 * socp ^ 4 - 0.4095e2 * socp ^ 6 - 0.2594e2 * socp ^ 8 + 0.4063e2 * socp ^ 10),(-0.5057e1 - 0.136e2 * socp ^ 2 + 0.1216e3 * socp ^ 4 - 0.1851e3 * socp ^ 6 - 0.4543e2 * socp ^ 8 + 0.1277e3 * socp ^ 10) / (-0.1e1 - 0.504e1 * socp ^ 2 + 0.323e2 * socp ^ 4 - 0.4095e2 * socp ^ 6 - 0.2594e2 * socp ^ 8 + 0.4063e2 * socp ^ 10),(-0.5057e1 - 0.136e2 * socp ^ 2 + 0.1216e3 * socp ^ 4 - 0.1851e3 * socp ^ 6 - 0.4543e2 * socp ^ 8 + 0.1277e3 * socp ^ 10) / (-0.1e1 - 0.504e1 * socp ^ 2 + 0.323e2 * socp ^ 4 - 0.4095e2 * socp ^ 6 - 0.2594e2 * socp ^ 8 + 0.4063e2 * socp ^ 10),(-0.5057e1 - 0.136e2 * socp ^ 2 + 0.1216e3 * socp ^ 4 - 0.1851e3 * socp ^ 6 - 0.4543e2 * socp ^ 8 + 0.1277e3 * socp ^ 10) / (-0.1e1 - 0.504e1 * socp ^ 2 + 0.323e2 * socp ^ 4 - 0.4095e2 * socp ^ 6 - 0.2594e2 * socp ^ 8 + 0.4063e2 * socp ^ 10),(-0.5057e1 - 0.136e2 * socp ^ 2 + 0.1216e3 * socp ^ 4 - 0.1851e3 * socp ^ 6 - 0.4543e2 * socp ^ 8 + 0.1277e3 * socp ^ 10) / (-0.1e1 - 0.504e1 * socp ^ 2 + 0.323e2 * socp ^ 4 - 0.4095e2 * socp ^ 6 - 0.2594e2 * socp ^ 8 + 0.4063e2 * socp ^ 10),(-0.5057e1 - 0.136e2 * socp ^ 2 + 0.1216e3 * socp ^ 4 - 0.1851e3 * socp ^ 6 - 0.4543e2 * socp ^ 8 + 0.1277e3 * socp ^ 10) / (-0.1e1 - 0.504e1 * socp ^ 2 + 0.323e2 * socp ^ 4 - 0.4095e2 * socp ^ 6 - 0.2594e2 * socp ^ 8 + 0.4063e2 * socp ^ 10),(-0.5057e1 - 0.136e2 * socp ^ 2 + 0.1216e3 * socp ^ 4 - 0.1851e3 * socp ^ 6 - 0.4543e2 * socp ^ 8 + 0.1277e3 * socp ^ 10) / (-0.1e1 - 0.504e1 * socp ^ 2 + 0.323e2 * socp ^ 4 - 0.4095e2 * socp ^ 6 - 0.2594e2 * socp ^ 8 + 0.4063e2 * socp ^ 10),(-0.5057e1 - 0.136e2 * socp ^ 2 + 0.1216e3 * socp ^ 4 - 0.1851e3 * socp ^ 6 - 0.4543e2 * socp ^ 8 + 0.1277e3 * socp ^ 10) / (-0.1e1 - 0.504e1 * socp ^ 2 + 0.323e2 * socp ^ 4 - 0.4095e2 * socp ^ 6 - 0.2594e2 * socp ^ 8 + 0.4063e2 * socp ^ 10),(-0.5057e1 - 0.136e2 * socp ^ 2 + 0.1216e3 * socp ^ 4 - 0.1851e3 * socp ^ 6 - 0.4543e2 * socp ^ 8 + 0.1277e3 * socp ^ 10) / (-0.1e1 - 0.504e1 * socp ^ 2 + 0.323e2 * socp ^ 4 - 0.4095e2 * socp ^ 6 - 0.2594e2 * socp ^ 8 + 0.4063e2 * socp ^ 10),-0.5e-1 + 0.2325e1 * exp(-0.100e3 * socn ^ 0.115e1) - 0.1721e0 * tanh(0.20000000e2 * socn - 0.21000000e2) - 0.25e-2 * tanh(0.39347962e2 * socn - 0.37241379e2) - 0.34e-1 * tanh(0.89411765e2 * socn - 0.60294118e1) - 0.2e-2 * tanh(0.70422535e1 * socn - 0.13661972e1) - 0.155e-1 * tanh(0.77519380e2 * socn - 0.81395349e1),-0.5e-1 + 0.2325e1 * exp(-0.100e3 * socn ^ 0.115e1) - 0.1721e0 * tanh(0.20000000e2 * socn - 0.21000000e2) - 0.25e-2 * tanh(0.39347962e2 * socn - 0.37241379e2) - 0.34e-1 * tanh(0.89411765e2 * socn - 0.60294118e1) - 0.2e-2 * tanh(0.70422535e1 * socn - 0.13661972e1) - 0.155e-1 * tanh(0.77519380e2 * socn - 0.81395349e1),-0.5e-1 + 0.2325e1 * exp(-0.100e3 * socn ^ 0.115e1) - 0.1721e0 * tanh(0.20000000e2 * socn - 0.21000000e2) - 0.25e-2 * tanh(0.39347962e2 * socn - 0.37241379e2) - 0.34e-1 * tanh(0.89411765e2 * socn - 0.60294118e1) - 0.2e-2 * tanh(0.70422535e1 * socn - 0.13661972e1) - 0.155e-1 * tanh(0.77519380e2 * socn - 0.81395349e1),-0.5e-1 + 0.2325e1 * exp(-0.100e3 * socn ^ 0.115e1) - 0.1721e0 * tanh(0.20000000e2 * socn - 0.21000000e2) - 0.25e-2 * tanh(0.39347962e2 * socn - 0.37241379e2) - 0.34e-1 * tanh(0.89411765e2 * socn - 0.60294118e1) - 0.2e-2 * tanh(0.70422535e1 * socn - 0.13661972e1) - 0.155e-1 * tanh(0.77519380e2 * socn - 0.81395349e1),-0.5e-1 + 0.2325e1 * exp(-0.100e3 * socn ^ 0.115e1) - 0.1721e0 * tanh(0.20000000e2 * socn - 0.21000000e2) - 0.25e-2 * tanh(0.39347962e2 * socn - 0.37241379e2) - 0.34e-1 * tanh(0.89411765e2 * socn - 0.60294118e1) - 0.2e-2 * tanh(0.70422535e1 * socn - 0.13661972e1) - 0.155e-1 * tanh(0.77519380e2 * socn - 0.81395349e1),-0.5e-1 + 0.2325e1 * exp(-0.100e3 * socn ^ 0.115e1) - 0.1721e0 * tanh(0.20000000e2 * socn - 0.21000000e2) - 0.25e-2 * tanh(0.39347962e2 * socn - 0.37241379e2) - 0.34e-1 * tanh(0.89411765e2 * socn - 0.60294118e1) - 0.2e-2 * tanh(0.70422535e1 * socn - 0.13661972e1) - 0.155e-1 * tanh(0.77519380e2 * socn - 0.81395349e1),-0.5e-1 + 0.2325e1 * exp(-0.100e3 * socn ^ 0.115e1) - 0.1721e0 * tanh(0.20000000e2 * socn - 0.21000000e2) - 0.25e-2 * tanh(0.39347962e2 * socn - 0.37241379e2) - 0.34e-1 * tanh(0.89411765e2 * socn - 0.60294118e1) - 0.2e-2 * tanh(0.70422535e1 * socn - 0.13661972e1) - 0.155e-1 * tanh(0.77519380e2 * socn - 0.81395349e1),-0.5e-1 + 0.2325e1 * exp(-0.100e3 * socn ^ 0.115e1) - 0.1721e0 * tanh(0.20000000e2 * socn - 0.21000000e2) - 0.25e-2 * tanh(0.39347962e2 * socn - 0.37241379e2) - 0.34e-1 * tanh(0.89411765e2 * socn - 0.60294118e1) - 0.2e-2 * tanh(0.70422535e1 * socn - 0.13661972e1) - 0.155e-1 * tanh(0.77519380e2 * socn - 0.81395349e1),-0.5e-1 + 0.2325e1 * exp(-0.100e3 * socn ^ 0.115e1) - 0.1721e0 * tanh(0.20000000e2 * socn - 0.21000000e2) - 0.25e-2 * tanh(0.39347962e2 * socn - 0.37241379e2) - 0.34e-1 * tanh(0.89411765e2 * socn - 0.60294118e1) - 0.2e-2 * tanh(0.70422535e1 * socn - 0.13661972e1) - 0.155e-1 * tanh(0.77519380e2 * socn - 0.81395349e1),socp,socp,socp,socp,socp,socp,socp,socp,socp,socp,socp,socp,socp,socp,socn,socn,socn,socn,socn,socn,socn,socn,socn,socn,socn,socn,socn,socn,(-0.5057e1 - 0.136e2 * socp ^ 2 + 0.1216e3 * socp ^ 4 - 0.1851e3 * socp ^ 6 - 0.4543e2 * socp ^ 8 + 0.1277e3 * socp ^ 10) / (-0.1e1 - 0.504e1 * socp ^ 2 + 0.323e2 * socp ^ 4 - 0.4095e2 * socp ^ 6 - 0.2594e2 * socp ^ 8 + 0.4063e2 * socp ^ 10) + 0.5e-1 - 0.2325e1 * exp(-0.100e3 * socn ^ 0.115e1) + 0.1721e0 * tanh(0.20000000e2 * socn - 0.21000000e2) + 0.25e-2 * tanh(0.39347962e2 * socn - 0.37241379e2) + 0.34e-1 * tanh(0.89411765e2 * socn - 0.60294118e1) + 0.2e-2 * tanh(0.70422535e1 * socn - 0.13661972e1) + 0.155e-1 * tanh(0.77519380e2 * socn - 0.81395349e1)]
end
y0=zeros(131)
n=length(y0)
MM=zeros((n,n))
node = 59
for i in 1:node
MM[i,i]=1.
end
pars = [7.33234842e-08,6.40146313e-12,1.56954148e-13,1.65301662e-06,
1.28277079e-05,1.39115369e+00,1.70413971e+00,1.93944836e+00,
1.15245117e+03,3.46144727e+04,4.02951641e+04,3.24118063e-02,
2.70097144e-02,5.20209372e-01,3.74625146e-01,4.16417062e-01,
5.51529622e-09,6.95793778e-09,4.91284482e-05,4.88584483e-05,
1.28054144e-05,1.38146591e+02,9.15019798e+00,9.78830695e-01,
4.58723247e-01,4.32648301e-01,0.02]
y0 = yyy(pars)
dy = zeros(n)
f = (dy,y) -> P2D2c(zero(y),y,pars,0.)
using ForwardDiff
# Really long compile time
ForwardDiff.jacobian(f,dy,y0) and I haven't been able to have the compilation finish. Edit: This regressed to 800 seconds.
|
Almost surely a duplicate of #25927? Take a If it's not |
# Really long compile time
using Profile
Profile.init(n = 10^6, delay = 1.0)
@profile ForwardDiff.jacobian(f,dy,y0)
Profile.print(format=:flat)
It looks like it shows up. Is that the step in type inference taking all of the time? |
Most likely. Maybe double-check in tree mode with Also go to |
Looks like domtree.
Anything but the default segfaults on Windows with the standard binary. That's probably issue worthy. |
Yes indeed.
Whoa! Definitely, thanks in advance for reporting that. I don't have easy access to a Windows machine so am not the right one to fix it (@vtjnash?), but I would be surprised if this is more than a couple-liner to fix. |
I haven't done a report since I'm not sure of an MWE. Any simple example doesn't seem to do it. But any time I've reported compiler issues that needed profiles, if I change Closing this as a duplicate of #25927 |
I isolated the issue SciML/DifferentialEquations.jl#303 at least down to ForwardDiff on a large nonlinear function.
The text was updated successfully, but these errors were encountered: