(***********SDtejnosmerny ustaleny stav**************)

R=5;
i=1.2;
u=R*i;
Print["P= ",i*u," W"]
Plot[i*u,{t,0,1},PlotStyle->Thick,AxesLabel->{"t[s]","p[W]"}]

(***********HUS**************)

Umax=10;
Imax=1.5;
fiU=0.5;
ω=314;
Manipulate[Plot[Umax*Sin[ω*t+fiU]*Imax*Sin[ω*t+fiI],{t,0,2*(Pi/ω)},PlotStyle->Thick,AxesLabel->{"t[s]","p[W]"},PlotRange->{Automatic,{-1.1Umax*Imax,1.1Umax*Imax}}],{{fiI,fiU},-Pi,Pi}]

(***********Odporovy delic z casove promennych odporu rezistoru**************)

ClearAll[R1,R2,u1,u2];
u1[t_]:=3.6;
Rmax=(10^6);
Rmin=1;
strmost=(10^2);
R1[t_]:=Rmin+Rmax*0.5*(1+Tanh[-strmost*t]);
R2[t_]:=Rmin+Rmax*0.5*(1+Tanh[strmost*(t+posun)]);
Plot[Evaluate[{R1[t],R2[t]}/.posun->0],{t,-0.1,0.1},AxesLabel->{"t[s]","R1[Ω],R2[Ω]"},PlotStyle->{{Thickness[0.006],Red},{Thickness[0.006],Blue}}]

u2[t_]:=u1[t]*((R2[t])/(R1[t]+R2[t]));
Plot[Evaluate[{u2[t],u1[t]}/.posun->0],{t,-0.1,0.1},AxesLabel->{"t[s]","u1[V],U2[V]"},PlotStyle->{{Thickness[0.006],Red},{Thickness[0.006],Blue}}]
p[t_]:=(((u1[t])^2)/(R1[t]+R2[t]));

Manipulate[Plot[Evaluate[p[t]/.posun->pp],{t,-0.1,0.1},AxesLabel->{"t[s]","p[W]"},PlotStyle->{Thickness[0.006],Red},PlotRange->{Automatic,{0,6*(10^(-5))}}],{pp,((-2)/strmost),(2/strmost)}]

(***********Priklad medeny drat**************)

ClearAll[u];
ω=314;
T=2.*(Pi/ω);
Umax=1;
u=Umax*Sin[ω*t];
R=(1./57);
delka=1;
mm=0.001;
prurez=1(mm^2);
objem=delka*prurez;
hustota=8920;
hmotnost=objem*hustota;
cp=384.4;
proud=(u/R);
vykon=u*proud;
vykonStredni=((((Umax/(Sqrt[2]))))^2)*(1/R);
tepelneRovniceHUS={Teplota[0]==20,hmotnost*cp*Teplota'[t]==vykon};
tepelneRovniceEff={Teplota[0]==20,hmotnost*cp*Teplota'[t]==vykonStredni};
tmax=100T;
resTeplotaHUS=NDSolve[tepelneRovniceHUS,Teplota[t],{t,0,tmax}][[1]];
resTeplotaEff=NDSolve[tepelneRovniceEff,Teplota[t],{t,0,tmax}][[1]];
Plot[Evaluate[Teplota[t]/.{resTeplotaHUS,resTeplotaEff}],{t,0,tmax},AxesLabel->{"t[s]","Teplota[°C]"},PlotStyle->Thick]
Plot[Evaluate[Teplota[t]/.{resTeplotaHUS,resTeplotaEff}],{t,tmax-T,tmax},AxesLabel->{"t[s]","Teplota[°C]"},PlotStyle->Thick]

(*************Podle Obr. 34-V-1************)
ClearAll[I1]
Rv=1;
Rz=100;
Lz=0.5;
f=50;
ω=2*Pi*f;
U1=230*(E^(0.I));
rce={I1==IRz+ILz,I1==((U1-Uz)/Rv),ILz==(Uz/(I*ω*Lz)),IRz==(Uz/Rz),URv==U1-Uz};
res=Solve[rce][[1]];
P1=Re[U1*Conjugate[I1]/.res];
Print["ze zdroje napeti jde ",P1," W"]
PRz=Re[Uz*Conjugate[IRz]/.res];
Print["na Rz se meni v teplo ",PRz," W"]
PRv=Re[URv*Conjugate[I1]/.res];
Print["na Rv se meni v teplo ",PRv," W"]
Print["PRv+PRz==P1  ",PRv+PRz==P1]
PLz=Chop@Re[Uz*Conjugate[ILz]/.res];
Print["cinny vykon na civce (stredni hodnota za periodu)=  ",PLz," W"]
velikostProuduVeVedeniSCivkou=Abs[I1/.res];
Print["eff hodnota proudu ve vedeni= ",velikostProuduVeVedeniSCivkou," A"]

ClearAll[I1]
Rv=1;
Rz=100;
Lz=∞;
f=50;
ω=2*Pi*f;
U1=230*(E^(0.I));
rce={I1==IRz+ILz,I1==((U1-Uz)/Rv),ILz==(Uz/(I*ω*Lz)),IRz==(Uz/Rz),URv==U1-Uz};
res=Solve[rce][[1]];
P1BezCivky=Re[U1*Conjugate[I1]/.res];
Print["ze zdroje napeti jde ",P1BezCivky," W"]
PRzBezCivky=Re[Uz*Conjugate[IRz]/.res];
Print["na Rz se meni v teplo ",PRzBezCivky," W"]
PRvBezCivky=Re[URv*Conjugate[I1]/.res];
Print["na Rv se meni v teplo ",PRvBezCivky," W"]
Print["PRvBezCivky+PRzBezCivky==P1BezCivky  ",PRvBezCivky+PRzBezCivky==P1BezCivky]
PLz=Chop@Re[Uz*Conjugate[ILz]/.res];
Print["cinny vykon na civce (stredni hodnota za periodu)=  ",PLz," W"]
rozdilVykonuZdroje=P1-P1BezCivky;
Print["ΔPzdroj= ",rozdilVykonuZdroje," W"]
rozdilZtrat=PRv-PRvBezCivky;
Print["rozdil ztrat= ",rozdilZtrat," W"]
rozdilVykonuSpotrebice=PRz-PRzBezCivky;
Print["ΔPspotrebic= ",rozdilVykonuSpotrebice," W"]
velikostProuduVeVedeniBezCivky=Abs[I1/.res];
Print["eff hodnota proudu ve vedeni= ",velikostProuduVeVedeniBezCivky," A"]

(*************Podle Obr. 34-V-2************)
ClearAll[Lz,U1];
Lv=0.1;
Roz=20;
par:=(((Plus@@((#)^(-1))))^(-1))&;
z1=Rv+I*ω*Lv;
z2=par@{Rz,Roz,I*ω*Lz};
Uz[Lz_]=U1*(z2/(z1+z2));
dosUBezCivky=FindRoot[Abs[Uz[∞]]==230,{U1,400}]
dosUScivkou=FindRoot[Abs[Uz[0.5]]==230,{U1,400}]
Abs[Uz[0.5]]/.dosUBezCivky;
Print["kdyz bez civky bylo 230V, je s civkou L=0.5H, za kterou nic neplatime, ",%," V"]

(*************Podle Obr. 34-V-3************)
ClearAll[Uz,Rz]
L1=Lv;
rceStavZaA={((UD-UzA)/(I*ω*L1))==(UzA/(I*ω*Lz)),Abs[(UzA/(I*ω*Lz))]==1,Abs[UzA]==230};
resStavA=FindRoot[rceStavZaA,{UD,400},{UzA,230+5I},{Lz,0.5}]
rceStavZaB={((UD-UzB)/(I*ω*L1))==(UzB/Rz),Abs[(UzB/Rz)]==1}/.resStavA;
resStavZaB=FindRoot[rceStavZaB,{UzB,230+5I},{Rz,100}]
Print["je-li s pripojenou civkou napeti ",Abs[UzA/.resStavA]," V, je bez ni ",Abs[UzB/.resStavZaB]," V"]
Print["pripojeni rezistoru, kterym tece 1A, tedy vyvolalo ubytek ",(Abs[UD]-Abs[UzB]/.resStavZaB)/.resStavA," V"]
Print["pripojeni civky, kterou tece 1A, tedy vyvolalo ubytek ",(Abs[UD]-Abs[UzA]/.resStavZaB)/.resStavA," V"]

ClearAll[Umax,Imax,ω,fiU]
p=Umax*Sin[ω*t+fiU]*Imax*Sin[ω*t+fiI]
Pstr=(ω/(2Pi))*Integrate[p,{t,0,((2*Pi)/ω)}]