Dioda

ClearAll["Global`*"];

Příklad nelineární charakteristiky

i[u_]:=0.01(0.4*u+0.01(u^3));
Plot[i[u],{u,-15,15},PlotStyle->Thick,AxesLabel->{"U[V]","I[A]"}]

uHUS=10*Sin[ω*t+0.4];
i[uHUS]
Chop[%//TrigReduce]

Ukázka idealizované charakteristiky diody

Zadefinujeme rovnici idealizované diody (závislost proudu diodou na napětí mezi svorkami diody)

(*iD[uD_]:=(10^(-7))*(Exp[19*uD]-1);*)
iD[uD_]:=(10^(-7))*((E^(19uD))-1)

Vykreslíme závislost iD(uD) na intervalu -1≤uD≤1.

Plot[iD[uD],{uD,-1,1},PlotRange->{Automatic,{-0.1,3}},PlotStyle->Thick,AxesLabel->{"uD[V]","iD[A]"}]

Vykreslíme tutéž závislost iD(uD) na intervalu -1≤uD≤0,1.

Plot[iD[uD],{uD,-1,0.1},PlotRange->All,PlotStyle->Thick,AxesLabel->{"uD[V]","iD[A]"}]

Usměrňovač

Zadání obvodu - hodnoty součástek a vstupu

L1=100;
L2=0.04;
M=0.999*(Sqrt[L1*L2]);
R1=.5;
R2=100;
c=(10^(-3));
ω=100.Pi;
T=2*(Pi/ω);
uz=230*(Sqrt[2])*Sin[ω*t];

Popis obvodu

induktory={uz==L1*i1'[t]+M*i2'[t],u1[t]==L2*i2'[t]+M*i1'[t]};
uzel1={0==i2[t]+((u1[t]-u2[t])/R1)};
uzel2=D[{((u1[t]-u2[t])/R1)==iD[u2[t]-u3[t]]},t];
uzel3={iD[u2[t]-u3[t]]==c*u3'[t]+((u3[t])/R2)};
pocs={i1[0]==0,i2[0]==0,u3[0]==0,u1[0]==0,u2[0]==0,u3[0]==0};
dohr=Union[induktory,uzel1,uzel2,uzel3,pocs];

Řešení

nezname=Cases[dohr,_[t],{0,∞}]/.a_'[t]:>a//Union;
tmax=5T;
res=NDSolve[dohr,nezname,{t,0,tmax},StartingStepSize->(10^(-6))*T,MaxSteps->(10^6)][[1]];

Zobrazení výsledků

Plot[u3[t]/.res,{t,0,tmax},PlotRange->All,PlotRange->All,PlotStyle->Thick,AxesLabel->{"t[s]","u3[V]"}]

Plot[i1[t]/.res,{t,0,tmax},PlotRange->All,PlotRange->All,PlotStyle->Thick,AxesLabel->{"t[s]","i1[A]"}]

n=200;
Δt=(T/n);
rn=Range[tmax-T,tmax,Δt];
f=i1/.res;
Plot[f[t],{t,tmax-T,tmax}]
integrandA[t_,0]:=(1/T)f[t];
integrandA[t_,i_]:=(2/T)f[t]*Cos[i*ω*t];
integrandB[t_,i_]:=(2/T)f[t]*Sin[i*ω*t];
a[i_]:=((Δt)/3)Plus@@({1,4,1}.#&/@Partition[integrandA[#,i]&/@rn,3,2]);
b[i_]:=((Δt)/3)Plus@@({1,4,1}.#&/@Partition[integrandB[#,i]&/@rn,3,2]);
nHarm=50;
rnH=Range[0,nHarm];
acka=a/@rnH;
bcka=b/@rnH;
siny=Sin[#*ω*t]&/@rnH;
cosiny=Cos[#*ω*t]&/@rnH;
rekonstrukce[n_Integer]:=Plus@@Take[acka*cosiny+bcka*siny,n];
plot[n_Integer]:=Plot[{rekonstrukce[n],f[t]},{t,tmax-T,tmax},AxesLabel->{"t [s]","f , nahrada"},PlotStyle->{{Blue,Thickness[0.006]},{Red,Thickness[0.006]}},PlotRange->{Automatic,{0,0.025}},PlotLabel->"n= "<>ToString[n]];
ploty=plot/@Range[nHarm];

Manipulate[ploty[[i]],{i,1,nHarm,1}]

THD=(Sqrt[(((∑_(i=3)^(nHarm+1))(((acka[[i]])^2)+((bcka[[i]])^2)))/(((acka[[2]])^2)+((bcka[[2]])^2)))])*100;
Print["THD= ",THD," %"]

THD=(Sqrt[(((∑_(i=2)^(nHarm+1))(((a[i])^2)+((b[i])^2)))/(((a[1])^2)+((b[1])^2)))])*100;
Print["THD= ",THD," %"]

ClearAll[rekonstrukce2]
rekonstrukce2[n_]:=(∑_(i=1)^(n+1))(acka[[i]]*Cos[(i-1)*ω*t]+bcka[[i]]*Sin[(i-1)*ω*t]);
fazory=Drop[bcka+I*acka,1];
fazory/.fazor_Complex:>{Abs[fazor],Arg[fazor]};
spektrum=ListLogPlot[%/.{abs_,arg_}:>abs,PlotRange->All,AxesLabel->{"n","Abs[fazor[n]]"}]

(100/(b[2]))((2/T)*NIntegrate[Sin[2*ω*t]*i1[t]/.res,{t,tmax-T,tmax}]-b[2])

Timing[b[2]]

myInt[f_]:=int[tmax]/.NDSolve[{f[t]==int'[t],int[tmax-T]==0},int,{t,tmax-T,tmax}][[1]];
aND[i_Integer]:=myInt[integrandA[#,i]&];
bND[i_Integer]:=myInt[integrandB[#,i]&];

nn=10;
Timing[a/@Range[0,nn]][[1]]
Timing[aND/@Range[0,nn]][[1]]
Timing[(2/T)*Quiet@NIntegrate[Sin[#*ω*t]*i1[t]/.res,{t,tmax-T,tmax}]&/@Range[0,nn]][[1]]

poly=Expand[(2x+3)*((3/4)x+1)*(x+4)];
Factor[poly]
%/.Plus[a_?NumericQ,b_*x_]:>b*(x+(a/b))

Factor[poly]//TreeForm

acka[[;;10]]

bcka[[;;10]]