I tried to simulate a negative feedback non-inverting op-amp, and got incorrect results.
I ran the following time-stepping code in python:
A = 100000 #open-loop gain
B = 0.75 #the feedback factor
V_out = 0 #initial output of op-amp is zero
V_in = 2 #input voltage of 5V (DC)
for t in range(1000):
feedback = B*V_out
V_out = A*(V_in - feedback)
if V_out > 10: #saturation
V_out = 10 #hits rails at 10V
elif V_out < -10: #saturation
V_out = -10 #hits rails at -10V
But this model doesn't behave like a practical op-amp. V_out saturates at -10V, and feedback goes to 7.5V, and not 2V, thus violating the second summing point constraint.
Why is this happening?
NOTE: I've used the standard general feedback model for reference.