Quiet@Remove["Global`*"];
SetDirectory[NotebookDirectory[]];
$HistoryLength=3;

Quiet@Remove["Global`*"];
μF=(10^(-6));
c0=4.7μF;
kc=0*2.5*(10^(-4));
R=0.0034;
L=20.*(10^(-9));
Rext=10*R;
RLext=0.5R;
Lext=1.5*L;
cext=0.5c0;
U0=100;
c[u_]:=c0*(1+kc*(u^2));
τ=((L+Lext)/(R+Rext));
tmax=6τ;

rce={i[t]==D[c[uc[t]]*uc[t],t],uc[0]==U0,
ucMer[t]==uc[t]+R*i[t]+L*i'[t],i[0]==0,
ucMer[t]==Rext*iext[t]+ucext[t],
icext[t]==cext*ucext'[t],ucext[0]==0,
0==iext[t]+i[t],iext[t]==icext[t]+iLext[t],
ucext[t]==RLext*iLext[t]+Lext*iLext'[t],iLext[0]==0
};
nezname=Union@Cases[rce,a_Symbol[t]:>a,{0,∞}];
derivace=Union@Cases[rce,_'[t],{0,∞}];
pocs=Union@Cases[rce,_[0]==_,{0,∞}];
{Length[rce],Length[nezname],Length[derivace]}

sol=NDSolve[rce,nezname,{t,0,3tmax},StartingStepSize->(10^(-12)),MaxSteps->(10^6)][[1]];

pl1=Plot[ucMer[t]/.sol,{t,0,tmax},PlotRange->All,AxesLabel->{"t[s]","ucMer[V]"}];
pl2=Plot[i[t]/.sol,{t,0,tmax},PlotRange->All,AxesLabel->{"t[s]","i[A]"}];
tk=0.006;
pl3=Plot[{L*i'[t]/.sol,uc[t]/.sol,R*i[t]/.sol,ucMer[t]/.sol},{t,0,tmax},PlotRange->All,AxesLabel->{"t[s]","uL uR uC uCelk [V]"},PlotStyle->Evaluate[{Thickness[tk],#}&/@{Red,Blue,Black,Green}]];
data={#,i[#]/.sol,ucMer[#]/.sol}&/@Range[0,tmax,(tmax/5000)];
{"{{R,L,c[0],kc,τ,tmax},{t,i,ucMer}...}",{{R,L,c[0],kc,τ,tmax},data}}>>"structKc0";

{pl1,pl2,pl3};
pl3;

(*{i,icext,iext,iLext,uc,ucext,ucMer}
*)
Plot[{100*ucMer'[t]/.sol,10*i'[t]/.sol,(10^(-6))i''[t]/.sol},{t,0,tmax},PlotRange->All,AxesLabel->{"t[s]","X[Y]"},PlotStyle->{{Red,Thickness[tk]},{Green,Thickness[tk]},{Thickness[tk],Blue}}];
Plot[{i[t]/.sol},{t,0,tmax},PlotRange->All,AxesLabel->{"t[s]","X[Y]"},PlotStyle->{Black,Thickness[tk]}];
{%,%%};

Plot[{(10^(-6))i''[t]/.sol},{t,0,0.03tmax},PlotRange->All,AxesLabel->{"t[s]","X[Y]"},PlotStyle->{{Thickness[tk],Blue}}];

(*to je proud, aby bylo jasno:-)
"c (-R i'[t]+ucMer'[t]-L i''[t])"
*)

nDat=100;
tmin=0.05tmax;
rn=Range[tmin,tmax,((tmax-tmin)/(nDat-1))];
data=({i'[#],ucMer'[#],i''[#],i[#]}/.sol)&/@rn;
vars={di,du,d2i};
fit=Fit[data,vars,vars];
{-cv*Rv,cv,-Lv*cv}==(Coefficient[fit,#]&/@vars);
Solve[Thread[%]][[1]]
(({L-Lv,R-Rv,c0-cv}/.%)/({L,R,c0}))*100