commit stale changes

This commit is contained in:
2026-07-26 21:32:56 +02:00
parent 4b1a76541d
commit 6555442f15
2 changed files with 10 additions and 8 deletions
+1
View File
@@ -0,0 +1 @@
.idea/
+9 -8
View File
@@ -3,17 +3,18 @@ import random
from matplotlib import pyplot as plot
import numpy as np
def calc_p(U0, Ri, Rl):
I = U0 / (Ri + Rl)
Ul = I * Rl
P = Ul * I
return P
return P, I, Ul
U0 = 10
Ri = 3.14
Rl_min = 0.1
Ri = 5.0
Rl_min = 0.0
Rl_max = 10.
Rl_step_start = 1
Rl_step_stop = 0.01
@@ -27,11 +28,11 @@ Rl_step = Rl_step_start
dir = "inc"
dir_last = dir
while Rl_step > Rl_step_stop:
p0 = calc_p(U0, Ri, Rl_s)
p0, _, _ = calc_p(U0, Ri, Rl_s)
p1 = p0
if "inc" in dir:
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 'inc' in dir_last:
Rl_step /= 2
@@ -39,7 +40,7 @@ while Rl_step > Rl_step_stop:
elif "dec" in dir:
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 'dec' in dir_last:
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.ylabel("Power [W]")
plot.xlabel("RL [Ohms]")
plot.title("Power vs RL")
plot.legend("RL [Ohms]")
plot.legend(("P_RL",))
plot.grid()
plot.show()