Skip to content
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

Closed
ChrisRackauckas opened this issue Jun 8, 2018 · 15 comments
Closed

800 second compile time on ForwardDiff example #27488

ChrisRackauckas opened this issue Jun 8, 2018 · 15 comments
Labels
compiler:latency Compiler latency

Comments

@ChrisRackauckas
Copy link
Member

I isolated the issue SciML/DifferentialEquations.jl#303 at least down to ForwardDiff on a large nonlinear function.

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.*D2pos/lp^2*(y[60]-2.*y[1]+y[2])+2.*ap*(1.-1.*t1)*kp*(y[1]*c0)^.5*(-1.*y[110]*ctp+ctp)^.5*(y[110]*ctp)^.5*sinh(.5*F/R/Tr*(y[86]-1.*y[65]-1.*ocp_cathode(y[110],up)))/c0)
    dy[2] = 1/ep*(64.*D2pos/lp^2*(y[1]-2.*y[2]+y[3])+2.*ap*(1.-1.*t1)*kp*(y[2]*c0)^.5*(-1.*y[111]*ctp+ctp)^.5*(y[111]*ctp)^.5*sinh(.5*F/R/Tr*(y[87]-1.*y[66]-1.*ocp_cathode(y[111],up)))/c0)
    dy[3] = 1/ep*(64.*D2pos/lp^2*(y[2]-2.*y[3]+y[4])+2.*ap*(1.-1.*t1)*kp*(y[3]*c0)^.5*(-1.*y[112]*ctp+ctp)^.5*(y[112]*ctp)^.5*sinh(.5*F/R/Tr*(y[88]-1.*y[67]-1.*ocp_cathode(y[112],up)))/c0)
    dy[4] = 1/ep*(64.*D2pos/lp^2*(y[3]-2.*y[4]+y[5])+2.*ap*(1.-1.*t1)*kp*(y[4]*c0)^.5*(-1.*y[113]*ctp+ctp)^.5*(y[113]*ctp)^.5*sinh(.5*F/R/Tr*(y[89]-1.*y[68]-1.*ocp_cathode(y[113],up)))/c0)
    dy[5] = 1/ep*(64.*D2pos/lp^2*(y[4]-2.*y[5]+y[6])+2.*ap*(1.-1.*t1)*kp*(y[5]*c0)^.5*(-1.*y[114]*ctp+ctp)^.5*(y[114]*ctp)^.5*sinh(.5*F/R/Tr*(y[90]-1.*y[69]-1.*ocp_cathode(y[114],up)))/c0)
    dy[6] = 1/ep*(64.*D2pos/lp^2*(y[5]-2.*y[6]+y[7])+2.*ap*(1.-1.*t1)*kp*(y[6]*c0)^.5*(-1.*y[115]*ctp+ctp)^.5*(y[115]*ctp)^.5*sinh(.5*F/R/Tr*(y[91]-1.*y[70]-1.*ocp_cathode(y[115],up)))/c0)
    dy[7] = 1/ep*(64.*D2pos/lp^2*(y[6]-2.*y[7]+y[61])+2.*ap*(1.-1.*t1)*kp*(y[7]*c0)^.5*(-1.*y[116]*ctp+ctp)^.5*(y[116]*ctp)^.5*sinh(.5*F/R/Tr*(y[92]-1.*y[71]-1.*ocp_cathode(y[116],up)))/c0)
    dy[8] = 16./es*D2sep/ls^2*(y[61]-2.*y[8]+y[9])
    dy[9] = 16./es*D2sep/ls^2*(y[8]-2.*y[9]+y[10])
    dy[10] = 16./es*D2sep/ls^2*(y[9]-2.*y[10]+y[62])
    dy[11] = 1/en*(64.*D2neg/ln1^2*(y[62]-2.*y[11]+y[12])+2.*an*(1.-1.*t1)*kn*(y[11]*c0)^.5*(-1.*y[124]*ctn+ctn)^.5*(y[124]*ctn)^.5*sinh(.5*F/R/Tr*(y[95]-1.*y[77]+.5e-1-2.325*exp(-100.*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.*D2neg/ln1^2*(y[11]-2.*y[12]+y[13])+2.*an*(1.-1.*t1)*kn*(y[12]*c0)^.5*(-1.*y[125]*ctn+ctn)^.5*(y[125]*ctn)^.5*sinh(.5*F/R/Tr*(y[96]-1.*y[78]+.5e-1-2.325*exp(-100.*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.*D2neg/ln1^2*(y[12]-2.*y[13]+y[14])+2.*an*(1.-1.*t1)*kn*(y[13]*c0)^.5*(-1.*y[126]*ctn+ctn)^.5*(y[126]*ctn)^.5*sinh(.5*F/R/Tr*(y[97]-1.*y[79]+.5e-1-2.325*exp(-100.*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.*D2neg/ln1^2*(y[13]-2.*y[14]+y[15])+2.*an*(1.-1.*t1)*kn*(y[14]*c0)^.5*(-1.*y[127]*ctn+ctn)^.5*(y[127]*ctn)^.5*sinh(.5*F/R/Tr*(y[98]-1.*y[80]+.5e-1-2.325*exp(-100.*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.*D2neg/ln1^2*(y[14]-2.*y[15]+y[16])+2.*an*(1.-1.*t1)*kn*(y[15]*c0)^.5*(-1.*y[128]*ctn+ctn)^.5*(y[128]*ctn)^.5*sinh(.5*F/R/Tr*(y[99]-1.*y[81]+.5e-1-2.325*exp(-100.*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.*D2neg/ln1^2*(y[15]-2.*y[16]+y[17])+2.*an*(1.-1.*t1)*kn*(y[16]*c0)^.5*(-1.*y[129]*ctn+ctn)^.5*(y[129]*ctn)^.5*sinh(.5*F/R/Tr*(y[100]-1.*y[82]+.5e-1-2.325*exp(-100.*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.*D2neg/ln1^2*(y[16]-2.*y[17]+y[63])+2.*an*(1.-1.*t1)*kn*(y[17]*c0)^.5*(-1.*y[130]*ctn+ctn)^.5*(y[130]*ctn)^.5*sinh(.5*F/R/Tr*(y[101]-1.*y[83]+.5e-1-2.325*exp(-100.*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.*(Dsp*(y[25]-1.*y[103])+Dsp*(y[103]-2.*y[18]+y[25]))/Rpp^2
    dy[19] = 16.*(Dsp*(y[26]-1.*y[104])+Dsp*(y[104]-2.*y[19]+y[26]))/Rpp^2
    dy[20] = 16.*(Dsp*(y[27]-1.*y[105])+Dsp*(y[105]-2.*y[20]+y[27]))/Rpp^2
    dy[21] = 16.*(Dsp*(y[28]-1.*y[106])+Dsp*(y[106]-2.*y[21]+y[28]))/Rpp^2
    dy[22] = 16.*(Dsp*(y[29]-1.*y[107])+Dsp*(y[107]-2.*y[22]+y[29]))/Rpp^2
    dy[23] = 16.*(Dsp*(y[30]-1.*y[108])+Dsp*(y[108]-2.*y[23]+y[30]))/Rpp^2
    dy[24] = 16.*(Dsp*(y[31]-1.*y[109])+Dsp*(y[109]-2.*y[24]+y[31]))/Rpp^2
    dy[25] = 4.*(2.*Dsp*(y[32]-1.*y[18])+4.*Dsp*(y[18]-2.*y[25]+y[32]))/Rpp^2
    dy[26] = 4.*(2.*Dsp*(y[33]-1.*y[19])+4.*Dsp*(y[19]-2.*y[26]+y[33]))/Rpp^2
    dy[27] = 4.*(2.*Dsp*(y[34]-1.*y[20])+4.*Dsp*(y[20]-2.*y[27]+y[34]))/Rpp^2
    dy[28] = 4.*(2.*Dsp*(y[35]-1.*y[21])+4.*Dsp*(y[21]-2.*y[28]+y[35]))/Rpp^2
    dy[29] = 4.*(2.*Dsp*(y[36]-1.*y[22])+4.*Dsp*(y[22]-2.*y[29]+y[36]))/Rpp^2
    dy[30] = 4.*(2.*Dsp*(y[37]-1.*y[23])+4.*Dsp*(y[23]-2.*y[30]+y[37]))/Rpp^2
    dy[31] = 4.*(2.*Dsp*(y[38]-1.*y[24])+4.*Dsp*(y[24]-2.*y[31]+y[38]))/Rpp^2
    dy[32] = 1.777777778*(3.*Dsp*(y[110]-1.*y[25])+9.*Dsp*(y[25]-2.*y[32]+y[110]))/Rpp^2
    dy[33] = 1.777777778*(3.*Dsp*(y[111]-1.*y[26])+9.*Dsp*(y[26]-2.*y[33]+y[111]))/Rpp^2
    dy[34] = 1.777777778*(3.*Dsp*(y[112]-1.*y[27])+9.*Dsp*(y[27]-2.*y[34]+y[112]))/Rpp^2
    dy[35] = 1.777777778*(3.*Dsp*(y[113]-1.*y[28])+9.*Dsp*(y[28]-2.*y[35]+y[113]))/Rpp^2
    dy[36] = 1.777777778*(3.*Dsp*(y[114]-1.*y[29])+9.*Dsp*(y[29]-2.*y[36]+y[114]))/Rpp^2
    dy[37] = 1.777777778*(3.*Dsp*(y[115]-1.*y[30])+9.*Dsp*(y[30]-2.*y[37]+y[115]))/Rpp^2
    dy[38] = 1.777777778*(3.*Dsp*(y[116]-1.*y[31])+9.*Dsp*(y[31]-2.*y[38]+y[116]))/Rpp^2
    dy[39] = 16.*Dsn*(2.*y[46]-2.*y[39])/Rpn^2
    dy[40] = 16.*Dsn*(2.*y[47]-2.*y[40])/Rpn^2
    dy[41] = 16.*Dsn*(2.*y[48]-2.*y[41])/Rpn^2
    dy[42] = 16.*Dsn*(2.*y[49]-2.*y[42])/Rpn^2
    dy[43] = 16.*Dsn*(2.*y[50]-2.*y[43])/Rpn^2
    dy[44] = 16.*Dsn*(2.*y[51]-2.*y[44])/Rpn^2
    dy[45] = 16.*Dsn*(2.*y[52]-2.*y[45])/Rpn^2
    dy[46] = 4.*Dsn*(6.*y[53]+2.*y[39]-8.*y[46])/Rpn^2
    dy[47] = 4.*Dsn*(6.*y[54]+2.*y[40]-8.*y[47])/Rpn^2
    dy[48] = 4.*Dsn*(6.*y[55]+2.*y[41]-8.*y[48])/Rpn^2
    dy[49] = 4.*Dsn*(6.*y[56]+2.*y[42]-8.*y[49])/Rpn^2
    dy[50] = 4.*Dsn*(6.*y[57]+2.*y[43]-8.*y[50])/Rpn^2
    dy[51] = 4.*Dsn*(6.*y[58]+2.*y[44]-8.*y[51])/Rpn^2
    dy[52] = 4.*Dsn*(6.*y[59]+2.*y[45]-8.*y[52])/Rpn^2
    dy[53] = 1.777777778*Dsn*(12.*y[124]+6.*y[46]-18.*y[53])/Rpn^2
    dy[54] = 1.777777778*Dsn*(12.*y[125]+6.*y[47]-18.*y[54])/Rpn^2
    dy[55] = 1.777777778*Dsn*(12.*y[126]+6.*y[48]-18.*y[55])/Rpn^2
    dy[56] = 1.777777778*Dsn*(12.*y[127]+6.*y[49]-18.*y[56])/Rpn^2
    dy[57] = 1.777777778*Dsn*(12.*y[128]+6.*y[50]-18.*y[57])/Rpn^2
    dy[58] = 1.777777778*Dsn*(12.*y[129]+6.*y[51]-18.*y[58])/Rpn^2
    dy[59] = 1.777777778*Dsn*(12.*y[130]+6.*y[52]-18.*y[59])/Rpn^2
    dy[60] = 4.*D2pos*(-1.*y[2]-3.*y[60]+4.*y[1])/lp
    dy[61] = 4.*D2pos*(y[6]+3.*y[61]-4.*y[7])/lp-2.*D2sep*(-1.*y[9]-3.*y[61]+4.*y[8])/ls
    dy[62] = 2.*D2sep*(y[9]+3.*y[62]-4.*y[10])/ls-4.*D2neg*(-1.*y[12]-3.*y[62]+4.*y[11])/ln1
    dy[63] = 4.*D2neg*(y[16]+3.*y[63]-4.*y[17])/ln1
    dy[64] = 4.*(-1.*y[66]-3.*y[64]+4.*y[65])/lp
    dy[65] = -4.*sigmap/lp*(y[87]-1.*y[85])-4.*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.*y[64])+8.*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.-1.*t1)/lp*(y[2]-1.*y[60])/y[1]-iapp
    dy[66] = -4.*sigmap/lp*(y[88]-1.*y[86])-4.*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.*y[65])+8.*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.-1.*t1)/lp*(y[3]-1.*y[1])/y[2]-iapp
    dy[67] = -4.*sigmap/lp*(y[89]-1.*y[87])-4.*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.*y[66])+8.*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.-1.*t1)/lp*(y[4]-1.*y[2])/y[3]-iapp
    dy[68] = -4.*sigmap/lp*(y[90]-1.*y[88])-4.*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.*y[67])+8.*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.-1.*t1)/lp*(y[5]-1.*y[3])/y[4]-iapp
    dy[69] = -4.*sigmap/lp*(y[91]-1.*y[89])-4.*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.*y[68])+8.*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.-1.*t1)/lp*(y[6]-1.*y[4])/y[5]-iapp
    dy[70] = -4.*sigmap/lp*(y[92]-1.*y[90])-4.*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.*y[69])+8.*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.-1.*t1)/lp*(y[7]-1.*y[5])/y[6]-iapp
    dy[71] = -4.*sigmap/lp*(y[93]-1.*y[91])-4.*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.*y[70])+8.*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.-1.*t1)/lp*(y[61]-1.*y[6])/y[7]-iapp
    dy[72] = 4.*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.*y[72]-4.*y[71])/lp-2.*es^brugs*(.41253e-1+.5007e-3*y[61]-.47212e-6*y[61]^2+.15904e-9*y[61]^3-.16018e-13*y[61]^4)*(-1.*y[74]-3.*y[72]+4.*y[73])/ls
    dy[73] = -2.*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.*y[72])+4.*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.-1.*t1)/ls*(y[9]-1.*y[61])/y[8]-iapp
    dy[74] = -2.*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.*y[73])+4.*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.-1.*t1)/ls*(y[10]-1.*y[8])/y[9]-iapp
    dy[75] = -2.*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.*y[74])+4.*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.-1.*t1)/ls*(y[62]-1.*y[9])/y[10]-iapp
    dy[76] = 2.*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.*y[76]-4.*y[75])/ls-4.*en^brugn*(.41253e-1+.5007e-3*y[62]-.47212e-6*y[62]^2+.15904e-9*y[62]^3-.16018e-13*y[62]^4)*(-1.*y[78]-3.*y[76]+4.*y[77])/ln1
    dy[77] = -4.*sigman/ln1*(y[96]-1.*y[94])-4.*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.*y[76])+8.*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.-1.*t1)/ln1*(y[12]-1.*y[62])/y[11]-iapp
    dy[78] = -4.*sigman/ln1*(y[97]-1.*y[95])-4.*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.*y[77])+8.*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.-1.*t1)/ln1*(y[13]-1.*y[11])/y[12]-iapp
    dy[79] = -4.*sigman/ln1*(y[98]-1.*y[96])-4.*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.*y[78])+8.*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.-1.*t1)/ln1*(y[14]-1.*y[12])/y[13]-iapp
    dy[80] = -4.*sigman/ln1*(y[99]-1.*y[97])-4.*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.*y[79])+8.*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.-1.*t1)/ln1*(y[15]-1.*y[13])/y[14]-iapp
    dy[81] = -4.*sigman/ln1*(y[100]-1.*y[98])-4.*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.*y[80])+8.*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.-1.*t1)/ln1*(y[16]-1.*y[14])/y[15]-iapp
    dy[82] = -4.*sigman/ln1*(y[101]-1.*y[99])-4.*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.*y[81])+8.*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.-1.*t1)/ln1*(y[17]-1.*y[15])/y[16]-iapp
    dy[83] = -4.*sigman/ln1*(y[102]-1.*y[100])-4.*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.*y[82])+8.*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.-1.*t1)/ln1*(y[63]-1.*y[16])/y[17]-iapp
    dy[84] = y[84]
    dy[85] = 4.*(-1.*y[87]-3.*y[85]+4.*y[86])/lp+1.*iapp/sigmap
    dy[86] = 64.*sigmap/lp^2*(y[85]-2.*y[86]+y[87])-2.*ap*F*kp*(y[1]*c0)^.5*(-1.*y[110]*ctp+ctp)^.5*(y[110]*ctp)^.5*sinh(.5*F/R/Tr*(y[86]-1.*y[65]-1.*ocp_cathode(y[110],up)))
    dy[87] = 64.*sigmap/lp^2*(y[86]-2.*y[87]+y[88])-2.*ap*F*kp*(y[2]*c0)^.5*(-1.*y[111]*ctp+ctp)^.5*(y[111]*ctp)^.5*sinh(.5*F/R/Tr*(y[87]-1.*y[66]-1.*ocp_cathode(y[111],up)))
    dy[88] = 64.*sigmap/lp^2*(y[87]-2.*y[88]+y[89])-2.*ap*F*kp*(y[3]*c0)^.5*(-1.*y[112]*ctp+ctp)^.5*(y[112]*ctp)^.5*sinh(.5*F/R/Tr*(y[88]-1.*y[67]-1.*ocp_cathode(y[112],up)))
    dy[89] = 64.*sigmap/lp^2*(y[88]-2.*y[89]+y[90])-2.*ap*F*kp*(y[4]*c0)^.5*(-1.*y[113]*ctp+ctp)^.5*(y[113]*ctp)^.5*sinh(.5*F/R/Tr*(y[89]-1.*y[68]-1.*ocp_cathode(y[113],up)))
    dy[90] = 64.*sigmap/lp^2*(y[89]-2.*y[90]+y[91])-2.*ap*F*kp*(y[5]*c0)^.5*(-1.*y[114]*ctp+ctp)^.5*(y[114]*ctp)^.5*sinh(.5*F/R/Tr*(y[90]-1.*y[69]-1.*ocp_cathode(y[114],up)))
    dy[91] = 64.*sigmap/lp^2*(y[90]-2.*y[91]+y[92])-2.*ap*F*kp*(y[6]*c0)^.5*(-1.*y[115]*ctp+ctp)^.5*(y[115]*ctp)^.5*sinh(.5*F/R/Tr*(y[91]-1.*y[70]-1.*ocp_cathode(y[115],up)))
    dy[92] = 64.*sigmap/lp^2*(y[91]-2.*y[92]+y[93])-2.*ap*F*kp*(y[7]*c0)^.5*(-1.*y[116]*ctp+ctp)^.5*(y[116]*ctp)^.5*sinh(.5*F/R/Tr*(y[92]-1.*y[71]-1.*ocp_cathode(y[116],up)))
    dy[93] = 4.*(y[91]+3.*y[93]-4.*y[92])/lp
    dy[94] = 4.*(-1.*y[96]-3.*y[94]+4.*y[95])/ln1
    dy[95] = 64.*sigman/ln1^2*(y[94]-2.*y[95]+y[96])-2.*an*F*kn*(y[11]*c0)^.5*(-1.*y[124]*ctn+ctn)^.5*(y[124]*ctn)^.5*sinh(.5*F/R/Tr*(y[95]-1.*y[77]+.5e-1-2.325*exp(-100.*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.*sigman/ln1^2*(y[95]-2.*y[96]+y[97])-2.*an*F*kn*(y[12]*c0)^.5*(-1.*y[125]*ctn+ctn)^.5*(y[125]*ctn)^.5*sinh(.5*F/R/Tr*(y[96]-1.*y[78]+.5e-1-2.325*exp(-100.*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.*sigman/ln1^2*(y[96]-2.*y[97]+y[98])-2.*an*F*kn*(y[13]*c0)^.5*(-1.*y[126]*ctn+ctn)^.5*(y[126]*ctn)^.5*sinh(.5*F/R/Tr*(y[97]-1.*y[79]+.5e-1-2.325*exp(-100.*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.*sigman/ln1^2*(y[97]-2.*y[98]+y[99])-2.*an*F*kn*(y[14]*c0)^.5*(-1.*y[127]*ctn+ctn)^.5*(y[127]*ctn)^.5*sinh(.5*F/R/Tr*(y[98]-1.*y[80]+.5e-1-2.325*exp(-100.*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.*sigman/ln1^2*(y[98]-2.*y[99]+y[100])-2.*an*F*kn*(y[15]*c0)^.5*(-1.*y[128]*ctn+ctn)^.5*(y[128]*ctn)^.5*sinh(.5*F/R/Tr*(y[99]-1.*y[81]+.5e-1-2.325*exp(-100.*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.*sigman/ln1^2*(y[99]-2.*y[100]+y[101])-2.*an*F*kn*(y[16]*c0)^.5*(-1.*y[129]*ctn+ctn)^.5*(y[129]*ctn)^.5*sinh(.5*F/R/Tr*(y[100]-1.*y[82]+.5e-1-2.325*exp(-100.*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.*sigman/ln1^2*(y[100]-2.*y[101]+y[102])-2.*an*F*kn*(y[17]*c0)^.5*(-1.*y[130]*ctn+ctn)^.5*(y[130]*ctn)^.5*sinh(.5*F/R/Tr*(y[101]-1.*y[83]+.5e-1-2.325*exp(-100.*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.*(y[100]+3.*y[102]-4.*y[101])/ln1+1.*iapp/sigman
    dy[103] = -2.*(-1.*y[25]-3.*y[103]+4.*y[18])/Rpp
    dy[104] = -2.*(-1.*y[26]-3.*y[104]+4.*y[19])/Rpp
    dy[105] = -2.*(-1.*y[27]-3.*y[105]+4.*y[20])/Rpp
    dy[106] = -2.*(-1.*y[28]-3.*y[106]+4.*y[21])/Rpp
    dy[107] = -2.*(-1.*y[29]-3.*y[107]+4.*y[22])/Rpp
    dy[108] = -2.*(-1.*y[30]-3.*y[108]+4.*y[23])/Rpp
    dy[109] = -2.*(-1.*y[31]-3.*y[109]+4.*y[24])/Rpp
    dy[110] = 2.*Dsp*(y[25]+3.*y[110]-4.*y[32])/Rpp+2.*kp*(y[1]*c0)^.5*(-1.*y[110]*ctp+ctp)^.5*(y[110]*ctp)^.5*sinh(.5*F/R/Tr*(y[86]-1.*y[65]-1.*ocp_cathode(y[110],up)))/ctp
    dy[111] = 2.*Dsp*(y[26]+3.*y[111]-4.*y[33])/Rpp+2.*kp*(y[2]*c0)^.5*(-1.*y[111]*ctp+ctp)^.5*(y[111]*ctp)^.5*sinh(.5*F/R/Tr*(y[87]-1.*y[66]-1.*ocp_cathode(y[111],up)))/ctp
    dy[112] = 2.*Dsp*(y[27]+3.*y[112]-4.*y[34])/Rpp+2.*kp*(y[3]*c0)^.5*(-1.*y[112]*ctp+ctp)^.5*(y[112]*ctp)^.5*sinh(.5*F/R/Tr*(y[88]-1.*y[67]-1.*ocp_cathode(y[112],up)))/ctp
    dy[113] = 2.*Dsp*(y[28]+3.*y[113]-4.*y[35])/Rpp+2.*kp*(y[4]*c0)^.5*(-1.*y[113]*ctp+ctp)^.5*(y[113]*ctp)^.5*sinh(.5*F/R/Tr*(y[89]-1.*y[68]-1.*ocp_cathode(y[113],up)))/ctp
    dy[114] = 2.*Dsp*(y[29]+3.*y[114]-4.*y[36])/Rpp+2.*kp*(y[5]*c0)^.5*(-1.*y[114]*ctp+ctp)^.5*(y[114]*ctp)^.5*sinh(.5*F/R/Tr*(y[90]-1.*y[69]-1.*ocp_cathode(y[114],up)))/ctp
    dy[115] = 2.*Dsp*(y[30]+3.*y[115]-4.*y[37])/Rpp+2.*kp*(y[6]*c0)^.5*(-1.*y[115]*ctp+ctp)^.5*(y[115]*ctp)^.5*sinh(.5*F/R/Tr*(y[91]-1.*y[70]-1.*ocp_cathode(y[115],up)))/ctp
    dy[116] = 2.*Dsp*(y[31]+3.*y[116]-4.*y[38])/Rpp+2.*kp*(y[7]*c0)^.5*(-1.*y[116]*ctp+ctp)^.5*(y[116]*ctp)^.5*sinh(.5*F/R/Tr*(y[92]-1.*y[71]-1.*ocp_cathode(y[116],up)))/ctp
    dy[117] = -2.*(-1.*y[46]-3.*y[117]+4.*y[39])/Rpn
    dy[118] = -2.*(-1.*y[47]-3.*y[118]+4.*y[40])/Rpn
    dy[119] = -2.*(-1.*y[48]-3.*y[119]+4.*y[41])/Rpn
    dy[120] = -2.*(-1.*y[49]-3.*y[120]+4.*y[42])/Rpn
    dy[121] = -2.*(-1.*y[50]-3.*y[121]+4.*y[43])/Rpn
    dy[122] = -2.*(-1.*y[51]-3.*y[122]+4.*y[44])/Rpn
    dy[123] = -2.*(-1.*y[52]-3.*y[123]+4.*y[45])/Rpn
    dy[124] = 2.*Dsn*(y[46]+3.*y[124]-4.*y[53])/Rpn+2.*kn*(y[11]*c0)^.5*(-1.*y[124]*ctn+ctn)^.5*(y[124]*ctn)^.5*sinh(.5*F/R/Tr*(y[95]-1.*y[77]+.5e-1-2.325*exp(-100.*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.*Dsn*(y[47]+3.*y[125]-4.*y[54])/Rpn+2.*kn*(y[12]*c0)^.5*(-1.*y[125]*ctn+ctn)^.5*(y[125]*ctn)^.5*sinh(.5*F/R/Tr*(y[96]-1.*y[78]+.5e-1-2.325*exp(-100.*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.*Dsn*(y[48]+3.*y[126]-4.*y[55])/Rpn+2.*kn*(y[13]*c0)^.5*(-1.*y[126]*ctn+ctn)^.5*(y[126]*ctn)^.5*sinh(.5*F/R/Tr*(y[97]-1.*y[79]+.5e-1-2.325*exp(-100.*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.*Dsn*(y[49]+3.*y[127]-4.*y[56])/Rpn+2.*kn*(y[14]*c0)^.5*(-1.*y[127]*ctn+ctn)^.5*(y[127]*ctn)^.5*sinh(.5*F/R/Tr*(y[98]-1.*y[80]+.5e-1-2.325*exp(-100.*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.*Dsn*(y[50]+3.*y[128]-4.*y[57])/Rpn+2.*kn*(y[15]*c0)^.5*(-1.*y[128]*ctn+ctn)^.5*(y[128]*ctn)^.5*sinh(.5*F/R/Tr*(y[99]-1.*y[81]+.5e-1-2.325*exp(-100.*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.*Dsn*(y[51]+3.*y[129]-4.*y[58])/Rpn+2.*kn*(y[16]*c0)^.5*(-1.*y[129]*ctn+ctn)^.5*(y[129]*ctn)^.5*sinh(.5*F/R/Tr*(y[100]-1.*y[82]+.5e-1-2.325*exp(-100.*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.*Dsn*(y[52]+3.*y[130]-4.*y[59])/Rpn+2.*kn*(y[17]*c0)^.5*(-1.*y[130]*ctn+ctn)^.5*(y[130]*ctn)^.5*sinh(.5*F/R/Tr*(y[101]-1.*y[83]+.5e-1-2.325*exp(-100.*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(zeros(n),y,pars,0.)
using ForwardDiff

# Really long compile time
ForwardDiff.jacobian(f,dy,y0)
@jrevels
Copy link
Member

jrevels commented Jun 8, 2018

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 Tuples of partial derivatives into a large portion of a target program's scalar computations, and then does a lot of unrolling and specialization on those tuples. Here's another ForwardDiff compilation nightmare example: JuliaDiff/ForwardDiff.jl#278

@ChrisRackauckas
Copy link
Member Author

So is this a max tuple length being too small kind of thing? #22370

@dlfivefifty
Copy link
Contributor

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)

@ChrisRackauckas
Copy link
Member Author

That seems unrelated. This is true on v0.6.3 and is not related to v0.7 regressions.

@dlfivefifty
Copy link
Contributor

dlfivefifty commented Jun 8, 2018

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

@ViralBShah ViralBShah added the compiler:latency Compiler latency label Jun 8, 2018
@ViralBShah ViralBShah modified the milestone: 1.0 Jun 8, 2018
@tknopp
Copy link
Contributor

tknopp commented Jun 9, 2018

I sped this up to "only" 15x slowdown on master by making the code type stable

This is where nobody has a concrete answer for:
https://discourse.julialang.org/t/does-compile-time-depend-on-type-stability/6548/4

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.

@ChrisRackauckas
Copy link
Member Author

ChrisRackauckas commented Jun 9, 2018

I'm not sure this is related though. This is type-stable and was tracked down to issues with large NTuples.

@dlfivefifty
Copy link
Contributor

I filed a separate issue #27512

@ChrisRackauckas
Copy link
Member Author

ChrisRackauckas commented Aug 25, 2018

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.

842.944606 seconds (15.81 M allocations: 1.411 GiB, 0.08% gc time)

@ChrisRackauckas ChrisRackauckas changed the title 500 second compile time on ForwardDiff example 800 second compile time on ForwardDiff example Aug 25, 2018
@timholy
Copy link
Member

timholy commented Aug 25, 2018

Almost surely a duplicate of #25927? Take a @profile and see if construct_domtree! is the major bottleneck during compilation. If so, put a link to this issue in #25927 and then close this.

If it's not construct_domtree!, leave this open (preferably with info from the profile about where the bottleneck is).

@ChrisRackauckas
Copy link
Member Author

# Really long compile time
using Profile
Profile.init(n = 10^6, delay = 1.0)
@profile ForwardDiff.jacobian(f,dy,y0)

Profile.print(format=:flat)
 Warning: The profile data buffer is full; profiling probably terminated
│ before your program finished. To profile for longer runs, call
│ `Profile.init()` with a larger buffer and/or larger delay.
└ @ Profile C:\cygwin\home\Administrator\buildbot\worker\package_win64\build\usr\share\julia\stdlib\v1.0\Profile\src\Profile.jl:312
 Count File                          Line Function
    15 .\abstractarray.jl             649 copyto!(::Array{Int64,1}, ::Core.Compil...    62 .\abstractarray.jl             650 copyto!(::Array{Int64,1}, ::Core.Compil...    14 .\abstractarray.jl            1835 foreach
     1 .\abstractarray.jl             841 isempty
     1 .\abstractarray.jl            1980 map!(::getfield(Core.Compiler, Symbol("...     1 .\abstractarray.jl            1981 map!
    39 .\abstractarray.jl             617 similar
    39 .\abstractarray.jl             618 similar
     1 .\abstractdict.jl              512 Type
     4 .\array.jl                    1024 Type
     1 .\array.jl                     523 _collect(::Type{Int64}, ::Core.Compiler...   105 .\array.jl                     563 _collect(::Core.Compiler.UnitRange{Int6...    14 .\array.jl                     814 _growend!
     1 .\array.jl                     532 _similar_for
     1 .\array.jl                     898 cfg_inline_item!(::Core.Compiler.Inlini...     1 .\array.jl                     518 collect
   105 .\array.jl                     557 collect
     1 .\array.jl                     557 collect(::Core.Compiler.Iterators.Filte...     7 .\array.jl                     274 copyto!(::Array{Int64,1}, ::Int64, ::Ar...     6 .\array.jl                     277 copyto!
     3 .\array.jl                     416 fill
     3 .\array.jl                     418 fill
    13 .\array.jl                     365 getindex
     1 .\array.jl                     366 getindex
  1875 .\array.jl                     731 getindex
   528 .\array.jl                     707 iterate
     1 .\array.jl                     707 iterate(::Array{Any,1})
     2 .\array.jl                     707 iterate
     1 .\array.jl                     707 iterate(::Array{Any,1})
    75 .\array.jl                     707 iterate
     4 .\array.jl                     199 length
     5 .\array.jl                     856 push!
     2 .\array.jl                     862 push!
     7 .\array.jl                    1006 resize!
   130 .\array.jl                     769 setindex!
     1 .\array.jl                    1024 sizehint!
     7 .\array.jl                     225 unsafe_copyto!
     7 .\array.jl                     244 unsafe_copyto!(::Array{UInt64,1}, ::Int...     3 .\array.jl                     464 zeros
     3 .\array.jl                     467 zeros
    14 .\bitarray.jl                   85 _div64
     8 .\bitarray.jl                 1356 unsafe_bitfindnext(::Array{UInt64,1}, :...     1 .\bitarray.jl                 1358 unsafe_bitfindnext(::Array{UInt64,1}, :...     7 .\bitarray.jl                 1361 unsafe_bitfindnext(::Array{UInt64,1}, :...     9 .\bitarray.jl                 1362 unsafe_bitfindnext(::Array{UInt64,1}, :...     3 .\bitset.jl                     18 Type
     1 .\bitset.jl                     29 Type
     6 .\bitset.jl                     76 _bits_findnext
    43 .\bitset.jl                     77 _bits_findnext
     6 .\bitset.jl                     78 _bits_findnext
  3286 .\bitset.jl                     67 _bits_getindex
   273 .\bitset.jl                     68 _bits_getindex
    28 .\bitset.jl                     69 _bits_getindex
    16 .\bitset.jl                     46 copy(::Core.Compiler.BitSet)
     6 .\bitset.jl                     58 copy!
     6 .\bitset.jl                     59 copy!
     1 .\bitset.jl                     18 find_ssavalue_uses(::Array{Any,1}, ::In...  3708 .\bitset.jl                    300 in
    56 .\bitset.jl                    304 iterate
     4 .\bitset.jl                    305 iterate
     1 .\bitset.jl                    322 length
   161 .\boot.jl                      506 (::Core.GeneratedFunctionStub)(::Any, :...    21 .\boot.jl                      221 Type
     1 .\boot.jl                      368 Type
     7 .\boot.jl                      372 Type
    72 .\boot.jl                      394 Type
    44 .\boot.jl                      403 Type
     1 .\boot.jl                      408 Type
    39 .\boot.jl                      411 Type
    16 .\boot.jl                      413 Type
    26 .\boot.jl                      394 _similar_for
     3 .\compiler/ssair\domtree.jl     10 Type
     1 .\compiler/ssair\domtree.jl     61 construct_domtree(::Core.Compiler.CFG)
    11 .\compiler/ssair\domtree.jl     62 construct_domtree(::Core.Compiler.CFG)
     2 .\compiler/ssair\domtree.jl     67 construct_domtree(::Core.Compiler.CFG)
     6 .\compiler/ssair\domtree.jl     69 construct_domtree(::Core.Compiler.CFG)
     2 .\compiler/ssair\domtree.jl     79 construct_domtree(::Core.Compiler.CFG)
   105 .\compiler/ssair\domtree.jl     81 construct_domtree(::Core.Compiler.CFG)
     5 .\compiler/ssair\domtree.jl     83 construct_domtree(::Core.Compiler.CFG)
    39 .\compiler/ssair\domtree.jl     85 construct_domtree(::Core.Compiler.CFG)
 21636 .\compiler/ssair\domtree.jl     86 construct_domtree(::Core.Compiler.CFG)
   548 .\compiler/ssair\domtree.jl     87 construct_domtree(::Core.Compiler.CFG)
   113 .\compiler/ssair\domtree.jl     91 construct_domtree(::Core.Compiler.CFG)
     3 .\compiler/ssair\domtree.jl    102 construct_domtree(::Core.Compiler.CFG)
     8 .\compiler/ssair\driver.jl     103 just_construct_ssa(::Core.CodeInfo, ::A...     4 .\compiler/ssair\driver.jl     104 just_construct_ssa(::Core.CodeInfo, ::A...    25 .\compiler/ssair\driver.jl     109 just_construct_ssa(::Core.CodeInfo, ::A...    41 .\compiler/ssair\driver.jl     114 run_passes(::Core.CodeInfo, ::Int64, ::...     3 .\compiler/ssair\driver.jl     117 run_passes(::Core.CodeInfo, ::Int64, ::...   368 .\compiler/ssair\driver.jl     118 run_passes(::Core.CodeInfo, ::Int64, ::... 22470 .\compiler/ssair\driver.jl     120 run_passes(::Core.CodeInfo, ::Int64, ::...     4 .\compiler/ssair\driver.jl     121 run_passes(::Core.CodeInfo, ::Int64, ::...    17 .\compiler/ssair\driver.jl     123 run_passes(::Core.CodeInfo, ::Int64, ::...     6 .\compiler/ssair\driver.jl     126 run_passes(::Core.CodeInfo, ::Int64, ::...     1 .\compiler/ssair\driver.jl     128 run_passes(::Core.CodeInfo, ::Int64, ::...     9 .\compiler/ssair\driver.jl     129 run_passes(::Core.CodeInfo, ::Int64, ::...     2 .\compiler/ssair\inlining.jl    10 Core.Compiler.InliningTodo(::Int64, ::B...     1 .\compiler/ssair\inlining.jl    79 Core.Compiler.CFGInliningState(::Core.C...     1 .\compiler/ssair\inlining.jl   621 analyze_method!(::Int64, ::Any, ::Any, ...     4 .\compiler/ssair\inlining.jl   644 analyze_method!(::Int64, ::Any, ::Any, ...     1 .\compiler/ssair\inlining.jl   652 analyze_method!(::Int64, ::Any, ::Any, ...     7 .\compiler/ssair\inlining.jl   655 analyze_method!(::Int64, ::Any, ::Any, ...    12 .\compiler/ssair\inlining.jl   675 analyze_method!(::Int64, ::Any, ::Any, ...    11 .\compiler/ssair\inlining.jl   677 analyze_method!(::Int64, ::Any, ::Any, ...    75 .\compiler/ssair\inlining.jl   682 analyze_method!(::Int64, ::Any, ::Any, ...     6 .\compiler/ssair\inlining.jl   686 analyze_method!(::Int64, ::Any, ::Any, ...     1 .\compiler/ssair\inlining.jl   767 assemble_inline_todo!(::Core.Compiler.I...     1 .\compiler/ssair\inlining.jl   773 assemble_inline_todo!(::Core.Compiler.I...     3 .\compiler/ssair\inlining.jl   776 assemble_inline_todo!(::Core.Compiler.I...     1 .\compiler/ssair\inlining.jl   777 assemble_inline_todo!(::Core.Compiler.I...     1 .\compiler/ssair\inlining.jl   779 assemble_inline_todo!(::Core.Compiler.I...     2 .\compiler/ssair\inlining.jl   785 assemble_inline_todo!(::Core.Compiler.I...     1 .\compiler/ssair\inlining.jl   791 assemble_inline_todo!(::Core.Compiler.I...    10 .\compiler/ssair\inlining.jl   840 assemble_inline_todo!(::Core.Compiler.I...     1 .\compiler/ssair\inlining.jl   850 assemble_inline_todo!(::Core.Compiler.I...    66 .\compiler/ssair\inlining.jl   869 assemble_inline_todo!(::Core.Compiler.I...     9 .\compiler/ssair\inlining.jl   877 assemble_inline_todo!(::Core.Compiler.I...     3 .\compiler/ssair\inlining.jl   883 assemble_inline_todo!(::Core.Compiler.I...     1 .\compiler/ssair\inlining.jl   884 assemble_inline_todo!(::Core.Compiler.I...   116 .\compiler/ssair\inlining.jl   889 assemble_inline_todo!(::Core.Compiler.I...     3 .\compiler/ssair\inlining.jl   937 assemble_inline_todo!(::Core.Compiler.I...     2 .\compiler/ssair\inlining.jl   946 assemble_inline_todo!(::Core.Compiler.I...     1 .\compiler/ssair\inlining.jl   950 assemble_inline_todo!(::Core.Compiler.I...     1 .\compiler/ssair\inlining.jl   464 batch_inline!(::Array{Any,1}, ::Core.Co...    13 .\compiler/ssair\inlining.jl   472 batch_inline!(::Array{Any,1}, ::Core.Co...     1 .\compiler/ssair\inlining.jl   475 batch_inline!(::Array{Any,1}, ::Core.Co...     3 .\compiler/ssair\inlining.jl   507 batch_inline!(::Array{Any,1}, ::Core.Co...    91 .\compiler/ssair\inlining.jl   515 batch_inline!(::Array{Any,1}, ::Core.Co...     1 .\compiler/ssair\inlining.jl   517 batch_inline!(::Array{Any,1}, ::Core.Co...     3 .\compiler/ssair\inlining.jl   534 batch_inline!(::Array{Any,1}, ::Core.Co...    32 .\compiler/ssair\inlining.jl   538 batch_inline!(::Array{Any,1}, ::Core.Co...    13 .\compiler/ssair\inlining.jl   106 cfg_inline_item!
     6 .\compiler/ssair\inlining.jl   148 cfg_inline_item!(::Core.Compiler.Inlini...     3 .\compiler/ssair\inlining.jl   156 cfg_inline_item!(::Core.Compiler.Inlini...     2 .\compiler/ssair\inlining.jl   159 cfg_inline_item!(::Core.Compiler.Inlini...     1 .\compiler/ssair\inlining.jl   165 cfg_inline_item!(::Core.Compiler.Inlini...     1 .\compiler/ssair\inlining.jl  1025 early_inline_special_case(::Core.Compil...     7 .\compiler/ssair\inlining.jl  1144 find_inferred(::Core.MethodInstance, ::...     1 .\compiler/ssair\inlining.jl   262 finish_cfg_inline!(::Core.Compiler.CFGI...     1 .\compiler/ssair\inlining.jl   741 handle_single_case!(::Core.Compiler.IRC...     1 .\compiler/ssair\inlining.jl   752 handle_single_case!(::Core.Compiler.IRC...     1 .\compiler/ssair\inlining.jl   277 ir_inline_item!(::Core.Compiler.Increme...     7 .\compiler/ssair\inlining.jl   278 ir_inline_item!(::Core.Compiler.Increme...     3 .\compiler/ssair\inlining.jl   299 ir_inline_item!(::Core.Compiler.Increme...     1 .\compiler/ssair\inlining.jl   300 ir_inline_item!(::Core.Compiler.Increme...     1 .\compiler/ssair\inlining.jl   307 ir_inline_item!(::Core.Compiler.Increme...     2 .\compiler/ssair\inlining.jl   316 ir_inline_item!(::Core.Compiler.Increme...     1 .\compiler/ssair\inlining.jl   330 ir_inline_item!(::Core.Compiler.Increme...    11 .\compiler/ssair\inlining.jl   331 ir_inline_item!(::Core.Compiler.Increme...    18 .\compiler/ssair\inlining.jl   332 ir_inline_item!(::Core.Compiler.Increme...    45 .\compiler/ssair\inlining.jl   363 ir_inline_item!(::Core.Compiler.Increme...     1 .\compiler/ssair\inlining.jl   371 ir_inline_item!(::Core.Compiler.Increme...     1 .\compiler/ssair\inlining.jl   430 ir_inline_unionsplit!(::Core.Compiler.I...     1 .\compiler/ssair\inlining.jl  1002 ispuretopfunction(::Any)
   223 .\compiler/ssair\inlining.jl    60 ssa_inlining_pass!
   145 .\compiler/ssair\inlining.jl    63 ssa_inlining_pass!
     1 .\compiler/ssair\inlining.jl  1079 ssa_substitute!
    17 .\compiler/ssair\inlining.jl  1081 ssa_substitute!
     1 .\compiler/ssair\inlining.jl  1092 ssa_substitute_op!(::Any, ::Array{Any,1...     1 .\compiler/ssair\inlining.jl  1107 ssa_substitute_op!(::Any, ::Array{Any,1...     4 .\compiler/ssair\inlining.jl  1124 ssa_substitute_op!(::Any, ::Array{Any,1...     5 .\compiler/ssair\inlining.jl  1125 ssa_substitute_op!(::Any, ::Array{Any,1...    11 .\compiler/ssair\inlining.jl  1126 ssa_substitute_op!(::Any, ::Array{Any,1...     1 .\compiler/ssair\inlining.jl  1128 ssa_substitute_op!(::Any, ::Array{Any,1...     1 .\compiler/ssair\ir.jl          39 Type
     1 .\compiler/ssair\ir.jl         207 Type
    33 .\compiler/ssair\ir.jl         245 Type
    46 .\compiler/ssair\ir.jl         250 Type
     1 .\compiler/ssair\ir.jl         469 Core.Compiler.IncrementalCompact(::Core...     1 .\compiler/ssair\ir.jl         474 Core.Compiler.IncrementalCompact(::Core...     1 .\compiler/ssair\ir.jl         477 Core.Compiler.IncrementalCompact(::Core...     2 .\compiler/ssair\ir.jl         490 Core.Compiler.IncrementalCompact(::Core...     1 .\compiler/ssair\ir.jl         491 Core.Compiler.IncrementalCompact(::Core...     1 .\compiler/ssair\ir.jl        1024 compact!(::Core.Compiler.IRCode)
    14 .\compiler/ssair\ir.jl        1026 compact!(::Core.Compiler.IRCode)
     1 .\compiler/ssair\ir.jl        1027 compact!(::Core.Compiler.IRCode)
     1 .\compiler/ssair\ir.jl         116 compute_basic_blocks(::Array{Any,1})
     1 .\compiler/ssair\ir.jl         119 compute_basic_blocks(::Array{Any,1})
     5 .\compiler/ssair\ir.jl         542 count_added_node!(::Core.Compiler.Incre...     1 .\compiler/ssair\ir.jl         543 count_added_node!(::Core.Compiler.Incre...     3 .\compiler/ssair\ir.jl         547 count_added_node!(::Core.Compiler.Incre...     1 .\compiler/ssair\ir.jl         551 count_added_node!(::Core.Compiler.Incre...    33 .\compiler/ssair\ir.jl        1014 finish
     1 .\compiler/ssair\ir.jl         823 finish_current_bb!(::Core.Compiler.Incr...     1 .\compiler/ssair\ir.jl         252 getindex
     8 .\compiler/ssair\ir.jl         267 getindex(::Core.Compiler.UseRef)
     1 .\compiler/ssair\ir.jl         268 getindex(::Core.Compiler.UseRef)
     1 .\compiler/ssair\ir.jl         277 getindex(::Core.Compiler.UseRef)
     2 .\compiler/ssair\ir.jl         279 getindex(::Core.Compiler.UseRef)
     2 .\compiler/ssair\ir.jl         280 getindex(::Core.Compiler.UseRef)
     2 .\compiler/ssair\ir.jl         303 getindex(::Core.Compiler.UseRef)
     2 .\compiler/ssair\ir.jl         305 getindex(::Core.Compiler.UseRef)
     2 .\compiler/ssair\ir.jl         310 is_relevant_expr
    15 .\compiler/ssair\ir.jl         367 iterate
    13 .\compiler/ssair\ir.jl         369 iterate(::Core.Compiler.UseRefIterator,...     1 .\compiler/ssair\ir.jl         372 iterate(::Core.Compiler.UseRefIterator,...    12 .\compiler/ssair\ir.jl         373 iterate(::Core.Compiler.UseRefIterator,...     2 .\compiler/ssair\ir.jl         375 iterate(::Core.Compiler.UseRefIterator,...     2 .\compiler/ssair\ir.jl         853 iterate
     1 .\compiler/ssair\ir.jl         853 iterate(::Core.Compiler.IncrementalComp...     1 .\compiler/ssair\ir.jl         858 iterate(::Core.Compiler.IncrementalComp...     1 .\compiler/ssair\ir.jl         881 iterate(::Core.Compiler.IncrementalComp...    54 .\compiler/ssair\ir.jl         882 iterate(::Core.Compiler.IncrementalComp...     1 .\compiler/ssair\ir.jl         887 iterate(::Core.Compiler.IncrementalComp...     5 .\compiler/ssair\ir.jl         889 iterate(::Core.Compiler.IncrementalComp...     4 .\compiler/ssair\ir.jl         894 iterate(::Core.Compiler.IncrementalComp...    33 .\compiler/ssair\ir.jl         898 maybe_erase_unused!
     3 .\compiler/ssair\ir.jl         903 maybe_erase_unused!(::Array{Int64,1}, :...    30 .\compiler/ssair\ir.jl         906 maybe_erase_unused!(::Array{Int64,1}, :...     2 .\compiler/ssair\ir.jl         760 process_node!(::Array{Any,1}, ::Int64, ...     1 .\compiler/ssair\ir.jl         763 process_node!(::Array{Any,1}, ::Int64, ...    51 .\compiler/ssair\ir.jl         769 process_node!(::Array{Any,1}, ::Int64, ...    54 .\compiler/ssair\ir.jl         790 process_node!
     1 .\compiler/ssair\ir.jl         726 renumber_ssa2(::Core.SSAValue, ::Array{...     8 .\compiler/ssair\ir.jl         734 renumber_ssa2(::Core.SSAValue, ::Array{...    25 .\compiler/ssair\ir.jl         740 renumber_ssa2!(::Any, ::Array{Any,1}, :...     6 .\compiler/ssair\ir.jl         741 renumber_ssa2!(::Any, ::Array{Any,1}, :...     3 .\compiler/ssair\ir.jl         742 renumber_ssa2!(::Any, ::Array{Any,1}, :...     1 .\compiler/ssair\ir.jl         743 renumber_ssa2!(::Any, ::Array{Any,1}, :...    10 .\compiler/ssair\ir.jl         747 renumber_ssa2!(::Any, ::Array{Any,1}, :...     5 .\compiler/ssair\ir.jl         752 renumber_ssa2!(::Any, ::Array{Any,1}, :...     1 .\compiler/ssair\ir.jl         754 renumber_ssa2!(::Any, ::Array{Any,1}, :...     1 .\compiler/ssair\ir.jl         801 resize!(::Core.Compiler.IncrementalComp...     1 .\compiler/ssair\ir.jl         319 setindex!(::Core.Compiler.UseRef, ::Any)
     2 .\compiler/ssair\ir.jl         333 setindex!(::Core.Compiler.UseRef, ::Any)
     1 .\compiler/ssair\ir.jl         345 setindex!(::Core.Compiler.UseRef, ::Any)
     1 .\compiler/ssair\ir.jl         636 setindex!(::Core.Compiler.IncrementalCo...     5 .\compiler/ssair\ir.jl         639 setindex!(::Core.Compiler.IncrementalCo...     1 .\compiler/ssair\ir.jl         640 setindex!(::Core.Compiler.IncrementalCo...     1 .\compiler/ssair\ir.jl         641 setindex!(::Core.Compiler.IncrementalCo...     1 .\compiler/ssair\ir.jl         643 setindex!(::Core.Compiler.IncrementalCo...    10 .\compiler/ssair\ir.jl         648 setindex!(::Core.Compiler.IncrementalCo...    19 .\compiler/ssair\ir.jl         655 setindex!
     2 .\compiler/ssair\ir.jl         987 simple_dce!(::Core.Compiler.Incremental...    31 .\compiler/ssair\ir.jl         991 simple_dce!(::Core.Compiler.Incremental...     1 .\compiler/ssair\ir.jl         409 ssamap(::getfield(Core.Compiler, Symbol...     1 .\compiler/ssair\ir.jl         411 ssamap(::getfield(Core.Compiler, Symbol...    23 .\compiler/ssair\ir.jl         245 userefs
     2 .\compiler/ssair\ir.jl         361 userefs
    46 .\compiler/ssair\ir.jl         364 userefs
    11 .\compiler/ssair\legacy.jl       8 inflate_ir(::Core.CodeInfo, ::Core.Meth...    64 .\compiler/ssair\legacy.jl      12 inflate_ir(::Core.CodeInfo, ::Core.Meth...    54 .\compiler/ssair\legacy.jl      16 inflate_ir(::Core.CodeInfo, ::Core.Simp...     2 .\compiler/ssair\legacy.jl      22 inflate_ir(::Core.CodeInfo, ::Core.Simp...     2 .\compiler/ssair\legacy.jl      25 inflate_ir(::Core.CodeInfo, ::Core.Simp...     1 .\compiler/ssair\legacy.jl      26 inflate_ir(::Core.CodeInfo, ::Core.Simp...     2 .\compiler/ssair\legacy.jl      29 inflate_ir(::Core.CodeInfo, ::Core.Simp...     2 .\compiler/ssair\legacy.jl      39 inflate_ir(::Core.CodeInfo, ::Core.Simp...     1 .\compiler/ssair\legacy.jl      48 inflate_ir(::Core.CodeInfo, ::Core.Simp...     3 .\compiler/ssair\legacy.jl      67 replace_code_newstyle!(::Core.CodeInfo,...     1 .\compiler/ssair\legacy.jl      71 replace_code_newstyle!(::Core.CodeInfo,...     1 .\compiler/ssair\legacy.jl      80 replace_code_newstyle!(::Core.CodeInfo,...     1 .\compiler/ssair\legacy.jl      83 replace_code_newstyle!(::Core.CodeInfo,...     1 .\compiler/ssair\passes.jl     197 (::getfield(Core.Compiler, Symbol("##27...     2 .\compiler/ssair\passes.jl     812 adce_erase!
     1 .\compiler/ssair\passes.jl     841 adce_pass!(::Core.Compiler.IRCode)
     1 .\compiler/ssair\passes.jl     843 adce_pass!(::Core.Compiler.IRCode)
     1 .\compiler/ssair\passes.jl     846 adce_pass!(::Core.Compiler.IRCode)
     1 .\compiler/ssair\passes.jl     854 adce_pass!(::Core.Compiler.IRCode)
     2 .\compiler/ssair\passes.jl     858 adce_pass!(::Core.Compiler.IRCode)
     1 .\compiler/ssair\passes.jl     506 getfield_elim_pass!(::Core.Compiler.IRC...     1 .\compiler/ssair\passes.jl     521 getfield_elim_pass!(::Core.Compiler.IRC...     1 .\compiler/ssair\passes.jl     523 getfield_elim_pass!(::Core.Compiler.IRC...     1 .\compiler/ssair\passes.jl     547 getfield_elim_pass!(::Core.Compiler.IRC...     2 .\compiler/ssair\passes.jl     554 getfield_elim_pass!(::Core.Compiler.IRC...     1 .\compiler/ssair\passes.jl     610 getfield_elim_pass!(::Core.Compiler.IRC...     1 .\compiler/ssair\passes.jl     612 getfield_elim_pass!(::Core.Compiler.IRC...     2 .\compiler/ssair\passes.jl     645 getfield_elim_pass!(::Core.Compiler.IRC...     2 .\compiler/ssair\passes.jl     652 getfield_elim_pass!(::Core.Compiler.IRC...     2 .\compiler/ssair\passes.jl     671 getfield_elim_pass!(::Core.Compiler.IRC...     3 .\compiler/ssair\passes.jl     688 getfield_elim_pass!(::Core.Compiler.IRC...     1 .\compiler/ssair\passes.jl     397 lift_comparison!(::Core.Compiler.Increm...     1 .\compiler/ssair\passes.jl     402 lift_comparison!(::Core.Compiler.Increm...     1 .\compiler/ssair\passes.jl     264 lift_leaves(::Core.Compiler.Incremental...     1 .\compiler/ssair\passes.jl     268 lift_leaves(::Core.Compiler.Incremental...     1 .\compiler/ssair\passes.jl     453 perform_lifting!(::Core.Compiler.Increm...     1 .\compiler/ssair\passes.jl     454 perform_lifting!(::Core.Compiler.Increm...     2 .\compiler/ssair\passes.jl     169 walk_to_defs(::Core.Compiler.Incrementa...     1 .\compiler/ssair\passes.jl     191 walk_to_defs(::Core.Compiler.Incrementa...     3 .\compiler/ssair\queries.jl     67 compact_exprtype
     3 .\compiler/ssair\queries.jl     76 is_known_call
     3 .\compiler/ssair\queries.jl      7 stmt_effect_free(::Any, ::Any, ::Core.C...     1 .\compiler/ssair\slot2ssa.jl     8 Type
     1 .\compiler/ssair\slot2ssa.jl   520 compute_live_ins(::Core.Compiler.CFG, :...     1 .\compiler/ssair\slot2ssa.jl   522 compute_live_ins(::Core.Compiler.CFG, :...     1 .\compiler/ssair\slot2ssa.jl   598 construct_ssa!(::Core.CodeInfo, ::Array...     2 .\compiler/ssair\slot2ssa.jl   628 construct_ssa!(::Core.CodeInfo, ::Array...     1 .\compiler/ssair\slot2ssa.jl   654 construct_ssa!(::Core.CodeInfo, ::Array...     1 .\compiler/ssair\slot2ssa.jl   670 construct_ssa!(::Core.CodeInfo, ::Array...     1 .\compiler/ssair\slot2ssa.jl   732 construct_ssa!(::Core.CodeInfo, ::Array...     6 .\compiler/ssair\slot2ssa.jl   740 construct_ssa!(::Core.CodeInfo, ::Array...     1 .\compiler/ssair\slot2ssa.jl   768 construct_ssa!(::Core.CodeInfo, ::Array...     1 .\compiler/ssair\slot2ssa.jl   775 construct_ssa!(::Core.CodeInfo, ::Array...     3 .\compiler/ssair\slot2ssa.jl   791 construct_ssa!(::Core.CodeInfo, ::Array...     1 .\compiler/ssair\slot2ssa.jl   813 construct_ssa!(::Core.CodeInfo, ::Array...     3 .\compiler/ssair\slot2ssa.jl   862 construct_ssa!(::Core.CodeInfo, ::Array...     1 .\compiler/ssair\slot2ssa.jl   864 construct_ssa!(::Core.CodeInfo, ::Array...     3 .\compiler/ssair\slot2ssa.jl   869 construct_ssa!(::Core.CodeInfo, ::Array...     2 .\compiler/ssair\slot2ssa.jl   494 domsort_ssa!(::Core.Compiler.IRCode, ::...     1 .\compiler/ssair\slot2ssa.jl   499 domsort_ssa!(::Core.Compiler.IRCode, ::...     2 .\compiler/ssair\slot2ssa.jl   122 fixemup!(::getfield(Core.Compiler, Symb...     3 .\compiler/ssair\slot2ssa.jl   126 fixemup!(::getfield(Core.Compiler, Symb...     1 .\compiler/ssair\slot2ssa.jl   159 fixemup!(::getfield(Core.Compiler, Symb...     1 .\compiler/ssair\slot2ssa.jl   160 fixemup!(::getfield(Core.Compiler, Symb...     1 .\compiler/ssair\slot2ssa.jl   163 fixemup!(::getfield(Core.Compiler, Symb...     1 .\compiler/ssair\slot2ssa.jl    94 new_to_regular(::Any, ::Int64)
     1 .\compiler/ssair\slot2ssa.jl    98 new_to_regular(::Any, ::Int64)
     6 .\compiler/ssair\slot2ssa.jl   182 rename_uses!(::Core.Compiler.IRCode, ::...     1 .\compiler/ssair\slot2ssa.jl    73 renumber_ssa!
     1 .\compiler/ssair\slot2ssa.jl    73 renumber_ssa!(::Any, ::Array{Any,1})
     2 .\compiler/ssair\slot2ssa.jl    74 renumber_ssa!
     2 .\compiler/ssair\slot2ssa.jl    23 scan_entry!(::Array{Core.Compiler.SlotI...     3 .\compiler/ssair\slot2ssa.jl    24 scan_entry!(::Array{Core.Compiler.SlotI...     1 .\compiler/ssair\slot2ssa.jl    29 scan_entry!(::Array{Core.Compiler.SlotI...     1 .\compiler/ssair\slot2ssa.jl    49 scan_slot_def_use(::Int64, ::Core.CodeI...     1 .\compiler/ssair\slot2ssa.jl    52 scan_slot_def_use(::Int64, ::Core.CodeI...     6 .\compiler/ssair\slot2ssa.jl    55 scan_slot_def_use(::Int64, ::Core.CodeI...     3 ...abstractinterpretation.jl   470 abstract_apply(::Any, ::Array{Any,1}, :...    68 ...abstractinterpretation.jl   487 abstract_apply(::Any, ::Array{Any,1}, :...    71 ...abstractinterpretation.jl   535 abstract_call(::Any, ::Array{Any,1}, ::...     5 ...abstractinterpretation.jl   561 abstract_call(::Any, ::Array{Any,1}, ::...     2 ...abstractinterpretation.jl   563 abstract_call(::Any, ::Array{Any,1}, ::...     3 ...abstractinterpretation.jl   708 abstract_call(::Any, ::Array{Any,1}, ::...     5 ...abstractinterpretation.jl   754 abstract_call(::Any, ::Tuple{}, ::Array...     6 ...abstractinterpretation.jl   755 abstract_call(::Any, ::Array{Any,1}, ::...     3 ...abstractinterpretation.jl   765 abstract_call(::Any, ::Array{Any,1}, ::...  2026 ...abstractinterpretation.jl   779 abstract_call(::Any, ::Tuple{}, ::Array...     1 ...abstractinterpretation.jl    17 abstract_call_gf_by_type(::Any, ::Array...     1 ...abstractinterpretation.jl    33 abstract_call_gf_by_type(::Any, ::Array...    74 ...abstractinterpretation.jl    45 abstract_call_gf_by_type(::Any, ::Array...  1649 ...abstractinterpretation.jl    79 abstract_call_gf_by_type(::Any, ::Array...     1 ...abstractinterpretation.jl    81 abstract_call_gf_by_type(::Any, ::Array...     3 ...abstractinterpretation.jl    83 abstract_call_gf_by_type(::Any, ::Array...   368 ...abstractinterpretation.jl    91 abstract_call_gf_by_type(::Any, ::Array...     1 ...abstractinterpretation.jl    99 abstract_call_gf_by_type(::Any, ::Array...    11 ...abstractinterpretation.jl   105 abstract_call_gf_by_type(::Any, ::Array...  1646 ...abstractinterpretation.jl   331 abstract_call_method(::Method, ::Any, :...     3 ...abstractinterpretation.jl   335 abstract_call_method(::Method, ::Any, :...     2 ...abstractinterpretation.jl   127 abstract_call_method_with_const_args(::...    13 ...abstractinterpretation.jl   166 abstract_call_method_with_const_args(::...     1 ...abstractinterpretation.jl   182 abstract_call_method_with_const_args(::...    12 ...abstractinterpretation.jl   187 abstract_call_method_with_const_args(::...     1 ...abstractinterpretation.jl   189 abstract_call_method_with_const_args(::...   338 ...abstractinterpretation.jl   191 abstract_call_method_with_const_args(::...     1 ...abstractinterpretation.jl   195 abstract_call_method_with_const_args(::...     1 ...abstractinterpretation.jl   879 abstract_eval(::Any, ::Array{Any,1}, ::...     1 ...abstractinterpretation.jl   880 abstract_eval(::Any, ::Array{Any,1}, ::...     1 ...abstractinterpretation.jl   882 abstract_eval(::Any, ::Array{Any,1}, ::...     1 ...abstractinterpretation.jl   884 abstract_eval(::Any, ::Array{Any,1}, ::...     1 ...abstractinterpretation.jl   892 abstract_eval(::Any, ::Array{Any,1}, ::...  2132 ...abstractinterpretation.jl   893 abstract_eval(::Any, ::Array{Any,1}, ::...    83 ...abstractinterpretation.jl   806 abstract_eval_call(::Array{Any,1}, ::Ar...  2049 ...abstractinterpretation.jl   808 abstract_eval_call(::Array{Any,1}, ::Ar...     4 ...abstractinterpretation.jl   973 abstract_eval_global
     2 ...abstractinterpretation.jl   974 abstract_eval_global
     1 ...abstractinterpretation.jl   980 abstract_eval_ssavalue(::Core.SSAValue,...     1 ...abstractinterpretation.jl   409 abstract_iteration(::Any, ::Array{Any,1...     3 ...abstractinterpretation.jl   356 precise_container_type(::Any, ::Any, ::...     1 ...abstractinterpretation.jl   394 precise_container_type(::Any, ::Any, ::...     1 ...abstractinterpretation.jl   399 precise_container_type(::Any, ::Any, ::...     6 ...abstractinterpretation.jl   512 pure_eval_call(::Any, ::Array{Any,1}, :...     1 ...abstractinterpretation.jl  1014 typeinf_local(::Core.Compiler.Inference...     1 ...abstractinterpretation.jl  1027 typeinf_local(::Core.Compiler.Inference...     1 ...abstractinterpretation.jl  1032 typeinf_local(::Core.Compiler.Inference...   171 ...abstractinterpretation.jl  1103 typeinf_local(::Core.Compiler.Inference...  1964 ...abstractinterpretation.jl  1117 typeinf_local(::Core.Compiler.Inference...     1 ...abstractinterpretation.jl  1120 typeinf_local(::Core.Compiler.Inference...     1 ...abstractinterpretation.jl  1141 typeinf_local(::Core.Compiler.Inference...     1 ...abstractinterpretation.jl  1146 typeinf_local(::Core.Compiler.Inference...  2141 ...abstractinterpretation.jl  1173 typeinf_nocycle(::Core.Compiler.Inferen...     1 ...mpiler\inferenceresult.jl   116 cache_lookup(::Core.MethodInstance, ::A...     2 ...mpiler\inferenceresult.jl   123 cache_lookup(::Core.MethodInstance, ::A...    12 ...mpiler\inferenceresult.jl   126 cache_lookup(::Core.MethodInstance, ::A...     5 ...mpiler\inferenceresult.jl   129 cache_lookup(::Core.MethodInstance, ::A...     1 ...mpiler\inferenceresult.jl    25 get_argtypes
     1 ...mpiler\inferenceresult.jl    36 get_argtypes(::Core.MethodInstance)
     8 ...mpiler\inferenceresult.jl    37 get_argtypes(::Core.MethodInstance)
     1 ...mpiler\inferenceresult.jl    63 get_argtypes(::Core.MethodInstance)
     1 ...mpiler\inferenceresult.jl    92 get_argtypes(::Core.MethodInstance)
     1 ...mpiler\inferenceresult.jl    97 get_argtypes(::Core.MethodInstance)
     1 .\compiler\inferencestate.jl    62 Core.Compiler.InferenceState(::Core.Com...     2 .\compiler\inferencestate.jl    73 Core.Compiler.InferenceState(::Core.Com...     1 .\compiler\inferencestate.jl    77 Core.Compiler.InferenceState(::Core.Com...   176 .\compiler\inferencestate.jl   117 Type
     4 .\compiler\inferencestate.jl   120 Type
     2 .\compiler\inferencestate.jl   213 add_backedge!(::Core.MethodInstance, ::...     1 .\compiler\inferencestate.jl   185 record_ssa_assign(::Int64, ::Any, ::Cor...     1 .\compiler\optimize.jl         373 inline_worthy
     1 .\compiler\optimize.jl         140 isinlineable(::Method, ::Core.Compiler.... 22918 .\compiler\optimize.jl         162 optimize(::Core.Compiler.OptimizationSt...     6 .\compiler\optimize.jl         208 optimize(::Core.Compiler.OptimizationSt...     1 .\compiler\optimize.jl         241 optimize(::Core.Compiler.OptimizationSt...     1 .\compiler\optimize.jl         284 statement_cost(::Expr, ::Int64, ::Core....     1 .\compiler\tfuncs.jl           398 (::getfield(Core.Compiler, Symbol("##19...     1 .\compiler\tfuncs.jl           927 apply_type_tfunc(::Any, ::Any)
     5 .\compiler\tfuncs.jl          1073 builtin_tfunction(::Any, ::Array{Any,1}...     1 .\compiler\tfuncs.jl          1152 builtin_tfunction(::Any, ::Array{Any,1}...     4 .\compiler\tfuncs.jl          1164 builtin_tfunction(::Any, ::Array{Any,1}...     1 .\compiler\tfuncs.jl           220 egal_tfunc(::Any, ::Any)
     1 .\compiler\tfuncs.jl            60 instanceof_tfunc(::Any)
     1 .\compiler\tfuncs.jl            86 math_tfunc(::Any, ::Any)
     3 .\compiler\tfuncs.jl          1185 return_type_tfunc(::Array{Any,1}, ::Arr...     1 .\compiler\typeinfer.jl        250 annotate_slot_load!(::Expr, ::Array{Any...     1 .\compiler\typeinfer.jl        251 annotate_slot_load!(::Expr, ::Array{Any...     4 .\compiler\typeinfer.jl        124 cache_result(::Core.Compiler.InferenceR...     1 .\compiler\typeinfer.jl        133 cache_result(::Core.Compiler.InferenceR...     5 .\compiler\typeinfer.jl        155 finish
     1 .\compiler\typeinfer.jl        170 finish
     1 .\compiler\typeinfer.jl        226 maybe_widen_conditional(::Any)
     1 .\compiler\typeinfer.jl        202 store_backedges(::Core.Compiler.Inferen...     1 .\compiler\typeinfer.jl        311 type_annotate!(::Core.Compiler.Inferenc...     1 .\compiler\typeinfer.jl        312 type_annotate!(::Core.Compiler.Inferenc...     2 .\compiler\typeinfer.jl        355 type_annotate!(::Core.Compiler.Inferenc...     1 .\compiler\typeinfer.jl        384 type_annotate!(::Core.Compiler.Inferenc...  2141 .\compiler\typeinfer.jl         15 typeinf(::Core.Compiler.InferenceState)
     5 .\compiler\typeinfer.jl         24 typeinf(::Core.Compiler.InferenceState)
 22925 .\compiler\typeinfer.jl         35 typeinf(::Core.Compiler.InferenceState)
     1 .\compiler\typeinfer.jl         36 typeinf(::Core.Compiler.InferenceState)
     5 .\compiler\typeinfer.jl         61 typeinf(::Core.Compiler.InferenceState)
     1 .\compiler\typeinfer.jl         72 typeinf(::Core.Compiler.InferenceState)
     8 .\compiler\typeinfer.jl        456 typeinf_edge(::Method, ::Any, ::Core.Si...     1 .\compiler\typeinfer.jl        459 typeinf_edge(::Method, ::Any, ::Core.Si...     1 .\compiler\typeinfer.jl        468 typeinf_edge(::Method, ::Any, ::Core.Si...   167 .\compiler\typeinfer.jl        483 typeinf_edge(::Method, ::Any, ::Core.Si...  1468 .\compiler\typeinfer.jl        492 typeinf_edge(::Method, ::Any, ::Core.Si...     1 .\compiler\typeinfer.jl        565 typeinf_ext(::Core.MethodInstance, ::Co... 23272 .\compiler\typeinfer.jl        567 typeinf_ext(::Core.MethodInstance, ::Co... 23273 .\compiler\typeinfer.jl        604 typeinf_ext(::Core.MethodInstance, ::UI...     1 .\compiler\typeinfer.jl        212 widen_all_consts!(::Core.CodeInfo)
     2 .\compiler\typelattice.jl       12 Type
     2 .\compiler\typelattice.jl      144 widenconst(::Core.Compiler.Const)
     2 .\compiler\typelattice.jl      148 widenconst(::Core.Compiler.Const)
     1 .\compiler\typelattice.jl      105 ⊑(::Any, ::Any)
     1 .\compiler\typelattice.jl      106 ⊑(::Any, ::Any)
     1 .\compiler\typelattice.jl      110 ⊑(::Any, ::Any)
     1 .\compiler\typelattice.jl      111 ⊑
     3 .\compiler\typelimits.jl       281 tmerge(::Any, ::Any)
    15 .\compiler\typeutils.jl         40 argtypes_to_type
     7 .\compiler\utilities.jl         39 anymap(::typeof(Core.Compiler.widencons...     5 .\compiler\utilities.jl        167 argextype
     5 .\compiler\utilities.jl        187 argextype(::Any, ::Core.CodeInfo, ::Cor...     1 .\compiler\utilities.jl        193 argextype(::Any, ::Core.Compiler.IRCode...     8 .\compiler\utilities.jl        125 code_for_method
     4 .\compiler\utilities.jl        138 code_for_method
     8 .\compiler\utilities.jl        142 code_for_method
     1 .\compiler\utilities.jl        202 find_ssavalue_uses(::Array{Any,1}, ::In...   173 .\compiler\utilities.jl         91 get_staged(::Core.MethodInstance)
     1 .\compiler\utilities.jl         67 is_self_quoting
     1 .\compiler\utilities.jl         48 istopfunction
     1 .\compiler\utilities.jl         72 quoted
   173 .\compiler\utilities.jl        112 retrieve_code_info(::Core.MethodInstance)
     3 .\compiler\utilities.jl        116 retrieve_code_info(::Core.MethodInstance)
     3 .\essentials.jl                429 setindex!
    20 .\expr.jl                       36 copy(::Expr)
    49 .\expr.jl                       37 copy(::Expr)
   119 .\expr.jl                       60 copy_exprargs(::Array{Any,1})
    69 .\expr.jl                       43 copy_exprs(::Expr)
     2 .\generator.jl                  32 Type
  1369 .\int.jl                        53 +
  1925 .\int.jl                        52 -
     1 .\int.jl                       443 <<
     1 .\int.jl                       450 <<
    14 .\int.jl                       441 >>
    14 .\int.jl                       448 >>
     2 .\int.jl                        53 iterate
     3 .\int.jl                       384 trailing_zeros
     1 .\iterators.jl                 434 _collect(::Core.Compiler.UnitRange{Int6...     3 .\iterators.jl                 138 iterate
     3 .\iterators.jl                 141 iterate(::Core.Compiler.Iterators.Enume... 23205 .\loading.jl                  1002 include_string(::Module, ::String, ::St...     2 .\operators.jl                 502 +
     1 .\operators.jl                  83 ==
     1 .\operators.jl                 949 in
     1 .\operators.jl                 950 in
     1 .\pair.jl                       12 Type
     1 .\range.jl                     576 iterate
   146 .\reflection.jl                717 _methods_by_ftype
     1 .\reflection.jl                227 isconst
     1 .\sort.jl                      687 #sort#8(::Core.Compiler.Iterators.Pairs... 23205 .\task.jl                       85 (::getfield(Atom, Symbol("##108#113")){...     3 .\tuple.jl                      24 getindex
     4 .\tuple.jl                      60 indexed_iterate
     2 .\tuple.jl                      41 iterate
 23205 ...es\Atom\jodeb\src\eval.jl    90 #109
 23205 ...es\Atom\jodeb\src\eval.jl    91 (::getfield(Atom, Symbol("##110#115")){... 23205 ...es\Atom\jodeb\src\eval.jl    89 macro expansion
 23205 ...es\Atom\jodeb\src\eval.jl    46 withpath
 23205 ...es\Atom\jodeb\src\repl.jl    76 hideprompt(::getfield(Atom, Symbol("##1... 23205 ...deTools\8CjYJ\src\eval.jl    30 include_string(::Module, ::String, ::St... 23205 ...eTools\8CjYJ\src\utils.jl    30 withpath(::getfield(Atom, Symbol("##110...     8 ...iff\kTOVi\src\apiutils.jl    51 #s31#67(::Any, ::Any, ::Any, ::Any)
    47 ...dDiff\kTOVi\src\config.jl   184 ForwardDiff.JacobianConfig(::getfield(M... 23008 ...iff\kTOVi\src\jacobian.jl   212 chunk_mode_jacobian(::getfield(Main, Sy... 46182 ...iff\kTOVi\src\jacobian.jl    32 jacobian(::Function, ::Array{Float64,1}... 23044 ...iff\kTOVi\src\jacobian.jl    36 jacobian(::Function, ::Array{Float64,1}...     9 ...iff\kTOVi\src\partials.jl    10 #s12#9(::Any, ::Any, ::Any, ::Any, ::Ty...    18 ...iff\kTOVi\src\partials.jl   174 #s19#17(::Any, ::Any, ::Any, ::Any)
    10 ...iff\kTOVi\src\partials.jl   198 #s19#29(::Any, ::Any, ::Any, ::Any)
    10 ...iff\kTOVi\src\partials.jl   202 #s19#32(::Any, ::Any, ::Any, ::Any)
    10 ...iff\kTOVi\src\partials.jl   206 #s19#35(::Any, ::Any, ::Any, ::Any)
    11 ...iff\kTOVi\src\partials.jl   210 #s19#38(::Any, ::Any, ::Any, ::Any)
    12 ...iff\kTOVi\src\partials.jl   214 #s19#41(::Any, ::Any, ::Any)
     9 ...iff\kTOVi\src\partials.jl   218 #s19#44(::Any, ::Any, ::Any, ::Any, ::A...    71 ...iff\kTOVi\src\partials.jl   151 tupexpr(::Function, ::Int64)
     1 ...a-1.0.0\lib\julia\sys.dll    -1 getindex(::Array{Core.Compiler.BasicBlo...     1 ...a-1.0.0\lib\julia\sys.dll    -1 length(::Array{Any,1})
     7 ...a-1.0.0\lib\julia\sys.dll    -1 stupdate1!(::Array{Any,1}, ::Core.Compi...     1 ...a-1.0.0\lib\julia\sys.dll    -1 switchtupleunion(::Any)
 23205 ....0\Profile\src\Profile.jl    25 top-level scope
 23008 ...\Computer\Desktop\test.jl   276 (::getfield(Main, Symbol("##13#14")))(:...

It looks like it shows up. Is that the step in type inference taking all of the time?

@timholy
Copy link
Member

timholy commented Aug 25, 2018

Most likely. Maybe double-check in tree mode with Profile.print(noisefloor=2) and make sure there isn't anything on the same order of magnitude below it. (In flat mode it's a little harder to tell who's really responsible.)

Also go to n = 10^7 (that's still only 80MB, no big deal on modern systems) to capture the whole trace.

@ChrisRackauckas
Copy link
Member Author

┌ Warning: The profile data buffer is full; profiling probably terminated
│ before your program finished. To profile for longer runs, call
│ `Profile.init()` with a larger buffer and/or larger delay.
└ @ Profile C:\cygwin\home\Administrator\buildbot\worker\package_win64\build\usr\share\julia\stdlib\v1.0\Profile\src\Profile.jl:312
1     .\compiler/ssair\driver.jl:120; run_passes(::Core.CodeInfo, ::Int64,...
23205 .\task.jl:85; (::getfield(Atom, Symbol("##108#113"...
 23205 ...\Atom\jodeb\src\eval.jl:89; macro expansion
  23205 ...Atom\jodeb\src\repl.jl:76; hideprompt(::getfield(Atom, Symbol(...
   23205 ...Atom\jodeb\src\eval.jl:90; #109
    23205 ...tom\jodeb\src\eval.jl:46; withpath
     23205 ...ls\8CjYJ\src\utils.jl:30; withpath(::getfield(Atom, Symbol(...
      23205 ...tom\jodeb\src\eval.jl:91; (::getfield(Atom, Symbol("##110#1...
       23205 ...ls\8CjYJ\src\eval.jl:30; include_string(::Module, ::Strin...
        23205 .\loading.jl:1002; include_string(::Module, ::Str...
         23205 ...file\src\Profile.jl:25; top-level scope
          23138 ...OVi\src\jacobian.jl:32; jacobian(::Function, ::Array{F...
           23044 ...Vi\src\jacobian.jl:32; jacobian(::Function, ::Array{...
            23044 ...Vi\src\jacobian.jl:36; jacobian(::Function, ::Array{...
             23008 ...i\src\jacobian.jl:212; chunk_mode_jacobian(::getfie...
              23008 ...r\Desktop\test.jl:276; (::getfield(Main, Symbol("#...
               23008 ...iler\typeinfer.jl:604; typeinf_ext(::Core.MethodIn...
                23007 ...ler\typeinfer.jl:567; typeinf_ext(::Core.MethodI...
                 22714 ...ler\typeinfer.jl:35; typeinf(::Core.Compiler.In...
                  22714 ...ler\optimize.jl:162; optimize(::Core.Compiler....
                   22463 ...ssair\driver.jl:120; run_passes(::Core.CodeIn...
                    21635 ...sair\domtree.jl:86; construct_domtree(::Core...
                     1798 .\array.jl:731; getindex
                     3708 .\bitset.jl:300; in
                      3286 .\bitset.jl:67; _bits_getindex
                       1364 .\int.jl:53; +
                       1922 .\int.jl:52; -
                      273  .\bitset.jl:68; _bits_getindex
                    548   ...sair\domtree.jl:87; construct_domtree(::Core...
                     523 .\array.jl:707; iterate

Looks like domtree.

Also go to n = 10^7 (that's still only 80MB, no big deal on modern systems) to capture the whole trace.

Anything but the default segfaults on Windows with the standard binary. That's probably issue worthy.

@timholy
Copy link
Member

timholy commented Aug 25, 2018

Yes indeed.

Anything but the default segfaults on Windows with the standard binary. That's probably issue worthy.

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.

@ChrisRackauckas
Copy link
Member Author

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 n it segfaults even when it should be fairly easy to fit into memory. 🤷‍♂️

Closing this as a duplicate of #25927

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
compiler:latency Compiler latency
Projects
None yet
Development

No branches or pull requests

6 participants