As has been mentioned, the schematic should be changed so that the feedback is to the negative terminal of the op amp rather than the positive terminal. Here is my updated circuit:
![Ideal diode rectifier](https://cdn.statically.io/img/i.sstatic.net/Gweo0.png)
SPICE simulation of the circuit gives data for the following plot:
![Simulation plot](https://cdn.statically.io/img/i.sstatic.net/3blwN.png)
I used the following model for a mostly ideal op amp:
* Mostly ideal op amp
* in+ in- vcc vdd out
.subckt opamp 1 2 3 4 5
Rin 1 2 10G
Cin 1 2 100pF
Rout 6 0 0.1
* Ignores power rails (more ideal)
* Bout 3 6 v={100k*v(1,2)}
* Has less amplification for low voltages and approaches supply voltages
Bout 3 6 v={(v(4)+v(5))/2+v(4,5)*atan(100k*v(1,2))/pi}
.ends
As to a simple, intuitive explanation as to why this circuit works, remember that:
- A diode may be loosely approximated by a small voltage source (usually about 0.7V) and a small resistor which allows current flow in only one direction.
- An ideal op amp with its output connected back to its negative input will try to output whatever voltage causes its inputs to be the same (i.e. it will make the negative input voltage match the positive input voltage).
When Vin is positive, current will want to flow to the right through R1. Nearly all of this current will flow through D1 (low resistance), causing Vx to be about -0.7V (since the input is brought to ground and the diode drops about 0.7V). Since nearly all of the current will flow through D1, no current flows through R2 and the output voltage is nearly the same as the input voltage (0V).
When Vin is negative, current will want to flow to the left through R1. Since almost no current will flow backwards through D1, this current has to travel through R2. By Ohm's law, the current will be Vin/R1 giving an output voltage of -(Vin/R1)*R2=-(R2/R1)*Vin. This voltage will be positive since Vin is negative.