commit stale changes
This commit is contained in:
@@ -0,0 +1 @@
|
|||||||
|
.idea/
|
||||||
@@ -3,17 +3,18 @@ import random
|
|||||||
from matplotlib import pyplot as plot
|
from matplotlib import pyplot as plot
|
||||||
import numpy as np
|
import numpy as np
|
||||||
|
|
||||||
|
|
||||||
def calc_p(U0, Ri, Rl):
|
def calc_p(U0, Ri, Rl):
|
||||||
I = U0 / (Ri + Rl)
|
I = U0 / (Ri + Rl)
|
||||||
Ul = I * Rl
|
Ul = I * Rl
|
||||||
P = Ul * I
|
P = Ul * I
|
||||||
|
|
||||||
return P
|
return P, I, Ul
|
||||||
|
|
||||||
|
|
||||||
U0 = 10
|
U0 = 10
|
||||||
Ri = 3.14
|
Ri = 5.0
|
||||||
Rl_min = 0.1
|
Rl_min = 0.0
|
||||||
Rl_max = 10.
|
Rl_max = 10.
|
||||||
Rl_step_start = 1
|
Rl_step_start = 1
|
||||||
Rl_step_stop = 0.01
|
Rl_step_stop = 0.01
|
||||||
@@ -27,11 +28,11 @@ Rl_step = Rl_step_start
|
|||||||
dir = "inc"
|
dir = "inc"
|
||||||
dir_last = dir
|
dir_last = dir
|
||||||
while Rl_step > Rl_step_stop:
|
while Rl_step > Rl_step_stop:
|
||||||
p0 = calc_p(U0, Ri, Rl_s)
|
p0, _, _ = calc_p(U0, Ri, Rl_s)
|
||||||
p1 = p0
|
p1 = p0
|
||||||
if "inc" in dir:
|
if "inc" in dir:
|
||||||
Rl_s = min(Rl_max, Rl_s + Rl_step)
|
Rl_s = min(Rl_max, Rl_s + Rl_step)
|
||||||
p1 = calc_p(U0, Ri, Rl_s)
|
p1, _, _ = calc_p(U0, Ri, Rl_s)
|
||||||
if p0 > p1:
|
if p0 > p1:
|
||||||
if 'inc' in dir_last:
|
if 'inc' in dir_last:
|
||||||
Rl_step /= 2
|
Rl_step /= 2
|
||||||
@@ -39,7 +40,7 @@ while Rl_step > Rl_step_stop:
|
|||||||
|
|
||||||
elif "dec" in dir:
|
elif "dec" in dir:
|
||||||
Rl_s = max(Rl_min, Rl_s - Rl_step)
|
Rl_s = max(Rl_min, Rl_s - Rl_step)
|
||||||
p1 = calc_p(U0, Ri, Rl_s)
|
p1, _, _ = calc_p(U0, Ri, Rl_s)
|
||||||
if p0 > p1:
|
if p0 > p1:
|
||||||
if 'dec' in dir_last:
|
if 'dec' in dir_last:
|
||||||
Rl_step /= 2
|
Rl_step /= 2
|
||||||
@@ -50,12 +51,12 @@ while Rl_step > Rl_step_stop:
|
|||||||
|
|
||||||
# --------------------------------------------------
|
# --------------------------------------------------
|
||||||
|
|
||||||
P = calc_p(U0, Ri, Rl)
|
P, I, U = calc_p(U0, Ri, Rl)
|
||||||
plot.plot(Rl, P)
|
plot.plot(Rl, P)
|
||||||
|
|
||||||
plot.ylabel("Power [W]")
|
plot.ylabel("Power [W]")
|
||||||
plot.xlabel("RL [Ohms]")
|
plot.xlabel("RL [Ohms]")
|
||||||
plot.title("Power vs RL")
|
plot.title("Power vs RL")
|
||||||
plot.legend("RL [Ohms]")
|
plot.legend(("P_RL",))
|
||||||
plot.grid()
|
plot.grid()
|
||||||
plot.show()
|
plot.show()
|
||||||
|
|||||||
Reference in New Issue
Block a user