如何在线使用Z3Py来解决运算放大器的问题

时间:2013-05-14 21:00:30

标签: z3

在以下电路中找到R的值

enter image description here

使用以下代码解决此问题:

R, V1, V2, Vo = Reals('R V1 V2 Vo')
I1 = V1/(R -50)
I2 = V2/(R + 10)
g = - R*(I1 + I2)
print g
equations = [Vo == g]
print equations
problem = [Vo == -2 ,  V1 == 1, V2 == 0.5, R != -10, R != 50, R > 0]
solve(equations + problem)

,相应的输出是:

-R·(V1/(R - 50) + V2/(R + 10))
 [Vo = -R·(V1/(R - 50) + V2/(R + 10))]
 [R = 143.8986691902?, V2 = 1/2, V1 = 1, Vo = -2]

其他示例:在以下电路中找到R的值

enter image description here

使用以下代码解决此问题:

R, Vs, Ve, R1, R2 = Reals('R Vs Ve R1 R2')
g1 = (Vs - Ve)/R1
print g1
g2 = Ve/R2
print g2
equations = [g1 == g2, R1 == 2*R - 100, R2 ==R]
print equations
problem = [Vs == 35 ,  Ve == 15,  R > 0, R1 >0, R2 >0]
solve(equations + problem)

,相应的输出是:

(Vs - Ve)/R1
Ve/R2
[(Vs - Ve)/R1 = Ve/R2, R1 = 2·R - 100, R2 = R]
[R = 150, Ve = 15, Vs = 35, R2 = 150, R1 = 200]

其他例子:

enter image description here

使用以下代码解决此问题:

Rf, Rg,  Vo, V1, V2, R1, R2, I1, I2, V = Reals('Rf Rg Vo V1 V2 R1 R2 I1 I2 V')
equations = [V1 - V == R1*I1, V - Vo == Rf*I1, 
V2 - V == R2*I2, V == Rg*I2]
print equations
problem = [V1 == 10 ,  V2 == 15, R1 == 100, R2 == 200,
Rf ==  100, Rg ==500]
solve(equations + problem)

,相应的输出是

[V1 - V = R1·I1, V - Vo = Rf·I1, V2 - V = R2·I2, V = Rg·I2]
[I1 = -1/140,
Vo = 80/7,
Rg = 500,
Rf = 100,
R2 = 200,
R1 = 100,
V2 = 15,
V1 = 10,
I2 = 3/140,
V = 75/7]

其他例子:

enter image description here

代码:

Rf, Rg,  Vo, V1, V2, R1, R2, I1, I2, V = Reals('Rf Rg Vo V1 V2 R1 R2 I1 I2 V')
equations = [V1 - V == R1*I1, V - Vo == Rf*I1, 
V2 - V == R2*I2, V == Rg*I2, Rf == 200 + Rg]
print equations
problem = [V1 == 10 ,  V2 == 15, R1 == 100, R2 == 200, Vo == 20, Rg > 0, Rf >0
]
solve(equations + problem)

输出:

[V1 - V = R1·I1, V - Vo = Rf·I1, V2 - V = R2·I2, V = Rg·I2, Rf = 200 + Rg]
[I1 = -0.0113999063?,
Rg = 577.2001872658?,
Vo = 20,
R2 = 200,
R1 = 100,
V2 = 15,
V1 = 10,
I2 = 0.0193000468?,
V = 11.1399906367?,
Rf = 777.2001872658?]

其他例子:

enter image description here

代码:

Vi, R1, I1, Va, R2, I2, R4, R3, Vo= Reals('Vi R1 I1 Va R2 I2 R4 R3 Vo')
equations = [Vi == R1*I1, -Va == R2*I1, Va == R4*I2, Va - Vo ==R3*(I1-I2)]
print equations
problem = [Vi == 1, R1 == 1000, R2 == 1000, R3 == 1000, R4 == 10]
solve(equations + problem)

输出:

[Vi = R1·I1, -Va = R2·I1, Va = R4·I2, Va - Vo = R3·(I1 - I2)]
[R4 = 10,
R3 = 1000,
R2 = 1000,
R1 = 1000,
Vi = 1,
Vo = -102,
I2 = -1/10,
Va = -1,
I1 = 1/1000]

其他例子:

enter image description here

代码:

Vi, R1, I1, Va, R2, I2, R4, R3, Vo= Reals('Vi R1 I1 Va R2 I2 R4 R3 Vo')
equations = [Vi == R1*I1, -Va == R2*I1, Va == R4*I2, Va - Vo ==R3*(I1-I2),
R2 == R1 - 100, R3 == R1 - 200]
print equations
problem = [Vi == 1, Vo == -10, R4 == 10, R1 >0, R2 > 0, R3 >0]
solve(equations + problem)

输出:

[Vi = R1·I1, -Va = R2·I1, Va = R4·I2, Va - Vo = R3·(I1 - I2), R2 = R1 - 100, R3 = R1 -   200]
[I1 = 0.0030468970?,
R1 = 328.2027496108?,
I2 = -0.0695310291?,
R4 = 10,
Vo = -10,
Vi = 1,
R3 = 128.2027496108?,
R2 = 228.2027496108?,
Va = -0.6953102918?]

其他例子:

enter image description here

代码:

Vi, V1, R, I1, V2, Ri, I2, R1, Vo, RF, A= Reals('Vi V1 R I1 V2 Ri I2 R1 Vo RF A')
equations = [Vi-V1 == R*I1,V1 -V2 == Ri*I2, V2 == R1*I2, V1 - Vo ==RF*(I1-I2), 
Vo==A* (V2-V1)]
print equations
problem = [Vi == 1, R1 == 2000, Ri == 100, RF == 1000, R == 300, A == 100]
set_option(rational_to_decimal=True)
solve(equations + problem)

输出:

[Vi - V1 = R·I1, V1 - V2 = Ri·I2, V2 = R1·I2, V1 - Vo = RF·(I1 - I2), Vo = A·(V2 - V1)]
[I2 = 0.0001658374?,
 A = 100,
 R = 300,
 RF = 1000,
 Ri = 100,
 R1 = 2000,
 Vi = 1,
 Vo = -1.6583747927?,
 I1 = 0.0021724709?,
 V1 = 0.3482587064?,
 V2 = 0.3316749585?]

其他例子:

enter image description here

代码:

Vi, V1, R, I1, V2, Ri, I2, R1, Vo, RF, A= Reals('Vi V1 R I1 V2 Ri I2 R1 Vo RF A')
equations = [Vi-V1 == R*I1,V1 -V2 == Ri*I2, V2 == R1*I2, V1 - Vo ==RF*(I1-I2), 
Vo==A* (V2-V1), RF == R + 1000, Ri == R + 500, R1 == R + 1500]
print equations
problem = [Vi == 1, A == 100, Vo == -2, R >0, RF >0, R1 >0]
set_option(rational_to_decimal=True)
solve(equations + problem)

输出:

[Vi - V1 = R·I1, V1 - V2 = Ri·I2, V2 = R1·I2, V1 - Vo = RF·(I1 - I2), 
Vo = A·(V2 -  V1), RF = R + 1000, Ri = R + 500, R1 = R + 1500]
[I2 = 0.0000150298?,
 R = 830.6885937397?,
 I1 = 0.0011375745?,
 Vo = -2,
 A = 100,
 Vi = 1,
 RF = 1830.6885937397?,
 V1 = 0.0550298124?,
 V2 = 0.0350298124?,
 R1 = 2330.6885937397?,
 Ri = 1330.6885937397?]

其他例子:

电阻RB的值将提供桥的平衡,产生Vo = 0

enter image description here

代码:

V, RC, RD, I1, VB, RA,RB, I2, VA, V2, R1, I3, R2, V1, R3, R4, I4, Vo = 
Reals('V RC RD  I1 VB RA RB I2 VA V2 R1 I3 R2 V1 R3 R4 I4 Vo')
equations = [V == (RC+RD)*I1, VB == RD*I1, V == (RA + RB)*I2,
VA == RB*I2, VB-V2 == R1*I3, V2 == R2*I3, VA-V1 == R3*I4,
V1 - Vo == R4*I4, V2 == V1, RD == RB + 10]
print equations
problem = [Vo == 0, V == 5, R1 == 10, R2 == 12, R3 == 10, R4 == 22, 
RA ==1, RC ==1, RB >0, RD >0]
set_option(rational_to_decimal=True)
solve(equations + problem)

输出:

[V = (RC + RD)·I1, VB = RD·I1, V = (RA + RB)·I2, VA = RB·I2, VB - V2 = R1·I3, 
V2 = R2·I3, VA - V1 = R3·I4, V1 - Vo = R4·I4, V2 = V1, RD = RB + 10]
[I1 = 0.3626991607?,
RB = 2.7855295545?,
I2 = 1.3208191688?,
I4 = 0.1149744009?,
I3 = 0.2107864017?,
RC = 1,
RA = 1,
R4 = 22,
R3 = 10,
R2 = 12,
R1 = 10,
V = 5,
Vo = 0,
V1 = 2.5294368214?,
V2 = 2.5294368214?,
VA = 3.6791808311?,
VB = 4.6373008392?,
RD = 12.7855295545?]

请让我知道你的想法,如果你知道这些问题的代码更有效。非常感谢。

0 个答案:

没有答案